uri-urn 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05fa7804f659ad3fc76e295280e767621645071f
4
- data.tar.gz: 81eaffaa1a1e5c6f707fcb3903c824e10f1277f5
3
+ metadata.gz: ceac9f15a424139fa6e8e2d6e3822c7dfe3c0b04
4
+ data.tar.gz: 1cfd4a1a3207aadd3aa1e9526c746c04e1605965
5
5
  SHA512:
6
- metadata.gz: a42f90f530ad629031815c8c4fea7ec97c7205a99e536a82968074feac84e2d4d199261bf7c4beddb4968ed061d1540fa9a91436177e078760d702491fbae4e1
7
- data.tar.gz: 7efb31337c70e1b03ba47176278d2ad228ba3fde0b4c3ea921367ddaa75d0851415a1502263142fff07be7b6fd1e3651bb7a5e61ca39e2f3578d6ab853c6b833
6
+ metadata.gz: ce5dc4edaed6a38533cea3ccf91463e79ea0408a14938135dadc998e0a1ca6351458e05e87557e3dce7101807a524eeb52bb1dc238dcf18d0b94211df581ac99
7
+ data.tar.gz: 4c769a7b98f4c07f8b982dd84a075be6e8666a7291ff74caa0ae231c6ea52976cfd6a09954521b8a80ec87fb3fd245bbec237fe1af9fd70aaad76e20196ced4d
data/CHANGELOG.markdown CHANGED
@@ -1,6 +1,11 @@
1
1
  URI::URN Changelog
2
2
  ==================
3
3
 
4
+ 0.0.2
5
+ -----
6
+
7
+ * Add `URI::URN::ISBN`
8
+
4
9
  0.0.1
5
10
  -----
6
11
 
data/README.markdown CHANGED
@@ -38,6 +38,7 @@ For unknown Namespace URN, returns URI::URN::Generic object.
38
38
  Currently supported:
39
39
 
40
40
  * UUID
41
+ * ISBN
41
42
 
42
43
  ### Adding Namespaces
43
44
 
@@ -0,0 +1,19 @@
1
+ require 'uri/urn'
2
+
3
+ module URI
4
+ module URN
5
+ class ISBN < Generic
6
+ ISBN10_PATTERN = '(?:\d+-\d+-\d+-\d)|(?:\d{9}[\dXx])'.freeze
7
+ ISBN13_PATTERN = '(?:\d{3}-\d+-\d+-\d+-\d)|(?:\d{3}-\d{10})|(?:\d{13})'.freeze
8
+ NSS_PATTERN = "#{ISBN10_PATTERN}|#{ISBN13_PATTERN}".freeze
9
+
10
+ def normalize!
11
+ super
12
+ set_nss(self.nss.upcase.gsub('-', ''))
13
+ end
14
+ end
15
+
16
+ @@nids['ISBN'] = ISBN
17
+ end
18
+ end
19
+
@@ -0,0 +1,41 @@
1
+ require 'test/unit'
2
+ require 'uri/urn/isbn'
3
+
4
+ module URI::URN
5
+
6
+ class TestISBN < Test::Unit::TestCase
7
+ def setup
8
+ @isbn_string = '978-1937785499'
9
+ end
10
+
11
+ def test_parse
12
+ uri = URI.parse("urn:isbn:#{@isbn_string}")
13
+
14
+ assert_instance_of ISBN, uri
15
+ assert_equal 'urn', uri.scheme
16
+ assert_equal 'isbn', uri.nid
17
+ assert_equal @isbn_string, uri.nss
18
+ assert_raise URI::InvalidComponentError do
19
+ URI.parse("urn:isbn:#{@isbn_string.chop}")
20
+ end
21
+ end
22
+
23
+ def test_build
24
+ uri = URI::URN::ISBN.build([@isbn_string])
25
+
26
+ assert_instance_of ISBN, uri
27
+ assert_equal 'urn', uri.scheme
28
+ assert_equal 'isbn', uri.nid
29
+ assert_equal @isbn_string, uri.nss
30
+ assert_raise URI::InvalidComponentError do
31
+ URI::URN::ISBN.build([@isbn_string.chop])
32
+ end
33
+ end
34
+
35
+ def test_equal
36
+ assert URI.parse('urn:isbn:193435693X') == URI.parse('urn:isbn:193435693X')
37
+ assert URI.parse('urn:isbn:978-4274064616') == URI.parse('urn:isbn:9784274064616')
38
+ end
39
+ end
40
+
41
+ end
data/uri-urn.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "uri-urn"
3
- spec.version = '0.0.1'
3
+ spec.version = '0.0.2'
4
4
  spec.authors = ["KITAITI Makoto"]
5
5
  spec.email = ["KitaitiMakoto@gmail.com"]
6
6
  spec.summary = %q{Adds URN Scheme support to URI lib.}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uri-urn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - KITAITI Makoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-08 00:00:00.000000000 Z
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubygems-tasks
@@ -42,8 +42,10 @@ files:
42
42
  - README.markdown
43
43
  - Rakefile
44
44
  - lib/uri/urn.rb
45
+ - lib/uri/urn/isbn.rb
45
46
  - lib/uri/urn/uuid.rb
46
47
  - test/uri/test_urn.rb
48
+ - test/uri/urn/test_isbn.rb
47
49
  - test/uri/urn/test_uuid.rb
48
50
  - uri-urn.gemspec
49
51
  homepage: https://gitorious.org/uri-ext
@@ -73,3 +75,4 @@ summary: Adds URN Scheme support to URI lib.
73
75
  test_files:
74
76
  - test/uri/test_urn.rb
75
77
  - test/uri/urn/test_uuid.rb
78
+ - test/uri/urn/test_isbn.rb