Skip to content

Fix gemspec and readme #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: ruby
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- jruby-18mode
- jruby-19mode
script: bundle exec rake
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
source "http://rubygems.org"
source "https://rubygems.org"

# Specify your gem's dependencies in test.gemspec
gemspec


gem 'rcov', :platform => :mri_18
gem 'simplecov', :platform => :mri_19
gem 'simplecov-rcov', :platform => :mri_19
gem 'simplecov', :platforms => [:mri_19, :mri_20]
gem 'simplecov-rcov', :platforms => [:mri_19, :mri_20]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pairtree

Ruby implementation of the [Pairtree](https://confluence.ucop.edu/display/Curation/PairTree microservice specification from the California Digital Librar)
Ruby implementation of the [Pairtree](https://confluence.ucop.edu/display/Curation/PairTree) microservice specification from the California Digital Library.

# Usage

Expand Down
20 changes: 19 additions & 1 deletion lib/pairtree/identifier.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module Pairtree
class Identifier
ENCODE_REGEX = Regexp.compile("[\"*+,<=>?\\\\^|]|[^\x21-\x7e]", nil)
Expand All @@ -14,7 +15,24 @@ def self.encode id
# Decode special characters within an identifier
# @param [String] id The identifier
def self.decode id
id.tr('=+,', '/:.').gsub(DECODE_REGEX) { |h| hex2char(h) }
input = id.tr('=+,', '/:.').bytes.to_a
intermediate = []
while input.first
if input.first == 94
h = []
input.shift
h << input.shift
h << input.shift
intermediate << h.pack('c*').hex
else
intermediate << input.shift
end
end
result = intermediate.pack('c*')
if result.respond_to? :force_encoding
result.force_encoding('UTF-8')
end
result
end

##
Expand Down
2 changes: 1 addition & 1 deletion pairtree.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |s|
s.email = %q{[email protected]}
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.extra_rdoc_files = ["LICENSE.txt", "README.textile"]
s.extra_rdoc_files = ["LICENSE.txt", "README.md"]
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

Expand Down
2 changes: 1 addition & 1 deletion spec/pairtree/pairtree_encoding_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def roundtrip(id, expected_encoded=nil, expected_path=nil)
end

it "should roundtrip French" do
roundtrip('Années de Pèlerinage')
roundtrip('Années de Pèlerinage', 'Ann^c3^a9es^20de^20P^c3^a8lerinage', 'An/n^/c3/^a/9e/s^/20/de/^2/0P/^c/3^/a8/le/ri/na/ge/Ann^c3^a9es^20de^20P^c3^a8lerinage')
roundtrip(%{
Années de Pèlerinage (Years of Pilgrimage) (S.160, S.161,
S.163) is a set of three suites by Franz Liszt for solo piano. Liszt's
Expand Down
4 changes: 2 additions & 2 deletions spec/pairtree/pairtree_obj_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
end

it "should be enumerable" do
block_body = mock('block_body')
block_body = double('block_body')
block_body.should_receive(:yielded).with('content.xml')
@obj.each { |file| block_body.yielded(file) }
end
Expand Down Expand Up @@ -66,4 +66,4 @@
end
end

end
end