aranha 0.12.1 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -7
- data/app/models/aranha/address.rb +14 -8
- data/db/migrate/20181125042102_add_extra_data_to_aranha_addresses.rb +1 -0
- data/lib/aranha/default_processor.rb +2 -3
- data/lib/aranha/fixtures.rb +1 -0
- data/lib/aranha/fixtures/download.rb +2 -0
- data/lib/aranha/processor.rb +3 -2
- data/lib/aranha/version.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fd4a817178b2fd09923d705b9209b6c419997eeaa4bcfd1f4df414e4d1bcc65
|
4
|
+
data.tar.gz: 987ef91043db5cf6b559cd00fad328583701018167a61f0934ad0af0e824b3a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
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
|
-
::
|
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
|
@@ -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
|
-
|
13
|
-
|
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
|
data/lib/aranha/fixtures.rb
CHANGED
@@ -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
|
|
data/lib/aranha/processor.rb
CHANGED
@@ -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
|
-
|
99
|
-
|
99
|
+
rescue ArgumentError, TypeError
|
100
|
+
DEFAULT_MAX_TRIES
|
100
101
|
end
|
101
102
|
end
|
102
103
|
end
|
data/lib/aranha/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -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.
|
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:
|
11
|
+
date: 2020-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_scaffold
|