call_sign 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d384c9c5e7d236f591b784670ab691f13889b7a8
4
- data.tar.gz: a9ed0718d149af8411a272321bf7006395649c84
3
+ metadata.gz: 2cf4e7306f8472c6878b67cc6e904b0518d2e28f
4
+ data.tar.gz: 57bc0c70a1195d7772a38192aa2da398c4347292
5
5
  SHA512:
6
- metadata.gz: b9b9e883c7f8c5713087543afe88861d33c49454ca9bc32e3606ac99e255458fa66c7dbb508d3bc52d5386700a8a64cc9e508abac12580d1968c8ae6f64274aa
7
- data.tar.gz: 8095ca77ce9c0353dbf0f6dbd705dac1763e7773adc0672735bd78864d5ecb00939d6ed16541a026b122aabfc42364fbe19cf1b8cc0efb522ebed67413d56a0c
6
+ metadata.gz: 49e965de44dc80d2060b35a1bffbf486abb4649b3bc8c20e191e4bc22e666e3d0b7e89b7e4627ae9a1093afe21cdd56956cce4ba7abf6d54042ef07cc5cc95d9
7
+ data.tar.gz: 62cb6bdf23556a50d4ade21a93e9eae5e2f11e1265dbfcb8ec596ae19ce22b0e63634cefc2b85958d1ee857c22c1bf4d95a3ecfa89f3287bdb8c2a663f366da0
data/call_sign.gemspec CHANGED
@@ -4,22 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'call_sign/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "call_sign"
7
+ spec.name = 'call_sign'
8
8
  spec.version = CallSign::VERSION
9
- spec.authors = ["Kevin Elliott"]
10
- spec.email = ["kevin@welikeinc.com"]
9
+ spec.authors = ['Kevin Elliott']
10
+ spec.email = ['kevin@welikeinc.com']
11
11
  spec.summary = %q{Handle and process ITU Call Signs}
12
12
  spec.description = %q{Handle and process ITU Call Signs}
13
- spec.homepage = "http://github.com/kevinelliott/call_sign"
13
+ spec.homepage = 'http://github.com/kevinelliott/call_sign'
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency 'countries'
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.5"
24
- spec.add_development_dependency "rake"
23
+ spec.add_development_dependency 'bundler', '~> 1.5'
24
+ spec.add_development_dependency 'rake'
25
25
  end
@@ -1,14 +1,16 @@
1
1
  module CallSign
2
2
  class CallSign
3
3
 
4
- EXTRACT_REGEX = /^(?<prefix>[BFGIKMNRW]{1}|[A-Z]{1}[0-9]{1}|[0-9][A-Z]|[A-Z]|[0-9A-Z]{3})(?<separator>[0-9]{1})(?<suffix>[0-9A-Z]{1,5})$/
4
+ EXTRACT_REGEX = /^(?<prefix>[BFGIKMNRW]{1}|[A-Z][A-Z]|[A-Z]{1}[0-9]{1}|[0-9][A-Z]|[A-Z]|[0-9A-Z]{3})(?<separator>[0-9]{1})(?<suffix>[0-9A-Z]{1,5})$/
5
+
6
+ attr_reader :call_sign, :prefix, :prefix_string, :separator_string, :suffix_string
5
7
 
6
8
  def initialize(call_sign)
7
9
  components = CallSign.extract(call_sign)
8
10
 
9
11
  if components.is_a? Hash
10
12
  @call_sign = components[:text]
11
- @prefix = ITUPrefix.parse(components[:prefix])
13
+ @prefix = ITUPrefix.parse(components[:prefix])
12
14
  @prefix_string = components[:prefix]
13
15
  @separator_string = components[:separator]
14
16
  @suffix_string = components[:suffix]
@@ -24,6 +26,10 @@ module CallSign
24
26
  end
25
27
  end
26
28
 
29
+ def country
30
+ valid? && prefix && prefix.country ? prefix.country : nil
31
+ end
32
+
27
33
  def valid?
28
34
  @valid
29
35
  end
@@ -227,9 +227,10 @@ module CallSign
227
227
  end
228
228
  end
229
229
 
230
+ attr_reader :country, :prefix
231
+
230
232
  def initialize(prefix='')
231
233
  identity = identify(prefix)
232
- puts identity
233
234
 
234
235
  if identity.is_a? Hash
235
236
  @country = ISO3166::Country.find_country_by_alpha3(identity[:iso_3166_alpha_3])
@@ -241,11 +242,15 @@ module CallSign
241
242
  @valid = false
242
243
  end
243
244
  end
244
-
245
+
245
246
  def identify(prefix)
246
247
  PREFIXES[prefix]
247
248
  end
248
249
 
250
+ def valid?
251
+ @valid
252
+ end
253
+
249
254
  def self.parse(prefix)
250
255
  self.new(prefix)
251
256
  end
@@ -1,3 +1,3 @@
1
1
  module CallSign
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: call_sign
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Elliott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-20 00:00:00.000000000 Z
11
+ date: 2014-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: countries
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.2.1
92
+ rubygems_version: 2.2.2
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: Handle and process ITU Call Signs