highline 2.0.0.pre.develop.9 → 2.0.0.pre.develop.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +59 -5
- data/.travis.yml +9 -4
- data/Changelog.md +11 -0
- data/Gemfile +12 -19
- data/Rakefile +5 -11
- data/examples/ansi_colors.rb +6 -11
- data/examples/asking_for_arrays.rb +4 -3
- data/examples/basic_usage.rb +29 -22
- data/examples/color_scheme.rb +11 -10
- data/examples/get_character.rb +6 -5
- data/examples/limit.rb +2 -1
- data/examples/menus.rb +11 -11
- data/examples/overwrite.rb +7 -6
- data/examples/page_and_wrap.rb +5 -4
- data/examples/password.rb +2 -1
- data/examples/repeat_entry.rb +7 -5
- data/examples/trapping_eof.rb +2 -1
- data/examples/using_readline.rb +2 -1
- data/highline.gemspec +25 -25
- data/lib/highline.rb +103 -111
- data/lib/highline/builtin_styles.rb +45 -41
- data/lib/highline/color_scheme.rb +32 -28
- data/lib/highline/compatibility.rb +3 -3
- data/lib/highline/custom_errors.rb +2 -1
- data/lib/highline/import.rb +8 -11
- data/lib/highline/list.rb +4 -8
- data/lib/highline/list_renderer.rb +207 -201
- data/lib/highline/menu.rb +75 -63
- data/lib/highline/menu/item.rb +2 -0
- data/lib/highline/paginator.rb +5 -6
- data/lib/highline/question.rb +38 -36
- data/lib/highline/question/answer_converter.rb +2 -2
- data/lib/highline/question_asker.rb +15 -17
- data/lib/highline/simulate.rb +11 -13
- data/lib/highline/statement.rb +12 -10
- data/lib/highline/string.rb +9 -8
- data/lib/highline/string_extensions.rb +30 -14
- data/lib/highline/style.rb +68 -45
- data/lib/highline/template_renderer.rb +5 -5
- data/lib/highline/terminal.rb +24 -31
- data/lib/highline/terminal/io_console.rb +2 -2
- data/lib/highline/terminal/ncurses.rb +4 -3
- data/lib/highline/terminal/unix_stty.rb +12 -9
- data/lib/highline/version.rb +1 -1
- data/lib/highline/wrapper.rb +12 -11
- metadata +34 -43
- data/test/acceptance/acceptance.rb +0 -62
- data/test/acceptance/acceptance_test.rb +0 -69
- data/test/acceptance/at_color_output_using_erb_templates.rb +0 -17
- data/test/acceptance/at_echo_false.rb +0 -23
- data/test/acceptance/at_readline.rb +0 -37
- data/test/io_console_compatible.rb +0 -37
- data/test/string_methods.rb +0 -35
- data/test/test_answer_converter.rb +0 -26
- data/test/test_color_scheme.rb +0 -94
- data/test/test_helper.rb +0 -22
- data/test/test_highline.rb +0 -1627
- data/test/test_import.rb +0 -55
- data/test/test_list.rb +0 -60
- data/test/test_menu.rb +0 -749
- data/test/test_paginator.rb +0 -73
- data/test/test_question_asker.rb +0 -20
- data/test/test_simulator.rb +0 -24
- data/test/test_string_extension.rb +0 -72
- data/test/test_string_highline.rb +0 -42
- data/test/test_style.rb +0 -613
- data/test/test_wrapper.rb +0 -188
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 384e4ddade0f40dc604fd6cbb4fed1f543f54fa3
|
4
|
+
data.tar.gz: 80ca4c698e1418b4a3476e27e4179bde0405721c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40e63c09636602c0a71582f8ea4033571202fe10721655b4853d74d3a391472ce6c574404fe750f543ec4f783b2e66afac247e21ec9ed729c521e0826d54187a
|
7
|
+
data.tar.gz: c35ebc20d89396e0af1f8b97716067308c726c290374fecfa71c1b9a9968dcd854f0a1d020e6e7a10407ded8f9fc52273e688538c1b33b54ee05f9c0a2d8fd8d
|
data/.rubocop.yml
CHANGED
@@ -3,16 +3,20 @@
|
|
3
3
|
# See options at:
|
4
4
|
# https://github.com/bbatsov/rubocop/tree/master/config
|
5
5
|
|
6
|
+
AllCops:
|
7
|
+
TargetRubyVersion: 1.9
|
8
|
+
|
6
9
|
# General
|
7
10
|
|
8
11
|
# Multi-line method chaining should be done with leading dots.
|
9
|
-
|
12
|
+
Layout/DotPosition:
|
10
13
|
EnforcedStyle: trailing
|
11
14
|
SupportedStyles:
|
12
15
|
- leading
|
13
16
|
- trailing
|
14
17
|
|
15
|
-
# Enabling
|
18
|
+
# Enabling
|
19
|
+
# --------
|
16
20
|
|
17
21
|
Style/CollectionMethods:
|
18
22
|
Description: 'Preferred collection methods.'
|
@@ -23,9 +27,59 @@ Style/StringMethods:
|
|
23
27
|
Description: 'Checks if configured preferred methods are used over non-preferred.'
|
24
28
|
Enabled: true
|
25
29
|
|
26
|
-
# Disabling
|
30
|
+
# Disabling
|
31
|
+
# ---------
|
32
|
+
|
33
|
+
# Modifying
|
34
|
+
# ---------
|
27
35
|
|
36
|
+
# Check quotes usage according to lint rule below.
|
28
37
|
Style/StringLiterals:
|
29
|
-
|
30
|
-
|
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
|
+
EnforcedStyle: always
|
54
|
+
|
55
|
+
# If we fix this, it will change method signature.
|
56
|
+
# Save it for major release.
|
57
|
+
Style/OptionalArguments:
|
58
|
+
Exclude:
|
59
|
+
- 'lib/highline/list_renderer.rb'
|
60
|
+
|
61
|
+
# TemplateRenderer should never fail on method missing.
|
62
|
+
Style/MethodMissing:
|
63
|
+
Exclude:
|
64
|
+
- 'lib/highline/template_renderer.rb'
|
65
|
+
|
66
|
+
# This is a breaking change for MRI 1.9.
|
67
|
+
# Revoke when updating to MRI 2.0 as minimum.
|
68
|
+
# Cop supports --auto-correct.
|
69
|
+
# Configuration parameters: MinSize, SupportedStyles.
|
70
|
+
# SupportedStyles: percent, brackets
|
71
|
+
Style/SymbolArray:
|
72
|
+
EnforcedStyle: brackets
|
73
|
+
|
74
|
+
# Cop supports --auto-correct.
|
75
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
76
|
+
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
|
77
|
+
Layout/IndentHeredoc:
|
78
|
+
Exclude:
|
79
|
+
- 'examples/page_and_wrap.rb'
|
80
|
+
- 'highline.gemspec'
|
81
|
+
- 'test/acceptance/acceptance.rb'
|
82
|
+
|
83
|
+
# Cop supports --auto-correct.
|
84
|
+
Lint/ScriptPermission:
|
31
85
|
Enabled: false
|
data/.travis.yml
CHANGED
@@ -2,12 +2,13 @@
|
|
2
2
|
language: ruby
|
3
3
|
dist: trusty
|
4
4
|
sudo: false
|
5
|
+
cache: bundler
|
5
6
|
script: "bundle exec rake test"
|
6
7
|
rvm:
|
7
|
-
- 1.9
|
8
8
|
- 2.0
|
9
9
|
- 2.1
|
10
10
|
- 2.2
|
11
|
+
- 2.3
|
11
12
|
- ruby-head
|
12
13
|
- rbx-3.81
|
13
14
|
- jruby-19mode # JRuby in 1.9 mode
|
@@ -23,6 +24,10 @@ matrix:
|
|
23
24
|
- rvm: jruby-19mode # JRuby in 1.9 mode
|
24
25
|
- rvm: jruby-head
|
25
26
|
include:
|
26
|
-
- rvm:
|
27
|
-
|
28
|
-
|
27
|
+
- rvm: 1.9
|
28
|
+
before_install:
|
29
|
+
- "gem update --system -N"
|
30
|
+
- "gem update bundler -N"
|
31
|
+
- rvm: 2.4
|
32
|
+
script: "bundle exec rake test && bundle exec codeclimate-test-reporter" # Run only for 2.4
|
33
|
+
bundler_args: --without code_quality
|
data/Changelog.md
CHANGED
@@ -2,6 +2,17 @@
|
|
2
2
|
|
3
3
|
Below is a complete listing of changes for each revision of HighLine.
|
4
4
|
|
5
|
+
### 2.0.0-develop.11 / 2017-09-25
|
6
|
+
* PR #215 - Apply several Rubocop stylistic suggestions (@abinoam)
|
7
|
+
* Update gemspec/Gemfile to newer standards
|
8
|
+
* Update travis configuration fixing 1.9 problem
|
9
|
+
* Adjust .rubocop.yml with things we don't want to change
|
10
|
+
|
11
|
+
### 2.0.0-develop.10 / 2017-06-29
|
12
|
+
* PR #214 - Remove `$terminal` (global variable) (@abinoam)
|
13
|
+
* Use HighLine.default_instance instead
|
14
|
+
* Reorganize/Group code at lib/highline.rb
|
15
|
+
|
5
16
|
### 2.0.0-develop.9 / 2017-06-24
|
6
17
|
|
7
18
|
* PR #211 / PR #212 - HighLine#use_color= and use_color? as instance methods (@abinoam, @phiggins)
|
data/Gemfile
CHANGED
@@ -1,13 +1,11 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
gem "rdoc", require: false
|
3
|
+
source "https://rubygems.org"
|
5
4
|
|
6
|
-
|
7
|
-
gem "code_statistics", require: false
|
8
|
-
gem "minitest", require: false
|
9
|
-
end
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
10
6
|
|
7
|
+
# Specify your gem's dependencies in tgem.gemspec
|
8
|
+
gemspec
|
11
9
|
|
12
10
|
# Reporting only at one ruby version of travis matrix (no repetition)
|
13
11
|
gem "codeclimate-test-reporter", group: :test, require: false
|
@@ -17,16 +15,11 @@ platform :ruby do
|
|
17
15
|
gem "simplecov", group: :test
|
18
16
|
end
|
19
17
|
|
20
|
-
group :
|
21
|
-
gem
|
22
|
-
gem
|
23
|
-
gem
|
24
|
-
gem
|
25
|
-
|
26
|
-
|
27
|
-
# PR https://github.com/mmozuras/pronto-flay/pull/11/files
|
28
|
-
# is not merged
|
29
|
-
gem 'flay', '2.7.0'
|
30
|
-
gem 'pronto-flay', '0.6.1', require: false
|
31
|
-
gem 'flog'
|
18
|
+
group :code_quality do
|
19
|
+
gem "flog", require: false
|
20
|
+
gem "pronto", require: false
|
21
|
+
gem "pronto-flay", require: false
|
22
|
+
gem "pronto-poper", require: false
|
23
|
+
gem "pronto-reek", require: false
|
24
|
+
gem "pronto-rubocop", require: false
|
32
25
|
end
|
data/Rakefile
CHANGED
@@ -1,21 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require "rake/testtask"
|
2
|
-
require "rubygems/package_task"
|
3
4
|
require "bundler/gem_tasks"
|
4
|
-
require "code_statistics"
|
5
|
-
|
6
|
-
require "rubygems"
|
7
5
|
|
8
|
-
task :
|
6
|
+
task default: [:test]
|
9
7
|
|
10
8
|
Rake::TestTask.new do |test|
|
11
|
-
test.libs = [
|
9
|
+
test.libs = %w[lib test]
|
12
10
|
test.verbose = true
|
13
11
|
test.warning = true
|
14
|
-
test.test_files = FileList[
|
15
|
-
end
|
16
|
-
|
17
|
-
Gem::PackageTask.new(SPEC) do |package|
|
18
|
-
# do nothing: I just need a gem but this block is required
|
12
|
+
test.test_files = FileList["test/test*.rb"]
|
19
13
|
end
|
20
14
|
|
21
15
|
desc "Run some interactive acceptance tests"
|
data/examples/ansi_colors.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
2
3
|
|
3
4
|
# ansi_colors.rb
|
4
5
|
#
|
@@ -9,19 +10,13 @@ require "rubygems"
|
|
9
10
|
require "highline/import"
|
10
11
|
|
11
12
|
# Supported color sequences.
|
12
|
-
colors = %w
|
13
|
+
colors = %w[black red green yellow blue magenta cyan white]
|
13
14
|
|
14
15
|
# Using color() with symbols.
|
15
16
|
colors.each_with_index do |c, i|
|
16
17
|
say("This should be <%= color('#{c}', :#{c}) %>!")
|
17
|
-
|
18
|
-
|
19
|
-
"<%= color('white on #{c}', :white, :on_#{c}) %>!")
|
20
|
-
else
|
21
|
-
say( "This should be " +
|
22
|
-
"<%= color( '#{colors[i - 1]} on #{c}',
|
23
|
-
:#{colors[i - 1]}, :on_#{c} ) %>!")
|
24
|
-
end
|
18
|
+
say("This should be <%= color('#{colors[i - 1]} on #{c}', \
|
19
|
+
:#{colors[i - 1]}, :on_#{c} ) %>!")
|
25
20
|
end
|
26
21
|
|
27
22
|
# Using color with constants.
|
@@ -32,7 +27,7 @@ say("This should be <%= color('underlined', UNDERLINE) %>!")
|
|
32
27
|
say("This might even <%= BLINK %>blink<%= CLEAR %>!")
|
33
28
|
|
34
29
|
# It even works with list wrapping.
|
35
|
-
erb_digits = %w
|
30
|
+
erb_digits = %w[Zero One Two Three Four] +
|
36
31
|
["<%= color('Five', :blue) %%>"] +
|
37
|
-
%w
|
32
|
+
%w[Six Seven Eight Nine]
|
38
33
|
say("<%= list(#{erb_digits.inspect}, :columns_down, 3) %>")
|
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
2
3
|
|
3
4
|
# asking_for_arrays.rb
|
4
5
|
#
|
@@ -9,11 +10,11 @@ require "rubygems"
|
|
9
10
|
require "highline/import"
|
10
11
|
require "pp"
|
11
12
|
|
12
|
-
puts "Using: #{
|
13
|
+
puts "Using: #{HighLine.default_instance.class}"
|
13
14
|
puts
|
14
15
|
|
15
|
-
grades = ask(
|
16
|
-
|
16
|
+
grades = ask("Enter test scores (or a blank line to quit):",
|
17
|
+
->(ans) { ans =~ /^-?\d+$/ ? Integer(ans) : ans }) do |q|
|
17
18
|
q.gather = ""
|
18
19
|
end
|
19
20
|
|
data/examples/basic_usage.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
2
3
|
|
3
4
|
# basic_usage.rb
|
4
5
|
#
|
@@ -9,35 +10,38 @@ require "rubygems"
|
|
9
10
|
require "highline/import"
|
10
11
|
require "yaml"
|
11
12
|
|
12
|
-
puts "Using: #{
|
13
|
+
puts "Using: #{HighLine.default_instance.terminal.class}"
|
13
14
|
puts
|
14
15
|
|
15
|
-
contacts = [
|
16
|
+
contacts = []
|
16
17
|
|
18
|
+
# Just define a parse class method and use the class
|
19
|
+
# as a parser for HighLine#ask
|
20
|
+
#
|
17
21
|
class NameClass
|
18
|
-
def self.parse(
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
22
|
+
def self.parse(string)
|
23
|
+
raise ArgumentError, "Invalid name format." unless
|
24
|
+
string =~ /^\s*(\w+),\s*(\w+)\s*$/
|
25
|
+
|
26
|
+
new(Regexp.last_match(2), Regexp.last_match(1))
|
24
27
|
end
|
25
28
|
|
26
29
|
def initialize(first, last)
|
27
|
-
@first
|
30
|
+
@first = first
|
31
|
+
@last = last
|
28
32
|
end
|
29
33
|
|
30
34
|
attr_reader :first, :last
|
31
35
|
end
|
32
36
|
|
33
|
-
|
34
|
-
entry =
|
37
|
+
loop do
|
38
|
+
entry = {}
|
35
39
|
|
36
40
|
# basic output
|
37
41
|
say("Enter a contact:")
|
38
42
|
|
39
43
|
# basic input
|
40
|
-
entry[:name]
|
44
|
+
entry[:name] = ask("Name? (last, first) ", NameClass) do |q|
|
41
45
|
q.validate = /\A\w+, ?\w+\Z/
|
42
46
|
end
|
43
47
|
entry[:company] = ask("Company? ") { |q| q.default = "none" }
|
@@ -47,27 +51,30 @@ begin
|
|
47
51
|
q.case = :up
|
48
52
|
q.validate = /\A[A-Z]{2}\Z/
|
49
53
|
end
|
50
|
-
entry[:zip]
|
54
|
+
entry[:zip] = ask("Zip? ") do |q|
|
51
55
|
q.validate = /\A\d{5}(?:-?\d{4})?\Z/
|
52
56
|
end
|
53
|
-
entry[:phone]
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
57
|
+
entry[:phone] = ask("Phone? ",
|
58
|
+
lambda { |p|
|
59
|
+
p.delete("^0-9").
|
60
|
+
sub(/\A(\d{3})/, '(\1) ').
|
61
|
+
sub(/(\d{4})\Z/, '-\1')
|
62
|
+
}) do |q|
|
63
|
+
q.validate = ->(p) { p.delete("^0-9").length == 10 }
|
58
64
|
q.responses[:not_valid] = "Enter a phone numer with area code."
|
59
65
|
end
|
60
66
|
entry[:age] = ask("Age? ", Integer) { |q| q.in = 0..105 }
|
61
67
|
entry[:birthday] = ask("Birthday? ", Date)
|
62
|
-
entry[:interests] = ask(
|
63
|
-
|
68
|
+
entry[:interests] = ask("Interests? (comma separated list) ",
|
69
|
+
->(str) { str.split(/,\s*/) })
|
64
70
|
entry[:description] = ask("Enter a description for this contact.") do |q|
|
65
71
|
q.whitespace = :strip_and_collapse
|
66
72
|
end
|
67
73
|
|
68
74
|
contacts << entry
|
69
|
-
# shortcut for yes and no questions
|
70
|
-
|
75
|
+
# shortcut for yes and no questions
|
76
|
+
break unless agree("Enter another contact? ", true)
|
77
|
+
end
|
71
78
|
|
72
79
|
if agree("Save these contacts? ", true)
|
73
80
|
file_name = ask("Enter a file name: ") do |q|
|
data/examples/color_scheme.rb
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
#!/usr/bin/env ruby -w
|
2
|
+
# encoding: utf-8
|
2
3
|
|
3
4
|
# color_scheme.rb
|
4
5
|
#
|
5
6
|
# Created by Jeremy Hinegardner on 2007-01-24
|
6
7
|
# Copyright 2007 Jeremy Hinegardner. All rights reserved
|
7
8
|
|
8
|
-
require
|
9
|
-
require
|
9
|
+
require "rubygems"
|
10
|
+
require "highline/import"
|
10
11
|
|
11
12
|
# Create a color scheme, naming color patterns with symbol names.
|
12
13
|
ft = HighLine::ColorScheme.new do |cs|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
cs[:headline] = [:bold, :yellow, :on_black]
|
15
|
+
cs[:horizontal_line] = [:bold, :white, :on_blue]
|
16
|
+
cs[:even_row] = [:green]
|
17
|
+
cs[:odd_row] = [:magenta]
|
18
|
+
end
|
18
19
|
|
19
20
|
# Assign that color scheme to HighLine...
|
20
21
|
HighLine.color_scheme = ft
|
@@ -26,7 +27,7 @@ say("<%= color('-'*20, :horizontal_line) %>")
|
|
26
27
|
# Setup a toggle for rows.
|
27
28
|
i = true
|
28
29
|
("A".."D").each do |row|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
row_color = i ? :even_row : :odd_row
|
31
|
+
say("<%= color('#{row}', '#{row_color}') %>")
|
32
|
+
i = !i
|
32
33
|
end
|
data/examples/get_character.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
2
3
|
|
3
4
|
require "rubygems"
|
4
5
|
require "highline/import"
|
5
6
|
|
6
|
-
puts "Using: #{
|
7
|
+
puts "Using: #{HighLine.default_instance.terminal.class}"
|
7
8
|
puts
|
8
9
|
|
9
10
|
choices = "ynaq"
|
10
11
|
answer = ask("Your choice [#{choices}]? ") do |q|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
q.echo = false
|
13
|
+
q.character = true
|
14
|
+
q.validate = /\A[#{choices}]\Z/
|
15
|
+
end
|
15
16
|
say("Your choice: #{answer}")
|
data/examples/limit.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby -w
|
2
|
+
# encoding: utf-8
|
2
3
|
|
3
4
|
# limit.rb
|
4
5
|
#
|
@@ -8,7 +9,7 @@
|
|
8
9
|
require "rubygems"
|
9
10
|
require "highline/import"
|
10
11
|
|
11
|
-
puts "Using: #{
|
12
|
+
puts "Using: #{HighLine.default_instance.terminal.class}"
|
12
13
|
puts
|
13
14
|
|
14
15
|
text = ask("Enter text (max 10 chars): ") { |q| q.limit = 10 }
|