niceid 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in niceid.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,3 @@
1
+ module NiceId
2
+ VERSION = "0.0.1"
3
+ end
data/lib/niceid.rb ADDED
@@ -0,0 +1,33 @@
1
+ module NiceId
2
+ class Id
3
+ VARS_NUM = %w{2 3 4 5 6 7 8 9}
4
+ VARS_LET = %w{f j k m p s t v w x y z}
5
+
6
+ attr_accessor :key
7
+
8
+ def initialize(how_many = 3)
9
+ @key = ''
10
+ @summ = 0
11
+ how_many.times do
12
+ a = rand VARS_NUM.size
13
+ b = rand VARS_LET.size
14
+ @key<<VARS_NUM[a]+VARS_LET[b]
15
+ end
16
+ @key=@key.chop << calc
17
+ end
18
+ def to_s
19
+ @key
20
+ end
21
+ def correct?
22
+ @key[-1..-1] == calc
23
+ end
24
+ private
25
+ def calc
26
+ @sum = @key.chop.scan(/./).map{|a| VARS_NUM.index(a)||VARS_LET.index(a)||0 }
27
+ VARS_LET.at @sum.inject(:+) % VARS_LET.size
28
+ end
29
+ end
30
+ end
31
+
32
+
33
+
data/niceid.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "niceid/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "niceid"
7
+ s.version = NiceId::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Serg Podtynnyi"]
10
+ s.email = ["serg.podtynnyi@gmail.com"]
11
+ s.homepage = "http://github.com/shtirlic/#{s.name}"
12
+ s.summary = %q{Nice ID Generator with checksum check.}
13
+ s.description = %q{Simple to remember and safe for handwriting, letters and numbers based ID.}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: niceid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Serg Podtynnyi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-04-29 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Simple to remember and safe for handwriting, letters and numbers based
15
+ ID.
16
+ email:
17
+ - serg.podtynnyi@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - Rakefile
25
+ - lib/niceid.rb
26
+ - lib/niceid/version.rb
27
+ - niceid.gemspec
28
+ homepage: http://github.com/shtirlic/niceid
29
+ licenses: []
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 1.7.2
49
+ signing_key:
50
+ specification_version: 3
51
+ summary: Nice ID Generator with checksum check.
52
+ test_files: []