soda-core 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/soda/cli.rb +15 -2
- data/lib/soda/processor.rb +19 -1
- data/lib/soda/rails.rb +7 -0
- data/lib/soda/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: 32e5b067cc3dfe374112b0eff7e91d3508f993ea58109bcab77f6a257d34513f
|
4
|
+
data.tar.gz: 12d12051cdeb103f889f4c104d68ed2d55818efe41705d18ae26ebbfa5fd98a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98481b769364a4cb9cafd63ae11394e631a97c5c914c94b6b3de380fab9324d6ccac4c8730f7483bb0b0bd0933de4585aa5dbc1650b8b0bf1e445b1fd56a2677
|
7
|
+
data.tar.gz: 1d28e5fbf250aa8c76098c2608a51df7b998369d6b9e738c3baaae06ce53ac27f79f18b3cfa16a62faf7ccc8f7c85db57d2b67e30b18f8561eca8e8d7c87a641
|
data/lib/soda/cli.rb
CHANGED
@@ -23,6 +23,16 @@ module Soda
|
|
23
23
|
def run
|
24
24
|
build_options
|
25
25
|
|
26
|
+
if rails?
|
27
|
+
if Rails::VERSION::MAJOR >= 5
|
28
|
+
require "./config/environment.rb"
|
29
|
+
require "soda/rails"
|
30
|
+
logger.info("Loaded Rails v%s application." % ::Rails.version)
|
31
|
+
else
|
32
|
+
raise "Not compatible with Rails v%s!" % Rails.version
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
26
36
|
manager = Manager.new
|
27
37
|
manager.start
|
28
38
|
|
@@ -126,8 +136,11 @@ module Soda
|
|
126
136
|
end
|
127
137
|
end
|
128
138
|
|
129
|
-
def
|
130
|
-
|
139
|
+
def rails?
|
140
|
+
require "rails"
|
141
|
+
defined?(::Rails)
|
142
|
+
rescue LoadError
|
143
|
+
false
|
131
144
|
end
|
132
145
|
end
|
133
146
|
end
|
data/lib/soda/processor.rb
CHANGED
@@ -50,7 +50,9 @@ module Soda
|
|
50
50
|
def process(msg)
|
51
51
|
if (job_hash = parse_job(msg.str))
|
52
52
|
job_logger.with(job_hash) do
|
53
|
-
|
53
|
+
reloader.wrap do
|
54
|
+
execute(job_hash, msg)
|
55
|
+
end
|
54
56
|
end
|
55
57
|
else
|
56
58
|
# We can't process the work because the JSON is invalid, so we have to
|
@@ -98,5 +100,21 @@ module Soda
|
|
98
100
|
def constantize(str)
|
99
101
|
Object.const_get(str)
|
100
102
|
end
|
103
|
+
|
104
|
+
# To support Rails reloading from the CLI context, the following code find
|
105
|
+
# the Rails reloader or stubs a no-op one.
|
106
|
+
class StubReloader
|
107
|
+
def wrap; yield; end
|
108
|
+
end
|
109
|
+
|
110
|
+
def reloader
|
111
|
+
@reloader ||=
|
112
|
+
if defined?(::Soda::Rails)
|
113
|
+
application = ::Rails.application
|
114
|
+
application.reloader
|
115
|
+
else
|
116
|
+
StubReloader.new
|
117
|
+
end
|
118
|
+
end
|
101
119
|
end
|
102
120
|
end
|
data/lib/soda/rails.rb
ADDED
data/lib/soda/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soda-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Portes Chaikin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-sqs
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/soda/processor.rb
|
71
71
|
- lib/soda/queue.rb
|
72
72
|
- lib/soda/queues/registry.rb
|
73
|
+
- lib/soda/rails.rb
|
73
74
|
- lib/soda/retrier.rb
|
74
75
|
- lib/soda/tools.rb
|
75
76
|
- lib/soda/version.rb
|