enum_ext 0.5.3 → 0.8.1

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: 3be0377b4cba2aee0f9ee1fbb19e5efa6c824b0e5965eefca3ea7de7108df363
4
- data.tar.gz: c7a15c944f6598129b29f0ab61f3650a251af242111d90b056f86677fdf51780
3
+ metadata.gz: 2c17ae56d510836b3106e8b1ca84b83f69a6854a0988192e71d7a7a62910dde0
4
+ data.tar.gz: 870773a5d09b15840695a8ff0ee57823b4bcc4c89753a88840b3daca7a69ae28
5
5
  SHA512:
6
- metadata.gz: d920ca2ae630226a778ba83144115f360b97c4e9e52759ecc05aae77fd095fe806912ef81c01fe6750031f700c6e2d9c9511a4c7164897ce6ac3ccf86479a365
7
- data.tar.gz: 4433d920ae0ec84e9ad33b6c728a238462f0884b7ce9c693143c06f0a41def984bc25ade651c7c4cdd1d15b32e8229b9deb6a13ba6059885dc9d5d216b591086
6
+ metadata.gz: dd80dfc1f862eb03fbd9065af6f1eee36a95254ce4dd7e708073683ca4d5483163457cb5a8b96da851943d93246436a0897965d11b0f5478d966a4a590c82276
7
+ data.tar.gz: f07fd0d4869deba68067d29a0e6ac6a8003ae4df28dea658decd66455f12a5cbcdd622e816042f93de452c7186bb7af885b9b0d549b2fe3c40edfccd6b3fadf1
data/CHANGELOG.md CHANGED
@@ -1,6 +1,30 @@
1
+ # 0.8.1
2
+ * Fixes issue https://github.com/alekseyl/enum_ext/issues/50
3
+ * Better describe for supersets.
4
+ * Multiple readme and comments fixes
5
+
6
+ # 0.8.0
7
+ * Methods annotations added:
8
+ * Full descriptions: Class.enum.describe(short=true) / Class.enum.describe_short / Class.enum.describe_long / Class.enum.describe_basic
9
+ * Per-methods: Class.enum.describe_enum_i, describe_mass_assign_enum, describe_multi_enum_scopes e.t.c.
10
+ * method Class.enum.supersets_raw added, it will return supersets decompositions to basic enum
11
+ * Class.enum.all method now returns basic enum_values + supersets_raw decomposition to basic enums ( previously was a supersets i.e. high level definition )
12
+
13
+ # 0.7.0
14
+ * rails 7 syntax support added
15
+ * massive test process refactoring docker with both rails 7 and earlier support
16
+ * simple translate_enum allowed via `ext: [:translate_enum]`
17
+
18
+ # 0.6.0 (BREAKING CHANGES)
19
+ * fixed issue with non array superset
20
+ * standard helpers are now private, you should use enum_ext / enum , ext: [] approach to the definitions
21
+ * class.superset_statuses moved to enum_obj -> class.statuses.superset_statuses
22
+ * massive ReadMe refactoring
23
+
1
24
  # 0.5.3
2
25
  * refactored tests
3
26
  * multi_enum_scopes will be chainable with empty params (i.e. will not change the scope)
27
+ * some development dependencies were added
4
28
 
5
29
  # 0.5.2
6
30
  * removed unused require from the upcoming version
data/Dockerfile ADDED
@@ -0,0 +1,22 @@
1
+ FROM ruby:3.0.3-bullseye
2
+
3
+ WORKDIR /app
4
+ #RUN apt-get update && apt-get -y install lsb-release
5
+ ##
6
+ #RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
7
+ # sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \
8
+ # apt-get update && apt-get -y install postgresql postgresql-client-12
9
+ #
10
+ #RUN sh -c 'echo "local all all trust" > /etc/postgresql/14/main/pg_hba.conf' && \
11
+ # service postgresql start && \
12
+ # psql -U postgres -c 'CREATE DATABASE "niceql-test"'
13
+
14
+ RUN gem install bundler
15
+
16
+ COPY lib/enum_ext/version.rb /app/lib/enum_ext/version.rb
17
+ COPY enum_ext.gemspec /app/
18
+ COPY Gemfile_rails_6 /app/Gemfile
19
+ COPY Gemfile_rails_6.lock /app/Gemfile.lock
20
+ COPY Rakefile /app/
21
+ #
22
+ RUN bundle install
@@ -0,0 +1,25 @@
1
+ FROM ruby:3.0.3-bullseye
2
+
3
+ WORKDIR /app
4
+ #RUN apt-get update && apt-get -y install lsb-release
5
+ ##
6
+ #RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
7
+ # sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \
8
+ # apt-get update && apt-get -y install postgresql postgresql-client-12
9
+ #
10
+ #RUN sh -c 'echo "local all all trust" > /etc/postgresql/14/main/pg_hba.conf' && \
11
+ # service postgresql start && \
12
+ # psql -U postgres -c 'CREATE DATABASE "niceql-test"'
13
+
14
+ RUN gem install bundler
15
+
16
+
17
+ RUN gem install bundler
18
+
19
+ COPY lib/enum_ext/version.rb /app/lib/enum_ext/version.rb
20
+ COPY enum_ext.gemspec /app/
21
+ COPY Gemfile_rails_7 /app/Gemfile
22
+ COPY Gemfile_rails_7.lock /app/Gemfile.lock
23
+ COPY Rakefile /app/
24
+
25
+ RUN bundle install
@@ -3,3 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in enum_ext.gemspec
4
4
  gemspec
5
5
 
6
+ gem 'activerecord', "<7"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enum_ext (0.5.2)
4
+ enum_ext (0.8.0)
5
5
  activerecord (>= 5.2.4.3)
6
6
 
7
7
  GEM
@@ -94,4 +94,4 @@ DEPENDENCIES
94
94
  stubberry
95
95
 
96
96
  BUNDLED WITH
97
- 2.1.4
97
+ 2.4.17
data/Gemfile_rails_7 ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in enum_ext.gemspec
4
+ gemspec
5
+
6
+ gem 'activerecord', ">=7"
@@ -0,0 +1,102 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ enum_ext (0.8.0)
5
+ activerecord (>= 5.2.4.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (7.0.6)
11
+ actionview (= 7.0.6)
12
+ activesupport (= 7.0.6)
13
+ rack (~> 2.0, >= 2.2.4)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
+ actionview (7.0.6)
18
+ activesupport (= 7.0.6)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
+ activemodel (7.0.6)
24
+ activesupport (= 7.0.6)
25
+ activerecord (7.0.6)
26
+ activemodel (= 7.0.6)
27
+ activesupport (= 7.0.6)
28
+ activesupport (7.0.6)
29
+ concurrent-ruby (~> 1.0, >= 1.0.2)
30
+ i18n (>= 1.6, < 2)
31
+ minitest (>= 5.1)
32
+ tzinfo (~> 2.0)
33
+ amazing_print (1.5.0)
34
+ builder (3.2.4)
35
+ byebug (11.1.3)
36
+ concurrent-ruby (1.2.2)
37
+ crass (1.0.6)
38
+ erubi (1.12.0)
39
+ i18n (1.14.1)
40
+ concurrent-ruby (~> 1.0)
41
+ loofah (2.21.3)
42
+ crass (~> 1.0.2)
43
+ nokogiri (>= 1.12.0)
44
+ method_source (1.0.0)
45
+ minitest (5.18.1)
46
+ niceql (0.6.1)
47
+ nokogiri (1.15.3-x86_64-darwin)
48
+ racc (~> 1.4)
49
+ nokogiri (1.15.3-x86_64-linux)
50
+ racc (~> 1.4)
51
+ racc (1.7.1)
52
+ rack (2.2.7)
53
+ rack-test (2.1.0)
54
+ rack (>= 1.3)
55
+ rails-dom-testing (2.1.1)
56
+ activesupport (>= 5.0.0)
57
+ minitest
58
+ nokogiri (>= 1.6)
59
+ rails-html-sanitizer (1.6.0)
60
+ loofah (~> 2.21)
61
+ nokogiri (~> 1.14)
62
+ rails-i18n (7.0.7)
63
+ i18n (>= 0.7, < 2)
64
+ railties (>= 6.0.0, < 8)
65
+ rails_sql_prettifier (7.0.4)
66
+ activerecord (>= 7)
67
+ niceql (~> 0.6)
68
+ railties (7.0.6)
69
+ actionpack (= 7.0.6)
70
+ activesupport (= 7.0.6)
71
+ method_source
72
+ rake (>= 12.2)
73
+ thor (~> 1.0)
74
+ zeitwerk (~> 2.5)
75
+ rake (13.0.6)
76
+ sqlite3 (1.6.3-x86_64-darwin)
77
+ sqlite3 (1.6.3-x86_64-linux)
78
+ stubberry (0.3.0)
79
+ thor (1.2.2)
80
+ tzinfo (2.0.6)
81
+ concurrent-ruby (~> 1.0)
82
+ zeitwerk (2.6.8)
83
+
84
+ PLATFORMS
85
+ x86_64-darwin-20
86
+ x86_64-linux
87
+
88
+ DEPENDENCIES
89
+ activerecord (>= 7)
90
+ amazing_print
91
+ bundler (>= 1.11)
92
+ byebug
93
+ enum_ext!
94
+ minitest
95
+ rails-i18n (>= 4)
96
+ rails_sql_prettifier
97
+ rake (>= 10.0)
98
+ sqlite3
99
+ stubberry
100
+
101
+ BUNDLED WITH
102
+ 2.4.17
data/README.md CHANGED
@@ -7,7 +7,7 @@ EnumExt extends rails enum with localization/translation and it's helpers, mass-
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'enum_ext', '~> 0.3'
10
+ gem 'enum_ext', '~> 0.8'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -26,12 +26,12 @@ Or install it yourself as:
26
26
 
27
27
  class SomeModel
28
28
  extend EnumExt
29
-
30
- enum kinds: {}, ext: [:enum_i, :enum_mass_assign, ]
31
- humanize_enum #...
32
- translate_enum #...
33
- ext_enum_sets #...
34
- end
29
+
30
+ enum status: {}, ext: [:enum_i, :enum_mass_assign, enum_supersets: { superset: [:basic_enum] } ]
31
+ humanize_enum #...
32
+ translate_enum #...
33
+ ext_enum_sets # if needed
34
+ end
35
35
  ```
36
36
 
37
37
  Let's assume that we have model Request representing some buying requests with enum **status**, and we have model Order with requests,
@@ -49,11 +49,45 @@ Or install it yourself as:
49
49
  end
50
50
  ```
51
51
 
52
- Now let's review some examples of possible enum extensions
52
+ ## Inline definitions. Starting 0.5.0!! BREAKING CHANGES!
53
+
54
+ Starting version 0.4.6, for concise and clearer code base, you can activate most of the extensions during enum definition, using `ext: [...]` notation.
55
+ This is a preferable way now, and old helpers are private starting version 0.6!:
56
+
57
+ ```ruby
58
+ #Instead of three method calls:
59
+ enum status: {}
60
+ enum_i :status # will raise an private method error starting ver 0.6
61
+ enum_mass_assign :status # will raise an private method error starting ver 0.6!!!
62
+
63
+ #You should go with ext option instead:
64
+ enum status: {}, ext: [:enum_i, :enum_mass_assign]
65
+
66
+ # OR in case of standalone enum definition:
67
+ enum status: {} # somewhere where you can't or don't want to reach
68
+ enum_ext :status, [:enum_i, :enum_mass_assign, enum_supersets: {} ]
69
+ ```
70
+ Rem: enum_ext could be called multiple times and merge later definitions, though I can't imagine why would you split it to multiple calls.
71
+
72
+ Rem: The only exceptions for the new syntax are full translation/humanization helpers definitions.
73
+ Those will not add any clarity to code, and should be used via standalone helpers.
74
+ But standard translate_enum without definitions still welcome:
75
+
76
+ ```ruby
77
+ # GOOD:
78
+ enum_ext :status, [:enum_i, :enum_mass_assign, :translate_enum, enum_supersets: {}]
79
+
80
+ # BAD (even if correctly defines internationalization):
81
+ enum_ext :status, [:enum_i, :enum_mass_assign, :translate_enum, enum_supersets: {}] do
82
+ I18n.t("scope.#{kind}")
83
+ end
84
+ ```
85
+
86
+ ## Humanization and localization
53
87
 
54
88
  ### Humanization (humanize_enum)
55
89
 
56
- if app doesn't need internationalization, it may use humanize_enum to make enum user friendly
90
+ If app doesn't need internationalization, it may use humanize_enum to make enum output user friendly
57
91
 
58
92
  ```ruby
59
93
  humanize_enum :status, {
@@ -69,33 +103,31 @@ Or install it yourself as:
69
103
  ```
70
104
 
71
105
  This humanize_enum adds to instance:
72
- - t_in_cart, t_paid, t_ready_for_shipment
106
+ - t_status
73
107
 
74
- and to class:
75
- - t_statuses - as given or generated values
76
- - t_statuses_options - translated enum values options for select input
77
- - t_statuses_options_i - same as above but use int values with translations works for ActiveAdmin filters for instance
108
+ and to enum object:
109
+ - statuses.t_options - translated enum values options for select input
110
+ - statuses.t_options_i - same as above but use int values with translations works for ActiveAdmin filters for instance
111
+
78
112
 
79
-
80
113
  Example with block:
81
114
 
82
115
  ```ruby
83
116
  humanize_enum :status do
84
- I18n.t("scope.#{status}")
117
+ I18n.t("scope.#{status}")
85
118
  end
86
119
  ```
87
120
 
88
121
  Example for select:
89
122
 
90
123
  ```ruby
91
- f.select :status, Request.t_statuses_options
124
+ f.select :status, Request.statuses.t_options
92
125
  ```
93
126
 
94
127
  in Active Admin filters
95
128
  ```ruby
96
- filter :status, as: :select, label: 'Status', collection: Request.t_statuses_options_i
129
+ filter :status, as: :select, label: 'Status', collection: Request.statuses.t_options_i
97
130
  ```
98
-
99
131
 
100
132
  **Rem:** select options may break when using lambda() or proc with instance method, but will survive with block
101
133
 
@@ -105,7 +137,7 @@ Or install it yourself as:
105
137
  request.paid!
106
138
  request.status # >> paid
107
139
  request.t_status # >> "paid 3 dollars"
108
- Request.t_statuses # >> { in_cart: -> { I18n.t("request.status.in_cart") }, .... }
140
+ Request.statuses.localizations # >> { in_cart: -> { I18n.t("request.status.in_cart") }, .... }
109
141
  ```
110
142
 
111
143
  Could be called multiple times, all humanization definitions will be merged under the hood.
@@ -113,6 +145,7 @@ Or install it yourself as:
113
145
  ### Translate (translate_enum)
114
146
 
115
147
  Enum is translated using scope 'active_record.attributes.class_name_underscore.enum_plural', or the given one:
148
+
116
149
  ```ruby
117
150
  translate_enum :status, 'active_record.request.enum'
118
151
  ```
@@ -124,7 +157,12 @@ Or it can be done with block either with translate or humanize:
124
157
  end
125
158
  ```
126
159
 
160
+ All humanization examples also should work same way as expected.
161
+
162
+ ## Enum extended functionality
163
+
127
164
  ### Enum to_i shortcut ( enum_i )
165
+
128
166
  Defines method enum_name_i shortcut for Model.enum_names[elem.enum_name] or enum_name_before_type_cast
129
167
 
130
168
  **Ex**
@@ -135,66 +173,79 @@ Defines method enum_name_i shortcut for Model.enum_names[elem.enum_name] or enum
135
173
  request.paid_i # 10
136
174
  ```
137
175
 
138
- ### Enum Sets (ext_enum_sets)
176
+ Rem: whenever underlying enum is not an integer will refuse to define helper and outputs WARNING
177
+
178
+ ### Enum SuperSets (enum_supersets)
139
179
 
140
- **Use-case** whenever you need superset of enums to behave like a enum.
180
+ **Use-case** whenever you need superset of enums to behave like a super enum.
141
181
 
142
- You can do this with method **ext_enum_sets** it creates:
182
+ You can do this with method **enum_supersets** it creates:
143
183
  - scopes for subsets,
144
184
  - instance methods with `?`
145
- - and some class methods helpers
146
185
 
147
186
  For instance:
148
187
 
149
188
  ```ruby
150
- ext_enum_sets :status, {
151
- delivery_set: [:ready_for_shipment, :on_delivery, :delivered], # for shipping department for example
152
- in_warehouse: [:ready_for_shipment]
153
- }
189
+ enum status: [:in_cart, :waiting_for_payment, :paid, :packing, :ready_for_shipment, :on_delivery, :delivered],
190
+ ext: [enum_supersets: {
191
+ around_delivery: [:ready_for_shipment, :on_delivery], # for shipping department for example
192
+ in_warehouse: [:packing, :ready_for_shipment], # this scope is just for superposition example below
193
+ sold: [:paid, :around_delivery, :in_warehouse, :delivered] # also you can define any superposition of already defined supersets or enum values
194
+ }]
195
+
196
+ # supersets will be stored inside enum wrapper object, and can be de-referenced to basic enum values
197
+ # using wrapper defined methods: "superset_enum_plural", i.e. statuses.sold_statuses -> [:paid, :packing, :ready_for_shipment, :on_delivery, :delivered]
198
+ # so new supersets could be defined using Array operations against newly defined methods
199
+ enum_ext :status, enum_supersets: {
200
+ outside_warehouse: ( statuses.around_delivery - statuses.in_warehouse ) #... any other array operations like &, + and so can be used
201
+ }
154
202
  ```
155
203
 
156
204
  it will generate:
157
205
 
158
206
  ```
159
207
  instance:
160
- - methods: delivery_set?, in_warehouse?
208
+ - methods: around_delivery?, in_warehouse?
161
209
 
162
210
  class:
163
- - named scopes: delivery_set, in_warehouse
164
- - parametrized scopes: with_statuses, without_statuses ( available as a standalone extension now, and will not be included by default in a versionafter 0.5.0)
165
- class helpers:
166
- - delivery_set_statuses (=[:ready_for_shipment, :on_delivery, :delivered] ), in_warehouse_statuses
167
- - delivery_set_statuses_i (= [3,4,5]), in_warehouse_statuses_i (=[3])
168
-
169
- class translation helpers ( started with t_... ):
170
- - t_delivery_set_statuses_options (= [['translation or humanization', :ready_for_shipment] ...] ) for select inputs purposes
171
- - t_delivery_set_statuses_options_i (= [['translation or humanization', 3] ...]) same as above but with integer as value ( for example to use in Active admin filters )
211
+ - named scopes: around_delivery, in_warehouse
212
+
213
+ enum methods:
214
+ - Class.statuses.supersets -- will output superset definition hash
215
+ - Class.statuses.supersets_raw -- will output superset decompositions to basic enum types hash
216
+
217
+ - Class.statuses.around_delivery (=[:ready_for_shipment, :on_delivery, :delivered] ), in_warehouse_statuses
218
+ - around_delivery_statuses_i (= [3,4,5]), in_warehouse_statuses_i (=[3])
219
+
220
+ translation helpers grouped for superset ( started with t_... ):
221
+ - Class.statuses.t_around_delivery_options (= [['translation or humanization', :ready_for_shipment] ...] ) for select inputs purposes
222
+ - Class.statuses.t_around_delivery_options_i (= [['translation or humanization', 3] ...]) same as above but with integer as value ( for example to use in Active admin filters )
172
223
  ```
173
224
 
174
225
  ```ruby
175
226
  request.on_delivery!
176
- request.delivery_set? # >> true
227
+ request.around_delivery? # >> true
177
228
 
178
- Request.delivery_set.exists?(request) # >> true
229
+ Request.around_delivery.exists?(request) # >> true
179
230
  Request.in_warehouse.exists?(request) # >> false
180
231
 
181
- Request.delivery_set_statuses # >> ["ready_for_shipment", "on_delivery", "delivered"]
232
+ Request.statuses.around_delivery # >> ["ready_for_shipment", "on_delivery", "delivered"]
182
233
  ```
183
234
  Rem:
184
- ext_enum_sets can be called multiple times defining a superposition of already defined sets ( considering previous example ):
235
+ supersets creation could be called multiple times defining a superposition of already defined sets ( considering previous example ):
185
236
 
186
237
  ```ruby
187
- ext_enum_sets :status, {
188
- outside_wharehouse: ( delivery_set_statuses - in_warehouse_statuses )#... any other array operations like &, + and so can be used
238
+ enum_ext :status, enum_supersets: {
239
+ outside_wharehouse: ( statuses.around_delivery_superset - statuses.in_warehouse_superset )#... any other array operations like &, + and so can be used
189
240
  }
190
241
  ```
191
242
 
192
243
  Rem: you can refer previously defined set as usual kind in the same method call:
193
244
 
194
245
  ```ruby
195
- ext_enum_sets :status, {
196
- delivery_set: [:ready_for_shipment, :on_delivery, :delivered],
197
- not_in_cart: [:paid, :delivery_set] #
246
+ enum_ext :status, enum_supersets: {
247
+ around_delivery: [:ready_for_shipment, :on_delivery, :delivered],
248
+ not_in_cart: [:paid, :around_delivery] #
198
249
  }
199
250
  ```
200
251
 
@@ -205,7 +256,7 @@ Rem: you can refer previously defined set as usual kind in the same method call:
205
256
  ext: [:multi_enum_scopes]
206
257
 
207
258
  # some place else:
208
- Request.with_statuses( :payed, :delivery_set ) # >> status IN (:payed, :ready_for_shipment, :on_delivery, :delivered)
259
+ Request.with_statuses( :payed, :around_delivery ) # >> status IN (:payed, :ready_for_shipment, :on_delivery, :delivered)
209
260
  Request.without_statuses( :payed, :in_warehouse ) # >> status NOT IN (:payed, :ready_for_shipment)
210
261
  ```
211
262
 
@@ -215,7 +266,7 @@ Rem: you can refer previously defined set as usual kind in the same method call:
215
266
 
216
267
  **Use-case:** it's often case when I need bulk update without callbacks, so it's gets frustrating to repeat:
217
268
  ```
218
- some_scope.update_all(status: Request.statuses[:new_status], update_at: Time.now)
269
+ some_scope.update_all(status: :new_status, update_at: Time.now)
219
270
  ```
220
271
  If you need callbacks you can do like this: some_scope.each(&:new_stat!) but if you don't need callbacks and you
221
272
  have hundreds and thousands of records to change at once you better call update_all
@@ -243,14 +294,50 @@ Rem: you can refer previously defined set as usual kind in the same method call:
243
294
  order.requests.delivered.count # >> N + M
244
295
  ```
245
296
 
297
+ ## Annotations helpers
298
+ Sometimes under irb console you need a quick tip on whats extension available on a enum, so some describe_* helpers added to enum wrapper
299
+
300
+ General description methods (describe/describe_short/describe_long)
301
+ ```
302
+ Class.enum.describe
303
+ ```
304
+ ![img.png](img.png)
305
+
306
+ ```
307
+ Class.enum.describe_short
308
+ ```
309
+ ![img_1.png](img_1.png)
310
+
311
+ ```
312
+ Class.enum.describe_long
313
+ ```
314
+ ![img_2.png](img_2.png)
315
+
316
+ And per extension methods (describe_enum_i, e.t.c)
317
+
318
+ ```ruby
319
+ EnumAnnotated.test_types.describe_mass_assign_enum
320
+ ```
321
+ ![img_3.png](img_3.png)
322
+
246
323
  ## Tests
247
- rake test
248
-
324
+ Starting version 0.6 added support for rails 7+ enum definitions, that's making testing a little bit not that easy as running `rake test`.
325
+ Now testings are done via `docker-compose up`. Look closer to Dockerfiles and `docker-compose.yml`
326
+ to get the idea how they working simultaneously without interference with each other.
327
+
328
+ Rem. I'm always freaking googling everytime I need to run single test so I'll just keep here:
329
+
330
+ ```ruby
331
+ rake test TEST=test/test_enum_ext.rb TESTOPTS="--name=/bb/"
332
+ ```
333
+
249
334
  ## Development
250
335
 
336
+ ## TODO
337
+ [] better support for suffix/prefix as enum does
338
+ [] add global config and allow global extension
251
339
 
252
340
  ## Contributing
253
-
254
341
  Bug reports and pull requests are welcome on GitHub at https://github.com/alekseyl/enum_ext or by email: leshchuk@gmail.com
255
342
 
256
343
 
@@ -258,6 +345,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/alekse
258
345
 
259
346
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
260
347
 
261
- ### Thanks
262
348
 
263
- Thanks for the star vzamanillo, it inspires me to do mass refactor and gracefully cover code in this gem by tests.
349
+ ### Thanks
350
+ Thanks for the first star to vzamanillo, it inspires me to do mass refactor and gracefully cover code in this gem by tests.
@@ -0,0 +1,24 @@
1
+ version: "3.7"
2
+
3
+ services:
4
+ test:
5
+ build: .
6
+ image: enum_ext
7
+ command: rake test
8
+ volumes:
9
+ - './lib:/app/lib'
10
+ - './test:/app/test'
11
+ - './Gemfile_rails_6:/app/Gemfile'
12
+ - './Gemfile_rails_6.lock:/app/Gemfile.lock'
13
+
14
+ test_7_0:
15
+ build:
16
+ context: .
17
+ dockerfile: Dockerfile_rails_7
18
+ image: enum_ext_rails_7
19
+ command: rake test
20
+ volumes:
21
+ - './lib:/app/lib'
22
+ - './test:/app/test'
23
+ - './Gemfile_rails_7:/app/Gemfile'
24
+ - './Gemfile_rails_7.lock:/app/Gemfile.lock'
data/img.png ADDED
Binary file
data/img_1.png ADDED
Binary file
data/img_2.png ADDED
Binary file
data/img_3.png ADDED
Binary file