learn-japanese 0.4.1 → 0.5.0

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: 3c33ddc115041a6485c767272b1b521ccc58d10fb878321d88fbd1a19ddd9e8a
4
- data.tar.gz: 51832c38dcbdf2c85a28b0581f7322f95beafe470734a9c59da75430a1cf3b73
3
+ metadata.gz: c326b07ac2656bdfcaf385898b70c589d8fa7571bf6adbcb4b7b369130dd51d5
4
+ data.tar.gz: 1c19e75e31d96b4d3b9e11d349c8c24f0e2f0b71649193afe73f4cb02c192a04
5
5
  SHA512:
6
- metadata.gz: a294fd686dc84b0dff8caf7b2e9b5392b27b383627af5cb1aa0f6c54521889b00689ed5ea96ed9176cbf9df7447e0ff5542a0e4963e65c75b46dc024764427b7
7
- data.tar.gz: 201ba0f0f1e8521fb52d2234c72a537da081b2bcbb07fd8ccc82dc3dae7fbfff6e385a9168541a5ccc5d50ef799961569f3685fc6aa1269ee755449cf17467f2
6
+ metadata.gz: 7e06b77a12fabb4667ecba8a4c681b7e1e4e6c3616d8c7ecfebc63da7cb7e21c1da8a2fade41a35d95549e9951276eca99ef358fc1e39156856eb663cacd688e
7
+ data.tar.gz: e67a8f0828e1d1683d085e6ab6ebabf8af0882a2524d9f3e84442f06d10e0407b00e86d97dfbcdbe0c9e70b3a899749f735d35ae0ecc65dccbfa876b3082e32d
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+ require 'learn-japanese/cli'
5
+
6
+ CLI.start(ARGV)
@@ -1,30 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
- require 'learn-japanese/hiragana'
5
- require 'learn-japanese/dictionary'
6
- require 'colorize'
4
+ require 'learn-japanese/game/sound-game'
7
5
 
8
- puts "[ Sounds to Hiragana ] Example: a i => あい (amor - ái)".white
9
-
10
- def sound_to_hiragana
11
- print " Write sounds ? ".light_yellow
12
- sounds = gets.chomp.split
13
- hiraganas = Hiragana.all
14
-
15
- hiragana_array = sounds.map { hiraganas[_1.to_sym] || '*' }
16
- hiragana = hiragana_array.join('')
17
-
18
- words = Dictionary.new.words
19
- word = (words.select { _1["hiragana"] == hiragana})[0] || {'spanish': '?', 'sounds': '?'}
20
-
21
- puts " Hiragana => #{hiragana}".cyan
22
- puts " Spanish => #{word["spanish"]}".cyan
23
- puts " Pronounce => #{word["sounds"]}".cyan
24
-
25
- return false if sounds.size.zero?
26
- true
27
- end
28
-
29
- while sound_to_hiragana
30
- end
6
+ SoundGame.loop_hiragana_game
@@ -5,14 +5,15 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
5
5
  name = "learn-japanese"
6
6
  require "#{name}/version"
7
7
 
8
- Gem::Specification.new name, JaponesTool::VERSION do |s|
9
- s.summary = "Learn Japanese (UNDER DEVELOPMENT!!!)"
8
+ Gem::Specification.new name, LearnJapanese::VERSION do |s|
9
+ s.summary = "Learn Japanese (UNDER DEVELOPMENT)"
10
10
  s.email = "dvarrui@protonmail.com"
11
- s.homepage = JaponesTool::HOMEPAGE
11
+ s.homepage = LearnJapanese::HOMEPAGE
12
12
  s.authors = ["David Vargas Ruiz"]
13
13
  s.files = `git ls-files`.split("\n")
14
14
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
15
  s.license = "GPL-3"
16
16
 
17
17
  s.add_runtime_dependency "colorize"
18
+ s.add_runtime_dependency "thor"
18
19
  end
@@ -0,0 +1,24 @@
1
+ require 'thor'
2
+ require_relative '../learn-japanese'
3
+
4
+ class CLI < Thor
5
+ map ['h', '-h', '--help'] => 'help'
6
+
7
+ map ['v', '-v', '--version'] => 'version'
8
+ desc 'version', 'Show the program version'
9
+ def version
10
+ LearnJapanese.show_version
11
+ end
12
+
13
+ map ['ca', '-ca', '--choose-answer', 'choose-answer'] => 'choose_answer'
14
+ desc 'choose-answer [LEVEL]', 'LEVEL = 1-4'
15
+ def choose_answer(level)
16
+ LearnJapanese.choose_answer(level.to_i)
17
+ end
18
+
19
+ map ['sa', '-sa', '--short-answer', 'short-answer'] => 'short_answer'
20
+ desc 'short-answer [LEVEL]', 'LEVEL = 1-4'
21
+ def short_answer(level)
22
+ LearnJapanese.short_answer(level.to_i)
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+
2
+ require_relative '../hiragana'
3
+ require_relative '../dictionary'
4
+ require 'colorize'
5
+
6
+ module SoundGame
7
+
8
+ def self.to_hiragana(sounds)
9
+ hiraganas = Hiragana.all
10
+
11
+ hiragana_array = sounds.map { hiraganas[_1.to_sym] || '*' }
12
+ hiragana = hiragana_array.join('')
13
+
14
+ none = {'hiragana': hiragana, 'spanish': '?', 'sounds': '?'}
15
+ words = Dictionary.new.words
16
+ word = (words.select {_1["hiragana"] == hiragana})[0] || none
17
+
18
+ word
19
+ end
20
+
21
+ def self.loop_hiragana_game
22
+ sounds = "init"
23
+ until sounds.empty?
24
+ puts "[ Sounds to Hiragana ] Example: a i => あい (amor - ái)".white
25
+ print " Write sounds ? ".light_yellow
26
+ sounds = gets.chomp.split
27
+ word = self.to_hiragana(sounds)
28
+ puts " Hiragana => #{word["hiragana"]}".cyan
29
+ puts " Spanish => #{word["spanish"]}".cyan
30
+ puts " Pronounce => #{word["sounds"]}".cyan
31
+ end
32
+ end
33
+
34
+ end
@@ -1,5 +1,6 @@
1
1
 
2
- module JaponesTool
3
- VERSION = '0.4.1'
2
+ module LearnJapanese
3
+ VERSION = '0.5.0'
4
+ NAME = 'learn-japanese'
4
5
  HOMEPAGE = 'https://github.com/dvarrui/learn-japanese'
5
6
  end
@@ -0,0 +1,28 @@
1
+
2
+ require_relative 'learn-japanese/version'
3
+ require_relative 'learn-japanese/game/choose-answer-game'
4
+ require_relative 'learn-japanese/game/short-answer-game'
5
+
6
+ module LearnJapanese
7
+
8
+ def self.show_version
9
+ puts "#{LearnJapanese::NAME} (version #{LearnJapanese::VERSION})"
10
+ end
11
+
12
+ def self.show_help
13
+ puts "Usage: learn-japanese --help"
14
+ exit 0
15
+ end
16
+
17
+ def self.choose_answer(level)
18
+ show_help unless level > 0
19
+ ChooseAnswerGame.show_help(level)
20
+ ChooseAnswerGame.new(level).run
21
+ end
22
+
23
+ def self.short_answer(level)
24
+ show_help unless level > 0
25
+ ShortAnswerGame.show_help(level)
26
+ ShortAnswerGame.new(level).run
27
+ end
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: learn-japanese
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Vargas Ruiz
@@ -24,10 +24,25 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description:
28
42
  email: dvarrui@protonmail.com
29
43
  executables:
30
44
  - choose-answer-game
45
+ - learn-japanese
31
46
  - short-answer-game
32
47
  - sounds-to-hiragana
33
48
  extensions: []
@@ -39,16 +54,20 @@ files:
39
54
  - README.md
40
55
  - Rakefile
41
56
  - bin/choose-answer-game
57
+ - bin/learn-japanese
42
58
  - bin/short-answer-game
43
59
  - bin/sounds-to-hiragana
44
60
  - examples/01-emoji.rb
45
61
  - examples/02-emoji.rb
46
62
  - learn-japanese.gemspec
63
+ - lib/learn-japanese.rb
64
+ - lib/learn-japanese/cli.rb
47
65
  - lib/learn-japanese/data/words.yaml
48
66
  - lib/learn-japanese/debug.rb
49
67
  - lib/learn-japanese/dictionary.rb
50
68
  - lib/learn-japanese/game/choose-answer-game.rb
51
69
  - lib/learn-japanese/game/short-answer-game.rb
70
+ - lib/learn-japanese/game/sound-game.rb
52
71
  - lib/learn-japanese/hiragana.rb
53
72
  - lib/learn-japanese/version.rb
54
73
  homepage: https://github.com/dvarrui/learn-japanese
@@ -73,5 +92,5 @@ requirements: []
73
92
  rubygems_version: 3.3.3
74
93
  signing_key:
75
94
  specification_version: 4
76
- summary: Learn Japanese (UNDER DEVELOPMENT!!!)
95
+ summary: Learn Japanese (UNDER DEVELOPMENT)
77
96
  test_files: []