Skip to content

Commit

Permalink
Fixup for ruby 1.8 and 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Aug 16, 2012
1 parent 16c3596 commit f4178b8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
language: ruby
rvm:
- 1.8.7
- 1.9.3
- jruby-18mode
- jruby-19mode
script: bundle exec rake
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
source "http://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
6 changes: 3 additions & 3 deletions lib/pairtree/identifier.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Pairtree
class Identifier
ENCODE_REGEX = Regexp.compile("[\"*+,<=>?\\\\^|]|[^\x21-\x7e]", nil, 'u')
DECODE_REGEX = Regexp.compile("\\^(..)", nil, 'u')
ENCODE_REGEX = Regexp.compile("[\"*+,<=>?\\\\^|]|[^\x21-\x7e]", nil)
DECODE_REGEX = Regexp.compile("\\^(..)", nil)

##
# Encode special characters within an identifier
Expand All @@ -21,7 +21,7 @@ def self.decode id
# Convert a character to its pairtree hexidecimal representation
# @param [Char] c The character to convert
def self.char2hex c
c.unpack('H*')[0].scan(/../).map { |x| "^#{x}"}
c.unpack('H*')[0].scan(/../).map { |x| "^#{x}"}.join('')
end

##
Expand Down
3 changes: 1 addition & 2 deletions pairtree.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]


s.add_development_dependency "bundler", "~> 1.0.0"
s.add_development_dependency "bundler"
s.add_development_dependency "rspec", ">= 2.0"
s.add_development_dependency "yard"
s.add_development_dependency "RedCloth"
end

5 changes: 3 additions & 2 deletions spec/pairtree/pairtree_encoding_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
# encoding: utf-8
require 'spec_helper'
require 'pairtree'

describe "Pairtree encoding" do
Expand All @@ -12,7 +13,7 @@ def roundtrip(id, expected_encoded=nil, expected_path=nil)
path = Pairtree::Path.id_to_path(id)
path.should == expected_path
end
Pairtree::Identifier.decode(encoded).should == id
Pairtree::Identifier.decode(encoded).force_encoding("UTF-8").should == id
end

it "should handle a" do
Expand Down
7 changes: 7 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
require 'rspec'
require 'rspec/autorun'

if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.9/
require 'simplecov'
SimpleCov.start
end

require 'pairtree'

RSpec.configure do |config|

end

0 comments on commit f4178b8

Please sign in to comment.