highline 2.0.0.pre.develop.9 → 2.0.0.pre.develop.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +59 -5
  3. data/.travis.yml +9 -4
  4. data/Changelog.md +11 -0
  5. data/Gemfile +12 -19
  6. data/Rakefile +5 -11
  7. data/examples/ansi_colors.rb +6 -11
  8. data/examples/asking_for_arrays.rb +4 -3
  9. data/examples/basic_usage.rb +29 -22
  10. data/examples/color_scheme.rb +11 -10
  11. data/examples/get_character.rb +6 -5
  12. data/examples/limit.rb +2 -1
  13. data/examples/menus.rb +11 -11
  14. data/examples/overwrite.rb +7 -6
  15. data/examples/page_and_wrap.rb +5 -4
  16. data/examples/password.rb +2 -1
  17. data/examples/repeat_entry.rb +7 -5
  18. data/examples/trapping_eof.rb +2 -1
  19. data/examples/using_readline.rb +2 -1
  20. data/highline.gemspec +25 -25
  21. data/lib/highline.rb +103 -111
  22. data/lib/highline/builtin_styles.rb +45 -41
  23. data/lib/highline/color_scheme.rb +32 -28
  24. data/lib/highline/compatibility.rb +3 -3
  25. data/lib/highline/custom_errors.rb +2 -1
  26. data/lib/highline/import.rb +8 -11
  27. data/lib/highline/list.rb +4 -8
  28. data/lib/highline/list_renderer.rb +207 -201
  29. data/lib/highline/menu.rb +75 -63
  30. data/lib/highline/menu/item.rb +2 -0
  31. data/lib/highline/paginator.rb +5 -6
  32. data/lib/highline/question.rb +38 -36
  33. data/lib/highline/question/answer_converter.rb +2 -2
  34. data/lib/highline/question_asker.rb +15 -17
  35. data/lib/highline/simulate.rb +11 -13
  36. data/lib/highline/statement.rb +12 -10
  37. data/lib/highline/string.rb +9 -8
  38. data/lib/highline/string_extensions.rb +30 -14
  39. data/lib/highline/style.rb +68 -45
  40. data/lib/highline/template_renderer.rb +5 -5
  41. data/lib/highline/terminal.rb +24 -31
  42. data/lib/highline/terminal/io_console.rb +2 -2
  43. data/lib/highline/terminal/ncurses.rb +4 -3
  44. data/lib/highline/terminal/unix_stty.rb +12 -9
  45. data/lib/highline/version.rb +1 -1
  46. data/lib/highline/wrapper.rb +12 -11
  47. metadata +34 -43
  48. data/test/acceptance/acceptance.rb +0 -62
  49. data/test/acceptance/acceptance_test.rb +0 -69
  50. data/test/acceptance/at_color_output_using_erb_templates.rb +0 -17
  51. data/test/acceptance/at_echo_false.rb +0 -23
  52. data/test/acceptance/at_readline.rb +0 -37
  53. data/test/io_console_compatible.rb +0 -37
  54. data/test/string_methods.rb +0 -35
  55. data/test/test_answer_converter.rb +0 -26
  56. data/test/test_color_scheme.rb +0 -94
  57. data/test/test_helper.rb +0 -22
  58. data/test/test_highline.rb +0 -1627
  59. data/test/test_import.rb +0 -55
  60. data/test/test_list.rb +0 -60
  61. data/test/test_menu.rb +0 -749
  62. data/test/test_paginator.rb +0 -73
  63. data/test/test_question_asker.rb +0 -20
  64. data/test/test_simulator.rb +0 -24
  65. data/test/test_string_extension.rb +0 -72
  66. data/test/test_string_highline.rb +0 -42
  67. data/test/test_style.rb +0 -613
  68. data/test/test_wrapper.rb +0 -188
data/test/test_wrapper.rb DELETED
@@ -1,188 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "test_helper"
5
-
6
- require "highline/wrapper"
7
-
8
- class TestHighLineWrapper < Minitest::Test
9
- def setup
10
- @wrap_at = 80
11
- end
12
-
13
- def wrap(text)
14
- HighLine::Wrapper.wrap text, @wrap_at
15
- end
16
-
17
- def test_dont_wrap_if_line_is_shorter_than_wrap_at
18
- wrapped = wrap("This is a very short line.\n")
19
- assert_equal "This is a very short line.\n", wrapped
20
- end
21
-
22
- def test_wrap_long_lines_correctly
23
- long_line =
24
- "This is a long flowing paragraph meant to span " +
25
- "several lines. This text should definitely be " +
26
- "wrapped at the set limit, in the result. Your code " +
27
- "does well with things like this.\n\n"
28
-
29
- wrapped_long_line =
30
- "This is a long flowing paragraph meant to span " +
31
- "several lines. This text should\n" +
32
-
33
- "definitely be wrapped at the set limit, in the " +
34
- "result. Your code does well with\n" +
35
-
36
- "things like this.\n\n"
37
-
38
- wrapped = wrap(long_line)
39
- assert_equal wrapped_long_line, wrapped
40
- end
41
-
42
- def test_dont_wrap_already_well_wrapped_text
43
- well_formatted_text =
44
- " * This is a simple embedded list.\n" +
45
- " * You're code should not mess with this...\n" +
46
- " * Because it's already formatted correctly and does not\n" +
47
- " exceed the limit!\n"
48
-
49
- wrapped = wrap(well_formatted_text)
50
- assert_equal well_formatted_text, wrapped
51
- end
52
-
53
- def test_wrap_single_word_longer_than_wrap_at
54
- wrapped = wrap("-=" * 50)
55
- assert_equal(("-=" * 40 + "\n") + ("-=" * 10), wrapped)
56
- end
57
-
58
- def test_wrap_plain_text
59
- line = "123 567 901 345"
60
-
61
- 1.upto(25) do |wrap_at|
62
- wrapped = HighLine::Wrapper.wrap(line, wrap_at)
63
-
64
- case wrap_at
65
- when 1
66
- assert_equal "1\n2\n3\n5\n6\n7\n9\n0\n1\n3\n4\n5", wrapped
67
- when 2
68
- assert_equal "12\n3\n56\n7\n90\n1\n34\n5", wrapped
69
- when 3..6
70
- assert_equal "123\n567\n901\n345", wrapped
71
- when 7..10
72
- assert_equal "123 567\n901 345", wrapped
73
- when 11..14
74
- assert_equal "123 567 901\n345", wrapped
75
- when 15..25
76
- assert_equal "123 567 901 345", wrapped
77
- end
78
- end
79
- end
80
-
81
- def test_wrap_whole_colored_text
82
- skip "TODO: Implement whole colored text wrapping!"
83
- line = "\e[31m123 567 901 345\e[0m"
84
-
85
- 1.upto(25) do |wrap_at|
86
- wrapped = HighLine::Wrapper.wrap(line, wrap_at)
87
-
88
- case wrap_at
89
- when 1
90
- assert_equal "\e[31m1\n2\n3\n5\n6\n7\n9\n0\n1\n3\n4\n5\e[0m", wrapped
91
- when 2
92
- assert_equal "\e[31m12\n3\n56\n7\n90\n1\n34\n5\e[0m", wrapped
93
- when 3..6
94
- assert_equal "\e[31m123\n567\n901\n345\e[0m", wrapped
95
- when 7..10
96
- assert_equal "\e[31m123 567\n901 345\e[0m", wrapped
97
- when 11..14
98
- assert_equal "\e[31m123 567 901\n345\e[0m", wrapped
99
- when 15..25
100
- assert_equal "\e[31m123 567 901 345\e[0m", wrapped
101
- end
102
- end
103
- end
104
-
105
- def test_wrap_partially_colored_text
106
- skip "TODO: Implement middle colored text wrapping!"
107
- line = "123 567 \e[31m901\e[0m 345"
108
-
109
- 1.upto(25) do |wrap_at|
110
- wrapped = HighLine::Wrapper.wrap(line, wrap_at)
111
-
112
- case wrap_at
113
- when 1
114
- assert_equal "1\n2\n3\n5\n6\n7\n\e[31m9\n0\n1\e[0m\n3\n4\n5", wrapped
115
- when 2
116
- assert_equal "12\n3\n56\n7\n\e[31m90\n1\e[0m\n34\n5", wrapped
117
- when 3..6
118
- assert_equal "123\n567\n\e[31m901\e[0m\n345", wrapped
119
- when 7..10
120
- assert_equal "123 567\n\e[31m901\e[0m 345", wrapped
121
- when 11..14
122
- assert_equal "123 567 \e[31m901\e[0m\n345", wrapped
123
- when 15..25
124
- assert_equal "123 567 \e[31m901\e[0m 345", wrapped
125
- end
126
- end
127
- end
128
-
129
- def test_wrap_text_with_partially_colored_word_in_the_middle
130
- skip "TODO: Implement middle partially colored text wrapping!"
131
- line = "123 567 9\e[31m0\e[0m1 345"
132
-
133
- 1.upto(25) do |wrap_at|
134
- wrapped = HighLine::Wrapper.wrap(line, wrap_at)
135
-
136
- case wrap_at
137
- when 1
138
- assert_equal "1\n2\n3\n5\n6\n7\n9\n\e[31m0\e[0m\n1\n3\n4\n5", wrapped
139
- when 2
140
- assert_equal "12\n3\n56\n7\n9\e[31m0\e[0m\n1\n34\n5", wrapped
141
- when 3..6
142
- assert_equal "123\n567\n9\e[31m0\e[0m1\n345", wrapped
143
- when 7..10
144
- assert_equal "123 567\n9\e[31m0\e[0m1 345", wrapped
145
- when 11..14
146
- assert_equal "123 567 9\e[31m0\e[0m1\n345", wrapped
147
- when 15..25
148
- assert_equal "123 567 9\e[31m0\e[0m1 345", wrapped
149
- end
150
- end
151
- end
152
-
153
- def test_wrap_when_multibyte_characters_present
154
- line_ascii = "Sera um passaro?"
155
- line_utf8 = "Será um pássaro?"
156
-
157
- assert_equal 16, line_ascii.size
158
- assert_equal 16, line_ascii.bytesize
159
-
160
- assert_equal 16, line_utf8.size
161
- assert_equal 18, line_utf8.bytesize
162
-
163
- 1.upto(18) do |wrap_at|
164
- wrapped = HighLine::Wrapper.wrap(line_utf8, wrap_at)
165
-
166
- case wrap_at
167
- when 1
168
- assert_equal "S\ne\nr\ná\nu\nm\np\ná\ns\ns\na\nr\no\n?", wrapped
169
- when 2
170
- assert_equal "Se\nrá\num\npá\nss\nar\no?", wrapped
171
- when 3
172
- assert_equal "Ser\ná\num\npás\nsar\no?", wrapped
173
- when 4
174
- assert_equal "Será\num\npáss\naro?", wrapped
175
- when 5
176
- assert_equal "Será\num\npássa\nro?", wrapped
177
- when 6
178
- assert_equal "Será\num\npássar\no?", wrapped
179
- when 7
180
- assert_equal "Será um\npássaro\n?", wrapped
181
- when 15..8
182
- assert_equal "Será um\npássaro?", wrapped
183
- when 16..18
184
- assert_equal "Será um pássaro?", wrapped
185
- end
186
- end
187
- end
188
- end