aranha 0.12.1 → 0.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 757ddf38d7f136f555d33165d6848447f7b0e299d39797bc5e857a2a5bd90710
4
- data.tar.gz: 64fd157452e0cbf1683b4a83f01adf766d341f576184add18409c2e3a0e99ce3
3
+ metadata.gz: 5fd4a817178b2fd09923d705b9209b6c419997eeaa4bcfd1f4df414e4d1bcc65
4
+ data.tar.gz: 987ef91043db5cf6b559cd00fad328583701018167a61f0934ad0af0e824b3a8
5
5
  SHA512:
6
- metadata.gz: a467c10ef68ab3d834c43f53e40de95b7a721e52e614691955d1f7d221145236c064df40a5a6695c3c07235a90b27618c763f06d655a5095b68d599feb753b33
7
- data.tar.gz: e75d62110669c105d9a2e3c11b0be6d77e96e9483a6dea4e0e1a5abf9e6263e9879dc9213d834afdb394fa62a2cf32769315716a89995f605060f60db6076fe7
6
+ metadata.gz: b30e3c388b661f374a6035c933243b314a4c6fdc2835e1445a8e38b6ed89cf3cf8e12ad09e40a2e32a4a1ce5c738786a42dd64d66f55dea963730533307d8cd5
7
+ data.tar.gz: 929a0a0232822a2361f9e88b510437b9f31d6f3352c951122b5fcc89e1a2fb28eb0bd331a5975c907307ae48265c39be977bb288f1b999a9fcff8b8b55b33343
data/Rakefile CHANGED
@@ -25,12 +25,8 @@ Bundler::GemHelper.install_tasks
25
25
 
26
26
  require 'rake/testtask'
27
27
 
28
- begin
29
- require 'rspec/core/rake_task'
30
- RSpec::Core::RakeTask.new(:spec)
31
- task test: :spec
32
- rescue LoadError
33
- # no rspec available
34
- end
28
+ require 'rspec/core/rake_task'
29
+ RSpec::Core::RakeTask.new(:spec)
30
+ task test: :spec
35
31
 
36
32
  task default: :test
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/yaml'
4
+
3
5
  module Aranha
4
6
  class Address < ActiveRecord::Base
5
7
  include ::Eac::InequalityQueries
@@ -68,23 +70,27 @@ module Aranha
68
70
  private
69
71
 
70
72
  def instanciate_processor
71
- if processor_instancier_arity == 2 || processor_instancier_arity < 0
72
- processor_instancier.call(url_to_process, YAML.load(extra_data))
73
- elsif processor_instancier_arity == 1
74
- processor_instancier.call(url_to_process)
75
- else
76
- raise("#{processor}.initialize should has 1 or 2 or * arguments")
77
- end
73
+ processor_instancier.call(*processor_instancier_arguments)
78
74
  end
79
75
 
80
76
  def url_to_process
81
- ::YAML.load(url)
77
+ ::EacRubyUtils::Yaml.load_common(url)
82
78
  end
83
79
 
84
80
  def processor_instancier
85
81
  processor.constantize.method(:new)
86
82
  end
87
83
 
84
+ def processor_instancier_arguments
85
+ if processor_instancier_arity == 2 || processor_instancier_arity.negative?
86
+ [url_to_process, EacRubyUtils::Yaml.load_common(extra_data)]
87
+ elsif processor_instancier_arity == 1
88
+ [processor_instancier.call(url_to_process)]
89
+ else
90
+ raise("#{processor}.initialize should has 1 or 2 or * arguments")
91
+ end
92
+ end
93
+
88
94
  def processor_instancier_arity
89
95
  processor.constantize.instance_method(:initialize).arity
90
96
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class AddExtraDataToAranhaAddresses < ActiveRecord::Migration
3
4
  def change
4
5
  add_column :aranha_addresses, :extra_data, :text
@@ -9,9 +9,8 @@ module Aranha
9
9
  class << self
10
10
  def sanitize_uri(uri)
11
11
  return uri if uri.is_a?(Hash)
12
- unless uri.is_a?(Addressable::URI)
13
- uri = uri.to_s.gsub(%r{\A/}, 'file:///')
14
- end
12
+
13
+ uri = uri.to_s.gsub(%r{\A/}, 'file:///') unless uri.is_a?(Addressable::URI)
15
14
  Addressable::URI.parse(uri)
16
15
  end
17
16
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Aranha
3
4
  module Fixtures
4
5
  require 'aranha/fixtures/download'
@@ -31,6 +31,7 @@ module Aranha
31
31
 
32
32
  def select_path?(path)
33
33
  return false unless match_prefix_pattern(path)
34
+
34
35
  !pending || !source_exist?(path)
35
36
  end
36
37
 
@@ -46,6 +47,7 @@ module Aranha
46
47
  Rails.logger.info "Baixando \"#{url}\"..."
47
48
  content = ::Aranha::Parsers::Base.new(url).content
48
49
  raise "Content is blank for \"#{url}\"" if content.blank?
50
+
49
51
  File.open(target, 'wb') { |file| file.write(content) }
50
52
  end
51
53
 
@@ -80,6 +80,7 @@ module Aranha
80
80
 
81
81
  def network_exception?(exception)
82
82
  return true if NETWORK_EXCEPTIONS.any? { |klass| exception.is_a?(klass) }
83
+
83
84
  exception.cause.present? ? network_exception?(exception.cause) : false
84
85
  end
85
86
 
@@ -95,8 +96,8 @@ module Aranha
95
96
  @max_tries ||= begin
96
97
  r = Integer(ENV['ARANHA_MAX_TRIES'])
97
98
  r <= 0 ? 0 : r
98
- rescue ArgumentError, TypeError
99
- DEFAULT_MAX_TRIES
99
+ rescue ArgumentError, TypeError
100
+ DEFAULT_MAX_TRIES
100
101
  end
101
102
  end
102
103
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Aranha
4
- VERSION = '0.12.1'
4
+ VERSION = '0.13.0'
5
5
  end
@@ -14,7 +14,7 @@ require 'rails/test_help'
14
14
  Minitest.backtrace_filter = Minitest::BacktraceFilter.new
15
15
 
16
16
  # Load support files
17
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
17
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
18
18
 
19
19
  # Load fixtures from the engine
20
20
  if ActiveSupport::TestCase.respond_to?(:fixture_path=)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aranha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-31 00:00:00.000000000 Z
11
+ date: 2020-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_scaffold