eitil 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +29 -1
- data/config/initializers/modules/dir.rb +21 -0
- data/config/initializers/monkeys/hash.rb +1 -1
- data/config/initializers/wrappers/jobs/active_job_macros.rb +8 -2
- data/config/initializers/wrappers/jobs/single_method_job.rb +18 -2
- data/config/initializers/wrappers/scopes/default_scopes.rb +1 -1
- data/lib/eitil/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56e99cc29a813ae79db47620342f21059e0ee2fc6ac57d3d1555472908d671e1
|
4
|
+
data.tar.gz: 9391db6351b7f43230b64c7c7fa5a78fb5f7b95055ab2103ed68e28dd6673dc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45540a3818ba26d7197ce4ed9cd2e7ab1061d7889445566f583a1fa5f1b218a324ae484f968c4291017bb12ea30c7e69cea3765135d2de2a703eee8ba02b8f9f
|
7
|
+
data.tar.gz: bec07d5c24641ce1e24dc31c450d01b98ca2a28b13ea799f8b285e59f701e946ae362e69e2e9c3ecc99dc805ce8bc6e48325acd5f8f19c04ccd2fd894b1cb786
|
data/README.md
CHANGED
@@ -177,7 +177,7 @@ decorate(dec_item, dec_method: nil, dec_class: nil, **dec_kwargs)
|
|
177
177
|
# initializers/eitil.rb
|
178
178
|
|
179
179
|
Eitil.set_config do |config|
|
180
|
-
config.get_controller_ivars_method = 'API::
|
180
|
+
config.get_controller_ivars_method = 'API::BaseController.controller_ivars' # => [:user, :env]
|
181
181
|
end
|
182
182
|
```
|
183
183
|
|
@@ -304,3 +304,31 @@ Scopes are generated through the columns of your model's database table. Which s
|
|
304
304
|
Your models should inherit the module Eitil::DefaultScopes through inclusion in a superclass, such as ApplicationRecord.
|
305
305
|
|
306
306
|
|
307
|
+
|
308
|
+
# Modules
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
## Eitil::Dir
|
313
|
+
|
314
|
+
### Info
|
315
|
+
|
316
|
+
The Eitil::Dir module provides methods which help you introspect your Rails project.
|
317
|
+
|
318
|
+
### Methods
|
319
|
+
|
320
|
+
```ruby
|
321
|
+
Eitil::Dir.contents(directory='app')
|
322
|
+
# returns all files and subdirectories of a given directory
|
323
|
+
|
324
|
+
Eitil::Dir.files(directory='app')
|
325
|
+
# returns all files of a given directory
|
326
|
+
|
327
|
+
Eitil::Dir.subdirs(directory='app')
|
328
|
+
# returns all subdirectories of a given directory
|
329
|
+
|
330
|
+
Eitil::Dir.lines(directory='app')
|
331
|
+
# returns the total amount of lines of all files of a given directory
|
332
|
+
```
|
333
|
+
|
334
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Eitil::Dir
|
2
|
+
class << self
|
3
|
+
|
4
|
+
def contents(directory='app')
|
5
|
+
Dir[File.join(directory, '**', '*')]
|
6
|
+
end
|
7
|
+
|
8
|
+
def files(directory='app')
|
9
|
+
contents(directory).select { |file| File.file?(file) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def subdirs(directory='app')
|
13
|
+
contents(directory).select { |file| File.directory?(file) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def lines(directory='app')
|
17
|
+
files(directory).map { |file| File.open(file).count }.sum
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -1,10 +1,16 @@
|
|
1
1
|
Kernel.module_eval do
|
2
2
|
|
3
|
+
# BEWARE: _self is currently not accepted in perform_later jobs due to serialization errors
|
4
|
+
|
5
|
+
# The cases of 'id' and '_self' both handle instances, with the difference
|
6
|
+
# being that 'id' works for objects that have a database record, while '_self'
|
7
|
+
# works for non database supported instanes, such as an Exporter instance.
|
8
|
+
|
3
9
|
def new_job(_method)
|
4
10
|
|
5
11
|
if instance_methods(false).include? _method
|
6
|
-
define_method "#{_method}_job" do
|
7
|
-
Eitil::SingleMethodJob.perform_later(_class: self.class.to_s, _method: _method.to_s, id: id)
|
12
|
+
define_method "#{_method}_job" do |_self = nil|
|
13
|
+
Eitil::SingleMethodJob.perform_later(_class: self.class.to_s, _method: _method.to_s, id: safe_send(:id), _self: self.to_json)
|
8
14
|
end
|
9
15
|
|
10
16
|
elsif singleton_methods(false).include? _method
|
@@ -2,8 +2,24 @@ module Eitil
|
|
2
2
|
class SingleMethodJob < ApplicationJob
|
3
3
|
queue_as :default
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
# BEWARE: _self is currently not accepted in perform_later jobs due to serialization errors
|
6
|
+
|
7
|
+
# The cases of 'id' and '_self' both handle instances, with the difference
|
8
|
+
# being that 'id' works for objects that have a database record, while '_self'
|
9
|
+
# works for non database supported instanes, such as an Exporter instance.
|
10
|
+
|
11
|
+
def perform(_class:, _method:, id: nil, _self: nil)
|
12
|
+
binding.pry
|
13
|
+
|
14
|
+
object =
|
15
|
+
if id
|
16
|
+
_class.constantize.find(id)
|
17
|
+
elsif _self
|
18
|
+
_self
|
19
|
+
else
|
20
|
+
_class.constantize
|
21
|
+
end
|
22
|
+
|
7
23
|
object.send _method
|
8
24
|
end
|
9
25
|
end
|
@@ -48,7 +48,7 @@ module Eitil
|
|
48
48
|
|
49
49
|
def create_eitil_boolean_scopes
|
50
50
|
columns_of_type(:boolean)&.map do |column, object|
|
51
|
-
eitil_scope :"#{column}_true",
|
51
|
+
eitil_scope :"#{column}_true", -> { where(column => true) }
|
52
52
|
eitil_scope :"#{column}_false", -> { where(column => [false, nil]) }
|
53
53
|
end
|
54
54
|
end
|
data/lib/eitil/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eitil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jurriaan Schrofer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- app/jobs/eitil/application_job.rb
|
53
53
|
- app/mailers/eitil/application_mailer.rb
|
54
54
|
- app/models/eitil/application_record.rb
|
55
|
+
- config/initializers/modules/dir.rb
|
55
56
|
- config/initializers/monkeys/application_controller.rb
|
56
57
|
- config/initializers/monkeys/application_record.rb
|
57
58
|
- config/initializers/monkeys/date_time.rb
|