Skip to content

Commit f4178b8

Browse files
committed
Fixup for ruby 1.8 and 1.9
1 parent 16c3596 commit f4178b8

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: ruby
2+
rvm:
3+
- 1.8.7
4+
- 1.9.3
5+
- jruby-18mode
6+
- jruby-19mode
7+
script: bundle exec rake

Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
source "http://rubygems.org"
22

3+
# Specify your gem's dependencies in test.gemspec
34
gemspec
5+
6+
47
gem 'rcov', :platform => :mri_18
8+
gem 'simplecov', :platform => :mri_19
9+
gem 'simplecov-rcov', :platform => :mri_19

lib/pairtree/identifier.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Pairtree
22
class Identifier
3-
ENCODE_REGEX = Regexp.compile("[\"*+,<=>?\\\\^|]|[^\x21-\x7e]", nil, 'u')
4-
DECODE_REGEX = Regexp.compile("\\^(..)", nil, 'u')
3+
ENCODE_REGEX = Regexp.compile("[\"*+,<=>?\\\\^|]|[^\x21-\x7e]", nil)
4+
DECODE_REGEX = Regexp.compile("\\^(..)", nil)
55

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

2727
##

pairtree.gemspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ Gem::Specification.new do |s|
1616
s.require_paths = ["lib"]
1717

1818

19-
s.add_development_dependency "bundler", "~> 1.0.0"
19+
s.add_development_dependency "bundler"
2020
s.add_development_dependency "rspec", ">= 2.0"
2121
s.add_development_dependency "yard"
22-
s.add_development_dependency "RedCloth"
2322
end
2423

spec/pairtree/pairtree_encoding_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
1+
# encoding: utf-8
2+
require 'spec_helper'
23
require 'pairtree'
34

45
describe "Pairtree encoding" do
@@ -12,7 +13,7 @@ def roundtrip(id, expected_encoded=nil, expected_path=nil)
1213
path = Pairtree::Path.id_to_path(id)
1314
path.should == expected_path
1415
end
15-
Pairtree::Identifier.decode(encoded).should == id
16+
Pairtree::Identifier.decode(encoded).force_encoding("UTF-8").should == id
1617
end
1718

1819
it "should handle a" do

spec/spec_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
require 'rspec'
66
require 'rspec/autorun'
77

8+
if ENV['COVERAGE'] and RUBY_VERSION =~ /^1.9/
9+
require 'simplecov'
10+
SimpleCov.start
11+
end
12+
13+
require 'pairtree'
14+
815
RSpec.configure do |config|
916

1017
end

0 commit comments

Comments
 (0)