ez-resources 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +106 -0
- data/Rakefile +34 -0
- data/app/cells/ez/resources/application_cell.rb +40 -0
- data/app/cells/ez/resources/collection/table.slim +42 -0
- data/app/cells/ez/resources/collection_cell.rb +115 -0
- data/app/cells/ez/resources/field/show.slim +2 -0
- data/app/cells/ez/resources/field_cell.rb +41 -0
- data/app/cells/ez/resources/form/show.slim +16 -0
- data/app/cells/ez/resources/form_cell.rb +33 -0
- data/app/cells/ez/resources/search/show.slim +20 -0
- data/app/cells/ez/resources/search_cell.rb +43 -0
- data/lib/ez/resources.rb +21 -0
- data/lib/ez/resources/engine.rb +14 -0
- data/lib/ez/resources/manager.rb +114 -0
- data/lib/ez/resources/manager/action.rb +17 -0
- data/lib/ez/resources/manager/config.rb +150 -0
- data/lib/ez/resources/manager/config_store.rb +48 -0
- data/lib/ez/resources/manager/dsl.rb +22 -0
- data/lib/ez/resources/manager/field.rb +46 -0
- data/lib/ez/resources/manager/fields.rb +31 -0
- data/lib/ez/resources/manager/hook.rb +16 -0
- data/lib/ez/resources/manager/hooks.rb +38 -0
- data/lib/ez/resources/railtie.rb +8 -0
- data/lib/ez/resources/version.rb +7 -0
- data/lib/tasks/ez/resources_tasks.rake +5 -0
- metadata +327 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ez
|
4
|
+
module Resources
|
5
|
+
module Manager
|
6
|
+
class Field
|
7
|
+
attr_reader :name,
|
8
|
+
:title,
|
9
|
+
:type,
|
10
|
+
:required,
|
11
|
+
:default,
|
12
|
+
:suffix,
|
13
|
+
:min,
|
14
|
+
:collection,
|
15
|
+
:wrapper,
|
16
|
+
:options,
|
17
|
+
:getter,
|
18
|
+
:presenter,
|
19
|
+
:builder,
|
20
|
+
:searchable,
|
21
|
+
:search_suffix,
|
22
|
+
:options
|
23
|
+
|
24
|
+
def initialize(options = {})
|
25
|
+
@name = options.delete(:name)
|
26
|
+
@title = options.delete(:title) || @name.to_s.capitalize
|
27
|
+
@type = options.delete(:type) || :string
|
28
|
+
@required = options.delete(:required) || true
|
29
|
+
@collection = options.delete(:collection) || []
|
30
|
+
@default = options.delete(:default)
|
31
|
+
@suffix = options.delete(:suffix)
|
32
|
+
@min = options.delete(:min)
|
33
|
+
@wrapper = options.delete(:wrapper)
|
34
|
+
@builder = options.delete(:builder)
|
35
|
+
@getter = options.delete(:getter)
|
36
|
+
@presenter = options.delete(:presenter)
|
37
|
+
@searchable = options.delete(:searchable) != false
|
38
|
+
@search_suffix = options.delete(:search_suffix) || :cont
|
39
|
+
@options = options # use for all other custom options
|
40
|
+
end
|
41
|
+
|
42
|
+
alias required? required
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ez/resources/manager/action'
|
4
|
+
require 'ez/resources/manager/field'
|
5
|
+
|
6
|
+
module Ez
|
7
|
+
module Resources
|
8
|
+
module Manager
|
9
|
+
class Fields
|
10
|
+
attr_reader :fields, :actions
|
11
|
+
|
12
|
+
def initialize(&block)
|
13
|
+
@fields = []
|
14
|
+
@actions = []
|
15
|
+
|
16
|
+
instance_eval(&block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def field(name, options = {})
|
20
|
+
@fields << Field.new(name: name, **options)
|
21
|
+
end
|
22
|
+
|
23
|
+
alias column field
|
24
|
+
|
25
|
+
def action(name, builder, options = {})
|
26
|
+
@actions << Action.new(name, builder, **options)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ez/resources/manager/hook'
|
4
|
+
|
5
|
+
module Ez
|
6
|
+
module Resources
|
7
|
+
module Manager
|
8
|
+
class Hooks
|
9
|
+
attr_reader :hooks
|
10
|
+
|
11
|
+
def self.can!(name, config, data = nil)
|
12
|
+
return true if config.hooks.empty?
|
13
|
+
if config.hooks.select { |h| h.name == name }.map { |h| h.callback.call(config.controller, data) }.all?(true)
|
14
|
+
return true
|
15
|
+
end
|
16
|
+
|
17
|
+
raise UnavailableError, "Negative #{name}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.can?(name, config, data = nil)
|
21
|
+
return true if config.hooks.empty?
|
22
|
+
|
23
|
+
config.hooks.select { |h| h.name == name }.map { |h| h.callback.call(config.controller, data) }.all?(true)
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(&block)
|
27
|
+
@hooks = []
|
28
|
+
|
29
|
+
instance_eval(&block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def add(name, callback)
|
33
|
+
@hooks << Hook.new(name: name, callback: callback)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,327 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ez-resources
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Volodya Sveredyuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cells-rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cells-slim
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.6
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.6
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ez-core
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pagy
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.2'
|
76
|
+
- - "<="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '7.0'
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '5.2'
|
86
|
+
- - "<="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '7.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: ransack
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2.3'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2.3'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: simple_form
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 5.0.1
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 5.0.1
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: bundler
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '2.0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '2.0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: capybara
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: factory_bot_rails
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: ffaker
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: guard-rspec
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
type: :development
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
name: launchy
|
189
|
+
requirement: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - ">="
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0'
|
194
|
+
type: :development
|
195
|
+
prerelease: false
|
196
|
+
version_requirements: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '0'
|
201
|
+
- !ruby/object:Gem::Dependency
|
202
|
+
name: pry-rails
|
203
|
+
requirement: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
type: :development
|
209
|
+
prerelease: false
|
210
|
+
version_requirements: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - ">="
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '0'
|
215
|
+
- !ruby/object:Gem::Dependency
|
216
|
+
name: rspec-rails
|
217
|
+
requirement: !ruby/object:Gem::Requirement
|
218
|
+
requirements:
|
219
|
+
- - ">="
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
type: :development
|
223
|
+
prerelease: false
|
224
|
+
version_requirements: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - ">="
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: '0'
|
229
|
+
- !ruby/object:Gem::Dependency
|
230
|
+
name: rubocop
|
231
|
+
requirement: !ruby/object:Gem::Requirement
|
232
|
+
requirements:
|
233
|
+
- - ">="
|
234
|
+
- !ruby/object:Gem::Version
|
235
|
+
version: '0'
|
236
|
+
type: :development
|
237
|
+
prerelease: false
|
238
|
+
version_requirements: !ruby/object:Gem::Requirement
|
239
|
+
requirements:
|
240
|
+
- - ">="
|
241
|
+
- !ruby/object:Gem::Version
|
242
|
+
version: '0'
|
243
|
+
- !ruby/object:Gem::Dependency
|
244
|
+
name: simplecov
|
245
|
+
requirement: !ruby/object:Gem::Requirement
|
246
|
+
requirements:
|
247
|
+
- - ">="
|
248
|
+
- !ruby/object:Gem::Version
|
249
|
+
version: '0'
|
250
|
+
type: :development
|
251
|
+
prerelease: false
|
252
|
+
version_requirements: !ruby/object:Gem::Requirement
|
253
|
+
requirements:
|
254
|
+
- - ">="
|
255
|
+
- !ruby/object:Gem::Version
|
256
|
+
version: '0'
|
257
|
+
- !ruby/object:Gem::Dependency
|
258
|
+
name: sqlite3
|
259
|
+
requirement: !ruby/object:Gem::Requirement
|
260
|
+
requirements:
|
261
|
+
- - ">="
|
262
|
+
- !ruby/object:Gem::Version
|
263
|
+
version: '0'
|
264
|
+
type: :development
|
265
|
+
prerelease: false
|
266
|
+
version_requirements: !ruby/object:Gem::Requirement
|
267
|
+
requirements:
|
268
|
+
- - ">="
|
269
|
+
- !ruby/object:Gem::Version
|
270
|
+
version: '0'
|
271
|
+
description: Easy resources engine for Rails app.
|
272
|
+
email:
|
273
|
+
- sveredyuk@gmail.com
|
274
|
+
executables: []
|
275
|
+
extensions: []
|
276
|
+
extra_rdoc_files: []
|
277
|
+
files:
|
278
|
+
- MIT-LICENSE
|
279
|
+
- README.md
|
280
|
+
- Rakefile
|
281
|
+
- app/cells/ez/resources/application_cell.rb
|
282
|
+
- app/cells/ez/resources/collection/table.slim
|
283
|
+
- app/cells/ez/resources/collection_cell.rb
|
284
|
+
- app/cells/ez/resources/field/show.slim
|
285
|
+
- app/cells/ez/resources/field_cell.rb
|
286
|
+
- app/cells/ez/resources/form/show.slim
|
287
|
+
- app/cells/ez/resources/form_cell.rb
|
288
|
+
- app/cells/ez/resources/search/show.slim
|
289
|
+
- app/cells/ez/resources/search_cell.rb
|
290
|
+
- lib/ez/resources.rb
|
291
|
+
- lib/ez/resources/engine.rb
|
292
|
+
- lib/ez/resources/manager.rb
|
293
|
+
- lib/ez/resources/manager/action.rb
|
294
|
+
- lib/ez/resources/manager/config.rb
|
295
|
+
- lib/ez/resources/manager/config_store.rb
|
296
|
+
- lib/ez/resources/manager/dsl.rb
|
297
|
+
- lib/ez/resources/manager/field.rb
|
298
|
+
- lib/ez/resources/manager/fields.rb
|
299
|
+
- lib/ez/resources/manager/hook.rb
|
300
|
+
- lib/ez/resources/manager/hooks.rb
|
301
|
+
- lib/ez/resources/railtie.rb
|
302
|
+
- lib/ez/resources/version.rb
|
303
|
+
- lib/tasks/ez/resources_tasks.rake
|
304
|
+
homepage: https://github.com/ez-engines/ez-resources
|
305
|
+
licenses:
|
306
|
+
- MIT
|
307
|
+
metadata: {}
|
308
|
+
post_install_message:
|
309
|
+
rdoc_options: []
|
310
|
+
require_paths:
|
311
|
+
- lib
|
312
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
313
|
+
requirements:
|
314
|
+
- - ">="
|
315
|
+
- !ruby/object:Gem::Version
|
316
|
+
version: '0'
|
317
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
318
|
+
requirements:
|
319
|
+
- - ">="
|
320
|
+
- !ruby/object:Gem::Version
|
321
|
+
version: '0'
|
322
|
+
requirements: []
|
323
|
+
rubygems_version: 3.2.15
|
324
|
+
signing_key:
|
325
|
+
specification_version: 4
|
326
|
+
summary: Easy resources engine for Rails app.
|
327
|
+
test_files: []
|