istc 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fa15edb78b40ae1ac5ebfb3c11b19005135f9a4d
4
+ data.tar.gz: 7d7800902401e279186fdc3a642a9c0ce7ba7bd7
5
+ SHA512:
6
+ metadata.gz: f18a81270546ea392dfbc7d557f64ff015e1d6b5be538c6b5e7b5bd57e76504e684a4c9c9d535acb840cbdf4bbf0a2bbda0c393cf04bad309d7bbb6b27b3a724
7
+ data.tar.gz: b3e00ca51185870e7a486c91f98c6c2ee8ef6efa456014675d65b10a1e8ef18fa8e49d1471317c3e0cb6261638224680f9ed811f2e641201b7073ba7f17cd65f
data/CHANGELOG CHANGED
@@ -1,2 +1,5 @@
1
+ v1.1 (16th July 2017)
2
+ - Updated packaging to work well with ruby 1.9.3 to 2.4
3
+
1
4
  v1.0 (26th September 2008)
2
5
  - Initial Release
@@ -0,0 +1,34 @@
1
+ A small class for generating and validating Internation Standard Text
2
+ Codes (ISTC).
3
+
4
+ # Installation
5
+
6
+ gem install istc
7
+
8
+ # Usage
9
+
10
+ ISTC.new("0A9200800000007C").valid?
11
+ => true
12
+
13
+ ISTC.valid?("0A9200800000007C")
14
+ => true
15
+
16
+ ISTC.valid?("0A9200800000007B")
17
+ => false
18
+
19
+ ISTC.complete("0A9200800000007")
20
+ => "0A9200800000007C"
21
+
22
+ ISTC.new("0A9200800000007").to_s
23
+ => "0A9-2008-00000007-C"
24
+
25
+ # Further Reading
26
+
27
+ - http://en.wikipedia.org/wiki/International_Standard_Text_Code
28
+ - http://www.istcinfo.org/
29
+ - http://www.ljndawson.com/Wiki/index.php/ISTC
30
+
31
+ # Contributing
32
+
33
+ Source code is publicly available @ http://github.com/yob/istc. Patches
34
+ welcome, preferably via a git repo I can pull from.
@@ -2,7 +2,7 @@ class ISTC
2
2
 
3
3
  class Version #:nodoc:
4
4
  Major = 1
5
- Minor = 0
5
+ Minor = 1
6
6
  Tiny = 0
7
7
 
8
8
  String = [Major, Minor, Tiny].join('.')
@@ -53,7 +53,6 @@ class ISTC
53
53
  num = num.to_s
54
54
  return nil unless num.length == 15 && num.match(/[\dA-Fa-f]{11}/)
55
55
 
56
- #puts num
57
56
  arr = (0..14).to_a.collect do |i|
58
57
  if i == 0 || i % 4 == 0
59
58
  num[i,1].hex * 11
@@ -65,7 +64,6 @@ class ISTC
65
64
  num[i,1].hex * 1
66
65
  end
67
66
  end
68
- #puts arr.inspect
69
67
  sum = arr.inject { |sum, n| sum + n }
70
68
  remainder = sum % 16
71
69
  check = remainder.to_s(16).upcase
@@ -1,38 +1,35 @@
1
- $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
2
-
3
- require 'spec'
4
1
  require 'istc'
5
2
 
6
3
  describe "The ISTC class" do
7
4
  it "should identify a valid ISTC" do
8
- ISTC.new("0A9200112C4F1324").valid?.should be_true
5
+ expect(ISTC.new("0A9200112C4F1324").valid?).to be_truthy
9
6
  end
10
7
 
11
8
  it "should identify a valid ISTC" do
12
- ISTC.valid?("0A9200112C4F1324").should be_true
9
+ expect(ISTC.valid?("0A9200112C4F1324")).to be_truthy
13
10
  end
14
11
 
15
12
  it "should identify an invalid ISTC" do
16
- ISTC.valid?(nil).should be_false
17
- ISTC.valid?("902865").should be_false
18
- ISTC.valid?(Array).should be_false
19
- ISTC.valid?(Array.new).should be_false
20
- ISTC.valid?("0A9200800000007B").should be_false
21
- ISTC.valid?("0A9200800000007").should be_false
13
+ expect(ISTC.valid?(nil)).to be_falsey
14
+ expect(ISTC.valid?("902865")).to be_falsey
15
+ expect(ISTC.valid?(Array)).to be_falsey
16
+ expect(ISTC.valid?(Array.new)).to be_falsey
17
+ expect(ISTC.valid?("0A9200800000007B")).to be_falsey
18
+ expect(ISTC.valid?("0A9200800000007")).to be_falsey
22
19
  end
23
20
 
24
21
  it "should calculate a ISTC check digit correctly" do
25
- ISTC.complete("0A9200112C4F132").should eql("0A9200112C4F1324")
22
+ expect(ISTC.complete("0A9200112C4F132")).to eql("0A9200112C4F1324")
26
23
  end
27
24
 
28
25
  it "should hyphen a ISTC correctly" do
29
- ISTC.new("0A9200112C4F1324").to_s.should eql("0A9-2001-12C4F132-4")
26
+ expect(ISTC.new("0A9200112C4F1324").to_s).to eql("0A9-2001-12C4F132-4")
30
27
  end
31
28
 
32
29
  it "should return sections of an ISTC correctly" do
33
- ISTC.new("0A9200112C4F1324").agency.should eql("0A9")
34
- ISTC.new("0A9200112C4F1324").year.should eql("2001")
35
- ISTC.new("0A9200112C4F1324").work.should eql("12C4F132")
36
- ISTC.new("0A9200112C4F1324").check.should eql("4")
30
+ expect(ISTC.new("0A9200112C4F1324").agency).to eql("0A9")
31
+ expect(ISTC.new("0A9200112C4F1324").year).to eql("2001")
32
+ expect(ISTC.new("0A9200112C4F1324").work).to eql("12C4F132")
33
+ expect(ISTC.new("0A9200112C4F1324").check).to eql("4")
37
34
  end
38
35
  end
metadata CHANGED
@@ -1,58 +1,80 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: istc
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - James Healy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2008-10-06 00:00:00 +11:00
13
- default_executable:
14
- dependencies: []
15
-
11
+ date: 2017-07-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
16
41
  description: a (very) small library for working with ISTC
17
42
  email: jimmy@deefa.com
18
43
  executables: []
19
-
20
44
  extensions: []
21
-
22
45
  extra_rdoc_files: []
23
-
24
- files:
25
- - lib/istc.rb
26
- - MIT-LICENSE
27
- - README.rdoc
46
+ files:
28
47
  - CHANGELOG
29
- has_rdoc: true
30
- homepage: http://github.com/yob/istc/tree/master
48
+ - MIT-LICENSE
49
+ - README.markdown
50
+ - lib/istc.rb
51
+ - spec/istc_spec.rb
52
+ homepage: http://github.com/yob/istc
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
31
56
  post_install_message:
32
- rdoc_options:
33
- - --title
57
+ rdoc_options:
58
+ - "--title"
34
59
  - ISTC
35
- - --line-numbers
36
- require_paths:
60
+ - "--line-numbers"
61
+ require_paths:
37
62
  - lib
38
- required_ruby_version: !ruby/object:Gem::Requirement
39
- requirements:
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
40
65
  - - ">="
41
- - !ruby/object:Gem::Version
42
- version: "0"
43
- version:
44
- required_rubygems_version: !ruby/object:Gem::Requirement
45
- requirements:
66
+ - !ruby/object:Gem::Version
67
+ version: 1.9.3
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
46
70
  - - ">="
47
- - !ruby/object:Gem::Version
48
- version: "0"
49
- version:
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
50
73
  requirements: []
51
-
52
- rubyforge_project: yob-projects
53
- rubygems_version: 1.2.0
74
+ rubyforge_project:
75
+ rubygems_version: 2.6.11
54
76
  signing_key:
55
- specification_version: 2
77
+ specification_version: 4
56
78
  summary: a (very) small library for working with ISTC
57
- test_files:
79
+ test_files:
58
80
  - spec/istc_spec.rb
@@ -1,33 +0,0 @@
1
- A small class for generating and validating Internation Standard Text
2
- Codes (ISTC).
3
-
4
- = Installation
5
-
6
- gem install istc
7
-
8
- = Usage
9
-
10
- ISTC.new("0A9200800000007C").valid?
11
- => true
12
-
13
- ISTC.valid?("0A9200800000007C")
14
- => true
15
-
16
- ISTC.valid?("0A9200800000007B")
17
- => false
18
-
19
- ISTC.complete?("0A9200800000007")
20
- => "0A9200800000007C"
21
-
22
- ISTC.new("0A9200800000007").to_s
23
- => "0A9-2008-00000007-C"
24
-
25
- = Further Reading
26
-
27
- - http://en.wikipedia.org/wiki/International_Standard_Text_Code
28
- - http://www.istcinfo.org/
29
-
30
- = Contributing
31
-
32
- Source code is publicly available @ http://github.com/yob/istc/tree/master.
33
- Patches welcome, preferably via a git repo I can pull from.