highline 1.7.10 → 2.0.3

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.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +5 -0
  3. data/.rubocop.yml +84 -0
  4. data/.simplecov +5 -0
  5. data/.travis.yml +35 -9
  6. data/Changelog.md +214 -15
  7. data/Gemfile +16 -5
  8. data/README.md +202 -0
  9. data/Rakefile +8 -20
  10. data/appveyor.yml +37 -0
  11. data/examples/ansi_colors.rb +6 -11
  12. data/examples/asking_for_arrays.rb +6 -2
  13. data/examples/basic_usage.rb +31 -21
  14. data/examples/color_scheme.rb +11 -10
  15. data/examples/get_character.rb +8 -4
  16. data/examples/limit.rb +4 -0
  17. data/examples/menus.rb +16 -10
  18. data/examples/overwrite.rb +9 -5
  19. data/examples/page_and_wrap.rb +5 -4
  20. data/examples/password.rb +4 -0
  21. data/examples/repeat_entry.rb +10 -5
  22. data/examples/trapping_eof.rb +2 -1
  23. data/examples/using_readline.rb +2 -1
  24. data/highline.gemspec +25 -27
  25. data/lib/highline/builtin_styles.rb +129 -0
  26. data/lib/highline/color_scheme.rb +49 -32
  27. data/lib/highline/compatibility.rb +11 -4
  28. data/lib/highline/custom_errors.rb +57 -0
  29. data/lib/highline/import.rb +19 -12
  30. data/lib/highline/io_console_compatible.rb +37 -0
  31. data/lib/highline/list.rb +177 -0
  32. data/lib/highline/list_renderer.rb +261 -0
  33. data/lib/highline/menu/item.rb +32 -0
  34. data/lib/highline/menu.rb +306 -111
  35. data/lib/highline/paginator.rb +52 -0
  36. data/lib/highline/question/answer_converter.rb +103 -0
  37. data/lib/highline/question.rb +281 -131
  38. data/lib/highline/question_asker.rb +150 -0
  39. data/lib/highline/simulate.rb +24 -13
  40. data/lib/highline/statement.rb +88 -0
  41. data/lib/highline/string.rb +36 -0
  42. data/lib/highline/string_extensions.rb +83 -64
  43. data/lib/highline/style.rb +196 -63
  44. data/lib/highline/template_renderer.rb +62 -0
  45. data/lib/highline/terminal/io_console.rb +36 -0
  46. data/lib/highline/terminal/ncurses.rb +38 -0
  47. data/lib/highline/terminal/unix_stty.rb +51 -0
  48. data/lib/highline/terminal.rb +190 -0
  49. data/lib/highline/version.rb +3 -1
  50. data/lib/highline/wrapper.rb +53 -0
  51. data/lib/highline.rb +390 -788
  52. metadata +56 -35
  53. data/INSTALL +0 -59
  54. data/README.rdoc +0 -74
  55. data/lib/highline/system_extensions.rb +0 -254
  56. data/setup.rb +0 -1360
  57. data/test/string_methods.rb +0 -32
  58. data/test/tc_color_scheme.rb +0 -96
  59. data/test/tc_highline.rb +0 -1402
  60. data/test/tc_import.rb +0 -52
  61. data/test/tc_menu.rb +0 -439
  62. data/test/tc_simulator.rb +0 -33
  63. data/test/tc_string_extension.rb +0 -33
  64. data/test/tc_string_highline.rb +0 -38
  65. data/test/tc_style.rb +0 -578
@@ -1,32 +0,0 @@
1
- # string_methods.rb
2
- #
3
- # Created by Richard LeBer 2011-06-27
4
- #
5
- # This is Free Software. See LICENSE and COPYING for details.
6
- #
7
- # String class convenience methods
8
-
9
- module StringMethods
10
- def test_color
11
- assert_equal("\e[34mstring\e[0m", @string.color(:blue))
12
- assert_equal("\e[1m\e[47mstring\e[0m", @string.color(:bold,:on_white))
13
- assert_equal("\e[45mstring\e[0m", @string.on(:magenta))
14
- assert_equal("\e[36mstring\e[0m", @string.cyan)
15
- assert_equal("\e[41m\e[5mstring\e[0m\e[0m", @string.blink.on_red)
16
- assert_equal("\e[38;5;137mstring\e[0m", @string.color(:rgb_906030))
17
- assert_equal("\e[38;5;101mstring\e[0m", @string.rgb('606030'))
18
- assert_equal("\e[38;5;107mstring\e[0m", @string.rgb('60','90','30'))
19
- assert_equal("\e[38;5;107mstring\e[0m", @string.rgb(96,144,48))
20
- assert_equal("\e[38;5;173mstring\e[0m", @string.rgb_c06030)
21
- assert_equal("\e[48;5;137mstring\e[0m", @string.color(:on_rgb_906030))
22
- assert_equal("\e[48;5;101mstring\e[0m", @string.on_rgb('606030'))
23
- assert_equal("\e[48;5;107mstring\e[0m", @string.on_rgb('60','90','30'))
24
- assert_equal("\e[48;5;107mstring\e[0m", @string.on_rgb(96,144,48))
25
- assert_equal("\e[48;5;173mstring\e[0m", @string.on_rgb_c06030)
26
- end
27
-
28
- def test_uncolor
29
- colored_string = HighLine::String("\e[38;5;137mstring\e[0m")
30
- assert_equal "string", colored_string.uncolor
31
- end
32
- end
@@ -1,96 +0,0 @@
1
- # tc_color_scheme.rb
2
- #
3
- # Created by Jeremy Hinegardner on 2007-01-24.
4
- # Copyright 2007 Jeremy Hinegardner. All rights reserved.
5
- #
6
- # This is Free Software. See LICENSE and COPYING for details.
7
-
8
- require "test/unit"
9
-
10
- require "highline"
11
- require "stringio"
12
-
13
- class TestColorScheme < Test::Unit::TestCase
14
- def setup
15
- @input = StringIO.new
16
- @output = StringIO.new
17
- @terminal = HighLine.new(@input, @output)
18
-
19
- @old_color_scheme = HighLine.color_scheme
20
- end
21
-
22
- def teardown
23
- HighLine.color_scheme = @old_color_scheme
24
- end
25
-
26
- def test_using_color_scheme
27
- assert_equal(false,HighLine.using_color_scheme?)
28
-
29
- HighLine.color_scheme = HighLine::ColorScheme.new
30
- assert_equal(true,HighLine.using_color_scheme?)
31
- end
32
-
33
- def test_scheme
34
- HighLine.color_scheme = HighLine::SampleColorScheme.new
35
-
36
- @terminal.say("This should be <%= color('warning yellow', :warning) %>.")
37
- assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string)
38
- @output.rewind
39
-
40
- @terminal.say("This should be <%= color('warning yellow', 'warning') %>.")
41
- assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string)
42
- @output.rewind
43
-
44
- @terminal.say("This should be <%= color('warning yellow', 'WarNing') %>.")
45
- assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string)
46
- @output.rewind
47
-
48
- # Check that keys are available, and as expected
49
- assert_equal ["critical", "error", "warning", "notice", "info", "debug", "row_even", "row_odd"].sort,
50
- HighLine.color_scheme.keys.sort
51
-
52
- # Color scheme doesn't care if we use symbols or strings, and is case-insensitive
53
- warning1 = HighLine.color_scheme[:warning]
54
- warning2 = HighLine.color_scheme["warning"]
55
- warning3 = HighLine.color_scheme[:wArning]
56
- warning4 = HighLine.color_scheme["warniNg"]
57
- assert_instance_of HighLine::Style, warning1
58
- assert_instance_of HighLine::Style, warning2
59
- assert_instance_of HighLine::Style, warning3
60
- assert_instance_of HighLine::Style, warning4
61
- assert_equal warning1, warning2
62
- assert_equal warning1, warning3
63
- assert_equal warning1, warning4
64
-
65
- # Nonexistent keys return nil
66
- assert_nil HighLine.color_scheme[:nonexistent]
67
-
68
- # Same as above, for definitions
69
- defn1 = HighLine.color_scheme.definition(:warning)
70
- defn2 = HighLine.color_scheme.definition("warning")
71
- defn3 = HighLine.color_scheme.definition(:wArning)
72
- defn4 = HighLine.color_scheme.definition("warniNg")
73
- assert_instance_of Array, defn1
74
- assert_instance_of Array, defn2
75
- assert_instance_of Array, defn3
76
- assert_instance_of Array, defn4
77
- assert_equal [:bold, :yellow], defn1
78
- assert_equal [:bold, :yellow], defn2
79
- assert_equal [:bold, :yellow], defn3
80
- assert_equal [:bold, :yellow], defn4
81
- assert_nil HighLine.color_scheme.definition(:nonexistent)
82
-
83
- color_scheme_hash = HighLine.color_scheme.to_hash
84
- assert_instance_of Hash, color_scheme_hash
85
- assert_equal ["critical", "error", "warning", "notice", "info", "debug", "row_even", "row_odd"].sort,
86
- color_scheme_hash.keys.sort
87
- assert_instance_of Array, HighLine.color_scheme.definition(:warning)
88
- assert_equal [:bold, :yellow], HighLine.color_scheme.definition(:warning)
89
-
90
- # turn it back off, should raise an exception
91
- HighLine.color_scheme = @old_color_scheme
92
- assert_raises(NameError) {
93
- @terminal.say("This should be <%= color('nothing at all', :error) %>.")
94
- }
95
- end
96
- end