curses_menu 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db0a039d187afe66e4986489a45193a3ca76bb5e748a14f9cf0e22f08a5b7065
4
- data.tar.gz: 6e0fc6819a62ff3e1da4060fa9f9891088624c1098d91cf066b701b6fe7e3cda
3
+ metadata.gz: 9f2157a04e11d3d2d1e5dbb21cf04a10c7cb4a74bb20594b7132ddb173affaa3
4
+ data.tar.gz: 65030812b200046ce239732987118775b3e4d8f334368d54d96a03f54d83b481
5
5
  SHA512:
6
- metadata.gz: 5786992710dfcd47c11d223884c0b4ecef021d28470386c1427e8666e3a62be675ac885f19e69f41d8529a3b9886a48b28b9096079f3b8182255fcf56a2ff6b8
7
- data.tar.gz: 6b210504415fe9c5e1d6956eb7024e03b982a5bcf1de034efc96c4ebae47ff0993dddec75e1cec0b52b6bb8a4dd4f6a48c0cfabd1a82d4d917b297cd2fe86f77
6
+ metadata.gz: 296ff3a85e3a7697a2122bdc0765b943b6c60c422391b7e2b5423e87036088a85248c79ca11cdee209f3d25cd2e0b2f558a4744ad74d0c5307ddbe50890eed2b
7
+ data.tar.gz: 3b5c8fcb76fac30961b8c636ab1411b77cc0e108f9762c70294da23d18b025589493becc649aec2ed6caae467ba79373e1b34178aca9fca81e90d2a19ca16784
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [v0.0.4](https://github.com/Muriel-Salvan/curses_menu/compare/v0.0.3...v0.0.4) (2021-08-18 10:25:59)
2
+
3
+ ### Patches
4
+
5
+ * [Test UTF-8 support](https://github.com/Muriel-Salvan/curses_menu/commit/f94129db540d41f17f0ed46563461601f140029f)
6
+
1
7
  # [v0.0.3](https://github.com/Muriel-Salvan/curses_menu/compare/v0.0.2...v0.0.3) (2021-08-15 16:16:16)
2
8
 
3
9
  ### Patches
data/examples/utf_8.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'curses_menu'
2
+
3
+ CursesMenu.new 'My awesome new menu! - 私の素晴らしい新しいメニュー' do |menu|
4
+ menu.item 'How\'s life? - 人生はどうですか?' do
5
+ puts 'Couldn\'t be easier - 簡単なことはありません'
6
+ :menu_exit
7
+ end
8
+ end
@@ -1,5 +1,5 @@
1
1
  class CursesMenu
2
2
 
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
 
5
5
  end
@@ -50,7 +50,7 @@ module CursesMenuTest
50
50
  chars.
51
51
  map do |chr|
52
52
  {
53
- char: (chr & Curses::A_CHARTEXT).chr,
53
+ char: (chr & Curses::A_CHARTEXT).chr(Encoding::UTF_8),
54
54
  color: color_pairs[chr & Curses::A_COLOR] || chr & Curses::A_COLOR,
55
55
  attributes: chr & Curses::A_ATTRIBUTES
56
56
  }
@@ -87,11 +87,15 @@ module CursesMenuTest
87
87
  #
88
88
  # Parameters::
89
89
  # * *line_idx* (Integer): The line index of the screenshot
90
- # * *expectation* (String): The expected line
90
+ # * *expectation* (String or Regexp): The expected line
91
91
  def assert_line(line_idx, expectation)
92
- line = @screenshot[line_idx][0..expectation.size].map { |char_info| char_info[:char] }.join
93
- # Add an ending space to make sure the line does not continue after what we test
94
- expect(line).to eq("#{expectation} "), "Screenshot line #{line_idx} differs:\n \"#{line}\" should be\n \"#{expectation} \""
92
+ line = @screenshot[line_idx][0..(expectation.is_a?(Regexp) ? -1 : expectation.size)].map { |char_info| char_info[:char] }.join
93
+ if expectation.is_a?(Regexp)
94
+ expect(line).to match(expectation), "Screenshot line #{line_idx} differs:\n \"#{line}\" should be\n \"#{expectation} \""
95
+ else
96
+ # Add an ending space to make sure the line does not continue after what we test
97
+ expect(line).to eq("#{expectation} "), "Screenshot line #{line_idx} differs:\n \"#{line}\" should be\n \"#{expectation} \""
98
+ end
95
99
  end
96
100
 
97
101
  # Assert that a line of the screenshot starts with a given content, using colors information
@@ -7,6 +7,20 @@ describe CursesMenu do
7
7
  assert_line 3, 'Simple string'
8
8
  end
9
9
 
10
+ it 'displays a single string in UTF-8' do
11
+ test_menu do |menu|
12
+ menu.item 'Simple string - 単純な文字列'
13
+ end
14
+ # Ruby curses does not handle wide characters correctly in the inch method.
15
+ # This test is pending a better support for UTF-8.
16
+ # cf https://github.com/ruby/curses/issues/65
17
+ # TODO: Uncomment when Ruby curses will be fixed.
18
+ # rubocop:disable Style/AsciiComments
19
+ # assert_line 3, 'Simple string - 単純な文字列'
20
+ # rubocop:enable Style/AsciiComments
21
+ assert_line 3, /^Simple string - .+$/
22
+ end
23
+
10
24
  it 'displays a single string in a CursesRow' do
11
25
  test_menu do |menu|
12
26
  menu.item CursesMenu::CursesRow.new({ cell: { text: 'Simple string' } })
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curses_menu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-15 00:00:00.000000000 Z
11
+ date: 2021-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -89,6 +89,7 @@ extra_rdoc_files:
89
89
  - CHANGELOG.md
90
90
  - README.md
91
91
  - LICENSE.md
92
+ - examples/utf_8.rb
92
93
  - examples/hello.rb
93
94
  - examples/sub_menus.rb
94
95
  - examples/automatic_key_presses.rb
@@ -109,6 +110,7 @@ files:
109
110
  - examples/scrolling.rb
110
111
  - examples/several_items.rb
111
112
  - examples/sub_menus.rb
113
+ - examples/utf_8.rb
112
114
  - lib/curses_menu.rb
113
115
  - lib/curses_menu/curses_row.rb
114
116
  - lib/curses_menu/version.rb