clli 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: b303b8d7d6cce5d91d98a6b7ec86433b97095932
4
- data.tar.gz: e69081a525be27eb5dff21d0b47f867ddc5a9fad
3
+ metadata.gz: 7fed2fa68851679d24a3d977749614df1f254de7
4
+ data.tar.gz: e06cd436511a92e21c6cb994a7e9bcd9b42edfaf
5
5
  SHA512:
6
- metadata.gz: 7776b925a5f2eaa43fd8f49d95d183f381efb42f742e304fcad748afba8af97a73b83d6d85e38f112526f66811fe35f0484d0742b1c2d2373e8e457a19838f68
7
- data.tar.gz: bf0c40bfb87fdb30e7a26645d3382e0c72b31bcedaa0c815ebc7a219e6d8bdab456818d75ceae713b6f71f4a3ba50159323d91b8217acceca4386fb1804a3983
6
+ metadata.gz: 8c0d085c0a98fc06961f94b622b29438fc76ed68ffee32f92c84ccd7a8f7ffcd9430968c31be24c5c54e465588c4647d8975ccd0440d90a98b2b3de52aaf9669
7
+ data.tar.gz: 830b24af359280a5fa2d2960c9369888b35be6d92e5c789203e3b49546cb93ef2583e2cac82440acb928deb2d099461b4786226f78aab1d8885c7c455ee488e5
@@ -0,0 +1,16 @@
1
+ ---
2
+ engines:
3
+ duplication:
4
+ enabled: true
5
+ config:
6
+ languages:
7
+ - ruby
8
+ fixme:
9
+ enabled: true
10
+ rubocop:
11
+ enabled: true
12
+ ratings:
13
+ paths:
14
+ - "**.rb"
15
+ exclude_paths:
16
+ - test/**/*
data/README.md CHANGED
@@ -1,44 +1,48 @@
1
- # CLLI
2
-
3
- This gem can be used to parse [Common Language Location Identification (CLLI) codes](https://en.wikipedia.org/wiki/CLLI_code). Given a CLLI this gem tries to determine the City, State/Provice, and Country the CLLI represents.
4
-
5
- The reference for this gem is [Bell System Practices Section 795-100-100](http://etler.com/docs/BSP/795/795-100-100_I5.pdf)
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'clli'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install clli
22
-
23
- ## Usage
24
-
25
- Parse a CLLI and determine the city, state, and country.
26
- ```ruby
27
- clli = CLLI.new('MPLSMNMSDS1')
28
- location = "#{clli.city_name}, #{clli.state_name}, #{clli.country_name}" # Minneapolis, Minnesota, United States
29
- ```
30
-
31
- ## Development
32
-
33
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
-
35
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
-
37
- ## Contributing
38
-
39
- Bug reports and pull requests are welcome on GitHub at https://github.com/steventwheeler/clli.
40
-
41
-
42
- ## License
43
-
44
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
1
+ [![Gem Version](https://badge.fury.io/rb/clli.svg)](https://badge.fury.io/rb/clli)
2
+ [![Build Status](https://travis-ci.org/steventwheeler/clli.svg)](https://travis-ci.org/steventwheeler/clli)
3
+ [![Code Climate](https://codeclimate.com/github/steventwheeler/clli/badges/gpa.svg)](https://codeclimate.com/github/steventwheeler/clli)
4
+
5
+ # CLLI
6
+
7
+ This gem can be used to parse [Common Language Location Identification (CLLI) codes](https://en.wikipedia.org/wiki/CLLI_code). Given a CLLI this gem tries to determine the City, State/Provice, and Country the CLLI represents.
8
+
9
+ The reference for this gem is [Bell System Practices Section 795-100-100](http://etler.com/docs/BSP/795/795-100-100_I5.pdf)
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'clli'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install clli
26
+
27
+ ## Usage
28
+
29
+ Parse a CLLI and determine the city, state, and country.
30
+ ```ruby
31
+ clli = CLLI.new('MPLSMNMSDS1')
32
+ location = "#{clli.city_name}, #{clli.state_name}, #{clli.country_name}" # Minneapolis, Minnesota, United States
33
+ ```
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/steventwheeler/clli.
44
+
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ Rake::TestTask.new(:test) do |t|
10
10
  t.test_files = FileList['test/**/*_test.rb']
11
11
  end
12
12
 
13
- task default: :spec
13
+ task default: :test
14
14
 
15
15
  namespace :generate do
16
16
  task :city_cache do
Binary file
@@ -29,26 +29,32 @@ class CLLI
29
29
 
30
30
  private
31
31
 
32
+ SWITCHING_TYPE_PATTERNS = {
33
+ "MG[#{x1}]" => %w(switching_types MGx),
34
+ "SG[#{x1}]" => %w(switching_types SGx),
35
+ "CG[#{x1}]" => %w(switching_types CGx),
36
+ "DS[#{x1}]" => %w(switching_types DSx),
37
+ "[#{n}]{2}[#{x1}]" => %w(switching_types nnx),
38
+ "[#{n}]{2}T" => %w(switching_types nnT),
39
+ "C[#{n}]T" => %w(switching_types CnT),
40
+ "B[#{n}]T" => %w(switching_types BnT),
41
+ "[#{n}]GT" => %w(switching_types nGT),
42
+ "Z[#{a}]Z" => %w(switching_types ZaZ),
43
+ "RS[#{n}]" => %w(switching_types RSn),
44
+ "X[#{a}]X" => %w(switching_types XaX),
45
+ "CT[#{x1}]" => %w(switching_types CTx)
46
+ }
47
+
32
48
  ##
33
49
  # Determine which key to use for the parsed entity code.
34
50
  #
35
51
  # Params:
36
52
  # +code+:: the +CLLI+ +:entity_code+ attribute value.
37
53
  def code_keys(code)
54
+ SWITCHING_TYPE_PATTERNS.each do |pattern, keys|
55
+ return keys if Regexp.new(pattern) =~ code
56
+ end
38
57
  case code
39
- when Regexp.new("MG[#{x1}]") then %w(switching_types MGx)
40
- when Regexp.new("SG[#{x1}]") then %w(switching_types SGx)
41
- when Regexp.new("CG[#{x1}]") then %w(switching_types CGx)
42
- when Regexp.new("DS[#{x1}]") then %w(switching_types DSx)
43
- when Regexp.new("[#{n}]{2}[#{x1}]") then %w(switching_types nnx)
44
- when Regexp.new("[#{n}]{2}T") then %w(switching_types nnT)
45
- when Regexp.new("C[#{n}]T") then %w(switching_types CnT)
46
- when Regexp.new("B[#{n}]T") then %w(switching_types BnT)
47
- when Regexp.new("[#{n}]GT") then %w(switching_types nGT)
48
- when Regexp.new("Z[#{a}]Z") then %w(switching_types ZaZ)
49
- when Regexp.new("RS[#{n}]") then %w(switching_types RSn)
50
- when Regexp.new("X[#{a}]X") then %w(switching_types XaX)
51
- when Regexp.new("CT[#{x1}]") then %w(switching_types CTx)
52
58
  when Regexp.new(switchboard_and_desk_entity_code_pattern) then ['switchboard_and_desk', code[1]]
53
59
  when Regexp.new(miscellaneous_switching_termination_entity_code_pattern) then ['miscellaneous_switching_termination', code[1]]
54
60
  when Regexp.new(nonswitching_entity_code_pattern) then ['nonswitching_types', code[0]]
@@ -1,4 +1,4 @@
1
1
  # This file defines the gem version.
2
2
  class CLLI
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clli
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
  - Steven Wheeler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-13 00:00:00.000000000 Z
11
+ date: 2016-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -79,6 +79,7 @@ executables: []
79
79
  extensions: []
80
80
  extra_rdoc_files: []
81
81
  files:
82
+ - ".codeclimate.yml"
82
83
  - ".gitignore"
83
84
  - ".rubocop.yml"
84
85
  - ".travis.yml"
@@ -88,6 +89,7 @@ files:
88
89
  - Rakefile
89
90
  - bin/console
90
91
  - bin/setup
92
+ - clli-0.0.1.gem
91
93
  - clli.gemspec
92
94
  - doc/795-100-100_I5.pdf
93
95
  - lib/clli.rb