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 +4 -4
- data/README.md +17 -9
- data/kokki.gemspec +2 -2
- data/lib/kokki/cli.rb +1 -1
- data/lib/kokki/converter.rb +8 -3
- data/lib/kokki/ip_address.rb +2 -2
- data/lib/kokki/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 772cdf4092ed406b8f744745b7b539ffa4375795498a4a688a71475a0df755be
|
4
|
+
data.tar.gz: 805150748bd3696df1463a85a01064e56d07aaf32723fed065667e8fb9b39da8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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", "~>
|
32
|
-
spec.add_development_dependency "webmock", "~> 3.
|
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
data/lib/kokki/converter.rb
CHANGED
@@ -15,12 +15,17 @@ module Kokki
|
|
15
15
|
def convert
|
16
16
|
flag = nil
|
17
17
|
|
18
|
-
|
19
|
-
|
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, "
|
28
|
+
raise InvalidInputError, "Invalid input given: #{input}" unless flag
|
24
29
|
|
25
30
|
flag
|
26
31
|
end
|
data/lib/kokki/ip_address.rb
CHANGED
@@ -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
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.
|
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-
|
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: '
|
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: '
|
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.
|
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.
|
96
|
+
version: '3.6'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: geocoder
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|