Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 44 additions & 22 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2018-02-27 16:14:20 +1300 using RuboCop version 0.52.1.
# on 2019-01-30 09:43:47 +1300 using RuboCop version 0.52.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
# Cop supports --auto-correct.
Layout/ElseAlignment:
Exclude:
- 'lib/supplejack_common/request.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Exclude:
- 'lib/supplejack_common/request.rb'

# Offense count: 3
Lint/AmbiguousOperator:
Exclude:
Expand All @@ -21,6 +34,14 @@ Lint/AssignmentInCondition:
- 'lib/supplejack_common/paginated_collection.rb'
- 'lib/supplejack_common/validations/size.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Lint/EndAlignment:
Exclude:
- 'lib/supplejack_common/request.rb'

# Offense count: 2
Lint/ShadowingOuterLocalVariable:
Exclude:
Expand All @@ -40,32 +61,37 @@ Lint/UselessAssignment:
- 'spec/supplejack_common/resources/file_resource_spec.rb'
- 'spec/supplejack_common/sitemap/paginated_collection_spec.rb'

# Offense count: 14
# Offense count: 21
Metrics/AbcSize:
Max: 33
Max: 40

# Offense count: 37
# Offense count: 46
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 226

# Offense count: 2
# Offense count: 3
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 135

# Offense count: 1
# Offense count: 2
Metrics/CyclomaticComplexity:
Max: 7

# Offense count: 16
# Offense count: 20
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 32
Max: 33

# Offense count: 2
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 6

# Offense count: 4
Metrics/PerceivedComplexity:
Max: 8
Max: 9

# Offense count: 3
Naming/AccessorMethodName:
Expand All @@ -85,34 +111,26 @@ Naming/VariableNumber:
Exclude:
- 'spec/supplejack_common/sitemap/paginated_collection_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect.
Performance/HashEachMethods:
Exclude:
- 'lib/supplejack_common/enrichments/enrichment.rb'

# Offense count: 1
Security/Eval:
Exclude:
- '.pryrc'

# Offense count: 2
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'lib/supplejack_common/parser/supplejack_common.rb'
- 'spec/supplejack_common/tmp/json/europeana.rb'

# Offense count: 2
Style/DateTime:
Exclude:
- 'lib/supplejack_common/modifiers/date_parser.rb'
- 'spec/supplejack_common/modifiers/date_parser_spec.rb'

# Offense count: 42
# Offense count: 44
Style/Documentation:
Enabled: false

Expand All @@ -128,15 +146,14 @@ Style/DoubleNegation:
Style/FormatStringToken:
EnforcedStyle: unannotated

# Offense count: 7
# Offense count: 6
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/supplejack_common/base.rb'
- 'lib/supplejack_common/loader.rb'
- 'lib/supplejack_common/modifiers/date_parser.rb'
- 'lib/supplejack_common/oai/paginated_collection.rb'
- 'lib/supplejack_common/paginated_collection.rb'
- 'lib/supplejack_common/validations/exclusion.rb'
- 'lib/supplejack_common/validations/inclusion.rb'

Expand Down Expand Up @@ -172,6 +189,11 @@ Style/ModuleFunction:
Exclude:
- 'lib/supplejack_common/utils.rb'

# Offense count: 2
Style/OptionalArguments:
Exclude:
- 'lib/supplejack_common/oai/client.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
Expand All @@ -181,7 +203,7 @@ Style/RegexpLiteral:
- 'lib/supplejack_common/json/base.rb'
- 'spec/supplejack_common/integrations/parsers/json_parser.rb'

# Offense count: 196
# Offense count: 293
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Expand Down
62 changes: 36 additions & 26 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ PATH
remote: .
specs:
supplejack_common (0.0.2)
actioncable
actionpack
activesupport
chronic (<= 0.10.2)
coderay
dimensions
htmlentities
json (~> 1.8.3)
Expand All @@ -22,44 +24,48 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actionpack (5.1.5)
actionview (= 5.1.5)
activesupport (= 5.1.5)
actioncable (5.2.2)
actionpack (= 5.2.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionpack (5.2.2)
actionview (= 5.2.2)
activesupport (= 5.2.2)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.5)
activesupport (= 5.1.5)
actionview (5.2.2)
activesupport (= 5.2.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activemodel (5.1.5)
activesupport (= 5.1.5)
activesupport (5.1.5)
activemodel (5.2.2)
activesupport (= 5.2.2)
activesupport (5.2.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ast (2.4.0)
bson (4.3.0)
bson (4.4.2)
builder (3.2.3)
byebug (10.0.2)
chronic (0.10.2)
coderay (1.1.2)
concurrent-ruby (1.0.5)
concurrent-ruby (1.1.4)
crack (0.4.3)
safe_yaml (~> 1.0.0)
crass (1.0.3)
diff-lcs (1.1.3)
dimensions (1.3.0)
docile (1.1.5)
domain_name (0.5.20170404)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
erubi (1.7.0)
erubi (1.8.0)
faraday (0.14.0)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.12.2)
Expand All @@ -68,7 +74,7 @@ GEM
htmlentities (4.3.4)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (0.9.5)
i18n (1.5.3)
concurrent-ruby (~> 1.0)
json (1.8.6)
jsonpath (0.5.8)
Expand All @@ -77,21 +83,22 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
method_source (0.9.0)
mime-types (3.1)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mimemagic (0.3.2)
mime-types-data (3.2018.0812)
mimemagic (0.3.3)
mini_portile2 (2.3.0)
minitest (5.11.3)
mock_redis (0.17.3)
mongo (2.5.1)
mongo (2.6.4)
bson (>= 4.3.0, < 5.0.0)
mongoid (6.3.0)
activemodel (~> 5.1)
mongo (>= 2.5.0, < 3.0.0)
mongoid (7.0.2)
activemodel (>= 5.1, < 6.0.0)
mongo (>= 2.5.1, < 3.0.0)
multi_json (1.13.1)
multipart-post (2.0.0)
netrc (0.11.0)
nio4r (2.3.1)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
nokogumbo (1.5.0)
Expand All @@ -111,8 +118,8 @@ GEM
byebug (~> 10.0)
pry (~> 0.10)
public_suffix (3.0.2)
rack (2.0.4)
rack-test (0.8.3)
rack (2.0.6)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
Expand All @@ -121,12 +128,12 @@ GEM
loofah (~> 2.0)
rainbow (3.0.0)
rake (10.5.0)
redis (4.0.1)
redis (4.1.0)
rest-client (2.0.2)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
retriable (3.1.1)
retriable (3.1.2)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
Expand All @@ -144,7 +151,7 @@ GEM
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
safe_yaml (1.0.4)
sanitize (4.6.0)
sanitize (4.6.6)
crass (~> 1.0.2)
nokogiri (>= 1.4.4)
nokogumbo (~> 1.4)
Expand All @@ -164,6 +171,9 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)

PLATFORMS
ruby
Expand Down
1 change: 1 addition & 0 deletions lib/supplejack_common/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def deletable?

def rejected?
return false if self.class.rejection_rules.nil?

self.class.rejection_rules.any? do |r|
instance_eval(&r)
end
Expand Down
4 changes: 1 addition & 3 deletions lib/supplejack_common/enrichments/enrichment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def attribute(name, options = {}, &block)
_attribute_definitions[name][:block] = block if block_given?
end

# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/CyclomaticComplexity
def resource
resource_class = "SupplejackCommon::#{_format.to_s.capitalize}Resource".constantize
Expand All @@ -80,7 +79,6 @@ def resource
options[:proxy] = _proxy if _proxy.present?
@resource ||= resource_class.new(_url, options)
end
# rubocop:enable Metrics/AbcSize
# rubocop:enable Metrics/CyclomaticComplexity

def set_attribute_values
Expand All @@ -97,7 +95,7 @@ def set_attribute_values
end

def enrichable?
_required_attributes.each do |_attribute, value|
_required_attributes.each_value do |value|
return false if value.nil?
end

Expand Down
14 changes: 7 additions & 7 deletions lib/supplejack_common/json/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def record_selector(path)
self._record_selector = path
end

def document(url)
def document(url, channel_options)
if url.include?('scroll')
self._document = SupplejackCommon::Request.scroll(url, _request_timeout, _throttle, _http_headers)
self._document = SupplejackCommon::Request.scroll(url, _request_timeout, _throttle, _http_headers, channel_options)
_document
elsif url =~ /^https?/
self._document = SupplejackCommon::Request.get(url, _request_timeout, _throttle, _http_headers, _proxy)
self._document = SupplejackCommon::Request.get(url, _request_timeout, _throttle, _http_headers, _proxy, channel_options)
_document
elsif url =~ /^file/
File.read(url.gsub(/file:\/\//, ''))
Expand All @@ -36,17 +36,17 @@ def total_results(total_selector)
JsonPath.on(_document, total_selector).try(:first).to_f
end

def records_json(url)
new_document = document(url)
def records_json(url, channel_options = {})
new_document = document(url, channel_options)
return [] if new_document.code == 204

records = JsonPath.on(new_document, _record_selector).try(:first)
records = [records] if records.is_a? Hash
records
end

def fetch_records(url)
records_json(url).map { |attributes| new(attributes) }
def fetch_records(url, channel_options = {})
records_json(url, channel_options).map { |attributes| new(attributes) }
end

def records(options = {})
Expand Down
Loading