progne_tapera 0.5.2 → 1.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
- SHA1:
3
- metadata.gz: f20bbffd40c23bd5976b19f8fc18ec3f8cae4136
4
- data.tar.gz: 7b40a0025a790f752ba33ca1bef881ece2097e87
2
+ SHA256:
3
+ metadata.gz: 8d10a2c3b33b51e33b9a5b4c10c515c1906f44b93363618e1c40e8f8287f4ca4
4
+ data.tar.gz: c55437dc658e85ab1926186d358c3a7939a44a176c334baed4f96be14a3b01a1
5
5
  SHA512:
6
- metadata.gz: 2d532bae2f9263f10a6eebfe7c52435be88d510ead89d470286e2d612a0a238d83816c85db171ffc1bb7c847302047146924e9fba4ebfcb86b93729e206f0e14
7
- data.tar.gz: 249e257751bcc5fb4f703f395072b5cd436623ae54a356ed9a6c09354083d2c759ef9e6be9c7463b6337aae464aa085ddbf5cf06b2f865cb16acf9ef9f8cd1aa
6
+ metadata.gz: 5b723d945d8ef7480ceadab714a395bc745b4c94c2d08d6eab6937815e8c37fa0bf9251869329c01539a7bf9be0bc7e857106f49e86928b7d385ac83294cb3cc
7
+ data.tar.gz: 0e7c5d705548d63ea6e8dec96f345c31c074b4099b37fd68296a3c598f76e931200fdf2cc280e934175501a94a925cc26c7c0ca21c35d5ceb1b09edd32a0a75b
@@ -1,28 +1,40 @@
1
1
  # Progne Tapera Change Log 枚举库变更日志
2
2
 
3
3
  ## v0.1
4
+
4
5
  1. Enum Item class
5
6
  2. Enum List concern
6
7
  3. Enum Config concern
7
8
  4. Enum Code concern
8
9
 
9
10
  ## v0.1.1
11
+
10
12
  1. Improved the Ruby Gem Specification to depend on [rails](https://github.com/rails/rails) v4.2
11
13
 
12
14
  ## v0.2
15
+
13
16
  1. Improved the Enum Config concern to support the customized enum i18n name
14
17
 
15
18
  ## v0.3
19
+
16
20
  1. Improved the Enum Config concern to support the overloaded enum i18n name
17
21
 
18
22
  ## v0.4
23
+
19
24
  1. Improved the Enum List concern to add the .``lookup`` method
20
25
 
21
26
  ## v0.5
27
+
22
28
  1. Improved the Enum Config concern to be able to be extended by lambda
23
29
 
24
30
  ## v0.5.1
31
+
25
32
  1. Improved the Enum config concern for the Item Methods module
26
33
 
27
34
  ## v0.5.2
28
- 1. Improve the Enum Config concern for the Item Methods module
35
+
36
+ 1. Improved the Enum Config concern for the Item Methods module
37
+
38
+ ## v1.0
39
+
40
+ 1. Improved the Ruby Gem Specification to depend on [rails](https://github.com/rails/rails) v6.0, bundler v2.0, rake v13.0, & rspec v3.9
@@ -2,132 +2,157 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  progne_tapera (0.5.2)
5
- rails (>= 4.2)
5
+ rails (~> 6.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (5.0.1)
11
- actionpack (= 5.0.1)
12
- nio4r (~> 1.2)
13
- websocket-driver (~> 0.6.1)
14
- actionmailer (5.0.1)
15
- actionpack (= 5.0.1)
16
- actionview (= 5.0.1)
17
- activejob (= 5.0.1)
10
+ actioncable (6.0.2.2)
11
+ actionpack (= 6.0.2.2)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.0.2.2)
15
+ actionpack (= 6.0.2.2)
16
+ activejob (= 6.0.2.2)
17
+ activerecord (= 6.0.2.2)
18
+ activestorage (= 6.0.2.2)
19
+ activesupport (= 6.0.2.2)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.0.2.2)
22
+ actionpack (= 6.0.2.2)
23
+ actionview (= 6.0.2.2)
24
+ activejob (= 6.0.2.2)
18
25
  mail (~> 2.5, >= 2.5.4)
19
26
  rails-dom-testing (~> 2.0)
20
- actionpack (5.0.1)
21
- actionview (= 5.0.1)
22
- activesupport (= 5.0.1)
23
- rack (~> 2.0)
24
- rack-test (~> 0.6.3)
27
+ actionpack (6.0.2.2)
28
+ actionview (= 6.0.2.2)
29
+ activesupport (= 6.0.2.2)
30
+ rack (~> 2.0, >= 2.0.8)
31
+ rack-test (>= 0.6.3)
25
32
  rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.0.1)
28
- activesupport (= 5.0.1)
33
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
+ actiontext (6.0.2.2)
35
+ actionpack (= 6.0.2.2)
36
+ activerecord (= 6.0.2.2)
37
+ activestorage (= 6.0.2.2)
38
+ activesupport (= 6.0.2.2)
39
+ nokogiri (>= 1.8.5)
40
+ actionview (6.0.2.2)
41
+ activesupport (= 6.0.2.2)
29
42
  builder (~> 3.1)
30
- erubis (~> 2.7.0)
43
+ erubi (~> 1.4)
31
44
  rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
33
- activejob (5.0.1)
34
- activesupport (= 5.0.1)
45
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
+ activejob (6.0.2.2)
47
+ activesupport (= 6.0.2.2)
35
48
  globalid (>= 0.3.6)
36
- activemodel (5.0.1)
37
- activesupport (= 5.0.1)
38
- activerecord (5.0.1)
39
- activemodel (= 5.0.1)
40
- activesupport (= 5.0.1)
41
- arel (~> 7.0)
42
- activesupport (5.0.1)
49
+ activemodel (6.0.2.2)
50
+ activesupport (= 6.0.2.2)
51
+ activerecord (6.0.2.2)
52
+ activemodel (= 6.0.2.2)
53
+ activesupport (= 6.0.2.2)
54
+ activestorage (6.0.2.2)
55
+ actionpack (= 6.0.2.2)
56
+ activejob (= 6.0.2.2)
57
+ activerecord (= 6.0.2.2)
58
+ marcel (~> 0.3.1)
59
+ activesupport (6.0.2.2)
43
60
  concurrent-ruby (~> 1.0, >= 1.0.2)
44
- i18n (~> 0.7)
61
+ i18n (>= 0.7, < 2)
45
62
  minitest (~> 5.1)
46
63
  tzinfo (~> 1.1)
47
- arel (7.1.4)
48
- builder (3.2.3)
49
- concurrent-ruby (1.0.4)
64
+ zeitwerk (~> 2.2)
65
+ builder (3.2.4)
66
+ concurrent-ruby (1.1.6)
67
+ crass (1.0.6)
50
68
  diff-lcs (1.3)
51
- erubis (2.7.0)
52
- globalid (0.3.7)
53
- activesupport (>= 4.1.0)
54
- i18n (0.8.0)
55
- loofah (2.0.3)
69
+ erubi (1.9.0)
70
+ globalid (0.4.2)
71
+ activesupport (>= 4.2.0)
72
+ i18n (1.8.2)
73
+ concurrent-ruby (~> 1.0)
74
+ loofah (2.5.0)
75
+ crass (~> 1.0.2)
56
76
  nokogiri (>= 1.5.9)
57
- mail (2.6.4)
58
- mime-types (>= 1.16, < 4)
59
- method_source (0.8.2)
60
- mime-types (3.1)
61
- mime-types-data (~> 3.2015)
62
- mime-types-data (3.2016.0521)
63
- mini_portile2 (2.1.0)
64
- minitest (5.10.1)
65
- nio4r (1.2.1)
66
- nokogiri (1.7.0.1)
67
- mini_portile2 (~> 2.1.0)
68
- rack (2.0.1)
69
- rack-test (0.6.3)
70
- rack (>= 1.0)
71
- rails (5.0.1)
72
- actioncable (= 5.0.1)
73
- actionmailer (= 5.0.1)
74
- actionpack (= 5.0.1)
75
- actionview (= 5.0.1)
76
- activejob (= 5.0.1)
77
- activemodel (= 5.0.1)
78
- activerecord (= 5.0.1)
79
- activesupport (= 5.0.1)
80
- bundler (>= 1.3.0, < 2.0)
81
- railties (= 5.0.1)
77
+ mail (2.7.1)
78
+ mini_mime (>= 0.1.1)
79
+ marcel (0.3.3)
80
+ mimemagic (~> 0.3.2)
81
+ method_source (1.0.0)
82
+ mimemagic (0.3.4)
83
+ mini_mime (1.0.2)
84
+ mini_portile2 (2.4.0)
85
+ minitest (5.14.0)
86
+ nio4r (2.5.2)
87
+ nokogiri (1.10.9)
88
+ mini_portile2 (~> 2.4.0)
89
+ rack (2.2.2)
90
+ rack-test (1.1.0)
91
+ rack (>= 1.0, < 3)
92
+ rails (6.0.2.2)
93
+ actioncable (= 6.0.2.2)
94
+ actionmailbox (= 6.0.2.2)
95
+ actionmailer (= 6.0.2.2)
96
+ actionpack (= 6.0.2.2)
97
+ actiontext (= 6.0.2.2)
98
+ actionview (= 6.0.2.2)
99
+ activejob (= 6.0.2.2)
100
+ activemodel (= 6.0.2.2)
101
+ activerecord (= 6.0.2.2)
102
+ activestorage (= 6.0.2.2)
103
+ activesupport (= 6.0.2.2)
104
+ bundler (>= 1.3.0)
105
+ railties (= 6.0.2.2)
82
106
  sprockets-rails (>= 2.0.0)
83
- rails-dom-testing (2.0.2)
84
- activesupport (>= 4.2.0, < 6.0)
85
- nokogiri (~> 1.6)
86
- rails-html-sanitizer (1.0.3)
87
- loofah (~> 2.0)
88
- railties (5.0.1)
89
- actionpack (= 5.0.1)
90
- activesupport (= 5.0.1)
107
+ rails-dom-testing (2.0.3)
108
+ activesupport (>= 4.2.0)
109
+ nokogiri (>= 1.6)
110
+ rails-html-sanitizer (1.3.0)
111
+ loofah (~> 2.3)
112
+ railties (6.0.2.2)
113
+ actionpack (= 6.0.2.2)
114
+ activesupport (= 6.0.2.2)
91
115
  method_source
92
116
  rake (>= 0.8.7)
93
- thor (>= 0.18.1, < 2.0)
94
- rake (11.3.0)
95
- rspec (3.5.0)
96
- rspec-core (~> 3.5.0)
97
- rspec-expectations (~> 3.5.0)
98
- rspec-mocks (~> 3.5.0)
99
- rspec-core (3.5.4)
100
- rspec-support (~> 3.5.0)
101
- rspec-expectations (3.5.0)
117
+ thor (>= 0.20.3, < 2.0)
118
+ rake (13.0.1)
119
+ rspec (3.9.0)
120
+ rspec-core (~> 3.9.0)
121
+ rspec-expectations (~> 3.9.0)
122
+ rspec-mocks (~> 3.9.0)
123
+ rspec-core (3.9.1)
124
+ rspec-support (~> 3.9.1)
125
+ rspec-expectations (3.9.1)
102
126
  diff-lcs (>= 1.2.0, < 2.0)
103
- rspec-support (~> 3.5.0)
104
- rspec-mocks (3.5.0)
127
+ rspec-support (~> 3.9.0)
128
+ rspec-mocks (3.9.1)
105
129
  diff-lcs (>= 1.2.0, < 2.0)
106
- rspec-support (~> 3.5.0)
107
- rspec-support (3.5.0)
108
- sprockets (3.7.1)
130
+ rspec-support (~> 3.9.0)
131
+ rspec-support (3.9.2)
132
+ sprockets (4.0.0)
109
133
  concurrent-ruby (~> 1.0)
110
134
  rack (> 1, < 3)
111
- sprockets-rails (3.2.0)
135
+ sprockets-rails (3.2.1)
112
136
  actionpack (>= 4.0)
113
137
  activesupport (>= 4.0)
114
138
  sprockets (>= 3.0.0)
115
- thor (0.19.4)
116
- thread_safe (0.3.5)
117
- tzinfo (1.2.2)
139
+ thor (1.0.1)
140
+ thread_safe (0.3.6)
141
+ tzinfo (1.2.7)
118
142
  thread_safe (~> 0.1)
119
- websocket-driver (0.6.5)
143
+ websocket-driver (0.7.1)
120
144
  websocket-extensions (>= 0.1.0)
121
- websocket-extensions (0.1.2)
145
+ websocket-extensions (0.1.4)
146
+ zeitwerk (2.3.0)
122
147
 
123
148
  PLATFORMS
124
149
  ruby
125
150
 
126
151
  DEPENDENCIES
127
- bundler (~> 1.12)
152
+ bundler (~> 2.0)
128
153
  progne_tapera!
129
- rake (~> 11.3)
130
- rspec (~> 3.5)
154
+ rake (~> 13.0)
155
+ rspec (~> 3.9)
131
156
 
132
157
  BUNDLED WITH
133
- 1.13.6
158
+ 2.1.4
data/ROADMAP.md CHANGED
@@ -1,31 +1,44 @@
1
1
  # Progne Tapera Road Map 枚举库线路图
2
2
 
3
3
  ## v0.1
4
+
4
5
  1. Enum Item class
5
6
  2. Enum List concern
6
7
  3. Enum Config concern
7
8
  4. Enum Code concern
8
9
 
9
10
  ## v0.1.1
11
+
10
12
  1. Improve the Ruby Gem Specification to depend on [rails](https://github.com/rails/rails) v4.2
11
13
 
12
14
  ## v0.2
15
+
13
16
  1. Improve the Enum Config concern to support the customized enum i18n name
14
17
 
15
18
  ## v0.3
19
+
16
20
  1. Improve the Enum Config concern to support the overloaded enum i18n name
17
21
 
18
22
  ## v0.4
23
+
19
24
  1. Improve the Enum List concern to add the .``lookup`` method
20
25
 
21
26
  ## v0.5
27
+
22
28
  1. Improve the Enum Code concern to be able to be extended by lambda
23
29
 
24
30
  ## v0.5.1
31
+
25
32
  1. Improve the Enum config concern for the Item Methods module
26
33
 
27
34
  ## v0.5.2
35
+
28
36
  1. Improve the Enum Config concern for the Item Methods module
29
37
 
30
- ## v0.6
38
+ ## v1.0
39
+
40
+ 1. Improve the Ruby Gem Specification to depend on [rails](https://github.com/rails/rails) v6.0, bundler v2.0, rake v13.0, & rspec v3.9
41
+
42
+ ## v1.1
43
+
31
44
  1. Improve the Enum Config concern to make the enum items be able to be updated or destroyable through the #enum method
@@ -11,6 +11,13 @@ module ProgneTapera::EnumConfig
11
11
 
12
12
  module ClassMethods
13
13
 
14
+ ##
15
+ # 为枚举类型提供 .enum 方法。如:
16
+ # enum :gender
17
+ # # 或
18
+ # enum :gender, :localized_gender
19
+ # 第一个参数是枚举类型在配置文件中存储的枚举项的 key 。
20
+ # 第二个参数是枚举类型在国际化配置文件中存储的枚举项文本的 key 。如果不提供第二个参数,则自动使用第一个参数进行查找。
14
21
  def enum(name = nil, localized_name = name)
15
22
 
16
23
  if block_given?
@@ -50,6 +57,9 @@ module ProgneTapera::EnumConfig
50
57
 
51
58
  end
52
59
 
60
+ ##
61
+ # 为枚举类型提供 .overload_enum_i18n 方法。如:
62
+ # overload_enum_i18n :your_gender_i18n_key
53
63
  def overload_enum_i18n(localized_name = nil)
54
64
 
55
65
  each do |enum_item|
@@ -8,6 +8,7 @@ class ProgneTapera::EnumItem
8
8
 
9
9
  attr_reader :code, :name, :options
10
10
 
11
+ ##
11
12
  # code = HA (value)
12
13
  # name = han
13
14
  # options = { localized_name: '汉' }
@@ -31,10 +32,14 @@ class ProgneTapera::EnumItem
31
32
 
32
33
  end
33
34
 
35
+ ##
36
+ # 判断两个枚举项的 #code 字段是否相等。
34
37
  def ==(that)
35
38
  self.code==that.code
36
39
  end
37
40
 
41
+ ##
42
+ # 根据 #code 字段的值,比较大小。
38
43
  def <=>(that)
39
44
  self.code<=>that.code
40
45
  end
@@ -13,12 +13,22 @@ module ProgneTapera::EnumList
13
13
  include Enumerable
14
14
 
15
15
  # Define the Enum type
16
+
17
+ ##
18
+ # 向枚举类型提供枚举的配置名。如果不提供配置名则根据枚举类型的名称自动猜测。如:
19
+ # eumu_name
20
+ # # 或
21
+ # enum_name :gender
16
22
  def enum_name(name = nil)
17
23
  return @enum_name if @enum_name.present?
18
24
  @enum_name = (name||self.name.demodulize.underscore).to_sym
19
25
  end
20
26
 
21
27
  # Define the Enum Items
28
+
29
+ ##
30
+ # 判断指定的枚举项是否已经定义。如:
31
+ # item_defined? male
22
32
  def item_defined?(item)
23
33
  const_defined? item.constant_name
24
34
  end
@@ -30,6 +40,11 @@ module ProgneTapera::EnumList
30
40
  const_set item.constant_name, item
31
41
  end
32
42
 
43
+ ##
44
+ # 以安全的方式向一个枚举列表中添加一个枚举项。如果该枚举项已经在枚举列表中,则不添加。如:
45
+ # Gender.safe_add_item male
46
+ # Gender.safe_add_item female
47
+ # Gender.safe_add_item male # male won't be added twice.
33
48
  def safe_add_item(item)
34
49
  const_set item.constant_name, item if item.is_a?(ProgneTapera::EnumItem)&&!item_defined?(item)
35
50
  end
@@ -47,6 +62,9 @@ module ProgneTapera::EnumList
47
62
  }
48
63
  end
49
64
 
65
+ ##
66
+ # 列出所有的枚举型。如:
67
+ # Gender.all
50
68
  def all
51
69
  enum_constants.map { |constant| const_get constant }
52
70
  end
@@ -1,3 +1,3 @@
1
1
  module ProgneTapera
2
- VERSION = '0.5.2'
2
+ VERSION = '1.0'
3
3
  end
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = [ 'lib' ]
20
20
 
21
- spec.add_dependency 'rails', '>= 4.2'
21
+ spec.add_dependency 'rails', '~> 6.0'
22
22
 
23
- spec.add_development_dependency 'bundler', '~> 1.12'
24
- spec.add_development_dependency 'rake', '~> 11.3'
25
- spec.add_development_dependency 'rspec', '~> 3.5'
23
+ spec.add_development_dependency 'bundler', '~> 2.0'
24
+ spec.add_development_dependency 'rake', '~> 13.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.9'
26
26
 
27
27
  end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: progne_tapera
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-20 00:00:00.000000000 Z
11
+ date: 2020-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: '6.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '4.2'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.12'
33
+ version: '2.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.12'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '11.3'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '11.3'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.5'
61
+ version: '3.9'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.5'
68
+ version: '3.9'
69
69
  description: Progne Tapera is a Rails-based configurable enumeration implementation.
70
70
  Progne Tapera is the Brown-chested Martin in Latin. Progne Tapera 是基于 Rails 的可配置的枚举实现。Progne
71
71
  Tapera 是棕胸崖燕的拉丁学名。
@@ -113,8 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.6.4
116
+ rubygems_version: 3.1.2
118
117
  signing_key:
119
118
  specification_version: 4
120
119
  summary: Rails-based configurable enumeration 基于 Rails 的可配置的枚举