pairtree 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +44 -0
- data/Gemfile +2 -11
- data/LICENSE.txt +12 -20
- data/README.textile +37 -0
- data/Rakefile +20 -45
- data/lib/pairtree.rb +72 -1
- data/lib/pairtree/identifier.rb +13 -0
- data/lib/pairtree/obj.rb +47 -0
- data/lib/pairtree/path.rb +41 -2
- data/lib/pairtree/root.rb +72 -26
- data/lib/tasks/rdoc.rake +32 -0
- data/pairtree.gemspec +24 -0
- data/spec/pairtree/pairtree_encoding_spec.rb +87 -0
- data/spec/pairtree/pairtree_obj_spec.rb +69 -0
- data/spec/pairtree/pairtree_path_spec.rb +35 -0
- data/spec/pairtree/pairtree_root_spec.rb +63 -0
- data/spec/pairtree/pairtree_spec.rb +69 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/test_data/fixtures/pairtree_root_spec/pairtree_prefix +1 -0
- data/spec/test_data/fixtures/pairtree_root_spec/pairtree_root/ab/c1/23/de/f/abc123def/content.xml +1 -0
- data/spec/test_data/fixtures/pairtree_root_spec/pairtree_version0_1 +1 -0
- metadata +82 -100
- data/README.rdoc +0 -19
- data/VERSION +0 -1
- data/lib/pairtree/client.rb +0 -18
- data/test/helper.rb +0 -18
- data/test/test_pairtree.rb +0 -91
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
= pairtree
|
2
|
-
|
3
|
-
Ruby Pairtre implementation
|
4
|
-
|
5
|
-
== Contributing to pairtree
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
-
* Fork the project
|
10
|
-
* Start a feature/bugfix branch
|
11
|
-
* Commit and push until you are happy with your contribution
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2010 Chris Beer. See LICENSE.txt for
|
18
|
-
further details.
|
19
|
-
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.0
|
data/lib/pairtree/client.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module Pairtree
|
2
|
-
class Client
|
3
|
-
attr_reader :root
|
4
|
-
attr_reader :prefix
|
5
|
-
def initialize path, args = {}
|
6
|
-
args[:root] ||= {}
|
7
|
-
|
8
|
-
@prefix = open(File.join(path, 'pairtree_prefix')).read.strip if File.exists? File.join(path, 'pairtree_prefix')
|
9
|
-
args[:root][:prefix] ||= @prefix
|
10
|
-
|
11
|
-
@version = nil
|
12
|
-
|
13
|
-
args[:root][:version] ||= @version
|
14
|
-
|
15
|
-
@root = Pairtree::Root.new File.join(path, 'pairtree_root'), args[:root]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/test/helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'test/unit'
|
11
|
-
require 'shoulda'
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
-
require 'pairtree'
|
16
|
-
|
17
|
-
class Test::Unit::TestCase
|
18
|
-
end
|
data/test/test_pairtree.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestPairtree < Test::Unit::TestCase
|
4
|
-
def roundtrip s
|
5
|
-
en = Pairtree::Identifier.encode s
|
6
|
-
de = Pairtree::Identifier.decode en
|
7
|
-
assert_equal(s,de)
|
8
|
-
end
|
9
|
-
def test_a
|
10
|
-
assert_equal(Pairtree::Identifier.encode('a'), 'a')
|
11
|
-
assert_equal(Pairtree::Path.id_to_path('a'), 'a')
|
12
|
-
self.roundtrip('a')
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_ab
|
16
|
-
assert_equal(Pairtree::Identifier.encode('ab'), 'ab')
|
17
|
-
assert_equal(Pairtree::Path.id_to_path('ab'), 'ab')
|
18
|
-
self.roundtrip('ab')
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_abc
|
22
|
-
assert_equal(Pairtree::Identifier.encode('abc'), 'abc')
|
23
|
-
assert_equal(Pairtree::Path.id_to_path('abc'), 'ab/c')
|
24
|
-
self.roundtrip('abc')
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_abcd
|
28
|
-
assert_equal(Pairtree::Identifier.encode('abcd'), 'abcd')
|
29
|
-
assert_equal(Pairtree::Path.id_to_path('abcd'), 'ab/cd')
|
30
|
-
self.roundtrip('abcd')
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_space
|
34
|
-
assert_equal(Pairtree::Identifier.encode('hello world'), 'hello^20world')
|
35
|
-
assert_equal(Pairtree::Path.id_to_path('hello world'), 'he/ll/o^/20/wo/rl/d')
|
36
|
-
self.roundtrip('hello world')
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_slash
|
40
|
-
assert_equal(Pairtree::Identifier.encode('/'), '=')
|
41
|
-
self.roundtrip('/')
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_urn
|
45
|
-
assert_equal(Pairtree::Identifier.encode('http://n2t.info/urn:nbn:se:kb:repos-1'), 'http+==n2t,info=urn+nbn+se+kb+repos-1')
|
46
|
-
self.roundtrip('http://n2t.info/urn:nbn:se:kb:repos-1')
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_wtf
|
50
|
-
assert_equal(Pairtree::Identifier.encode('what-the-*@?#!^!?'), "what-the-^2a@^3f#!^5e!^3f")
|
51
|
-
self.roundtrip('what-the-*@?#!^!?')
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_weird
|
55
|
-
assert_equal(Pairtree::Identifier.encode('\\"*+,<=>?^|'), "^5c^22^2a^2b^2c^3c^3d^3e^3f^5e^7c")
|
56
|
-
assert_equal(Pairtree::Path.id_to_path('\\"*+,<=>?^|'), "^5/c^/22/^2/a^/2b/^2/c^/3c/^3/d^/3e/^3/f^/5e/^7/c")
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_hardcore_unicode
|
60
|
-
self.roundtrip(" 1. Euro Symbol: €.
|
61
|
-
2. Greek: Μπορώ να φάω σπασμένα γυαλιά χωρίς να πάθω τίποτα.
|
62
|
-
3. Íslenska / Icelandic: Ég get etið gler án þess að meiða mig.
|
63
|
-
4. Polish: Mogę jeść szkło, i mi nie szkodzi.
|
64
|
-
5. Romanian: Pot să mănânc sticlă și ea nu mă rănește.
|
65
|
-
6. Ukrainian: Я можу їсти шкло, й воно мені не пошкодить.
|
66
|
-
7. Armenian: Կրնամ ապակի ուտել և ինծի անհանգիստ չըներ։
|
67
|
-
8. Georgian: მინას ვჭამ და არა მტკივა.
|
68
|
-
9. Hindi: मैं काँच खा सकता हूँ, मुझे उस से कोई पीडा नहीं होती.
|
69
|
-
10. Hebrew(2): אני יכול לאכול זכוכית וזה לא מזיק לי.
|
70
|
-
11. Yiddish(2): איך קען עסן גלאָז און עס טוט מיר נישט װײ.
|
71
|
-
12. Arabic(2): أنا قادر على أكل الزجاج و هذا لا يؤلمني.
|
72
|
-
13. Japanese: 私はガラスを食べられます。それは私を傷つけません。
|
73
|
-
14. Thai: ฉันกินกระจกได้ แต่มันไม่ทำให้ฉันเจ็บ ")
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_french
|
77
|
-
self.roundtrip 'Années de Pèlerinage'
|
78
|
-
self.roundtrip "Années de Pèlerinage (Years of Pilgrimage) (S.160, S.161,\n\
|
79
|
-
S.163) is a set of three suites by Franz Liszt for solo piano. Liszt's\n\
|
80
|
-
complete musical style is evident in this masterwork, which ranges from\n\
|
81
|
-
virtuosic fireworks to sincerely moving emotional statements. His musical\n\
|
82
|
-
maturity can be seen evolving through his experience and travel. The\n\
|
83
|
-
third volume is especially notable as an example of his later style: it\n\
|
84
|
-
was composed well after the first two volumes and often displays less\n\
|
85
|
-
showy virtuosity and more harmonic experimentation."
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|