enum_ext 0.5.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/Dockerfile +22 -0
- data/Dockerfile_rails_7 +25 -0
- data/{Gemfile → Gemfile_rails_6} +1 -0
- data/{Gemfile.lock → Gemfile_rails_6.lock} +9 -2
- data/Gemfile_rails_7 +6 -0
- data/Gemfile_rails_7.lock +102 -0
- data/README.md +106 -25
- data/docker-compose.yml +24 -0
- data/enum_ext.gemspec +2 -0
- data/img.png +0 -0
- data/img_1.png +0 -0
- data/img_2.png +0 -0
- data/img_3.png +0 -0
- data/lib/enum_ext/annotated.rb +172 -0
- data/lib/enum_ext/basic_helpers.rb +79 -0
- data/lib/enum_ext/enum_wrapper.rb +78 -0
- data/lib/enum_ext/humanize_helpers.rb +161 -0
- data/lib/enum_ext/superset_helpers.rb +77 -0
- data/lib/enum_ext/version.rb +1 -1
- data/lib/enum_ext.rb +45 -356
- metadata +47 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d99346b1ae5f9458733025608cad6e8a1ab427091ce44d10a544e880722633c
|
4
|
+
data.tar.gz: 6a1943ddedaa37022bdfe421dbc4c5d063c63149a96aaa0f05cdab35f423de6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce540db8aca9002c6a46a5ae5eb7a45f7a296d4fd183493a8796e3b9dd007ebb04bc0793b1162b82e177de5b59ff06e8e553248a2aa4c725b17d3570d682444f
|
7
|
+
data.tar.gz: 7db85461bd47c03b3169259f699a29e7a1855fd791d53fb4fe84995b812739fe4968b8184665dfd04230b71e2d78152dc8868f78f89452f37d6b20ed00c77ecc
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
# 0.8.0
|
2
|
+
* Methods annotations added:
|
3
|
+
* Full descriptions: Class.enum.describe(short=true) / Class.enum.describe_short / Class.enum.describe_long / Class.enum.describe_basic
|
4
|
+
* Per-methods: Class.enum.describe_enum_i, describe_mass_assign_enum, describe_multi_enum_scopes e.t.c.
|
5
|
+
* method Class.enum.supersets_raw added, it will return supersets decompositions to basic enum
|
6
|
+
* Class.enum.all method now returns basic enum_values + supersets_raw decomposition to basic enums ( previously was a supersets i.e. high level definition )
|
7
|
+
|
8
|
+
# 0.7.0
|
9
|
+
* rails 7 syntax support added
|
10
|
+
* massive test process refactoring docker with both rails 7 and earlier support
|
11
|
+
* simple translate_enum allowed via `ext: [:translate_enum]`
|
12
|
+
|
13
|
+
# 0.6.0 (BREAKING CHANGES)
|
14
|
+
* fixed issue with non array superset
|
15
|
+
* standard helpers are now private, you should use enum_ext / enum , ext: [] approach to the definitions
|
16
|
+
* class.superset_statuses moved to enum_obj -> class.statuses.superset_statuses
|
17
|
+
* massive ReadMe refactoring
|
18
|
+
|
19
|
+
# 0.5.3
|
20
|
+
* refactored tests
|
21
|
+
* multi_enum_scopes will be chainable with empty params (i.e. will not change the scope)
|
22
|
+
* some development dependencies were added
|
23
|
+
|
1
24
|
# 0.5.2
|
2
25
|
* removed unused require from the upcoming version
|
3
26
|
|
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
|
data/Dockerfile_rails_7
ADDED
@@ -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
|
data/{Gemfile → Gemfile_rails_6}
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
enum_ext (0.
|
4
|
+
enum_ext (0.8.0)
|
5
5
|
activerecord (>= 5.2.4.3)
|
6
6
|
|
7
7
|
GEM
|
@@ -31,6 +31,7 @@ GEM
|
|
31
31
|
minitest (>= 5.1)
|
32
32
|
tzinfo (~> 2.0)
|
33
33
|
zeitwerk (~> 2.3)
|
34
|
+
amazing_print (1.4.0)
|
34
35
|
builder (3.2.4)
|
35
36
|
byebug (11.1.3)
|
36
37
|
concurrent-ruby (1.1.10)
|
@@ -44,6 +45,7 @@ GEM
|
|
44
45
|
method_source (1.0.0)
|
45
46
|
mini_portile2 (2.8.0)
|
46
47
|
minitest (5.14.2)
|
48
|
+
niceql (0.6.1)
|
47
49
|
nokogiri (1.13.10)
|
48
50
|
mini_portile2 (~> 2.8.0)
|
49
51
|
racc (~> 1.4)
|
@@ -59,6 +61,9 @@ GEM
|
|
59
61
|
rails-i18n (7.0.6)
|
60
62
|
i18n (>= 0.7, < 2)
|
61
63
|
railties (>= 6.0.0, < 8)
|
64
|
+
rails_sql_prettifier (6.1.5)
|
65
|
+
activerecord (>= 6.1, < 7)
|
66
|
+
niceql (~> 0.6)
|
62
67
|
railties (6.1.7)
|
63
68
|
actionpack (= 6.1.7)
|
64
69
|
activesupport (= 6.1.7)
|
@@ -77,14 +82,16 @@ PLATFORMS
|
|
77
82
|
ruby
|
78
83
|
|
79
84
|
DEPENDENCIES
|
85
|
+
amazing_print
|
80
86
|
bundler (>= 1.11)
|
81
87
|
byebug
|
82
88
|
enum_ext!
|
83
89
|
minitest
|
84
90
|
rails-i18n (>= 4)
|
91
|
+
rails_sql_prettifier
|
85
92
|
rake (>= 10.0)
|
86
93
|
sqlite3
|
87
94
|
stubberry
|
88
95
|
|
89
96
|
BUNDLED WITH
|
90
|
-
2.
|
97
|
+
2.4.17
|
data/Gemfile_rails_7
ADDED
@@ -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.
|
10
|
+
gem 'enum_ext', '~> 0.7'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -49,7 +49,41 @@ Or install it yourself as:
|
|
49
49
|
end
|
50
50
|
```
|
51
51
|
|
52
|
-
|
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 kind: {}
|
60
|
+
enum_i :kind # will raise an private method error starting ver 0.6
|
61
|
+
enum_mass_assign :kind # will raise an private method error starting ver 0.6
|
62
|
+
|
63
|
+
#You should go with ext option instead:
|
64
|
+
enum kinds: {}, ext: [:enum_i, :enum_mass_assign]
|
65
|
+
|
66
|
+
# OR in case of standalone enum definition:
|
67
|
+
enum kinds: {} # somewhere where you can't or don't want reach
|
68
|
+
enum_ext :kinds, [: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 :kinds, [:enum_i, :enum_mass_assign, :translate_enum, enum_supersets: {}]
|
79
|
+
|
80
|
+
# BAD (even if correctly defines internationalization):
|
81
|
+
enum_ext :kinds, [: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
|
|
@@ -81,7 +115,7 @@ Or install it yourself as:
|
|
81
115
|
|
82
116
|
```ruby
|
83
117
|
humanize_enum :status do
|
84
|
-
|
118
|
+
I18n.t("scope.#{status}")
|
85
119
|
end
|
86
120
|
```
|
87
121
|
|
@@ -95,7 +129,6 @@ Or install it yourself as:
|
|
95
129
|
```ruby
|
96
130
|
filter :status, as: :select, label: 'Status', collection: Request.t_statuses_options_i
|
97
131
|
```
|
98
|
-
|
99
132
|
|
100
133
|
**Rem:** select options may break when using lambda() or proc with instance method, but will survive with block
|
101
134
|
|
@@ -113,6 +146,7 @@ Or install it yourself as:
|
|
113
146
|
### Translate (translate_enum)
|
114
147
|
|
115
148
|
Enum is translated using scope 'active_record.attributes.class_name_underscore.enum_plural', or the given one:
|
149
|
+
|
116
150
|
```ruby
|
117
151
|
translate_enum :status, 'active_record.request.enum'
|
118
152
|
```
|
@@ -124,7 +158,10 @@ Or it can be done with block either with translate or humanize:
|
|
124
158
|
end
|
125
159
|
```
|
126
160
|
|
161
|
+
## Enum extended functionality
|
162
|
+
|
127
163
|
### Enum to_i shortcut ( enum_i )
|
164
|
+
|
128
165
|
Defines method enum_name_i shortcut for Model.enum_names[elem.enum_name] or enum_name_before_type_cast
|
129
166
|
|
130
167
|
**Ex**
|
@@ -135,22 +172,30 @@ Defines method enum_name_i shortcut for Model.enum_names[elem.enum_name] or enum
|
|
135
172
|
request.paid_i # 10
|
136
173
|
```
|
137
174
|
|
138
|
-
### Enum
|
175
|
+
### Enum SuperSets (enum_supersets)
|
139
176
|
|
140
|
-
**Use-case** whenever you need superset of enums to behave like a enum.
|
177
|
+
**Use-case** whenever you need superset of enums to behave like a super enum.
|
141
178
|
|
142
|
-
You can do this with method **
|
179
|
+
You can do this with method **enum_supersets** it creates:
|
143
180
|
- scopes for subsets,
|
144
181
|
- instance methods with `?`
|
145
|
-
- and some class methods helpers
|
146
182
|
|
147
183
|
For instance:
|
148
184
|
|
149
185
|
```ruby
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
186
|
+
enum status: [:in_cart, :waiting_for_payment, :paid, :packing, :ready_for_shipment, :on_delivery, :delivered],
|
187
|
+
ext: [enum_supersets: {
|
188
|
+
delivery_set: [:ready_for_shipment, :on_delivery], # for shipping department for example
|
189
|
+
in_warehouse: [:packing, :ready_for_shipment], # this scope is just for superposition example below
|
190
|
+
sold: [:paid, :delivery_set, :in_warehouse, :delivered] # also you can define any superposition of already defined supersets or enum values
|
191
|
+
}]
|
192
|
+
|
193
|
+
# supersets will be stored inside enum wrapper object, and can be de-referenced to basic enum values
|
194
|
+
# using wrapper defined methods: "superset_enum_plural", i.e. statuses.sold_statuses -> [:paid, :packing, :ready_for_shipment, :on_delivery, :delivered]
|
195
|
+
# so new supersets could be defined using Array operations against newly defined methods
|
196
|
+
enum_ext :status, enum_supersets: {
|
197
|
+
outside_warehouse: ( statuses.delivery_set_statuses - statuses.in_warehouse_statuses ) #... any other array operations like &, + and so can be used
|
198
|
+
}
|
154
199
|
```
|
155
200
|
|
156
201
|
it will generate:
|
@@ -162,13 +207,17 @@ instance:
|
|
162
207
|
class:
|
163
208
|
- named scopes: delivery_set, in_warehouse
|
164
209
|
- 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
210
|
|
169
|
-
|
170
|
-
|
171
|
-
|
211
|
+
enum methods:
|
212
|
+
- Class.statuses.supersets -- will output superset definition hash
|
213
|
+
- Class.statuses.supersets_raw -- will output superset decompositions to basic enum types hash
|
214
|
+
|
215
|
+
- Class.statuses.delivery_superset (=[:ready_for_shipment, :on_delivery, :delivered] ), in_warehouse_statuses
|
216
|
+
- delivery_set_statuses_i (= [3,4,5]), in_warehouse_statuses_i (=[3])
|
217
|
+
|
218
|
+
translation helpers ( started with t_... ):
|
219
|
+
- Class.statuses.t_delivery_set_options (= [['translation or humanization', :ready_for_shipment] ...] ) for select inputs purposes
|
220
|
+
- Class.statuses.t_delivery_set_options_i (= [['translation or humanization', 3] ...]) same as above but with integer as value ( for example to use in Active admin filters )
|
172
221
|
```
|
173
222
|
|
174
223
|
```ruby
|
@@ -181,10 +230,10 @@ class:
|
|
181
230
|
Request.delivery_set_statuses # >> ["ready_for_shipment", "on_delivery", "delivered"]
|
182
231
|
```
|
183
232
|
Rem:
|
184
|
-
|
233
|
+
supersets creation could be called multiple times defining a superposition of already defined sets ( considering previous example ):
|
185
234
|
|
186
235
|
```ruby
|
187
|
-
|
236
|
+
enum_ext :status, enum_supersets: {
|
188
237
|
outside_wharehouse: ( delivery_set_statuses - in_warehouse_statuses )#... any other array operations like &, + and so can be used
|
189
238
|
}
|
190
239
|
```
|
@@ -192,7 +241,7 @@ ext_enum_sets can be called multiple times defining a superposition of already d
|
|
192
241
|
Rem: you can refer previously defined set as usual kind in the same method call:
|
193
242
|
|
194
243
|
```ruby
|
195
|
-
|
244
|
+
enum_ext :status, enum_supersets: {
|
196
245
|
delivery_set: [:ready_for_shipment, :on_delivery, :delivered],
|
197
246
|
not_in_cart: [:paid, :delivery_set] #
|
198
247
|
}
|
@@ -243,11 +292,43 @@ Rem: you can refer previously defined set as usual kind in the same method call:
|
|
243
292
|
order.requests.delivered.count # >> N + M
|
244
293
|
```
|
245
294
|
|
295
|
+
## Annotations helpers
|
296
|
+
Sometimes under irb console you need a quick tip on whats extension available on a enum, so some describe_* helpers added to enum wrapper
|
297
|
+
|
298
|
+
General description methods (describe/describe_short/describe_long)
|
299
|
+
```
|
300
|
+
Class.enum.describe
|
301
|
+
```
|
302
|
+
![img.png](img.png)
|
303
|
+
|
304
|
+
```
|
305
|
+
Class.enum.describe_short
|
306
|
+
```
|
307
|
+
![img_1.png](img_1.png)
|
308
|
+
|
309
|
+
```
|
310
|
+
Class.enum.describe_long
|
311
|
+
```
|
312
|
+
![img_2.png](img_2.png)
|
313
|
+
|
314
|
+
And per extension methods (describe_enum_i, e.t.c)
|
315
|
+
|
316
|
+
```ruby
|
317
|
+
EnumAnnotated.test_types.describe_mass_assign_enum
|
318
|
+
```
|
319
|
+
![img_3.png](img_3.png)
|
320
|
+
|
246
321
|
## Tests
|
247
|
-
|
248
|
-
|
322
|
+
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`.
|
323
|
+
Now testings are done via `docker-compose up`. Look closer to Dockerfiles and `docker-compose.yml`
|
324
|
+
to get the idea how they working simultaneously without interference with each other.
|
325
|
+
|
326
|
+
|
249
327
|
## Development
|
250
328
|
|
329
|
+
## TODO
|
330
|
+
[] better support for suffix/prefix as enum does
|
331
|
+
[] describe method to observe current extension
|
251
332
|
|
252
333
|
## Contributing
|
253
334
|
|
@@ -258,6 +339,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/alekse
|
|
258
339
|
|
259
340
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
260
341
|
|
261
|
-
### Thanks
|
262
342
|
|
263
|
-
Thanks
|
343
|
+
### Thanks
|
344
|
+
Thanks for the first star to vzamanillo, it inspires me to do mass refactor and gracefully cover code in this gem by tests.
|
data/docker-compose.yml
ADDED
@@ -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/enum_ext.gemspec
CHANGED
@@ -28,4 +28,6 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency 'sqlite3'
|
29
29
|
spec.add_development_dependency 'byebug'
|
30
30
|
spec.add_development_dependency 'stubberry'
|
31
|
+
spec.add_development_dependency 'rails_sql_prettifier'
|
32
|
+
spec.add_development_dependency 'amazing_print'
|
31
33
|
end
|
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
|