highline 1.7.10 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +5 -0
- data/.rubocop.yml +84 -0
- data/.simplecov +5 -0
- data/.travis.yml +35 -9
- data/Changelog.md +214 -15
- data/Gemfile +16 -5
- data/README.md +202 -0
- data/Rakefile +8 -20
- data/appveyor.yml +37 -0
- data/examples/ansi_colors.rb +6 -11
- data/examples/asking_for_arrays.rb +6 -2
- data/examples/basic_usage.rb +31 -21
- data/examples/color_scheme.rb +11 -10
- data/examples/get_character.rb +8 -4
- data/examples/limit.rb +4 -0
- data/examples/menus.rb +16 -10
- data/examples/overwrite.rb +9 -5
- data/examples/page_and_wrap.rb +5 -4
- data/examples/password.rb +4 -0
- data/examples/repeat_entry.rb +10 -5
- data/examples/trapping_eof.rb +2 -1
- data/examples/using_readline.rb +2 -1
- data/highline.gemspec +25 -27
- data/lib/highline/builtin_styles.rb +129 -0
- data/lib/highline/color_scheme.rb +49 -32
- data/lib/highline/compatibility.rb +11 -4
- data/lib/highline/custom_errors.rb +57 -0
- data/lib/highline/import.rb +19 -12
- data/lib/highline/io_console_compatible.rb +37 -0
- data/lib/highline/list.rb +177 -0
- data/lib/highline/list_renderer.rb +261 -0
- data/lib/highline/menu/item.rb +32 -0
- data/lib/highline/menu.rb +306 -111
- data/lib/highline/paginator.rb +52 -0
- data/lib/highline/question/answer_converter.rb +103 -0
- data/lib/highline/question.rb +281 -131
- data/lib/highline/question_asker.rb +150 -0
- data/lib/highline/simulate.rb +24 -13
- data/lib/highline/statement.rb +88 -0
- data/lib/highline/string.rb +36 -0
- data/lib/highline/string_extensions.rb +83 -64
- data/lib/highline/style.rb +196 -63
- data/lib/highline/template_renderer.rb +62 -0
- data/lib/highline/terminal/io_console.rb +36 -0
- data/lib/highline/terminal/ncurses.rb +38 -0
- data/lib/highline/terminal/unix_stty.rb +51 -0
- data/lib/highline/terminal.rb +190 -0
- data/lib/highline/version.rb +3 -1
- data/lib/highline/wrapper.rb +53 -0
- data/lib/highline.rb +390 -788
- metadata +56 -35
- data/INSTALL +0 -59
- data/README.rdoc +0 -74
- data/lib/highline/system_extensions.rb +0 -254
- data/setup.rb +0 -1360
- data/test/string_methods.rb +0 -32
- data/test/tc_color_scheme.rb +0 -96
- data/test/tc_highline.rb +0 -1402
- data/test/tc_import.rb +0 -52
- data/test/tc_menu.rb +0 -439
- data/test/tc_simulator.rb +0 -33
- data/test/tc_string_extension.rb +0 -33
- data/test/tc_string_highline.rb +0 -38
- data/test/tc_style.rb +0 -578
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8c2652997ba01a32e3b6357a60c0567724e235d3763fa7dd000a6adbf71a6d75
|
4
|
+
data.tar.gz: 93fa0727991ba6d16e36a3a76f48784b54c15b8d4e8b32a0703a12c665e62601
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aae3c4c97d87a3b3fd5e12fcb234acc5a3470e3392942db6b369ea42c83fdd2ae90104b8a6957f8250616c35c16f1ab5acb11edeeb585f505f392367293154e9
|
7
|
+
data.tar.gz: 1dc931251446b234c9fff7c2389cd4d156a2fdd8619dc3f57a74cc06b8b50cf4c10ae7943fdfb6b20c2ef1359721d38faa03c875c5ef973bf38a87942173c060
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Bellow the changes to default Rubocop behavior.
|
2
|
+
|
3
|
+
# See options at:
|
4
|
+
# https://github.com/bbatsov/rubocop/tree/master/config
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
TargetRubyVersion: 2.1
|
8
|
+
|
9
|
+
# General
|
10
|
+
|
11
|
+
# Multi-line method chaining should be done with leading dots.
|
12
|
+
Layout/DotPosition:
|
13
|
+
EnforcedStyle: trailing
|
14
|
+
SupportedStyles:
|
15
|
+
- leading
|
16
|
+
- trailing
|
17
|
+
|
18
|
+
# Enabling
|
19
|
+
# --------
|
20
|
+
|
21
|
+
Style/CollectionMethods:
|
22
|
+
Description: 'Preferred collection methods.'
|
23
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size'
|
24
|
+
Enabled: true
|
25
|
+
|
26
|
+
Style/StringMethods:
|
27
|
+
Description: 'Checks if configured preferred methods are used over non-preferred.'
|
28
|
+
Enabled: true
|
29
|
+
|
30
|
+
# Disabling
|
31
|
+
# ---------
|
32
|
+
|
33
|
+
# Modifying
|
34
|
+
# ---------
|
35
|
+
|
36
|
+
# Check quotes usage according to lint rule below.
|
37
|
+
Style/StringLiterals:
|
38
|
+
Enabled: true
|
39
|
+
EnforcedStyle: double_quotes
|
40
|
+
|
41
|
+
# Configuration parameters: SupportedStyles.
|
42
|
+
# SupportedStyles: snake_case, camelCase
|
43
|
+
Naming/MethodName:
|
44
|
+
EnforcedStyle: snake_case
|
45
|
+
Exclude:
|
46
|
+
- 'test/**/*'
|
47
|
+
|
48
|
+
# Cop supports --auto-correct.
|
49
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, AutoCorrectEncodingComment.
|
50
|
+
# SupportedStyles: when_needed, always, never
|
51
|
+
Style/Encoding:
|
52
|
+
Enabled: true
|
53
|
+
|
54
|
+
# If we fix this, it will change method signature.
|
55
|
+
# Save it for major release.
|
56
|
+
Style/OptionalArguments:
|
57
|
+
Exclude:
|
58
|
+
- 'lib/highline/list_renderer.rb'
|
59
|
+
|
60
|
+
# TemplateRenderer should never fail on method missing.
|
61
|
+
Style/MethodMissing:
|
62
|
+
Exclude:
|
63
|
+
- 'lib/highline/template_renderer.rb'
|
64
|
+
|
65
|
+
# This is a breaking change for MRI 1.9.
|
66
|
+
# Revoke when updating to MRI 2.0 as minimum.
|
67
|
+
# Cop supports --auto-correct.
|
68
|
+
# Configuration parameters: MinSize, SupportedStyles.
|
69
|
+
# SupportedStyles: percent, brackets
|
70
|
+
Style/SymbolArray:
|
71
|
+
EnforcedStyle: brackets
|
72
|
+
|
73
|
+
# Cop supports --auto-correct.
|
74
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
75
|
+
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
|
76
|
+
Layout/IndentHeredoc:
|
77
|
+
Exclude:
|
78
|
+
- 'examples/page_and_wrap.rb'
|
79
|
+
- 'highline.gemspec'
|
80
|
+
- 'test/acceptance/acceptance.rb'
|
81
|
+
|
82
|
+
# Cop supports --auto-correct.
|
83
|
+
Lint/ScriptPermission:
|
84
|
+
Enabled: false
|
data/.simplecov
ADDED
data/.travis.yml
CHANGED
@@ -1,17 +1,43 @@
|
|
1
1
|
---
|
2
2
|
language: ruby
|
3
|
-
|
3
|
+
dist: trusty
|
4
|
+
cache: bundler
|
4
5
|
script: "bundle exec rake test"
|
5
6
|
rvm:
|
6
|
-
-
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- 2.
|
11
|
-
-
|
12
|
-
-
|
7
|
+
- 2.0
|
8
|
+
- 2.1
|
9
|
+
- 2.2
|
10
|
+
- 2.3
|
11
|
+
- 2.4
|
12
|
+
- jruby-19mode # JRuby in 1.9 mode
|
13
|
+
- jruby-head
|
14
|
+
|
13
15
|
notifications:
|
14
16
|
email: false
|
15
17
|
matrix:
|
16
18
|
allow_failures:
|
17
|
-
- rvm:
|
19
|
+
- rvm: 1.9
|
20
|
+
- rvm: ruby-head
|
21
|
+
- rvm: rbx-3.81
|
22
|
+
- rvm: jruby-19mode # JRuby in 1.9 mode
|
23
|
+
- rvm: jruby-head
|
24
|
+
fast_finish: true
|
25
|
+
include:
|
26
|
+
- rvm: 1.9
|
27
|
+
before_install:
|
28
|
+
- "gem update --system -N"
|
29
|
+
- "gem update bundler -N"
|
30
|
+
- rvm: 2.5
|
31
|
+
before_install:
|
32
|
+
- gem install bundler
|
33
|
+
- rvm: 2.6
|
34
|
+
before_install:
|
35
|
+
- gem install bundler
|
36
|
+
- rvm: ruby-head
|
37
|
+
before_install:
|
38
|
+
- gem install bundler
|
39
|
+
- rvm: rbx-3.81
|
40
|
+
before_install:
|
41
|
+
- gem install bundler
|
42
|
+
|
43
|
+
bundler_args: --without code_quality
|
data/Changelog.md
CHANGED
@@ -2,26 +2,225 @@
|
|
2
2
|
|
3
3
|
Below is a complete listing of changes for each revision of HighLine.
|
4
4
|
|
5
|
-
###
|
6
|
-
*
|
5
|
+
### 2.0.3 / 2019-10-11
|
6
|
+
* PR #245 - Suppress `Psych.safe_load` arg warn (@koic)
|
7
7
|
|
8
|
-
###
|
9
|
-
*
|
8
|
+
### 2.0.2 / 2019-04-08
|
9
|
+
* PR #243 - Add new capital_letter option to menu index (@Ana06)
|
10
|
+
* This is a really special PR. It has come from "The Biggest
|
11
|
+
Mobprogramming Session Ever" and around 250 people
|
12
|
+
participated in crafting it!
|
13
|
+
* PR #241 - CI: Add 2.6 (@olleolleolle)
|
14
|
+
* PR #240 - Avoid YARD warning UnknownParam (@olleolleolle)
|
10
15
|
|
11
|
-
###
|
12
|
-
*
|
16
|
+
### 2.0.1 / 2019-01-23
|
17
|
+
* PR #238 / I #237 - Rescue Errno::ENOTTY when pipeing
|
13
18
|
|
14
|
-
###
|
15
|
-
*
|
19
|
+
### 2.0.0 / 2018-06-10
|
20
|
+
* Release 2.0.0 (major version release).
|
16
21
|
|
17
|
-
###
|
18
|
-
*
|
22
|
+
### 2.0.0-develop.16 / 2018-05-12
|
23
|
+
* PR #231 - Deprecate safe_level of ERB.new in Ruby 2.6 (@koic)
|
24
|
+
* PR #230 - Fix behavior when shell and gather options are selected together
|
19
25
|
|
20
|
-
###
|
21
|
-
*
|
26
|
+
### 2.0.0-develop.15 / 2017-12-28
|
27
|
+
* PR #229 - Update .travis.yml. Add Ruby 2.5 to matrix (@abinoam)
|
22
28
|
|
23
|
-
###
|
24
|
-
*
|
29
|
+
### 2.0.0-develop.14 / 2017-11-21
|
30
|
+
* PR #222 / I #221 - Fix inconsistent behaviour when using agree with readline (@abinoam, @ailisp)
|
31
|
+
|
32
|
+
### 2.0.0-develop.13 / 2017-11-05
|
33
|
+
* PR #219 - Make possible to use a callable as response (@abinoam)
|
34
|
+
|
35
|
+
### 2.0.0-develop.12 / 2017-10-19
|
36
|
+
* PR #218 - Ease transition from 1.7.x to 2.0.x (@abinoam)
|
37
|
+
* Copy use_color from HighLine.default_instance
|
38
|
+
* Expose IOConsoleCompatible
|
39
|
+
* PR #216 - Update .appveyor.yml - Fix Windows CI (@abinoam)
|
40
|
+
|
41
|
+
### 2.0.0-develop.11 / 2017-09-25
|
42
|
+
* PR #215 - Apply several Rubocop stylistic suggestions (@abinoam)
|
43
|
+
* Update gemspec/Gemfile to newer standards
|
44
|
+
* Update travis configuration fixing 1.9 problem
|
45
|
+
* Adjust .rubocop.yml with things we don't want to change
|
46
|
+
|
47
|
+
### 2.0.0-develop.10 / 2017-06-29
|
48
|
+
* PR #214 - Remove `$terminal` (global variable) (@abinoam)
|
49
|
+
* Use HighLine.default_instance instead
|
50
|
+
* Reorganize/Group code at lib/highline.rb
|
51
|
+
|
52
|
+
### 2.0.0-develop.9 / 2017-06-24
|
53
|
+
|
54
|
+
* PR #211 / PR #212 - HighLine#use_color= and use_color? as instance methods (@abinoam, @phiggins)
|
55
|
+
* PR #203 / I #191 - Default values are shown in menus by Frederico (@fredrb)
|
56
|
+
* PR #201 / I #198 - Confirm in question now accepts Proc (@mmihira)
|
57
|
+
* PR #197 - Some HighLine::Menu improvements
|
58
|
+
* Move Menu::MenuItem to Menu::Item with its own file
|
59
|
+
* Some small refactorings
|
60
|
+
|
61
|
+
### 2.0.0-develop.8 / 2016-06-03
|
62
|
+
|
63
|
+
* PR #195 - Add PRONTO to development group at Gemfile by Abinoam Jr. (@abinoam)
|
64
|
+
|
65
|
+
### 2.0.0-develop.7 / 2016-05-31
|
66
|
+
|
67
|
+
* PR #194 - Indices coloring on HighLine::Menu by Aregic (@aregic)
|
68
|
+
* PR #190 - Add Ruby 2.3.0 to travis matrix by Koichi (@koic/ruby-23)
|
69
|
+
* PR #189 - Improve #agree tests by @kevinoid
|
70
|
+
|
71
|
+
### 2.0.0-develop.6 / 2016-02-01
|
72
|
+
|
73
|
+
* PR #184 - Menu improvements, bug fixes, and more tests by Geoff Lee (@matrinox)
|
74
|
+
* Add third arg to menu that overides the choice displayed to the user
|
75
|
+
* FIX: autocomplete prompt does not include menu choices after the first
|
76
|
+
* Add specs to cover the new features and the bug fix
|
77
|
+
* PR #183 - Fix menu example in README.md by Fabien Foerster (@fabienfoerster)
|
78
|
+
|
79
|
+
### 2.0.0-develop.5 / 2015-12-27
|
80
|
+
|
81
|
+
* Fix #180 with PR #181 - Make it possible to overwrite the menu prompt shown on errors.
|
82
|
+
|
83
|
+
### 2.0.0-develop.4 / 2015-12-14
|
84
|
+
|
85
|
+
This versions makes the code documentation 100% 'A' grade on inch.
|
86
|
+
We have used inch and http://inch-ci.org to guide the priorities
|
87
|
+
on documentation production.
|
88
|
+
|
89
|
+
The grade 'A' (on inch) number of objects on master branch was 44,22% (153/346).
|
90
|
+
After this PR we have a 100% grade 'A' (344 objects).
|
91
|
+
|
92
|
+
There's already a inch-ci.org badge on README.md. And now it's all green!
|
93
|
+
|
94
|
+
We also bring some improvement on CodeClimate scores.
|
95
|
+
|
96
|
+
#### CHANGES SUMMARY
|
97
|
+
|
98
|
+
* PR #179 - Make inch happy. Grade "A" for the whole HighLine documentation. By Abinoam Jr. (@abinoam)
|
99
|
+
* PR #178 - Improve score on Code Climate by applying some refactoring. By Abinoam Jr. (@abinoam)
|
100
|
+
* PR #172 - Initial work on documentation by Abinoam Jr. (@abinoam)
|
101
|
+
* Use yard
|
102
|
+
* Use inch
|
103
|
+
* New Readme file
|
104
|
+
* Fix #166 with PR #173 by (@matugm)
|
105
|
+
|
106
|
+
|
107
|
+
### 2.0.0-develop.3 / 2015-10-28
|
108
|
+
|
109
|
+
This version brings some improvements on documentation (switch to Yardoc).
|
110
|
+
This is the first 2.0.0-develop.x version to be release as gem.
|
111
|
+
|
112
|
+
### 2.0.0-develop.2 / 2015-09-09
|
113
|
+
|
114
|
+
(by Abinoam P. Marques Jr. - @abinoam)
|
115
|
+
|
116
|
+
#### NOTES
|
117
|
+
|
118
|
+
This version brings greater compatibility with JRuby and Windows.
|
119
|
+
But we still have a lot of small issues in both platforms.
|
120
|
+
We were able to unify/converge all approaches into using io/console,
|
121
|
+
so we could delete old code that relied solely on stty, termios, java api and
|
122
|
+
windows apis (DL and Fiddle).
|
123
|
+
|
124
|
+
Another improvement is the beginning of what I called "acceptance tests".
|
125
|
+
If you type ```rake acceptance``` you'll be guided through some tests
|
126
|
+
where you have to input some thing and see if everything work as expected.
|
127
|
+
This makes easier to catch bugs that otherwise would be over-sighted.
|
128
|
+
|
129
|
+
#### CHANGES SUMMARY
|
130
|
+
|
131
|
+
* Fix Simplecov - it was reporting erroneous code coverage
|
132
|
+
* Add new tests. Improves code coverage
|
133
|
+
* Extract HighLine::BuiltinStyles
|
134
|
+
* Try to avoid nil checking
|
135
|
+
* Try to avoid class variables (mis)use
|
136
|
+
* Fix RDoc include path and some small fixes to the docs
|
137
|
+
* Move HighLine::String to its own file
|
138
|
+
* Add HighLine::Terminal::IOConsole
|
139
|
+
- Add an IOConsoleCompatibility module with some stubbed
|
140
|
+
methods for using at StringIO, File and Tempfile to help
|
141
|
+
on tests.
|
142
|
+
- Any enviroment that can require 'io/console' will
|
143
|
+
use HighLine::Terminal::IOConsole by default. This kind
|
144
|
+
of unifies most environments where HighLine runs. For
|
145
|
+
example, we can use Terminal::IOConsole on JRuby!!!
|
146
|
+
* Add ruby-head and JRuby (19mode and head) to Travis CI matrix. Yes, this
|
147
|
+
our first step to a more peaceful JRuby compatibility.
|
148
|
+
* Add AppVeyor Continuous Integration for Windows
|
149
|
+
* Add _acceptance_ tests for HighLine
|
150
|
+
- Use ```rake acceptance``` to run them
|
151
|
+
- Basically it interactively asks the user to confirm if
|
152
|
+
some expected HighLine behavior is actually happening.
|
153
|
+
After that it gather some environment debug information,
|
154
|
+
so the use could send to the HighLine contributors in case
|
155
|
+
of failure.
|
156
|
+
* Remove old and unused files (as a result of relying on io/console)
|
157
|
+
- JRuby
|
158
|
+
- Windows (DL and Fiddle)
|
159
|
+
- Termios
|
160
|
+
* Fix some small (old and new) bugs
|
161
|
+
* Make some more tuning for Windows compatibility
|
162
|
+
* Make some more tuning for JRuby compatibility
|
163
|
+
|
164
|
+
### 2.0.0-develop.1 / 2015-06-11
|
165
|
+
|
166
|
+
This is the first development version of the 2.0.0 series. It's the begining of a refactoring phase on HighLine development cycle.
|
167
|
+
|
168
|
+
#### SOME HISTORY
|
169
|
+
|
170
|
+
In 2014 I emailed James Edward Gray II (@JEG2) about HighLine. One of his ideas was to completely refactor the library so that it could be easier to reuse and improve it. I've began my contributions to HighLine trying to fix some of the open issues at that time so that we could "freeze" a stable version of HighLine that people could rely on. Then I've began to study HighLine source code with James' help and started to refactor some parts of the code. Abinoam P. Marques Jr. (@abinoam)
|
171
|
+
|
172
|
+
#### NOTES
|
173
|
+
|
174
|
+
* This release differs from current master branch by more than 180 commits.
|
175
|
+
* The main changes will be only summarized bellow (as there are many, and a detailed description of each is not productive).
|
176
|
+
* You could try `git log -p` to see all of them.
|
177
|
+
* During the last commits, all possible efforts were taken to preserve the tests passing status.
|
178
|
+
* 100% test passing gives you no guarantee that this new version will work for you. This happens for many reasons. One of them is that we don't currently have 100% test coverage.
|
179
|
+
* So, this version is not suitable for use in production.
|
180
|
+
* [Metric_fu](https://github.com/metricfu/metric_fu) and [Code Climate](https://codeclimate.com/github/abinoam/highline) were used here not to strictly "guide" what should be changed, but to have some way to objectively measure the progresses made so far.
|
181
|
+
|
182
|
+
#### CHANGES SUMMARY
|
183
|
+
* Extracted a lot of smaller methods from bigger ones
|
184
|
+
* Extracted smaller classes/modules from bigger ones, so they could be self contained with less external dependencies as possible, for example:
|
185
|
+
* HighLine::Statement
|
186
|
+
* HighLine::List
|
187
|
+
* HighLine::ListRenderer
|
188
|
+
* HighLine::TemplateRenderer
|
189
|
+
* HighLine::Question::AnswerConverter
|
190
|
+
* HighLine::Terminal
|
191
|
+
* HighLine::Terminal::UnixStty
|
192
|
+
* HighLine::Paginator
|
193
|
+
* HighLine::Wrapper
|
194
|
+
* After extracting each class/module some refactoring were applied to them lowering code complexity
|
195
|
+
|
196
|
+
#### METRICS SUMMARY
|
197
|
+
Some of the metrics used to track progress are summarized bellow. Some of them have got a lot better as Flay, Flog and Reek, others like Cane haven't (probably because we didn't commented out the new code yet)
|
198
|
+
|
199
|
+
__CODECLIMATE__
|
200
|
+
|
201
|
+
* GPA: 3.60 -> 3.67 (higher is better)
|
202
|
+
|
203
|
+
__CANE__ - reports code quality threshold violations (lower is better)
|
204
|
+
|
205
|
+
* Total 92 -> 105
|
206
|
+
* Methods exceeding allowed Abc complexity: 14 -> 10
|
207
|
+
* Lines violating style requirements: 69 -> 72
|
208
|
+
* Class definitions requiring comments: 9 -> 23
|
209
|
+
|
210
|
+
__FLAY__ - analyzes ruby code for structural similarities (code duplication - lower is better)
|
211
|
+
|
212
|
+
* Total: 490 -> 94
|
213
|
+
|
214
|
+
__FLOG__ - measures code complexity (lower is better)
|
215
|
+
|
216
|
+
* Top 5% average: 127.9458 -> 40.99812
|
217
|
+
* Average: 17.37982 -> 7.663875
|
218
|
+
* Total: 2158.5 -> 1969.6
|
219
|
+
|
220
|
+
__REEK__ - detects common code smells in ruby code (lower is better)
|
221
|
+
|
222
|
+
* DuplicateMethodCall: 144 -> 54
|
223
|
+
* TooManyStatements: 26 -> 30
|
25
224
|
|
26
225
|
### 1.7.3 / 2015-06-29
|
27
226
|
* Add HighLine::Simulator tests (Bala Paranj (@bparanj) and Abinoam Marques Jr. (@abinoam), #142, PR #143)
|
@@ -391,7 +590,7 @@ Patch by Jeremy Hinegardner:
|
|
391
590
|
HighLine's own cross-platform terminal input routine.
|
392
591
|
* Improved type conversion to handle user defined classes.
|
393
592
|
|
394
|
-
### 0.2.0
|
593
|
+
### 0.2.0 / 2005-04-29
|
395
594
|
|
396
595
|
* Added Unit Tests to cover an already fixed output bug in the future.
|
397
596
|
* Added Rakefile and setup test action (default).
|
data/Gemfile
CHANGED
@@ -1,11 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
source "https://rubygems.org"
|
2
4
|
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in tgem.gemspec
|
3
8
|
gemspec
|
4
9
|
|
5
|
-
|
6
|
-
|
10
|
+
platform :ruby do
|
11
|
+
# Running only on MRI
|
12
|
+
gem "simplecov", group: :test
|
13
|
+
end
|
7
14
|
|
8
|
-
group
|
9
|
-
gem "
|
10
|
-
gem "
|
15
|
+
group :code_quality do
|
16
|
+
gem "flog", require: false
|
17
|
+
gem "pronto", require: false, platform: :ruby
|
18
|
+
gem "pronto-flay", require: false, platform: :ruby
|
19
|
+
gem "pronto-poper", require: false, platform: :ruby
|
20
|
+
gem "pronto-reek", require: false, platform: :ruby
|
21
|
+
gem "pronto-rubocop", require: false, platform: :ruby
|
11
22
|
end
|
data/README.md
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
HighLine
|
2
|
+
========
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/JEG2/highline.svg?branch=master)](https://travis-ci.org/JEG2/highline)
|
5
|
+
[![Build status](https://ci.appveyor.com/api/projects/status/4p05fijpah77d28x/branch/master?svg=true)](https://ci.appveyor.com/project/JEG2/highline/branch/master)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/highline.svg)](https://badge.fury.io/rb/highline)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/JEG2/highline/badges/gpa.svg)](https://codeclimate.com/github/JEG2/highline)
|
8
|
+
[![Test Coverage](https://codeclimate.com/github/JEG2/highline/badges/coverage.svg)](https://codeclimate.com/github/JEG2/highline/coverage)
|
9
|
+
[![Inline docs](http://inch-ci.org/github/JEG2/highline.svg?branch=master)](http://inch-ci.org/github/JEG2/highline)
|
10
|
+
|
11
|
+
Description
|
12
|
+
-----------
|
13
|
+
|
14
|
+
Welcome to HighLine.
|
15
|
+
|
16
|
+
HighLine was designed to ease the tedious tasks of doing console input and
|
17
|
+
output with low-level methods like ```gets``` and ```puts```. HighLine provides a
|
18
|
+
robust system for requesting data from a user, without needing to code all the
|
19
|
+
error checking and validation rules and without needing to convert the typed
|
20
|
+
Strings into what your program really needs. Just tell HighLine what you're
|
21
|
+
after, and let it do all the work.
|
22
|
+
|
23
|
+
Documentation
|
24
|
+
-------------
|
25
|
+
|
26
|
+
See: [Rubydoc.info for HighLine](http://www.rubydoc.info/github/JEG2/highline/master).
|
27
|
+
Specially [HighLine](http://www.rubydoc.info/github/JEG2/highline/master/HighLine) and [HighLine::Question](http://www.rubydoc.info/github/JEG2/highline/master/HighLine/Question).
|
28
|
+
|
29
|
+
Usage
|
30
|
+
-----
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
|
34
|
+
require 'highline'
|
35
|
+
|
36
|
+
# Basic usage
|
37
|
+
|
38
|
+
cli = HighLine.new
|
39
|
+
answer = cli.ask "What do you think?"
|
40
|
+
puts "You have answered: #{answer}"
|
41
|
+
|
42
|
+
|
43
|
+
# Default answer
|
44
|
+
|
45
|
+
cli.ask("Company? ") { |q| q.default = "none" }
|
46
|
+
|
47
|
+
|
48
|
+
# Validation
|
49
|
+
|
50
|
+
cli.ask("Age? ", Integer) { |q| q.in = 0..105 }
|
51
|
+
cli.ask("Name? (last, first) ") { |q| q.validate = /\A\w+, ?\w+\Z/ }
|
52
|
+
|
53
|
+
|
54
|
+
# Type conversion for answers:
|
55
|
+
|
56
|
+
cli.ask("Birthday? ", Date)
|
57
|
+
cli.ask("Interests? (comma sep list) ", lambda { |str| str.split(/,\s*/) })
|
58
|
+
|
59
|
+
|
60
|
+
# Reading passwords:
|
61
|
+
|
62
|
+
cli.ask("Enter your password: ") { |q| q.echo = false }
|
63
|
+
cli.ask("Enter your password: ") { |q| q.echo = "x" }
|
64
|
+
|
65
|
+
|
66
|
+
# ERb based output (with HighLine's ANSI color tools):
|
67
|
+
|
68
|
+
cli.say("This should be <%= color('bold', BOLD) %>!")
|
69
|
+
|
70
|
+
|
71
|
+
# Menus:
|
72
|
+
|
73
|
+
cli.choose do |menu|
|
74
|
+
menu.prompt = "Please choose your favorite programming language? "
|
75
|
+
menu.choice(:ruby) { cli.say("Good choice!") }
|
76
|
+
menu.choices(:python, :perl) { cli.say("Not from around here, are you?") }
|
77
|
+
menu.default = :ruby
|
78
|
+
end
|
79
|
+
|
80
|
+
## Using colored indices on Menus
|
81
|
+
|
82
|
+
HighLine::Menu.index_color = :rgb_77bbff # set default index color
|
83
|
+
|
84
|
+
cli.choose do |menu|
|
85
|
+
menu.index_color = :rgb_999999 # override default color of index
|
86
|
+
# you can also use constants like :blue
|
87
|
+
menu.prompt = "Please choose your favorite programming language? "
|
88
|
+
menu.choice(:ruby) { cli.say("Good choice!") }
|
89
|
+
menu.choices(:python, :perl) { cli.say("Not from around here, are you?") }
|
90
|
+
end
|
91
|
+
```
|
92
|
+
|
93
|
+
If you want to save some characters, you can inject/import HighLine methods on Kernel by doing the following. Just be sure to avoid name collisions in the top-level namespace.
|
94
|
+
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
require 'highline/import'
|
98
|
+
|
99
|
+
say "Now you can use #say directly"
|
100
|
+
```
|
101
|
+
|
102
|
+
For more examples see the examples/ directory of this project.
|
103
|
+
|
104
|
+
Requirements
|
105
|
+
------------
|
106
|
+
|
107
|
+
HighLine from version >= 1.7.0 requires ruby >= 1.9.3
|
108
|
+
|
109
|
+
Installing
|
110
|
+
----------
|
111
|
+
|
112
|
+
To install HighLine, use the following command:
|
113
|
+
|
114
|
+
```sh
|
115
|
+
$ gem install highline
|
116
|
+
```
|
117
|
+
|
118
|
+
(Add `sudo` if you're installing under a POSIX system as root)
|
119
|
+
|
120
|
+
If you're using [Bundler](http://bundler.io/), add this to your Gemfile:
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
source "https://rubygems.org"
|
124
|
+
gem 'highline'
|
125
|
+
```
|
126
|
+
|
127
|
+
And then run:
|
128
|
+
|
129
|
+
```sh
|
130
|
+
$ bundle
|
131
|
+
```
|
132
|
+
|
133
|
+
If you want to build the gem locally, use the following command from the root of the sources:
|
134
|
+
|
135
|
+
```sh
|
136
|
+
$ rake package
|
137
|
+
```
|
138
|
+
|
139
|
+
You can also build and install directly:
|
140
|
+
|
141
|
+
```sh
|
142
|
+
$ rake install
|
143
|
+
```
|
144
|
+
|
145
|
+
Contributing
|
146
|
+
------------
|
147
|
+
|
148
|
+
1. Open an issue
|
149
|
+
- https://github.com/JEG2/highline/issues
|
150
|
+
|
151
|
+
2. Fork the repository
|
152
|
+
- https://github.com/JEG2/highline/fork
|
153
|
+
|
154
|
+
3. Clone it locally
|
155
|
+
- ```git clone git@github.com:YOUR-USERNAME/highline.git```
|
156
|
+
|
157
|
+
4. Add the main HighLine repository as the __upstream__ remote
|
158
|
+
- ```cd highline``` # to enter the cloned repository directory.
|
159
|
+
- ```git remote add upstream https://github.com/JEG2/highline```
|
160
|
+
|
161
|
+
5. Keep your fork in sync with __upstream__
|
162
|
+
- ```git fetch upstream```
|
163
|
+
- ```git checkout master```
|
164
|
+
- ```git merge upstream/master```
|
165
|
+
|
166
|
+
6. Create your feature branch
|
167
|
+
- ```git checkout -b your_branch```
|
168
|
+
|
169
|
+
7. Hack the source code, run the tests and __pronto__
|
170
|
+
- ```rake test```
|
171
|
+
- ```rake acceptance```
|
172
|
+
- ```pronto run```
|
173
|
+
|
174
|
+
8. Commit your changes
|
175
|
+
- ```git commit -am "Your commit message"```
|
176
|
+
|
177
|
+
9. Push it
|
178
|
+
- ```git push```
|
179
|
+
|
180
|
+
10. Open a pull request
|
181
|
+
- https://github.com/JEG2/highline/pulls
|
182
|
+
|
183
|
+
Details on:
|
184
|
+
|
185
|
+
* GitHub Guide to Contributing to Open Source - https://guides.github.com/activities/contributing-to-open-source/
|
186
|
+
* GitHub issues - https://guides.github.com/features/issues/
|
187
|
+
* Forking - https://help.github.com/articles/fork-a-repo/
|
188
|
+
* Cloning - https://help.github.com/articles/cloning-a-repository/
|
189
|
+
* Adding upstream - https://help.github.com/articles/configuring-a-remote-for-a-fork/
|
190
|
+
* Syncing your fork - https://help.github.com/articles/syncing-a-fork/
|
191
|
+
* Branching - https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
|
192
|
+
* Commiting - https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository
|
193
|
+
* Pushing - https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes
|
194
|
+
|
195
|
+
The Core HighLine Team
|
196
|
+
----------------------
|
197
|
+
|
198
|
+
* [James Edward Gray II](https://github.com/JEG2) - Author
|
199
|
+
* [Gregory Brown](https://github.com/practicingruby) - Core contributor
|
200
|
+
* [Abinoam P. Marques Jr.](https://github.com/abinoam) - Core contributor
|
201
|
+
|
202
|
+
_For a list of people who have contributed to the codebase, see [GitHub's list of contributors](https://github.com/JEG2/highline/contributors)._
|
data/Rakefile
CHANGED
@@ -1,30 +1,18 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
2
3
|
require "rake/testtask"
|
3
|
-
require "rubygems/package_task"
|
4
4
|
require "bundler/gem_tasks"
|
5
|
-
require "code_statistics"
|
6
|
-
|
7
|
-
require "rubygems"
|
8
5
|
|
9
|
-
task :
|
6
|
+
task default: [:test]
|
10
7
|
|
11
8
|
Rake::TestTask.new do |test|
|
12
|
-
test.libs = [
|
13
|
-
test.test_files = FileList[ "test/tc_*.rb"]
|
9
|
+
test.libs = %w[lib test]
|
14
10
|
test.verbose = true
|
15
11
|
test.warning = true
|
12
|
+
test.test_files = FileList["test/test*.rb"]
|
16
13
|
end
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
"AUTHORS", "COPYING",
|
22
|
-
"LICENSE", "lib /*.rb" )
|
23
|
-
rdoc.main = "README.rdoc"
|
24
|
-
rdoc.rdoc_dir = "doc/html"
|
25
|
-
rdoc.title = "HighLine Documentation"
|
26
|
-
end
|
27
|
-
|
28
|
-
Gem::PackageTask.new(SPEC) do |package|
|
29
|
-
# do nothing: I just need a gem but this block is required
|
15
|
+
desc "Run some interactive acceptance tests"
|
16
|
+
task :acceptance do
|
17
|
+
load "test/acceptance/acceptance.rb"
|
30
18
|
end
|