progne_tapera 0.1.1 → 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: c347517d3cc7131f1969253a474a29966720f1e1
4
- data.tar.gz: da0e6d466b75fcc15823623de76a97e00e0335b5
3
+ metadata.gz: 10afe562fb832aeb33de65ed73dd5e18bf465c85
4
+ data.tar.gz: 8a5d1f77fcf1f97304121df8b6f83548b06d4079
5
5
  SHA512:
6
- metadata.gz: 77d5dad91214242e8bca4fe35c0f33278648fd98c940da3c9e2a4b5898cf9439ba0fce86288835440d4ad192b594992ee4a7a0093da74ca2d4180d563fa6cd4f
7
- data.tar.gz: 04d98c24b1377dfdd90524aaed64c3c53ff031fd121860297efb9e9d8e71ba76586857903c9fb1a2fb6fb31e5cfd4fb0687f39abddaa0b9975ecb0eba2b21365
6
+ metadata.gz: 31f8cb8c615dcb0862e0fc2dad0feff04f24956e5c0335366ded17f8cf4538eb12c08b03ddba604ba32298923c33ac064549e655e8eed0e5673a88421b7295c5
7
+ data.tar.gz: 063a7070511318424744873786868fed98145644888faef68a9a3cc9575780ff027ce308ec06d6bca00fa4bcccaa3ce8395e340a1d90d8996bdd1f6845ecefa8
data/CHANGELOG.md CHANGED
@@ -8,3 +8,6 @@
8
8
 
9
9
  ## v0.1.1
10
10
  1. Improve the Ruby Gem Specification to depend on Rails v4.2
11
+
12
+ ## v0.2
13
+ 1. Improve the Enum Config concern to support the customized enum i18n name
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- progne_tapera (0.1)
4
+ progne_tapera (0.1.1)
5
5
  rails (>= 4.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -95,6 +95,31 @@ class Ethnicity < ActiveRecord::Type::Value
95
95
  include ProgneTapera::EnumConfig
96
96
 
97
97
  enum :china_ethnicity
98
+ # 用 :china_ethnicity 指定的 i18n 资源。
99
+
100
+ end
101
+ ```
102
+
103
+ app/types/ethnicity.rb
104
+ ```ruby
105
+ class Ethnicity < ActiveRecord::Type::Value
106
+
107
+ include ProgneTapera::EnumConfig
108
+
109
+ enum :china_ethnicity_alphabetic, :china_ethnicity
110
+ # 以民族字母代码为代码,用 :china_ethnicity 指定的 i18n 资源。
111
+
112
+ end
113
+ ```
114
+
115
+ app/types/ethnicity.rb
116
+ ```ruby
117
+ class Ethnicity < ActiveRecord::Type::Value
118
+
119
+ include ProgneTapera::EnumConfig
120
+
121
+ enum :china_ethnicity_numeric, :china_ethnicity
122
+ # 民族数字代码,用 :china_ethnicity 指定的 i18n 资源。
98
123
 
99
124
  end
100
125
  ```
data/ROADMAP.md CHANGED
@@ -8,3 +8,6 @@
8
8
 
9
9
  ## v0.1.1
10
10
  1. Improve the Ruby Gem Specification to depend on Rails v4.2
11
+
12
+ ## v0.2
13
+ 1. Improve the Enum Config concern to support the customized enum i18n name
@@ -8,14 +8,14 @@ module ProgneTapera::EnumConfig
8
8
 
9
9
  module ClassMethods
10
10
 
11
- def enum(name = nil)
11
+ def enum(name = nil, localized_name = name)
12
12
  name = enum_name(name).to_s
13
13
  enumerations = Rails.configuration.enum[name]
14
14
  raise ArgumentError.new "The enum.#{name} was not configured in the config/enum.yml file." if enumerations.blank?
15
15
  enumerations.each do |key, value|
16
16
  options = value.map { |k, v| [ k.to_sym, v ] }.to_h
17
17
  code = options.delete :code
18
- options[:localized_name] = I18n.t "enum.#{name}.#{key}"
18
+ options[:localized_name] = I18n.t "enum.#{localized_name}.#{key}"
19
19
  safe_add_item ProgneTapera::EnumItem.new(code, key, options)
20
20
  end
21
21
  end
@@ -1,3 +1,3 @@
1
1
  module ProgneTapera
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: progne_tapera
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-10 00:00:00.000000000 Z
11
+ date: 2016-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails