grape-batch 1.2.1 → 2.0.0
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/CHANGELOG.md +4 -0
- data/README.md +2 -4
- data/lib/grape/batch.rb +1 -2
- data/lib/grape/batch/configuration.rb +1 -2
- data/lib/grape/batch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72ecca1274e9f2e1f1d2a896d85a75dc538b5b89
|
4
|
+
data.tar.gz: 6892ba66a0aa07eb03434d9f385208135bde27c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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
|
-
|
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
|
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
|
data/lib/grape/batch/version.rb
CHANGED
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:
|
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-
|
13
|
+
date: 2015-08-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|