kokki 0.2.2 β†’ 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3da23aba8c12bb8f3d0088ba298a6ff89f36eac9dc15096a186fc1a9db532ecb
4
- data.tar.gz: 67ceca8f92a7c0cd5c98f18d3a1fca90c59f36ee76777e1e82ea84818d91cc00
3
+ metadata.gz: 772cdf4092ed406b8f744745b7b539ffa4375795498a4a688a71475a0df755be
4
+ data.tar.gz: 805150748bd3696df1463a85a01064e56d07aaf32723fed065667e8fb9b39da8
5
5
  SHA512:
6
- metadata.gz: c1a216dea356b7c62e7863158ba2171ea25730ac0e74ea37da37ba4d21f449b96de11f3093fee502fc9867dcc8b250fff1b6228bffc0360e970dbc31b7acb645
7
- data.tar.gz: d53903b8f416378c618cf051a291d2b1ae4b4ed0e12cee4159ac3b91578d7b0c217ba0efb27bb23e093b9e2bf3ab78f594d7409146e524607d72465c6dcc4b94
6
+ metadata.gz: dad024a32e0b8da163ef23d513f85bacb258753a9e51c268e7c1cf35954dee0ef31c7956ee8c3291c83827db9b4d2a9f57a0eebbde77a1efadf64e1560dc72e2
7
+ data.tar.gz: f5a67b073fa69e1eaf2fb8a997187da4d62df03421eca50716387120f48015c945e38defe7399dba371d5de8282083b3fa3dccd4b588b3bb2275d3403e6e4d30
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # kokki
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/kokki.svg)](https://badge.fury.io/rb/kokki)
3
4
  [![Build Status](https://travis-ci.org/ninoseki/kokki.svg?branch=master)](https://travis-ci.org/ninoseki/kokki)
4
5
  [![Coverage Status](https://coveralls.io/repos/github/ninoseki/kokki/badge.svg?branch=master)](https://coveralls.io/github/ninoseki/kokki?branch=master)
6
+ [![CodeFactor](https://www.codefactor.io/repository/github/ninoseki/kokki/badge)](https://www.codefactor.io/repository/github/ninoseki/kokki)
5
7
 
6
8
  A Ruby gem for converting a country name / code & IP address to an emoji flag.
7
9
 
@@ -13,6 +15,21 @@ gem install kokki
13
15
 
14
16
  ## Usage
15
17
 
18
+ ### As a CLI
19
+
20
+ ```bash
21
+ $ kokki TW
22
+ πŸ‡ΉπŸ‡Ό
23
+ $ kokki USA
24
+ πŸ‡ΊπŸ‡Έ
25
+ $ kokki japan
26
+ πŸ‡―πŸ‡΅
27
+ $ kokki 202.214.194.147
28
+ πŸ‡―πŸ‡΅
29
+ ```
30
+
31
+ ### As a library
32
+
16
33
  ```ruby
17
34
  require "kokki"
18
35
 
@@ -32,12 +49,3 @@ rescue Kokki::InvalidInputError => e
32
49
  # => invalid input: test
33
50
  end
34
51
  ```
35
-
36
- ### CLI
37
-
38
- ```bash
39
- $ kokki TW
40
- πŸ‡ΉπŸ‡Ό
41
- $ kokki japan
42
- πŸ‡―πŸ‡΅
43
- ```
data/kokki.gemspec CHANGED
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "coveralls", "~> 0.8"
29
29
  spec.add_development_dependency "rake", "~> 12.3"
30
30
  spec.add_development_dependency "rspec", "~> 3.8"
31
- spec.add_development_dependency "vcr", "~> 4.0"
32
- spec.add_development_dependency "webmock", "~> 3.5"
31
+ spec.add_development_dependency "vcr", "~> 5.0"
32
+ spec.add_development_dependency "webmock", "~> 3.6"
33
33
 
34
34
  spec.add_dependency "geocoder", "~> 1.5"
35
35
  end
data/lib/kokki/cli.rb CHANGED
@@ -10,7 +10,7 @@ module Kokki
10
10
  puts e.message
11
11
  end
12
12
  else
13
- puts "Input not found: plase give a word to convert."
13
+ puts "Input not found: please give a word to convert."
14
14
  end
15
15
  end
16
16
  end
@@ -15,12 +15,17 @@ module Kokki
15
15
  def convert
16
16
  flag = nil
17
17
 
18
- flag = dict.lookup_by_alpha_2_code(upcase) if input.length == 2
19
- flag = dict.lookup_by_alpha_3_code(upcase) if input.length == 3
18
+ case input.length
19
+ when 2
20
+ flag = dict.lookup_by_alpha_2_code(upcase)
21
+ when 3
22
+ flag = dict.lookup_by_alpha_3_code(upcase)
23
+ end
24
+
20
25
  flag ||= dict.lookup_by_name(upcase)
21
26
  flag ||= convert_as_ip_address(input)
22
27
 
23
- raise InvalidInputError, "invalid input: #{input}" unless flag
28
+ raise InvalidInputError, "Invalid input given: #{input}" unless flag
24
29
 
25
30
  flag
26
31
  end
@@ -17,7 +17,7 @@ module Kokki
17
17
  @country_code ||=
18
18
  [].tap do |out|
19
19
  out << Geocoder.search(address)&.first&.country_code&.upcase
20
- rescue Geocoder::Error => _
20
+ rescue Geocoder::Error => _e
21
21
  out << nil
22
22
  end.first
23
23
  end
@@ -27,7 +27,7 @@ module Kokki
27
27
  def ip_address?(address)
28
28
  IPAddr.new(address)
29
29
  true
30
- rescue IPAddr::InvalidAddressError => _
30
+ rescue IPAddr::InvalidAddressError => _e
31
31
  false
32
32
  end
33
33
  end
data/lib/kokki/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kokki
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kokki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-27 00:00:00.000000000 Z
11
+ date: 2019-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '4.0'
75
+ version: '5.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '4.0'
82
+ version: '5.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.5'
89
+ version: '3.6'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.5'
96
+ version: '3.6'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: geocoder
99
99
  requirement: !ruby/object:Gem::Requirement