wor-batchifier 0.0.2 → 1.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.
@@ -1,10 +1,10 @@
1
- module Wor
2
- module Batchifier
3
- class ArrayMerge < Strategy
4
- def merge_strategy(response,rec)
5
- rec = [] if rec.empty?
6
- return rec + response
7
- end
8
- end
9
- end
10
- end
1
+ module Wor
2
+ module Batchifier
3
+ class ArrayMerge < Strategy
4
+ def merge_strategy(response,memo)
5
+ memo = [] if memo.empty?
6
+ return memo + response
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,10 +1,11 @@
1
- module Wor
2
- module Batchifier
3
- module Exceptions
4
- class WrongStrategy < StandardError; end
5
- class ExistingStrategy < StandardError; end
6
- class InterfaceNotImplemented < StandardError; end
7
- class StrategyNotFound < StandardError; end
8
- end
9
- end
10
- end
1
+ module Wor
2
+ module Batchifier
3
+ module Exceptions
4
+ class WrongStrategy < StandardError; end
5
+ class ExistingStrategy < StandardError; end
6
+ class InterfaceNotImplemented < StandardError; end
7
+ class StrategyNotFound < StandardError; end
8
+ class InvalidStrategyType < StandardError; end
9
+ end
10
+ end
11
+ end
@@ -1,9 +1,9 @@
1
- module Wor
2
- module Batchifier
3
- class MaintainUnique < Strategy
4
- def merge_strategy(response,rec)
5
- return response.merge(rec) { |_, v1, _| v1 }
6
- end
7
- end
8
- end
9
- end
1
+ module Wor
2
+ module Batchifier
3
+ class MaintainUnique < Strategy
4
+ def merge_strategy(response,memo)
5
+ return response.merge(memo) { |_, v1, _| v1 }
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ module Wor
2
+ module Batchifier
3
+ module MergeParams
4
+ refine Object do
5
+ def merge_method
6
+ raise Wor::Batchifier::Exceptions::InvalidStrategyType
7
+ end
8
+
9
+ def merge_base_case
10
+ raise Wor::Batchifier::Exceptions::InvalidStrategyType
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Wor
2
+ module Batchifier
3
+ module MergeParams
4
+ refine Proc do
5
+ def merge_method
6
+ self
7
+ end
8
+
9
+ def merge_base_case
10
+ {}
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ module Wor
2
+ module Batchifier
3
+ module MergeParams
4
+ refine Symbol do
5
+ def merge_method
6
+ classify_strategy.new.method(:merge_strategy)
7
+ end
8
+
9
+ def merge_base_case
10
+ classify_strategy.new.base_case
11
+ end
12
+
13
+ private
14
+
15
+ def classify_strategy
16
+ strategy_class_name = to_s.split('_').collect(&:capitalize).join
17
+ Kernel.const_get("Wor::Batchifier::#{strategy_class_name}")
18
+ rescue NameError => e
19
+ raise Wor::Batchifier::Exceptions::StrategyNotFound
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,9 +1,9 @@
1
- module Wor
2
- module Batchifier
3
- class NoResponse < Strategy
4
- def merge_strategy(_response, _rec)
5
- return {}
6
- end
7
- end
8
- end
9
- end
1
+ module Wor
2
+ module Batchifier
3
+ class NoResponse < Strategy
4
+ def merge_strategy(_response, _memo)
5
+ return {}
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,20 +1,20 @@
1
- module Wor
2
- module Batchifier
3
- class Strategy
4
-
5
- def merge_strategy
6
- raise Wor::Batchifier::Exceptions::InterfaceNotImplemented.new "Class #{self.class.name} does not implement contract merge_strategy!"
7
- end
8
-
9
- def base_case
10
- {}
11
- end
12
-
13
- # When defining your own strategy for merging, you should define a new class that extends from
14
- # this class, "Strategy", and implement the method "merge_strategy" which will take care
15
- # of parsing the response of the batchified endpoint.
16
- # Should you not implement the method "merge_strategy" the exception "InterfaceNotImplemented"
17
- # will be raised to notify the developer of such issue.
18
- end
19
- end
20
- end
1
+ module Wor
2
+ module Batchifier
3
+ class Strategy
4
+
5
+ def merge_strategy
6
+ raise Wor::Batchifier::Exceptions::InterfaceNotImplemented.new "Class #{self.class.name} does not implement contract merge_strategy!"
7
+ end
8
+
9
+ def base_case
10
+ {}
11
+ end
12
+
13
+ # When defining your own strategy for merging, you should define a new class that extends from
14
+ # this class, "Strategy", and implement the method "merge_strategy" which will take care
15
+ # of parsing the response of the batchified endpoint.
16
+ # Should you not implement the method "merge_strategy" the exception "InterfaceNotImplemented"
17
+ # will be raised to notify the developer of such issue.
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
- module Wor
2
- module Batchifier
3
- VERSION = '0.0.2'.freeze
4
- end
5
- end
1
+ module Wor
2
+ module Batchifier
3
+ VERSION = '1.0.0'.freeze
4
+ end
5
+ end
@@ -1,33 +1,33 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'wor/batchifier/version'
5
- require 'date'
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = 'wor-batchifier'
9
- spec.version = Wor::Batchifier::VERSION
10
- spec.platform = Gem::Platform::RUBY
11
- spec.date = Date.today
12
- spec.authors = ['enanodr', 'redwarewolf']
13
- spec.email = ['diego.raffo@wolox.com.ar', 'pedro.jara@wolox.com.ar']
14
-
15
- spec.summary = 'Easily batchify your requests!.'
16
- spec.description = 'Gem to batchify your requests.'
17
- spec.homepage = 'https://github.com/Wolox/wor-batchifier'
18
- spec.license = 'MIT'
19
-
20
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec)/}) }
21
- spec.test_files = spec.files.grep(%r{^(test|spec)/})
22
- spec.require_paths = ['lib']
23
-
24
- spec.add_dependency 'httparty', '~> 0.13'
25
-
26
- spec.add_development_dependency 'byebug', '~> 9.0'
27
- spec.add_development_dependency 'rubocop', '~> 0.47'
28
- spec.add_development_dependency 'bundler'
29
- spec.add_development_dependency 'rake', '~> 10.0'
30
- spec.add_development_dependency 'rspec', '~> 3.0'
31
- spec.add_development_dependency 'simplecov'
32
- spec.add_development_dependency 'webmock'
33
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'wor/batchifier/version'
5
+ require 'date'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'wor-batchifier'
9
+ spec.version = Wor::Batchifier::VERSION
10
+ spec.platform = Gem::Platform::RUBY
11
+ spec.date = Date.today
12
+ spec.authors = ['enanodr', 'redwarewolf']
13
+ spec.email = ['diego.raffo@wolox.com.ar', 'pedro.jara@wolox.com.ar']
14
+
15
+ spec.summary = 'Easily batchify your requests!.'
16
+ spec.description = 'Gem to batchify your requests.'
17
+ spec.homepage = 'https://github.com/Wolox/wor-batchifier'
18
+ spec.license = 'MIT'
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec)/}) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec)/})
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'httparty', '~> 0.13'
25
+
26
+ spec.add_development_dependency 'byebug', '~> 9.0'
27
+ spec.add_development_dependency 'rubocop', '~> 0.47'
28
+ spec.add_development_dependency 'bundler'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'rspec', '~> 3.0'
31
+ spec.add_development_dependency 'simplecov'
32
+ spec.add_development_dependency 'webmock'
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wor-batchifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - enanodr
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-04-30 00:00:00.000000000 Z
12
+ date: 2019-09-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -142,6 +142,9 @@ files:
142
142
  - lib/wor/batchifier/array_merge.rb
143
143
  - lib/wor/batchifier/exceptions.rb
144
144
  - lib/wor/batchifier/maintain_unique.rb
145
+ - lib/wor/batchifier/merge_params/object.rb
146
+ - lib/wor/batchifier/merge_params/proc.rb
147
+ - lib/wor/batchifier/merge_params/symbol.rb
145
148
  - lib/wor/batchifier/no_response.rb
146
149
  - lib/wor/batchifier/strategy.rb
147
150
  - lib/wor/batchifier/version.rb
@@ -166,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
169
  version: '0'
167
170
  requirements: []
168
171
  rubyforge_project:
169
- rubygems_version: 2.7.6.2
172
+ rubygems_version: 2.5.2.1
170
173
  signing_key:
171
174
  specification_version: 4
172
175
  summary: Easily batchify your requests!.