nexaas-async-collector 1.0.2 → 1.2.0

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
  SHA1:
3
- metadata.gz: 1f581d99eadd9c89653976bae829da7a41b3cb3e
4
- data.tar.gz: f8536ee8f83082febba407dbce62b06ea6c18d2b
3
+ metadata.gz: 10fc3220c993eadd31eeeea97cb1df5e80494f06
4
+ data.tar.gz: 88b146d82cb06133baf6822b9c82b5a2f4abfaa2
5
5
  SHA512:
6
- metadata.gz: f18c4347e88fc3386cbacb5deca78c8d5b3626a94917295000d04d747a326ac62cd30d92a924a8e46cab1e36100119b09e5d8832e6cafa52f595be2d8b0304a3
7
- data.tar.gz: 40de4e4f4609fed9a47251257e8d4a012f1e223c05a7cd225b938d57288406979aede844f4928d5be72d18661d08e114bb4cb32aaf28d2a3612872ffcc29ebc1
6
+ metadata.gz: 6191da8490ee082bec3015795c3b890db54e70b0ee146a3de114a61681024750ddd9b38f00ca75678fd46d024a75a4e5353fd707d23cd3ccd2722b9bbee5fa79
7
+ data.tar.gz: 23b9fac62ee720198cf8330c06db2a5ae4c605ebf235f79e25df0a6051cb19c98ff0261ab3bfd884e853370bd26edd5c8a4e59249b54758f0a723e5c1d5313f2
data/README.md CHANGED
@@ -45,6 +45,9 @@ $ gem install nexaas-async-collector
45
45
  # The namespace where you want to store you data within Redis
46
46
  config.redis_namespace = 'nexaas_async'
47
47
 
48
+ # The name of the sidekiq queue to be used
49
+ config.queue_name = :high_fast
50
+
48
51
  # The method that returns the user object (or any other object you want. It must respond to id method)
49
52
  config.scope = :current_user
50
53
 
@@ -53,10 +56,20 @@ $ gem install nexaas-async-collector
53
56
  end
54
57
  ```
55
58
 
56
- 2) Use the view helper to do all the process:
59
+ 2) Add this to your *config/routes.rb* file:
60
+
61
+ ```ruby
62
+ Rails.application.routes.draw do
63
+ # ...
64
+ mount Nexaas::Async::Collector::Engine => '/nexaas_async_collect'
65
+ # ...
66
+ end
67
+ ```
68
+
69
+ 3) Use the view helper to do all the process:
57
70
 
58
71
  ```ruby
59
- <%= nexaas_async_collector(user.id, ModelService, :model_method, [arg1, arg2]) %>
72
+ <%= nexaas_async_collect(user.id, ModelService, :model_method, [arg1, arg2]) %>
60
73
  ```
61
74
 
62
75
  ## Contributing
@@ -1,3 +1,5 @@
1
+ require_dependency "nexaas/async/collector/application_controller"
2
+
1
3
  module Nexaas
2
4
  module Async
3
5
  module Collector
@@ -17,6 +17,12 @@ module Nexaas
17
17
  render(partial: 'nexaas/async/collector/async_resource/show')
18
18
  end
19
19
 
20
+ # Rails 4.x does not add this helper automatically as Rails 5.X and 3.X does. So we had to created it to keep
21
+ # the same interface.
22
+ def nexaas_async_collector
23
+ @@nexaas_async_collector ||= Nexaas::Async::Collector::Engine.routes.url_helpers
24
+ end
25
+
20
26
  private
21
27
 
22
28
  def collector_user_id
@@ -1,7 +1,7 @@
1
1
  <script type="text/javascript" id="js-nexaas-async-collector">
2
2
  var requestContent = function() {
3
3
  $.ajax({
4
- url: '<%= Rails.application.routes.url_helpers.nexaas_async_collect_path(@collector_user_id) %>',
4
+ url: '<%= nexaas_async_collector.async_resource_path(@collector_user_id) %>',
5
5
  dataType: 'script'
6
6
  })
7
7
  }
@@ -4,7 +4,7 @@ module Nexaas
4
4
  class AsyncResourceJob
5
5
 
6
6
  include Sidekiq::Worker
7
- sidekiq_options queue: :high_fast
7
+ sidekiq_options queue: Nexaas::Async::Collector.queue_name
8
8
 
9
9
  def perform(collector_id, user_id, klass_name, klass_method, args=[])
10
10
  content = call_for_method(klass_name, klass_method, args)
data/config/routes.rb CHANGED
@@ -1,3 +1,3 @@
1
- Rails.application.routes.draw do
2
- get 'nexaas/async/collect/:id' => 'nexaas/async/collector/async_resource#show', as: :nexaas_async_collect
1
+ Nexaas::Async::Collector::Engine.routes.draw do
2
+ resources :async_resource, only: :show
3
3
  end
@@ -17,6 +17,10 @@ module Nexaas
17
17
  mattr_accessor :redis_namespace
18
18
  @@redis_namespace = 'nexaas_async'
19
19
 
20
+ # Name of the sidekiq queue to be used
21
+ mattr_accessor :queue_name
22
+ @@queue_name = :high_fast
23
+
20
24
  # Method will be called to get the user/account id
21
25
  # This ID is used to store and ensure only the user
22
26
  # will fetch the processed data.
@@ -2,6 +2,12 @@ module Nexaas
2
2
  module Async
3
3
  module Collector
4
4
  class Engine < ::Rails::Engine
5
+ isolate_namespace Nexaas::Async::Collector
6
+
7
+ config.before_initialize do
8
+ Nexaas::Async::Collector.parent_controller.constantize.helper(Nexaas::Async::Collector::ApplicationHelper)
9
+ end
10
+
5
11
  config.generators do |g|
6
12
  g.test_framework :rspec
7
13
  end
@@ -1,7 +1,7 @@
1
1
  module Nexaas
2
2
  module Async
3
3
  module Collector
4
- VERSION = '1.0.2'
4
+ VERSION = '1.2.0'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexaas-async-collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Hertz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-22 00:00:00.000000000 Z
11
+ date: 2017-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -42,14 +42,14 @@ dependencies:
42
42
  name: redis-namespace
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.5.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.5.2
55
55
  - !ruby/object:Gem::Dependency