wor-batchifier 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
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
+ end
9
+ end
10
+ 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,rec)
5
+ return response.merge(rec) { |_, v1, _| v1 }
6
+ end
7
+ end
8
+ end
9
+ 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, _rec)
5
+ return {}
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,28 +1,20 @@
1
- module Wor
2
- module Batchifier
3
- class Strategy
4
- extend Wor::Batchifier::Interface
5
-
6
- implements :merge_strategy
7
-
8
- class << self
9
- alias_method :__new__, :new
10
-
11
- def new(*args)
12
- raise Wor::Batchifier::Exceptions::InterfaceNotImplemented.new "class #{name} does not implement contract #{contract}!" if breaches_contract?
13
- __new__(*args)
14
- end
15
- end
16
-
17
- def base_case
18
- {}
19
- end
20
-
21
- # When defining your own strategy for merging, you should define a new class that extends from
22
- # this class, "Strategy", and implement the method "merge_strategy" which will take care
23
- # of parsing the response of the batchified endpoint.
24
- # Should you not implement the method "merge_strategy" the exception "InterfaceNotImplemented"
25
- # will be raised to notify the developer of such issue.
26
- end
27
- end
28
- 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.1'.freeze
4
- end
5
- end
1
+ module Wor
2
+ module Batchifier
3
+ VERSION = '0.0.2'.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.1
4
+ version: 0.0.2
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-17 00:00:00.000000000 Z
12
+ date: 2019-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -141,7 +141,6 @@ files:
141
141
  - lib/wor/batchifier/add.rb
142
142
  - lib/wor/batchifier/array_merge.rb
143
143
  - lib/wor/batchifier/exceptions.rb
144
- - lib/wor/batchifier/interface.rb
145
144
  - lib/wor/batchifier/maintain_unique.rb
146
145
  - lib/wor/batchifier/no_response.rb
147
146
  - lib/wor/batchifier/strategy.rb
@@ -167,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
166
  version: '0'
168
167
  requirements: []
169
168
  rubyforge_project:
170
- rubygems_version: 2.5.2.1
169
+ rubygems_version: 2.7.6.2
171
170
  signing_key:
172
171
  specification_version: 4
173
172
  summary: Easily batchify your requests!.
@@ -1,23 +0,0 @@
1
- module Wor
2
- module Batchifier
3
- module Interface
4
- attr_writer :contract
5
-
6
- def implements(*selectors)
7
- self.contract += selectors
8
- end
9
-
10
- def contract
11
- @contract ||= []
12
- end
13
-
14
- def full_contract
15
- (contract + ancestors.flat_map(&:contract)).uniq
16
- end
17
-
18
- def breaches_contract?
19
- full_contract.any? { |it| !method_defined? it }
20
- end
21
- end
22
- end
23
- end