aranha-rails 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aranha/rails/fixtures_download.rb +27 -10
- data/lib/aranha/rails/version.rb +1 -1
- data/lib/tasks/aranha.rake +4 -3
- 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: b5ce68bb8da1755e2c5b3667c314ea10e556c1a8050152348d386900dfd5383e
|
4
|
+
data.tar.gz: 8bedbf6e02d127b69e49c02d11cec3d9173f0b8cc4eff02bf1128ad4ad2900f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cc382aefdf04bcd68f22557fda034377564e349e31f97d168ad541de8c79312edffa87fc1f7bd1198a2362bc4eb7874f32d3a946eb2d11c4b40f274580b1a68
|
7
|
+
data.tar.gz: 4f7adf4bf7353a07c54a05ebba718b26c6469b3d657dcbf355aec33baccac3110e3c7f1ac7db112b22d5941e3311f9ccfadace9c42b4d6b6a1805cbf37dc5e86
|
@@ -3,23 +3,40 @@
|
|
3
3
|
require 'aranha/parsers/base'
|
4
4
|
require 'aranha/parsers/source_address'
|
5
5
|
require 'aranha/parsers/source_target_fixtures'
|
6
|
+
require 'eac_ruby_utils/core_ext'
|
6
7
|
|
7
8
|
module Aranha
|
8
9
|
module Rails
|
9
10
|
class FixturesDownload
|
10
|
-
|
11
|
+
DEFAULT_EXTENSION = '.html'
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
enable_listable
|
14
|
+
lists.add_symbol :option, :extension, :prefix, :download, :pending
|
15
|
+
|
16
|
+
common_constructor :options do
|
17
|
+
self.options = self.class.lists.option.hash_keys_validate!(options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def download?
|
21
|
+
options[OPTION_DOWNLOAD] ? true : false
|
22
|
+
end
|
23
|
+
|
24
|
+
def extension
|
25
|
+
options[OPTION_EXTENSION].if_present(DEFAULT_EXTENSION)
|
26
|
+
end
|
27
|
+
|
28
|
+
def pending?
|
29
|
+
options[OPTION_PENDING] ? true : false
|
30
|
+
end
|
31
|
+
|
32
|
+
def prefix
|
33
|
+
options[OPTION_PREFIX].if_present('')
|
17
34
|
end
|
18
35
|
|
19
36
|
def run
|
20
37
|
url_files.each do |f|
|
21
38
|
::Rails.logger.info(relative_path(f))
|
22
|
-
download(url(f), target(f)) if
|
39
|
+
download(url(f), target(f)) if download?
|
23
40
|
end
|
24
41
|
end
|
25
42
|
|
@@ -32,11 +49,11 @@ module Aranha
|
|
32
49
|
def select_path?(path)
|
33
50
|
return false unless match_prefix_pattern(path)
|
34
51
|
|
35
|
-
!pending || !source_exist?(path)
|
52
|
+
!pending? || !source_exist?(path)
|
36
53
|
end
|
37
54
|
|
38
55
|
def match_prefix_pattern(path)
|
39
|
-
relative_path(path).start_with?(
|
56
|
+
relative_path(path).start_with?(prefix)
|
40
57
|
end
|
41
58
|
|
42
59
|
def fixtures_root
|
@@ -56,7 +73,7 @@ module Aranha
|
|
56
73
|
end
|
57
74
|
|
58
75
|
def target(file)
|
59
|
-
File.expand_path(File.basename(file, '.url') + '.source
|
76
|
+
File.expand_path(File.basename(file, '.url') + '.source' + extension, File.dirname(file))
|
60
77
|
end
|
61
78
|
|
62
79
|
def relative_path(path)
|
data/lib/aranha/rails/version.rb
CHANGED
data/lib/tasks/aranha.rake
CHANGED
@@ -15,9 +15,10 @@ namespace(:aranha) do
|
|
15
15
|
desc 'Download remote content for fixtures.'
|
16
16
|
task download: :environment do
|
17
17
|
::Aranha::Rails::FixturesDownload.new(
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
::Aranha::Rails::FixturesDownload::OPTION_EXTENSION => ENV['EXTENSION'],
|
19
|
+
::Aranha::Rails::FixturesDownload::OPTION_PREFIX => ENV['PREFIX'],
|
20
|
+
::Aranha::Rails::FixturesDownload::OPTION_DOWNLOAD => ENV['DOWNLOAD'].present?,
|
21
|
+
::Aranha::Rails::FixturesDownload::OPTION_PENDING => ENV['PENDING'].present?
|
21
22
|
).run
|
22
23
|
end
|
23
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aranha-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Put here the authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_scaffold
|