cellularity 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 +4 -4
- data/README.md +1 -1
- data/lib/cellularity.rb +15 -2
- data/lib/cellularity/version.rb +1 -1
- data/spec/cellularity_spec.rb +39 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75aaa9b6f4b60b625705c946904ec9f81b26aee0
|
4
|
+
data.tar.gz: 13b1a0d00cb90e1cc61074ea0fecdc3c7a7f8f9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68972f790a34a1bb2106654305340cf5f542b8a2adcfa3e30a23eb6d68f3a91ee6e59d93a567f89fc1f22e80ab8ad8c5186c5d23e2ada8e319ff2ca6b3fbac7d
|
7
|
+
data.tar.gz: 94a7ad6aa69851a36b7b3414c86fb55c9e28b5184c7b4da895aabe994ee49f1390b8999a61b493d7ed05cc3be728095d3a3457b85b476b040fdcad72a39f84aa
|
data/README.md
CHANGED
@@ -39,4 +39,4 @@ Cellularity::Iccid.new(iccid).valid? # => true
|
|
39
39
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
40
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
41
|
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
-
5. Create new Pull Request
|
42
|
+
5. Create new Pull Request
|
data/lib/cellularity.rb
CHANGED
@@ -5,5 +5,18 @@ require 'cellularity/imei'
|
|
5
5
|
require 'cellularity/iccid'
|
6
6
|
|
7
7
|
module Cellularity
|
8
|
-
|
9
|
-
|
8
|
+
def self.determine_id_type(id)
|
9
|
+
return :esn if Cellularity::Esn.new(id).valid?
|
10
|
+
return :imei if Cellularity::Imei.new(id).valid?
|
11
|
+
return :iccid if Cellularity::Iccid.new(id).valid?
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.parse_id(id)
|
15
|
+
case determine_id_type(id)
|
16
|
+
when :esn then Cellularity::Esn.new(id)
|
17
|
+
when :imei then Cellularity::Imei.new(id)
|
18
|
+
when :iccid then Cellularity::Iccid.new(id)
|
19
|
+
else nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/cellularity/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cellularity do
|
4
|
+
|
5
|
+
let(:esn) { '0xabc12345' }
|
6
|
+
let(:imei) { '123456789012345' }
|
7
|
+
let(:iccid) { 12345678901234567890 }
|
8
|
+
let(:nada) { :not_an_id }
|
9
|
+
|
10
|
+
context 'when an esn' do
|
11
|
+
it 'should think it is an esn' do
|
12
|
+
Cellularity.determine_id_type(esn).should == :esn
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should return an Esn object' do
|
16
|
+
Cellularity.parse_id(esn).is_a?(Cellularity::Esn).should be_true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when an imei' do
|
21
|
+
it 'should think it is an imei' do
|
22
|
+
Cellularity.determine_id_type(imei).should == :imei
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should return an Imei object' do
|
26
|
+
Cellularity.parse_id(imei).is_a?(Cellularity::Imei).should be_true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when an iccid' do
|
31
|
+
it 'should think it is an iccid' do
|
32
|
+
Cellularity.determine_id_type(iccid).should == :iccid
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should return an Iccid object' do
|
36
|
+
Cellularity.parse_id(iccid).is_a?(Cellularity::Iccid).should be_true
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cellularity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- johnotander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/cellularity/iccid.rb
|
71
71
|
- lib/cellularity/imei.rb
|
72
72
|
- lib/cellularity/version.rb
|
73
|
+
- spec/cellularity_spec.rb
|
73
74
|
- spec/esn_spec.rb
|
74
75
|
- spec/iccid_spec.rb
|
75
76
|
- spec/imei_spec.rb
|
@@ -99,6 +100,7 @@ signing_key:
|
|
99
100
|
specification_version: 4
|
100
101
|
summary: Determine whether a string is an ICCID, IMEI, ESN, or MDN.
|
101
102
|
test_files:
|
103
|
+
- spec/cellularity_spec.rb
|
102
104
|
- spec/esn_spec.rb
|
103
105
|
- spec/iccid_spec.rb
|
104
106
|
- spec/imei_spec.rb
|