input_reader 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +6 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/input_reader.gemspec +0 -2
- data/lib/input_reader/version.rb +1 -1
- data/spec/input_reader_spec.rb +23 -24
- data/spec/spec_helper.rb +3 -4
- data/spec/support/coverage_loader.rb +1 -2
- metadata +3 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37defb639f3959810c915c979bfe13fa7cad752870af668a547586a39c75874a
|
4
|
+
data.tar.gz: fbcafeecb19ebe6e02b9c4152d4ea0f522ac4ef73041194e1674b377b1c5a0e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53f353a09c38a7b7e95f129ef3108e13046801aeae4b34fd454f6e5ac7966e5d0533065346b3fdd5fd361119f03b70e983df4e71b08a9abb2c0730a45a7bdbe6
|
7
|
+
data.tar.gz: a4aee48c6d77f9e0e570a40537c7574c771802ca6cf4b845e7b88cec56d082f362e936354e2fb625e0fdba23d7746ad436e9eb00b6324443dc413b20495e5461
|
data/.github/workflows/ruby.yml
CHANGED
@@ -5,7 +5,7 @@ jobs:
|
|
5
5
|
strategy:
|
6
6
|
fail-fast: false
|
7
7
|
matrix:
|
8
|
-
ruby: ["2.6", "2.7", "3.0"]
|
8
|
+
ruby: ["2.6", "2.7", "3.0", "3.1"]
|
9
9
|
runs-on: ubuntu-latest
|
10
10
|
steps:
|
11
11
|
- uses: actions/checkout@v2
|
@@ -14,3 +14,8 @@ jobs:
|
|
14
14
|
ruby-version: ${{ matrix.ruby }}
|
15
15
|
bundler-cache: true
|
16
16
|
- run: bundle exec rake
|
17
|
+
- name: Coveralls
|
18
|
+
uses: coverallsapp/github-action@master
|
19
|
+
with:
|
20
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
21
|
+
path-to-lcov: coverage/lcov.info
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.1.0
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
|
5
5
|
|
6
|
+
## 0.3.0
|
7
|
+
|
8
|
+
- [PLAT-183] Ruby 3.1, update deprecated rspec syntax, and publish coverage with github action
|
9
|
+
|
6
10
|
## 0.2.0
|
7
11
|
|
8
12
|
- [TT-8631] Update to build with github actions / ruby 3.0 / rails 6.1
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# InputReader
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/input_reader.svg)](http://badge.fury.io/rb/input_reader)
|
4
|
-
[![Build Status](https://
|
5
|
-
[![
|
4
|
+
[![Build Status](https://github.com/sealink/input_reader/workflows/Build%20and%20Test/badge.svg?branch=master)](https://github.com/sealink/input_reader/actions)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/sealink/input_reader/badge.png)](https://coveralls.io/r/sealink/input_reader)
|
6
6
|
|
7
7
|
Reads and parses input and helps build input menus, etc.
|
8
8
|
|
data/input_reader.gemspec
CHANGED
@@ -19,8 +19,6 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_development_dependency 'rake'
|
20
20
|
gem.add_development_dependency 'rspec'
|
21
21
|
gem.add_development_dependency 'coverage-kit'
|
22
|
-
gem.add_development_dependency 'simplecov-rcov'
|
23
22
|
gem.add_development_dependency 'guard-rspec'
|
24
|
-
gem.add_development_dependency 'coveralls'
|
25
23
|
gem.add_development_dependency 'pry-byebug'
|
26
24
|
end
|
data/lib/input_reader/version.rb
CHANGED
data/spec/input_reader_spec.rb
CHANGED
@@ -6,55 +6,55 @@ describe InputReader do
|
|
6
6
|
it 'should read strings' do
|
7
7
|
expect_output ' '
|
8
8
|
input '1'
|
9
|
-
InputReader.get_input.
|
9
|
+
expect(InputReader.get_input).to eq '1'
|
10
10
|
|
11
11
|
expect_output 'number '
|
12
12
|
input '2'
|
13
|
-
InputReader.get_input(:prompt => 'number').
|
13
|
+
expect(InputReader.get_input(:prompt => 'number')).to eq '2'
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should read integers' do
|
17
17
|
input '1'
|
18
|
-
InputReader.get_int.
|
18
|
+
expect(InputReader.get_int).to eq 1
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should read booleans' do
|
22
22
|
input 'y'
|
23
|
-
InputReader.get_boolean.
|
23
|
+
expect(InputReader.get_boolean).to be true
|
24
24
|
|
25
25
|
input 'F'
|
26
|
-
InputReader.get_boolean.
|
26
|
+
expect(InputReader.get_boolean).to be false
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should handle invalid boolean values' do
|
30
30
|
input 'x'
|
31
31
|
input 'y'
|
32
|
-
InputReader.get_boolean.
|
32
|
+
expect(InputReader.get_boolean).to be true
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should handle dates' do
|
36
36
|
input '2012-01-13'
|
37
|
-
InputReader.get_date.
|
37
|
+
expect(InputReader.get_date).to eq Date.new(2012, 1, 13)
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should handle date times' do
|
41
41
|
input '2012-01-13 18:45'
|
42
|
-
InputReader.get_datetime.
|
42
|
+
expect(InputReader.get_datetime).to eq DateTime.new(2012, 1, 13, 18, 45, 0)
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should handle arrays' do
|
46
46
|
input ['1', '2', '3', '']
|
47
|
-
InputReader.get_array.
|
47
|
+
expect(InputReader.get_array).to eq ['1', '2', '3']
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'should handle array of ints' do
|
51
51
|
input ['1', '2', '3', '']
|
52
|
-
InputReader.get_array_of_ints.
|
52
|
+
expect(InputReader.get_array_of_ints).to eq [1, 2, 3]
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'should handle array of dates' do
|
56
56
|
input ['2012-01-13', '2012-07-24', '']
|
57
|
-
InputReader.get_array_of_dates.
|
57
|
+
expect(InputReader.get_array_of_dates).to eq [
|
58
58
|
Date.new(2012, 1, 13),
|
59
59
|
Date.new(2012, 7, 24)
|
60
60
|
]
|
@@ -62,7 +62,7 @@ describe InputReader do
|
|
62
62
|
|
63
63
|
it 'should handle array of date times' do
|
64
64
|
input ['2012-01-13 14:45', '2012-07-24 19:59', '']
|
65
|
-
InputReader.get_array_of_datetimes.
|
65
|
+
expect(InputReader.get_array_of_datetimes).to eq [
|
66
66
|
DateTime.new(2012, 1, 13, 14, 45, 0),
|
67
67
|
DateTime.new(2012, 7, 24, 19, 59)
|
68
68
|
]
|
@@ -70,13 +70,13 @@ describe InputReader do
|
|
70
70
|
|
71
71
|
it 'should allow selecting between choices' do
|
72
72
|
input '2'
|
73
|
-
InputReader.select_item(['Alpha', 'Beta', 'Gamma']).
|
73
|
+
expect(InputReader.select_item(['Alpha', 'Beta', 'Gamma'])).to eq 'Beta'
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should return nil if no choice is selected' do
|
77
77
|
input ''
|
78
|
-
InputReader.select_item(['Alpha', 'Beta', 'Gamma'],
|
79
|
-
:allow_blank => true).
|
78
|
+
expect(InputReader.select_item(['Alpha', 'Beta', 'Gamma'],
|
79
|
+
:allow_blank => true)).to eq nil
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'should handle selecting between multiple choices' do
|
@@ -86,8 +86,7 @@ describe InputReader do
|
|
86
86
|
double(:name => 'Gamma')
|
87
87
|
]
|
88
88
|
input '1,3'
|
89
|
-
InputReader.select_items(objects, :selection_attribute => :name).
|
90
|
-
[objects[0], objects[2]]
|
89
|
+
expect(InputReader.select_items(objects, :selection_attribute => :name)).to eq ([objects[0], objects[2]])
|
91
90
|
end
|
92
91
|
|
93
92
|
it 'should return an empty array if no choices are selected' do
|
@@ -97,29 +96,29 @@ describe InputReader do
|
|
97
96
|
double(:name => 'Gamma')
|
98
97
|
]
|
99
98
|
input ''
|
100
|
-
InputReader.select_items(objects,
|
99
|
+
expect(InputReader.select_items(objects,
|
101
100
|
:selection_attribute => :name,
|
102
|
-
:allow_blank => true).
|
101
|
+
:allow_blank => true)).to eq []
|
103
102
|
end
|
104
103
|
|
105
104
|
it 'should allow confirming' do
|
106
105
|
input 'N'
|
107
106
|
block = lambda{ }
|
108
|
-
block.
|
107
|
+
expect(block).not_to receive(:call)
|
109
108
|
InputReader.confirmation_required do
|
110
109
|
block.call
|
111
110
|
end
|
112
111
|
|
113
112
|
input 'Y'
|
114
113
|
block = lambda{ }
|
115
|
-
block.
|
114
|
+
expect(block).to receive(:call)
|
116
115
|
InputReader.confirmation_required do
|
117
116
|
block.call
|
118
117
|
end
|
119
118
|
|
120
119
|
input 'X'
|
121
120
|
block = lambda{ }
|
122
|
-
block.
|
121
|
+
expect(block).not_to receive(:call)
|
123
122
|
InputReader.confirmation_required do
|
124
123
|
block.call
|
125
124
|
end
|
@@ -127,8 +126,8 @@ describe InputReader do
|
|
127
126
|
|
128
127
|
it 'should validate unparsed input' do
|
129
128
|
input ['1', '2']
|
130
|
-
InputReader.get_int(
|
129
|
+
expect(InputReader.get_int(
|
131
130
|
:parsed_input_validators => [{:validator => :even?}]
|
132
|
-
).
|
131
|
+
)).to eq 2
|
133
132
|
end
|
134
133
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
#
|
6
6
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
7
|
RSpec.configure do |config|
|
8
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
8
|
config.run_all_when_everything_filtered = true
|
10
9
|
config.filter_run :focus
|
11
10
|
|
@@ -19,14 +18,14 @@ end
|
|
19
18
|
require 'support/coverage_loader'
|
20
19
|
|
21
20
|
def expect_output(output)
|
22
|
-
$stdout.
|
21
|
+
expect($stdout).to receive(:print).with(output)
|
23
22
|
end
|
24
23
|
|
25
24
|
def input(input)
|
26
25
|
if input.is_a?(String)
|
27
|
-
$stdin.
|
26
|
+
expect($stdin).to receive(:gets).once.and_return(input)
|
28
27
|
elsif input.is_a?(Array)
|
29
|
-
$stdin.
|
28
|
+
expect($stdin).to receive(:gets).exactly(input.size).times.and_return(*input)
|
30
29
|
else
|
31
30
|
end
|
32
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: input_reader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Berardi, Michael Noack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: simplecov-rcov
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: guard-rspec
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +66,6 @@ dependencies:
|
|
80
66
|
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: coveralls
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: pry-byebug
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
124
|
- !ruby/object:Gem::Version
|
153
125
|
version: '0'
|
154
126
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
127
|
+
rubygems_version: 3.3.3
|
156
128
|
signing_key:
|
157
129
|
specification_version: 4
|
158
130
|
summary: Command line helpers to read input, etc.
|