niceid 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/niceid/version.rb +1 -1
- data/lib/niceid.rb +1 -3
- data/niceid.gemspec +1 -1
- data/spec/niceid_spec.rb +4 -7
- metadata +45 -39
data/lib/niceid/version.rb
CHANGED
data/lib/niceid.rb
CHANGED
@@ -4,8 +4,6 @@ module NiceId
|
|
4
4
|
VARS_LET = %w{f j k m p s t v w x y z}
|
5
5
|
DEFAULT_SIZE = 3
|
6
6
|
|
7
|
-
attr_accessor :key
|
8
|
-
|
9
7
|
def initialize(how_many = DEFAULT_SIZE)
|
10
8
|
@key = ''
|
11
9
|
@summ = 0
|
@@ -19,10 +17,10 @@ module NiceId
|
|
19
17
|
def to_s
|
20
18
|
@key
|
21
19
|
end
|
20
|
+
private
|
22
21
|
def correct?
|
23
22
|
@key[-1..-1] == calc
|
24
23
|
end
|
25
|
-
private
|
26
24
|
def calc
|
27
25
|
@sum = @key.chop.scan(/./).map{|a| VARS_NUM.index(a)||VARS_LET.index(a)||0 }
|
28
26
|
VARS_LET.at @sum.inject(:+) % VARS_LET.size
|
data/niceid.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Serg Podtynnyi"]
|
10
10
|
s.email = ["serg.podtynnyi@gmail.com"]
|
11
|
-
s.homepage = "
|
11
|
+
s.homepage = "https://github.com/shtirlic/#{s.name}"
|
12
12
|
s.summary = %q{Nice ID Generator with checksum check.}
|
13
13
|
s.description = %q{Simple to remember and safe for handwriting, letters and numbers based ID.}
|
14
14
|
|
data/spec/niceid_spec.rb
CHANGED
@@ -10,19 +10,16 @@ describe NiceId::Id do
|
|
10
10
|
|
11
11
|
it "should generate proper Id" do
|
12
12
|
@id.should be
|
13
|
-
@id.should be_kind_of described_class
|
14
13
|
end
|
15
14
|
it "should have default size" do
|
16
15
|
@id.to_s.length.should eq described_class::DEFAULT_SIZE*2
|
17
16
|
end
|
18
17
|
it "should check checksum" do
|
19
|
-
@id.correct
|
20
|
-
@id.key="
|
21
|
-
@id.correct
|
22
|
-
end
|
23
|
-
it "should change Id via key accessor" do
|
24
|
-
expect {@id.key}.to change{@id.key = described_class.new.to_s}
|
18
|
+
@id.send(:correct?).should be_true
|
19
|
+
@id.instance_eval{ @key = "4f2f2j"}
|
20
|
+
@id.send(:correct?).should be_false
|
25
21
|
end
|
22
|
+
|
26
23
|
it "should genarate Id with custom size" do
|
27
24
|
described_class.new(7).to_s.length.should eq 7*2
|
28
25
|
end
|
metadata
CHANGED
@@ -1,47 +1,49 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: niceid
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.3
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Serg Podtynnyi
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2011-06-10 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: rspec
|
16
|
-
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
19
|
none: false
|
18
|
-
requirements:
|
20
|
+
requirements:
|
19
21
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version:
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "2.3"
|
22
24
|
type: :development
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
26
27
|
name: backports
|
27
|
-
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
30
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version:
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "2.0"
|
33
35
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
ID.
|
38
|
-
email:
|
36
|
+
version_requirements: *id002
|
37
|
+
description: Simple to remember and safe for handwriting, letters and numbers based ID.
|
38
|
+
email:
|
39
39
|
- serg.podtynnyi@gmail.com
|
40
|
-
executables:
|
40
|
+
executables:
|
41
41
|
- niceid
|
42
42
|
extensions: []
|
43
|
+
|
43
44
|
extra_rdoc_files: []
|
44
|
-
|
45
|
+
|
46
|
+
files:
|
45
47
|
- .gitignore
|
46
48
|
- .rspec
|
47
49
|
- Gemfile
|
@@ -52,28 +54,32 @@ files:
|
|
52
54
|
- niceid.gemspec
|
53
55
|
- spec/niceid_spec.rb
|
54
56
|
- spec/spec_helper.rb
|
55
|
-
homepage:
|
57
|
+
homepage: https://github.com/shtirlic/niceid
|
56
58
|
licenses: []
|
59
|
+
|
57
60
|
post_install_message:
|
58
61
|
rdoc_options: []
|
59
|
-
|
62
|
+
|
63
|
+
require_paths:
|
60
64
|
- lib
|
61
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
66
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version:
|
67
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
72
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version:
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
73
77
|
requirements: []
|
78
|
+
|
74
79
|
rubyforge_project:
|
75
|
-
rubygems_version: 1.
|
80
|
+
rubygems_version: 1.8.3
|
76
81
|
signing_key:
|
77
82
|
specification_version: 3
|
78
83
|
summary: Nice ID Generator with checksum check.
|
79
84
|
test_files: []
|
85
|
+
|