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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0cd6f12c574c3d16d4fffa570b8917498e57256a4cd8f6e82d820cd47ed56af
4
- data.tar.gz: f6a2778547e583eea191a8db95cd44801f2853cc3b9a6b6a66f8575ce19cf22b
3
+ metadata.gz: 32e5b067cc3dfe374112b0eff7e91d3508f993ea58109bcab77f6a257d34513f
4
+ data.tar.gz: 12d12051cdeb103f889f4c104d68ed2d55818efe41705d18ae26ebbfa5fd98a4
5
5
  SHA512:
6
- metadata.gz: b8bae44f1114dcc75d0aef262d2dbdd8aa0e627c8e9f0ce5d3c65ab78f49f839efdf22743282ce753d04b65b3989a6c9d310df34f5f51ad4bce6bdb6558bb21a
7
- data.tar.gz: 39b3ec82b864aa278f4152d0054c04ec3b60267269333892614b5e58490ad14db549eb65fef10447cefaa6b70d3dce494b0130eafd5f7381b522bdefd47dbc42
6
+ metadata.gz: 98481b769364a4cb9cafd63ae11394e631a97c5c914c94b6b3de380fab9324d6ccac4c8730f7483bb0b0bd0933de4585aa5dbc1650b8b0bf1e445b1fd56a2677
7
+ data.tar.gz: 1d28e5fbf250aa8c76098c2608a51df7b998369d6b9e738c3baaae06ce53ac27f79f18b3cfa16a62faf7ccc8f7c85db57d2b67e30b18f8561eca8e8d7c87a641
@@ -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 options
130
- Soda.options
139
+ def rails?
140
+ require "rails"
141
+ defined?(::Rails)
142
+ rescue LoadError
143
+ false
131
144
  end
132
145
  end
133
146
  end
@@ -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
- execute(job_hash, msg)
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
@@ -0,0 +1,7 @@
1
+ module Soda
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ # TODO: define AJ integration
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Soda
2
- VERSION = "0.0.5".freeze
2
+ VERSION = "0.0.6".freeze
3
3
  end
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.5
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-15 00:00:00.000000000 Z
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