language_cards 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f7f8621d542935a3fd0ef4a0f3443adb400b770
4
- data.tar.gz: c3e5c5271866b9b2ccc29715db06459847a27a86
3
+ metadata.gz: b9b17dee4ee233e521d211a5f25fb3ab666f619c
4
+ data.tar.gz: 43f4d40ecf065c78d19fe149812204175d672eae
5
5
  SHA512:
6
- metadata.gz: efa78c38cbf83cccef29b98897b2b2434f2c777d09b7b95850c2cc78bd663b85bbec2b3c7d27926c50b560014ad206bb3e4c1d4394d2ea3c30e50596ec296f68
7
- data.tar.gz: 263f886122db25b28b0919d01d0bdb5fc451a584219788a46015a21c10bad4c09131c405dd623d6d16c5eea523d4db8cdf359295ee071879db7cf4814ef38211
6
+ metadata.gz: 26053e6f86a8e79fe943227b3fde5f2dd5310cf18c9490621282b7ed7aa1e628c53e1783f84680f1801c427fc752a73a1173bbe32ec94a46a4b3d23039d77236
7
+ data.tar.gz: 70b7c8c51b4cbbfb492ab0b912fce3962e58186db7879aebe785a649559016734ca808485fd6d430650fa8461a9d97a1f07518e34ca99d3b63123a46f55d882a
data/README.md CHANGED
@@ -41,6 +41,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
41
41
  ## Contributing
42
42
 
43
43
  Bug reports and pull requests are welcome on GitHub at https://github.com/danielpclark/language_cards.
44
+ Translations of the game itself are kept in the `locales` folder. Flash cards are stored in YAML format in the`cards` folder.
44
45
 
45
46
 
46
47
  ## License
@@ -6,7 +6,13 @@ module LanguageCards
6
6
  ##
7
7
  # @title should be a hash like {"Romaji"=>"Katakana"}
8
8
  # @mapping should be an array like [:k, :v]
9
- @mapped_as, @mapping = mapping[mapping_key].reduce
9
+ raise I18n.t('Error.MappingNotFound') unless mapping.has_key? mapping_key
10
+ begin
11
+ @mapped_as, @mapping = mapping[mapping_key].reduce
12
+ rescue LocalJumpError
13
+ raise I18n.t('Errors.InvalidMapping')
14
+ end
15
+
10
16
  @collection = collection
11
17
  end
12
18
 
@@ -37,6 +37,10 @@ module LanguageCards
37
37
  self[key].values.flatten
38
38
  end
39
39
 
40
+ def has_key? key
41
+ @mappings.has_key? key
42
+ end
43
+
40
44
  def keys
41
45
  @mappings.keys
42
46
  end
@@ -1,3 +1,3 @@
1
1
  module LanguageCards
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -31,7 +31,7 @@ module LanguageCards
31
31
 
32
32
  SUBMENUWIDTH = 60
33
33
 
34
- ::I18n.load_path = Dir[File.join 'locales', '*.yml']
34
+ ::I18n.load_path = Dir[File.join(File.expand_path(File.join('..','..'), __FILE__), 'locales', '*.yml')]
35
35
 
36
36
  def self.start
37
37
  LanguageCards.new.start
data/locales/en.yml CHANGED
@@ -20,6 +20,7 @@ en:
20
20
  * and one with one language name as the key and the other as a value
21
21
  Fix your language mapping.
22
22
  EmptyCollection: Invalid option on empty card collection!
23
+ MappingNotFound: The key for the mapping you've provided isn't in the collection!
23
24
  LanguageName:
24
25
  Japanese: Japanese
25
26
  Romaji: Romaji
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: language_cards
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark