niceid 0.0.1 → 0.0.2
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/.rspec +2 -0
- data/Gemfile +1 -0
- data/Rakefile +5 -0
- data/lib/niceid/version.rb +1 -1
- data/lib/niceid.rb +2 -1
- data/niceid.gemspec +3 -0
- data/spec/niceid_spec.rb +30 -0
- data/spec/spec_helper.rb +5 -0
- metadata +28 -3
data/.rspec
ADDED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/niceid/version.rb
CHANGED
data/lib/niceid.rb
CHANGED
@@ -2,10 +2,11 @@ module NiceId
|
|
2
2
|
class Id
|
3
3
|
VARS_NUM = %w{2 3 4 5 6 7 8 9}
|
4
4
|
VARS_LET = %w{f j k m p s t v w x y z}
|
5
|
+
DEFAULT_SIZE = 3
|
5
6
|
|
6
7
|
attr_accessor :key
|
7
8
|
|
8
|
-
def initialize(how_many =
|
9
|
+
def initialize(how_many = DEFAULT_SIZE)
|
9
10
|
@key = ''
|
10
11
|
@summ = 0
|
11
12
|
how_many.times do
|
data/niceid.gemspec
CHANGED
@@ -12,6 +12,9 @@ Gem::Specification.new do |s|
|
|
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
|
|
15
|
+
s.add_development_dependency "rspec", "~> 2.3"
|
16
|
+
s.add_development_dependency "backports", ">= 2.0"
|
17
|
+
|
15
18
|
s.files = `git ls-files`.split("\n")
|
16
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
data/spec/niceid_spec.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'backports'
|
2
|
+
require_relative 'spec_helper'
|
3
|
+
|
4
|
+
|
5
|
+
describe NiceId::Id do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@id = described_class.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should generate proper Id" do
|
12
|
+
@id.should be
|
13
|
+
@id.should be_kind_of described_class
|
14
|
+
end
|
15
|
+
it "should have default size" do
|
16
|
+
@id.to_s.length.should eq described_class::DEFAULT_SIZE*2
|
17
|
+
end
|
18
|
+
it "should check checksum" do
|
19
|
+
@id.correct?.should be_true
|
20
|
+
@id.key="2f2f2j"
|
21
|
+
@id.correct?.should be_false
|
22
|
+
end
|
23
|
+
it "should change Id via key accessor" do
|
24
|
+
expect {@id.key}.to change{@id.key = described_class.new.to_s}
|
25
|
+
end
|
26
|
+
it "should genarate Id with custom size" do
|
27
|
+
described_class.new(7).to_s.length.should eq 7*2
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: niceid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,30 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
13
|
-
dependencies:
|
12
|
+
date: 2011-05-01 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &77233260 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *77233260
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: backports
|
27
|
+
requirement: &77233000 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *77233000
|
14
36
|
description: Simple to remember and safe for handwriting, letters and numbers based
|
15
37
|
ID.
|
16
38
|
email:
|
@@ -20,11 +42,14 @@ extensions: []
|
|
20
42
|
extra_rdoc_files: []
|
21
43
|
files:
|
22
44
|
- .gitignore
|
45
|
+
- .rspec
|
23
46
|
- Gemfile
|
24
47
|
- Rakefile
|
25
48
|
- lib/niceid.rb
|
26
49
|
- lib/niceid/version.rb
|
27
50
|
- niceid.gemspec
|
51
|
+
- spec/niceid_spec.rb
|
52
|
+
- spec/spec_helper.rb
|
28
53
|
homepage: http://github.com/shtirlic/niceid
|
29
54
|
licenses: []
|
30
55
|
post_install_message:
|