batch_request_api 1.0.13 → 1.0.15

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: 18cd9a1f66383662dde2e3af3a36484f89acf0c4
4
- data.tar.gz: 57705c7afc4a46e7b1082831acfe621bcf9efe82
3
+ metadata.gz: 95f9990c2d768e9e8d142ab3f354ffb62a489a55
4
+ data.tar.gz: c24eeedcbf58673347a7afffb71bd26c63d5c5d0
5
5
  SHA512:
6
- metadata.gz: f15ed05c2cc23c357c3a59147d702bc9251491c494f7e4bb8ae049c38a8dd0a972c7bd5960e19693d05dd9598a1b8fb8ac2e99da1c6c29a2f28ff2b381022efd
7
- data.tar.gz: 1fcb62c942298ddffa36208f544c47b6275a57593c119e9a66f6b18877259a414127529ee74bcf9fd9af916df90b4bd46197a47449e5ccee3b947c6a8a109309
6
+ metadata.gz: 9da5cf0eb497b10155c06bcde3e6c3845a328363d154a330453cf412a8338df06f2595f3b7c6dc78867b707f0db9073614a79733481f3063e002a9048dc2cdda
7
+ data.tar.gz: 4eb5725cb6cf3d29185e96ddf1cbdaeab12b6ac02e521778aa7ee57098800804ee1e91c66d28a5c53425581f78bf8c7f519d30018837024a8f1ce3dfd7153020
data/config/routes.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  Rails.application.routes.draw do
2
- scope :api do
3
- namespace :v1, defaults: {format: 'json'} do
4
- resources :batch_sequential
5
- resources :batch_parallel
6
- end
2
+ BatchRequestApi.config.batch_sequential_paths.each do |batch_sequential_path|
3
+ post batch_sequential_path, constraints: { format: :json }
4
+ end
5
+
6
+ BatchRequestApi.config.batch_parallel_paths.each do |batch_parallel_path|
7
+ post batch_parallel_path, constraints: { format: :json }
7
8
  end
8
9
  end
@@ -0,0 +1,21 @@
1
+ module BatchRequestApi
2
+ class << self
3
+ def config
4
+ @config ||= Configuration.new
5
+ end
6
+
7
+ def configure
8
+ yield(config)
9
+ end
10
+ end
11
+
12
+ class Configuration
13
+ attr_accessor :batch_sequential_paths
14
+ attr_accessor :batch_parallel_paths
15
+
16
+ def initialize
17
+ self.batch_sequential_paths = ['/api/v1/batch_sequential']
18
+ self.batch_parallel_paths = ['/api/v1/batch_parallel']
19
+ end
20
+ end
21
+ end
@@ -1,24 +1,34 @@
1
1
  require 'batch_request_api/batch_parallel'
2
2
  require 'batch_request_api/batch_sequential'
3
+ require 'json'
3
4
 
4
5
  module BatchRequestApi
5
6
  class Middleware
6
7
  include BatchParallel
7
8
  include BatchSequential
8
- require 'json'
9
+
10
+ PATH_INFO_HEADER_KEY = 'PATH_INFO'.freeze
9
11
 
10
12
  def initialize(app)
11
13
  @app = app
12
14
  end
13
15
 
14
16
  def call(env)
15
- if env['PATH_INFO'] == '/api/v1/batch_sequential'
17
+ if is_batch_sequential_path?(env[PATH_INFO_HEADER_KEY])
16
18
  batch_sequential(env)
17
- elsif env['PATH_INFO'] == '/api/v1/batch_parallel'
19
+ elsif is_batch_parallel_path?(env[PATH_INFO_HEADER_KEY])
18
20
  batch_parallel(env)
19
21
  else
20
22
  @app.call(env) # regular RAILS CRUD
21
23
  end
22
24
  end
25
+
26
+ def is_batch_sequential_path?(path)
27
+ BatchRequestApi.config.batch_sequential_paths.include?(path)
28
+ end
29
+
30
+ def is_batch_parallel_path?(path)
31
+ BatchRequestApi.config.batch_parallel_paths.include?(path)
32
+ end
23
33
  end
24
34
  end
@@ -1,3 +1,3 @@
1
1
  module BatchRequestApi
2
- VERSION = "1.0.13"
2
+ VERSION = "1.0.15"
3
3
  end
@@ -2,6 +2,7 @@ require 'batch_request_api/version'
2
2
  require 'batch_request_api/railtie' if defined?(Rails)
3
3
  require 'batch_request_api/middleware'
4
4
  require 'batch_request_api/engine'
5
+ require 'batch_request_api/configuration'
5
6
 
6
7
  module BatchRequestApi
7
8
  # Keep moving forward.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: batch_request_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.13
4
+ version: 1.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Srinivas Raghunathan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-10 00:00:00.000000000 Z
12
+ date: 2017-08-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -66,6 +66,7 @@ files:
66
66
  - lib/batch_request_api/batch_parallel.rb
67
67
  - lib/batch_request_api/batch_sequential.rb
68
68
  - lib/batch_request_api/batch_util.rb
69
+ - lib/batch_request_api/configuration.rb
69
70
  - lib/batch_request_api/engine.rb
70
71
  - lib/batch_request_api/middleware.rb
71
72
  - lib/batch_request_api/railtie.rb
@@ -90,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
91
  version: '0'
91
92
  requirements: []
92
93
  rubyforge_project:
93
- rubygems_version: 2.6.11
94
+ rubygems_version: 2.4.6
94
95
  signing_key:
95
96
  specification_version: 4
96
97
  summary: Rails Batch Request API.