progne_tapera 0.1.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +25 -0
- data/ROADMAP.md +3 -0
- data/lib/progne_tapera/enum_config.rb +2 -2
- data/lib/progne_tapera/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10afe562fb832aeb33de65ed73dd5e18bf465c85
|
4
|
+
data.tar.gz: 8a5d1f77fcf1f97304121df8b6f83548b06d4079
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31f8cb8c615dcb0862e0fc2dad0feff04f24956e5c0335366ded17f8cf4538eb12c08b03ddba604ba32298923c33ac064549e655e8eed0e5673a88421b7295c5
|
7
|
+
data.tar.gz: 063a7070511318424744873786868fed98145644888faef68a9a3cc9575780ff027ce308ec06d6bca00fa4bcccaa3ce8395e340a1d90d8996bdd1f6845ecefa8
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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,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.#{
|
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
|
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.
|
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-
|
11
|
+
date: 2016-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|