shuang_pin_tutorial 1.1.1 → 1.2.1

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: e4a10efd89f18dd8b4cd10dd74e7f3fcda75c89765b7fadea755e17f560b3847
4
- data.tar.gz: f88c8a9c0a893c4d89247cd79d90147444a61d4c73386d57324d96cb891c59ad
3
+ metadata.gz: fbb3c723acf9687739b71629fff9587badfcc52764b4c78363180ac425d9b785
4
+ data.tar.gz: d112cf132103aaac133cec736855d82b7b1e1b99e68503ffd281fd95b9a4a94b
5
5
  SHA512:
6
- metadata.gz: f710a194ea96bae7d148e17017fef7c0514a7fc2ab3d15b832a7788775838cf3815ea23d38cf405f17b8c53fc68789b9d68ff0e96ab1d64d46016eea1ad760d1
7
- data.tar.gz: 69b963816a2c38794280ee9882de3d8200543d3222de3f7c8320102803f6a72edd17f853868196e986b8bdd0ab8c012c00274623f96cdd7d7a69803b374482ac
6
+ metadata.gz: 7b8ee8448f6f121a1e1fb50fd7014f4847c391b5a90f1ca708f80cd66378b69495f67b06a00190afb35513e73d2a68dffa9705cc4d6a64990a8427494dcd97ec
7
+ data.tar.gz: ac4effda71c7bec01e380f56702f294ba4014fc5e02dedcf448ed2d5f1fa901660068476bbde95ce375733e2694802086cf265a4fd15383352a16141c625b613
data/README.md CHANGED
@@ -3,12 +3,13 @@
3
3
  ### 程序簡介:
4
4
 
5
5
  一個萌妹子風格的輸入法學習套件,參考新華字典的設定,每次隨機出現出合理的拼音組合。<br>
6
- 根據輸出的拼音組合中打出對應的雙拼,每個字用空格隔開,按 Enter 提交,輸入 ```exit``` 提交或者按下 Ctrl+c 退出練習。
6
+ 根據輸出的拼音組合中打出對應的雙拼,每個字用空格隔開,按 Enter 提交,輸入 ```exit``` 提交或者按下 Ctrl+c 退出練習。<br>
7
+ 程式已掛載上 [RubyGems][rubygem_shuang_pin_tutorial],請用 [Gem 工具][rubygem_package_manager] 下載與使用本套件。
7
8
 
8
- 快速學習雙拼 程序畫面:\
9
+ 快速學習雙拼 程序畫面:<br>
9
10
  ![image][shuang_pin_tutorial_console]
10
11
 
11
- 微軟雙拼鍵盤方案圖:\
12
+ 微軟雙拼鍵盤方案圖:<br>
12
13
  ![image][shuang_pin_keyboard]
13
14
 
14
15
  <br>另外,[參考文件夾][folder_img]中附上:
@@ -29,7 +30,11 @@
29
30
  gem install shuang_pin_tutorial # 透過 Gem 安裝學習雙拼套件
30
31
 
31
32
  shuang_pin_tutorial # 運行套件
33
+ shuang_pin_tutorial --help # 查看選項
34
+ shuang_pin_tutorial [OPTIONS] # 運行自選項套件
32
35
  ```
36
+ [rubygem_shuang_pin_tutorial]: https://rubygems.org/gems/shuang_pin_tutorial
37
+ [rubygem_package_manager]: https://rubygems.org/pages/download
33
38
 
34
39
  [shuang_pin_tutorial_console]: ./img/shuang_pin_tutorial_console.png "shuang pin tutorial console"
35
40
  [shuang_pin_keyboard]: ./img/shuang_pin_keyboard.png "shuang pin keyboard"
@@ -4,7 +4,28 @@
4
4
  STDOUT.sync = true
5
5
  $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
6
6
 
7
+ require 'mercenary'
7
8
  require 'shuang_pin_tutorial'
8
9
 
9
- main = ShuangPinTutorial::Main.new()
10
- main.run()
10
+ spt = ShuangPinTutorial
11
+ Mercenary.program(spt::NAME) do |p|
12
+ p.version spt::VERSION
13
+ p.description "A tutorial application for Microsoft Shuang Pin input method(zh-tw)."
14
+ p.syntax "#{spt::NAME} [OPTIONS]"
15
+
16
+ long_opt = Proc.new { |sym| "--#{spt::OPTIONS[sym].gsub(/_/, '-')}" }
17
+
18
+ p.option "#{spt::OPTIONS[:w]}",
19
+ "-w", "#{long_opt.call(:w)} [num]", "Words display in each section (defaults 6)"
20
+ p.option "#{spt::OPTIONS[:r]}",
21
+ "-r", "#{long_opt.call(:r)}", "Turn off the input reminder (defaults on)"
22
+ p.option "#{spt::OPTIONS[:z]}",
23
+ "-z", "#{long_opt.call(:z)}", "Turn off the Taiwan zhuyin display (defaults on)"
24
+ p.option "#{spt::OPTIONS[:c]}",
25
+ "-c", "#{long_opt.call(:c)}", "Turn off the Chinese word display (defaults on)"
26
+
27
+ p.action do |_args, options|
28
+ main = spt::Main.new()
29
+ main.run(options)
30
+ end
31
+ end
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/ruby
1
2
  # frozen_string_literal: true
2
3
 
3
4
  # $LOAD_PATH.unshift __dir__ # For use/testing when no gem is installed
@@ -13,9 +14,16 @@ end
13
14
  module ShuangPinTutorial
14
15
  MODULE = "ShuangPinTutorial"
15
16
  NAME = "shuang_pin_tutorial"
16
- VERSION = "1.1.1"
17
+ VERSION = "1.2.1"
18
+ OPTIONS = {w: "words", r: "remind_off", z: "zhuyin_off", c: "cword_off"}
19
+ OPTIONS_DEFAULT = {w: 6, r: true, z: true, c: true}
17
20
 
18
21
  autoload(:Main, "#{NAME}/main")
19
22
  autoload(:Handler, "#{NAME}/handler")
20
23
  autoload(:Data, "#{NAME}/data")
24
+ end
25
+
26
+ if __FILE__ == $0 # for test-run use
27
+ main = ShuangPinTutorial::Main.new()
28
+ main.run()
21
29
  end
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/ruby
1
2
  # encoding: UTF-8
2
3
 
3
4
  module ShuangPinTutorial
@@ -4,14 +4,15 @@ require 'date'
4
4
  require_relative 'data'
5
5
 
6
6
  module ShuangPinTutorial
7
- INT_WORDS_DISPLAYED = 6
7
+ # fixed const
8
8
  STR_TIPS_SEPARATOR='———'
9
- IS_ENABLE_TIPS = true
10
- IS_DISPLAY_ZHUYIN = true
11
- IS_DISPLAY_CWORD = true
12
9
 
13
10
  class Handler
14
- def initialize()
11
+ def initialize(options)
12
+ @int_words_displayed = options && options.key?(OPTIONS[:w]) ? options[OPTIONS[:w]].to_i : OPTIONS_DEFAULT[:w] # integer
13
+ @is_enable_reminder = options && options.key?(OPTIONS[:r]) ? !options[OPTIONS[:r]] : OPTIONS_DEFAULT[:r] # boolean(reverse)
14
+ @is_display_zhuyin = options && options.key?(OPTIONS[:z]) ? !options[OPTIONS[:z]] : OPTIONS_DEFAULT[:z] # boolean(reverse)
15
+ @is_display_cword = options && options.key?(OPTIONS[:c]) ? !options[OPTIONS[:c]] : OPTIONS_DEFAULT[:c] # boolean(reverse)
15
16
  end
16
17
 
17
18
  def start()
@@ -38,7 +39,7 @@ module ShuangPinTutorial
38
39
  end
39
40
  end
40
41
 
41
- def get_words_showlines(num = INT_WORDS_DISPLAYED, display_delim: "|") # return [words(str), [display line(s)]]
42
+ def get_words_showlines(num = @int_words_displayed, display_delim: "|") # return [words(str), [display line(s)]]
42
43
  result = []
43
44
  display = []
44
45
  display_py = []
@@ -55,8 +56,8 @@ module ShuangPinTutorial
55
56
  display_cw.push(cw + "\t")
56
57
  end
57
58
  display << display_py.join(display_delim)
58
- display << display_zy.join(display_delim) if IS_DISPLAY_ZHUYIN
59
- display << display_cw.join(display_delim) if IS_DISPLAY_CWORD
59
+ display << display_zy.join(display_delim) if @is_display_zhuyin
60
+ display << display_cw.join(display_delim) if @is_display_cword
60
61
  [result.join(" "), display]
61
62
  end
62
63
 
@@ -100,7 +101,7 @@ module ShuangPinTutorial
100
101
  result_words = result[0]
101
102
  result_display = result[1]
102
103
  result_tips = []
103
- if IS_ENABLE_TIPS
104
+ if @is_enable_reminder
104
105
  result_words.split.each { |res| result_tips.push(@sp_data.get_correct_keys(res)) }
105
106
  result_display[0] = "#{result_display[0]} #{STR_TIPS_SEPARATOR} 【#{result_tips.join(" ")}】"
106
107
  end
@@ -1,4 +1,3 @@
1
- #!/usr/bin/ruby
2
1
  # encoding: UTF-8
3
2
 
4
3
  require_relative 'handler'
@@ -10,8 +9,8 @@ module ShuangPinTutorial
10
9
  @obj_tutorial = nil
11
10
  end
12
11
 
13
- def run()
14
- @obj_tutorial = Handler.new()
12
+ def run(options = nil)
13
+ @obj_tutorial = Handler.new(options)
15
14
  @obj_tutorial.start()
16
15
  rescue Interrupt => ir
17
16
  $stdout.puts('累了就該休息一下吧!')
@@ -29,9 +28,4 @@ module ShuangPinTutorial
29
28
  exit(@is_run_success)
30
29
  end
31
30
  end
32
- end
33
-
34
- if __FILE__ == $0 # for test-run use
35
- main = ShuangPinTutorial::Main.new()
36
- main.run()
37
31
  end
metadata CHANGED
@@ -1,17 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shuang_pin_tutorial
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David N
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-25 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2020-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mercenary
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.4.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.4.0
13
27
  description: An interesting, featured tutorial application for practicing Microsoft
14
- Shuang Pin input method.
28
+ Shuang Pin input method(zh-tw).
15
29
  email: dn@jsdn.hk
16
30
  executables:
17
31
  - shuang_pin_tutorial
@@ -32,8 +46,8 @@ licenses:
32
46
  - MIT
33
47
  metadata:
34
48
  source_code_uri: https://github.com/jsdnhk/shuang_pin_tutorial
35
- changelog_uri: https://github.com/jsdnhk/shuang_pin_tutorial/CHANGELOG.md
36
- documentation_uri: https://github.com/jsdnhk/shuang_pin_tutorial/README.md
49
+ changelog_uri: https://github.com/jsdnhk/shuang_pin_tutorial/blob/master/CHANGELOG.md
50
+ documentation_uri: https://github.com/jsdnhk/shuang_pin_tutorial/blob/master/README.md
37
51
  post_install_message: Welcome using Microsoft Shuang Pin tutorial!
38
52
  rdoc_options:
39
53
  - "--charset=UTF-8"
@@ -50,8 +64,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
64
  - !ruby/object:Gem::Version
51
65
  version: 2.7.0
52
66
  requirements: []
53
- rubygems_version: 3.1.2
67
+ rubyforge_project:
68
+ rubygems_version: 2.7.6.2
54
69
  signing_key:
55
70
  specification_version: 4
56
- summary: A tutorial application for Microsoft Shuang Pin input method.
71
+ summary: A tutorial application for Microsoft Shuang Pin input method(zh-tw).
57
72
  test_files: []