gsm_tools 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gsm_tools.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require "gsm_tools/version"
2
2
  require "gsm_tools/base"
3
3
  require "gsm_tools/string"
4
+ require "gsm_tools/cell_global_id"
@@ -0,0 +1,25 @@
1
+ class CellGlobalId
2
+
3
+ attr_reader :raw_hex_value, :mcc, :mnc, :lac, :cell_id
4
+
5
+ def initialize(str)
6
+ @raw_hex_value = str.gsub(/.{2}/, '\0 ').split
7
+ octet_1 = @raw_hex_value[0].hex.to_s(2).rjust(8, "0")
8
+ octet_2 = @raw_hex_value[1].hex.to_s(2).rjust(8, "0")
9
+ octet_3 = @raw_hex_value[2].hex.to_s(2).rjust(8, "0")
10
+
11
+ @mcc = octet_1[4,4].to_i(2).to_s
12
+ @mcc << octet_1[0,4].to_i(2).to_s
13
+ @mcc << octet_2[4,4].to_i(2).to_s
14
+ @mcc = @mcc.to_i.to_s
15
+
16
+ @mnc = octet_3[4,4].to_i(2).to_s
17
+ @mnc << octet_3[0,4].to_i(2).to_s
18
+ @mnc << ""
19
+ @mnc << octet_2[0,4].to_i(2).to_s unless octet_2[0,4].match(/1111/)
20
+ @mnc = @mnc.to_i.to_s
21
+
22
+ @lac = @raw_hex_value[3] + @raw_hex_value[4]
23
+ @cell_id = @raw_hex_value[5] + @raw_hex_value[6]
24
+ end
25
+ end
@@ -1,3 +1,3 @@
1
1
  module GsmTools
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe GSMTools, "Cell Global ID" do
4
+ it "must be able to initialize and parse a hex string correctly" do
5
+ cell_gid = CellGlobalId.new("15f5302f022d86")
6
+ cell_gid.mcc.should == "515"
7
+ cell_gid.mnc.should == "3"
8
+ cell_gid.lac.should == "2f02"
9
+ cell_gid.cell_id.should == "2d86"
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gsm_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-09 00:00:00.000000000Z
12
+ date: 2012-01-24 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70344682777260 !ruby/object:Gem::Requirement
16
+ requirement: &70103757573680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70344682777260
24
+ version_requirements: *70103757573680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: guard-rspec
27
- requirement: &70344682781580 !ruby/object:Gem::Requirement
27
+ requirement: &70103757579900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70344682781580
35
+ version_requirements: *70103757579900
36
36
  description: Adds various methods to check GSM 03.38 character encoding compatibility.
37
37
  email:
38
38
  - andukz@gmail.com
@@ -48,9 +48,11 @@ files:
48
48
  - gsm_tools.gemspec
49
49
  - lib/gsm_tools.rb
50
50
  - lib/gsm_tools/base.rb
51
+ - lib/gsm_tools/cell_global_id.rb
51
52
  - lib/gsm_tools/string.rb
52
53
  - lib/gsm_tools/version.rb
53
54
  - spec/lib/gsm_tools/base_spec.rb
55
+ - spec/lib/gsm_tools/cell_global_id_spec.rb
54
56
  - spec/lib/gsm_tools/string_spec.rb
55
57
  - spec/lib/gsm_tools_spec.rb
56
58
  - spec/spec_helper.rb
@@ -68,7 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
70
  version: '0'
69
71
  segments:
70
72
  - 0
71
- hash: -1888712993988250446
73
+ hash: -3578868216986994201
72
74
  required_rubygems_version: !ruby/object:Gem::Requirement
73
75
  none: false
74
76
  requirements:
@@ -77,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
79
  version: '0'
78
80
  segments:
79
81
  - 0
80
- hash: -1888712993988250446
82
+ hash: -3578868216986994201
81
83
  requirements: []
82
84
  rubyforge_project: gsm_tools
83
85
  rubygems_version: 1.8.10
@@ -86,6 +88,7 @@ specification_version: 3
86
88
  summary: GSM 03.38 extension libraries
87
89
  test_files:
88
90
  - spec/lib/gsm_tools/base_spec.rb
91
+ - spec/lib/gsm_tools/cell_global_id_spec.rb
89
92
  - spec/lib/gsm_tools/string_spec.rb
90
93
  - spec/lib/gsm_tools_spec.rb
91
94
  - spec/spec_helper.rb