ph_no_to_word 2.0.0 → 2.1.0

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
  SHA256:
3
- metadata.gz: ac15e2fbf7b0aa75ff86a0b2ff3ac8f25b09faaaa51b5ea9acb40fcef1918c15
4
- data.tar.gz: 8a5ad371a10bf4066df410bfbdc35282f7929c841a32ea1d209ac0e4b7818596
3
+ metadata.gz: 3d24e17ec78136038cda980d62bc4d43dbe6a2cdd0fa7748b2c900923d268ea3
4
+ data.tar.gz: 72df027cdfb2086cc5b9314842c839d46bb61d1adb4243eef2c0a8bc8513ca56
5
5
  SHA512:
6
- metadata.gz: 835da6c62126dca333a994200b9b3e098d1586c2ede34d4e55174e9db92411672e4a0b94c7fac044f42bedc1813cd9d6992bcb209ad9e05ae5684c5ea39b1d96
7
- data.tar.gz: 33f21a8f93c023bc9f9765f837b00507d8f44b3a92d403d3047e9f8ad883ccb66a003a83a1b36af41ef3350d582db6ef38cd7508022ff03d648580901bf91a29
6
+ metadata.gz: d0bdcfe74d4a0a5dc1a8a4cc25fe3e27135c8ad7dc4dd3483e7bbd80255163cc3bac186ed89a9d127d1c9873f3a9c45eb5cbeace7191627130fecf220496a6a7
7
+ data.tar.gz: 9d783c0316660b8c1ba50441bc0a49be063604605acf131f7a2f8e6845edbd96f0105b209b31d96c51da14d5acb1c4dee393480b124824d32345b2b1bad72f1a
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ !.gitignore
2
+ *.gem
3
+ .Trashes
4
+ /.bundle/
5
+ /.yardoc
6
+ /.vscode
7
+ /_yardoc/
8
+ /coverage/
9
+ /doc/
10
+ /pkg/
11
+ /spec/reports/
12
+ /tmp/
13
+
14
+ # rspec failure tracking
15
+ .rspec_status
16
+
17
+ # rbenv config
18
+ .ruby-gemset
19
+ .ruby-version
20
+
21
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 2.0.1
data/CHANGELOG.md CHANGED
@@ -32,7 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
32
32
  - Moved the splitting code to separate namespace
33
33
  ### Removed
34
34
 
35
- ## [2.0.0] - 2019-06-02
35
+ ## [2.0.0] - 2019-06-05
36
36
  ### Added
37
37
  - New methods and completely rewritten the logic for high performance improvements
38
38
  - Performance Improvements, now get the result in 1/10 of the previous version
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ph_no_to_word.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'simplecov', '>= 0.16.1'
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Abhilash A K
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -27,7 +27,7 @@ After installing the gem goto
27
27
  ```ruby
28
28
  irb(main):001:0> require 'ph_no_to_word'
29
29
  => true
30
- irb(main):002:0> PhNoToWord::convert "2282668687"
30
+ irb(main):002:0> PhNoToWord.convert "2282668687"
31
31
  => ["act, amounts", "act, boo, tots", "act, boo, tour", "act, boot, mus",
32
32
  ....... "cat, coot, mus", "cat, coot, nus", "cat, coot, our", "catamounts"]
33
33
 
@@ -54,7 +54,7 @@ Results:
54
54
  ```
55
55
 
56
56
  ```ruby
57
- irb(main):004:0> PhNoToWord::convert '6686787825'
57
+ irb(main):004:0> PhNoToWord.convert '6686787825'
58
58
  => ["act, amounts", "act, boo, tots", "act, boo, tour", "act, boot, mus",
59
59
  ....."oot, orts, taj", "motor, truck", "motor, usual", "motortruck", "nouns, truck","nouns, usual"]
60
60
 
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # TODO: for future use
3
+ # Helper
4
4
  module PhNoToWord
5
5
  # helper module to expand functionalities
6
6
  module Helpers
@@ -110,15 +110,10 @@ module PhNoToWord
110
110
 
111
111
  # Level 1: 3 char words
112
112
  # Level 2: > 3 char words
113
- # Level 3: 10 char words
114
113
  def filename_frm_lvl(str)
115
- case str.length
116
- when MIN_WD_LENGTH
114
+ if str.length == MIN_WD_LENGTH
117
115
  level = 1
118
116
  filename = nil
119
- when PH_LENGTH
120
- level = 3
121
- filename = str[0..2] + FILE_EXT
122
117
  else
123
118
  level = 2
124
119
  filename = str[0..3] + FILE_EXT
@@ -12,11 +12,12 @@
12
12
  # end
13
13
  module PhNoToWord
14
14
  module Logger
15
+ # TODO
15
16
  # Log a PhNoToWord-specific line.
16
- def log(level, message)
17
- File.open('log.txt', 'a') do |f|
18
- f.write "#{level}: #{message}"
19
- end
20
- end
17
+ # def log(level, message)
18
+ # File.open('error.log', 'a') do |f|
19
+ # f.write "#{level}: #{message}"
20
+ # end
21
+ # end
21
22
  end
22
- end
23
+ end
@@ -2,9 +2,9 @@
2
2
 
3
3
  require 'ph_no_to_word/error'
4
4
 
5
- # TODO: for future use
5
+ # included the error module and validation
6
6
  module PhNoToWord
7
- # helper module to expand functionalities
7
+ # helper module to validating the phone number
8
8
  module Validator
9
9
  # Module methods
10
10
  module ClassMethods
@@ -1,3 +1,3 @@
1
1
  module PhNoToWord
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -1,48 +1,35 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "ph_no_to_word/version"
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+ require 'ph_no_to_word/version'
5
3
 
6
4
  Gem::Specification.new do |spec|
7
- spec.name = "ph_no_to_word"
5
+ spec.name = 'ph_no_to_word'
8
6
  spec.version = PhNoToWord::VERSION
9
- spec.authors = ["Abhilash A K"]
10
- spec.email = ["abhilash.amballur@gmail.com"]
7
+ spec.authors = ['Abhilash A K']
8
+ spec.email = ['abhilash.amballur@gmail.com']
11
9
 
12
- spec.summary = %q{Converts the phone number into word characters}
13
- spec.description = %q{This gem allows given 10 character phone number to convert into a word contained in a dictionary}
14
- spec.homepage = "https://github.com/abhilashak/ph_no_to_word"
15
- spec.license = "MIT"
10
+ spec.summary = 'Converts the phone number into word characters'
11
+ spec.description = 'This gem allows given 10 character phone number to convert into a word contained in a dictionary'
12
+ spec.homepage = 'https://github.com/abhilashak/ph_no_to_word'
13
+ spec.license = 'MIT'
16
14
 
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
15
  if spec.respond_to?(:metadata)
20
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
- spec.metadata["homepage_uri"] = spec.homepage
22
- spec.metadata["source_code_uri"] = spec.homepage
23
- spec.metadata["changelog_uri"] = spec.homepage + '/blob/master/CHANGELOG.md'
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = spec.homepage
18
+ spec.metadata['changelog_uri'] = spec.homepage + '/blob/master/CHANGELOG.md'
24
19
  else
25
- raise "RubyGems 2.0 or newer is required to protect against " \
26
- "public gem pushes."
20
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
21
+ 'public gem pushes.'
27
22
  end
28
23
 
29
- # Specify which files should be added to the gem when it is released.
30
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.required_ruby_version = '>= 2.5.3'
25
+ spec.required_rubygems_version = '>= 2.7.6'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 2.0'
28
+ spec.add_development_dependency 'rake', '~> 10.0'
29
+ spec.add_development_dependency 'rspec', '~> 3.0'
31
30
 
32
- spec.files = %w[ph_no_to_word.gemspec] + Dir["*.md",
33
- "bin/*",
34
- "lib/**/*.rb",
35
- "lib/**/**/*.txt",
36
- "lib/**/**/**/*.txt"
37
- ]
31
+ spec.require_paths = %w[lib]
32
+ spec.files = `git ls-files`.split("\n")
38
33
  spec.bindir = 'exe'
39
34
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
40
- spec.require_paths = %w[lib]
41
-
42
- spec.required_ruby_version = '>= 2.5.3'
43
- spec.required_rubygems_version = ">= 2.7.6"
44
-
45
- spec.add_development_dependency "bundler", "~> 2.0"
46
- spec.add_development_dependency "rake", "~> 10.0"
47
- spec.add_development_dependency "rspec", "~> 3.0"
48
35
  end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe PhNoToWord do
4
+ it 'has a version number' do
5
+ expect(PhNoToWord::VERSION).not_to be nil
6
+ end
7
+
8
+ it `convert the given 10 digit phone number (2282668687) to words
9
+ and return an array and expected result` do
10
+ result = PhNoToWord.convert '2282668687'
11
+
12
+ expect(result.is_a?(Array)).to be true
13
+ expect(result).to include('act, amounts', 'catamounts', 'acta, oot, mus')
14
+ expect(result.size).to eq(53)
15
+ end
16
+
17
+ it `convert the given 10 digit phone number (6686787825) to words
18
+ and return an array and expected result` do
19
+ result = PhNoToWord.convert '6686787825'
20
+
21
+ expect(result.is_a?(Array)).to be true
22
+ expect(result).to include('not, ort, suck', 'motortruck', 'motor, truck')
23
+ expect(result.size).to eq(44)
24
+ end
25
+
26
+ it `convert the given 10 digit phone number (8325783555) to words
27
+ and return an empty array` do
28
+ result = PhNoToWord.convert '8325783555'
29
+
30
+ expect(result).to be_empty
31
+ expect(result.is_a?(Array)).to be true
32
+ end
33
+
34
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ if RUBY_VERSION >= '2.5.3'
4
+ require 'simplecov'
5
+
6
+ SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter]
7
+
8
+ SimpleCov.start do
9
+ add_filter '/spec'
10
+ minimum_coverage(90)
11
+ end
12
+ end
13
+
14
+ require 'bundler/setup'
15
+ require 'ph_no_to_word'
16
+
17
+ RSpec.configure do |config|
18
+ # Enable flags like --only-failures and --next-failure
19
+ config.example_status_persistence_file_path = '.rspec_status'
20
+
21
+ # Disable RSpec exposing methods globally on `Module` and `main`
22
+ config.disable_monkey_patching!
23
+
24
+ config.expect_with :rspec do |c|
25
+ c.syntax = :expect
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe PhNoToWord::SplitDictionary do
4
+ it 'should split the provided dictionary file' do
5
+ expect { PhNoToWord::SplitDictionary.split_files('fake/path/test.txt') }.to raise_error(PhNoToWord::Error::FileNotExists)
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe PhNoToWord::Validator do
4
+ it 'should raise RequiredArgumentMissingError if phone number empty' do
5
+ err_msg = PhNoToWord::Constants::ERRORS[:missing_ph]
6
+ expect { PhNoToWord.convert '' }.to raise_error(PhNoToWord::Error::RequiredArgumentMissingError, err_msg)
7
+ end
8
+
9
+ it 'should raise MalformattedArgumentError if phone number length is less than 10' do
10
+ err_msg = PhNoToWord::Constants::ERRORS[:ph_length]
11
+ expect { PhNoToWord.convert '228266868' }.to raise_error(PhNoToWord::Error::MalformattedArgumentError, err_msg)
12
+ expect { PhNoToWord.convert '2' }.to raise_error(PhNoToWord::Error::MalformattedArgumentError, err_msg)
13
+ end
14
+
15
+ it 'should raise MalformattedArgumentError if phone number contains 0 or 1' do
16
+ err_msg = PhNoToWord::Constants::ERRORS[:malformed_ph_no]
17
+ expect { PhNoToWord.convert '2282668681' }.to raise_error(PhNoToWord::Error::MalformattedArgumentError, err_msg)
18
+ expect { PhNoToWord.convert '2282068687' }.to raise_error(PhNoToWord::Error::MalformattedArgumentError, err_msg)
19
+ end
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ph_no_to_word
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abhilash A K
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-04 00:00:00.000000000 Z
11
+ date: 2019-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,9 +60,15 @@ executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
63
66
  - CHANGELOG.md
64
67
  - CODE_OF_CONDUCT.md
68
+ - Gemfile
69
+ - LICENSE.txt
65
70
  - README.md
71
+ - Rakefile
66
72
  - bin/console
67
73
  - bin/setup
68
74
  - lib/ph_no_to_word.rb
@@ -15349,6 +15355,10 @@ files:
15349
15355
  - lib/ph_no_to_word/word_files/level_3/zyg.txt
15350
15356
  - lib/ph_no_to_word/word_files/level_3/zym.txt
15351
15357
  - ph_no_to_word.gemspec
15358
+ - spec/ph_no_to_word_spec.rb
15359
+ - spec/spec_helper.rb
15360
+ - spec/split_dictionary_spec.rb
15361
+ - spec/validator_spec.rb
15352
15362
  homepage: https://github.com/abhilashak/ph_no_to_word
15353
15363
  licenses:
15354
15364
  - MIT