yano 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +5 -0
- data/.travis.yml +1 -3
- data/Gemfile +6 -0
- data/README.md +3 -0
- data/Rakefile +7 -3
- data/lib/yano/lenient.rb +12 -7
- data/lib/yano/version.rb +3 -1
- data/lib/yano.rb +4 -2
- data/yano.gemspec +12 -13
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b8c3c1664cd21178b5a13bd8c5232476f2ce00304a228a80e76cc55f978864bc
|
4
|
+
data.tar.gz: 3780633c1390da38836dda8e2fefc0f5c14960cd844ee0d1e7791f34aad17f6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d62a6054705233a06c5489d806227fa5e291806067ca5cf76cb297c0441c76b052ea1151203a99fd046affaed6d378a8a279e8f1d42d3453a74a958eb44edab3
|
7
|
+
data.tar.gz: a4ec229d570d5071b7f5f04cdf14d9b546b045932dcf14663b90af6dd1d81b65317b872b72e5c14fbf0218ed2f36fe3c66b321f3c02486fb07b97cf4500ae73a
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
# Yano
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/nikkypx/yano.svg?branch=master)](https://travis-ci.org/nikkypx/yano)
|
4
|
+
|
2
5
|
**This is a ruby port of [yn](https://github.com/sindresorhus/yn) by [sindresorhus](https://github.com/sindresorhus)**
|
3
6
|
|
4
7
|
> Parse yes/no like values
|
data/Rakefile
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
3
6
|
|
4
7
|
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
RuboCop::RakeTask.new
|
5
9
|
|
6
|
-
task :
|
10
|
+
task default: %i[spec]
|
data/lib/yano/lenient.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Yano
|
2
4
|
module Lenient
|
3
5
|
YES_MATCH_SCORE_THRESHOLD = 2
|
@@ -13,7 +15,7 @@ module Yano
|
|
13
15
|
'g' => 0.25,
|
14
16
|
'h' => 0.25,
|
15
17
|
'k' => 0.25
|
16
|
-
}
|
18
|
+
}.freeze
|
17
19
|
|
18
20
|
E_MATCH = {
|
19
21
|
'2' => 0.25,
|
@@ -25,7 +27,7 @@ module Yano
|
|
25
27
|
's' => 0.25,
|
26
28
|
'd' => 0.25,
|
27
29
|
'f' => 0.25
|
28
|
-
}
|
30
|
+
}.freeze
|
29
31
|
|
30
32
|
S_MATCH = {
|
31
33
|
'q' => 0.25,
|
@@ -37,7 +39,7 @@ module Yano
|
|
37
39
|
'z' => 0.25,
|
38
40
|
'x' => 0.25,
|
39
41
|
'c' => 0.25
|
40
|
-
}
|
42
|
+
}.freeze
|
41
43
|
|
42
44
|
N_MATCH = {
|
43
45
|
'h' => 0.25,
|
@@ -46,7 +48,7 @@ module Yano
|
|
46
48
|
'b' => 0.75,
|
47
49
|
'n' => 1,
|
48
50
|
'm' => 0.75
|
49
|
-
}
|
51
|
+
}.freeze
|
50
52
|
|
51
53
|
O_MATCH = {
|
52
54
|
'9' => 0.25,
|
@@ -56,10 +58,12 @@ module Yano
|
|
56
58
|
'p' => 0.75,
|
57
59
|
'k' => 0.25,
|
58
60
|
'l' => 0.25
|
59
|
-
}
|
61
|
+
}.freeze
|
60
62
|
|
61
63
|
def self.get_yes_match_score(val)
|
62
|
-
y
|
64
|
+
y = val[0]
|
65
|
+
e = val[1]
|
66
|
+
s = val[2]
|
63
67
|
[].tap do |score|
|
64
68
|
score << Y_MATCH[y].to_f
|
65
69
|
score << E_MATCH[e].to_f
|
@@ -68,7 +72,8 @@ module Yano
|
|
68
72
|
end
|
69
73
|
|
70
74
|
def self.get_no_match_score(val)
|
71
|
-
n
|
75
|
+
n = val[0]
|
76
|
+
o = val[1]
|
72
77
|
|
73
78
|
[].tap do |score|
|
74
79
|
score << N_MATCH[n].to_f
|
data/lib/yano/version.rb
CHANGED
data/lib/yano.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yano/version'
|
2
4
|
require 'yano/lenient'
|
3
5
|
|
@@ -7,8 +9,8 @@ module Yano
|
|
7
9
|
|
8
10
|
def self.parse(val, opts = {})
|
9
11
|
val = val.to_s.strip
|
10
|
-
return true if !!(val =~ VALID_YES_VALUE)
|
11
|
-
return false if !!(val =~ VALID_NO_VALUE)
|
12
12
|
return Lenient.check_lenient_values(val) if opts.delete(:lenient)
|
13
|
+
return true if val =~ VALID_YES_VALUE
|
14
|
+
return false if val =~ VALID_NO_VALUE
|
13
15
|
end
|
14
16
|
end
|
data/yano.gemspec
CHANGED
@@ -1,23 +1,22 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'yano/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'yano'
|
8
9
|
spec.version = Yano::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['Nick Palaniuk']
|
11
|
+
spec.email = ['npalaniuk@gmail.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
13
|
+
spec.summary = 'Parse yes/no like values, useful for CLI prompts'
|
14
|
+
spec.description = 'Parse yes/no like values'
|
15
|
+
spec.homepage = 'https://github.com/nikkypx/yano'
|
16
|
+
spec.license = 'MIT'
|
16
17
|
|
17
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = ["lib"]
|
19
|
+
spec.require_paths = ['lib']
|
21
20
|
|
22
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler'
|
23
22
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Palaniuk
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
description: Parse yes/no like values
|
28
28
|
email:
|
29
29
|
- npalaniuk@gmail.com
|
@@ -32,6 +32,7 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- ".gitignore"
|
35
|
+
- ".rubocop.yml"
|
35
36
|
- ".travis.yml"
|
36
37
|
- Gemfile
|
37
38
|
- LICENSE.txt
|
@@ -61,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
62
|
version: '0'
|
62
63
|
requirements: []
|
63
64
|
rubyforge_project:
|
64
|
-
rubygems_version: 2.
|
65
|
+
rubygems_version: 2.7.6
|
65
66
|
signing_key:
|
66
67
|
specification_version: 4
|
67
68
|
summary: Parse yes/no like values, useful for CLI prompts
|