grape-batch 1.2.1 → 2.0.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: bac086f102c0e6f7a25ccb1cff49caae216cefbb
4
- data.tar.gz: 0dca92ed6c95d4dd984a536a41774a3517b579b5
3
+ metadata.gz: 72ecca1274e9f2e1f1d2a896d85a75dc538b5b89
4
+ data.tar.gz: 6892ba66a0aa07eb03434d9f385208135bde27c2
5
5
  SHA512:
6
- metadata.gz: 5830ac465a1725e1135c370a6daf8f83c0c81aafd5ad2f06a9e0d3468395a06a4e2ea66284639fe0284bf17efcf26b91d1572194d68cc82f4706b1e4b997601e
7
- data.tar.gz: cfcf71b8da3c1f9dc67f863f61a2c3562e932905766439c73bec4eac5d9baa52452fda0d980cad2ad24c7c2189da7ad7b4a8519cd709d0f25d7ef8f0e2cbbc0d
6
+ metadata.gz: 7a8e2550213099227213f61f904636d13145eb295b4f2069fd16042f7ad4e10612587a204cab4c603f6ca7231e18ba37ae4a724bfd4b82a9de96d985f51f4400
7
+ data.tar.gz: 168dc3ca5de9a49c36d2f7b87659f3ad15127ee65d47bc4f2b8cc5c95c138219f6ffb4fa198d8cc6143c979936d8e1a6849c92ddc8addc807cd79361465be0fc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.0.0 (26rd August 2015)
2
+ * Removed session_header from configuration options
3
+ # Now passes the whole env to the session Proc
4
+
1
5
  # 1.2.1 (24rd July 2015)
2
6
  * Using env['HTTP_X_REQUEST_ID'] or env['rack-timeout.info'][:id] or generate unique hex to identify request batch
3
7
 
data/README.md CHANGED
@@ -48,7 +48,6 @@ Grape::Batch.configure do |config|
48
48
  config.path = '/batch'
49
49
  config.formatter = Grape::Batch::Response
50
50
  config.logger = nil
51
- config.session_header = 'HTTP_X_SESSION_TOKEN'
52
51
  config.session_proc = Proc.new {}
53
52
  end
54
53
  ```
@@ -101,13 +100,12 @@ POST http request on the default URL with a similar body:
101
100
  'body' is optional.
102
101
 
103
102
  ### Sessions
104
- It's possible ensure a single session during the execution of the batch. You have to specify your session/token/auth header and your session Proc. Before running the batch, the Proc is executed with the data extracted from the specified session header and stored in rack env 'api.session' key.
103
+ It's possible ensure a single session during the execution of the batch. You have to specify your session Proc. Before running the batch, the Proc is executed (with env as argument) and stored in rack env 'api.session' key.
105
104
  ```ruby
106
105
  # Example
107
106
  # Considering the config
108
107
  Grape::Batch.configure do |config|
109
- config.session_header = 'HTTP_X_SESSION_TOKEN'
110
- config.session_proc = Proc.new {|token| User.where(token: token).first }
108
+ config.session_proc = Proc.new {|env| User.where(token: env['HTTP_X_TOKEN']).first }
111
109
  end
112
110
 
113
111
  # You can build a Grape helper like this
data/lib/grape/batch.rb CHANGED
@@ -47,8 +47,7 @@ module Grape
47
47
  end
48
48
 
49
49
  def dispatch(env, batch_requests)
50
- session_data = env[Grape::Batch.configuration.session_header]
51
- env['api.session'] = Grape::Batch.configuration.session_proc.call(session_data)
50
+ env['api.session'] = Grape::Batch.configuration.session_proc.call(env)
52
51
 
53
52
  # iterate
54
53
  batch_env = env.dup
@@ -1,14 +1,13 @@
1
1
  module Grape
2
2
  module Batch
3
3
  class Configuration
4
- attr_accessor :path, :limit, :formatter, :logger, :session_proc, :session_header
4
+ attr_accessor :path, :limit, :formatter, :logger, :session_proc
5
5
 
6
6
  def initialize
7
7
  @path = '/batch'
8
8
  @limit = 10
9
9
  @formatter = Grape::Batch::Response
10
10
  @logger = nil
11
- @session_header = 'HTTP_X_SESSION_TOKEN'
12
11
  @session_proc = Proc.new {}
13
12
  end
14
13
  end
@@ -1,5 +1,5 @@
1
1
  module Grape
2
2
  module Batch
3
- VERSION = '1.2.1'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-batch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lionel Oto
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-07-24 00:00:00.000000000 Z
13
+ date: 2015-08-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack