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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 276592968b7aa54fad42ac7b5d55f12ef4297f47ca17edd442d86e5583302569
4
- data.tar.gz: 4dfce89c1c0ea962fc03d49fac0ef655b17bbf0bdafd8e31cd1fbcd3ce1bc44b
3
+ metadata.gz: b5ce68bb8da1755e2c5b3667c314ea10e556c1a8050152348d386900dfd5383e
4
+ data.tar.gz: 8bedbf6e02d127b69e49c02d11cec3d9173f0b8cc4eff02bf1128ad4ad2900f2
5
5
  SHA512:
6
- metadata.gz: 7899f2898f8540357265f99278a8acdf311c252dc1e4b0521ee8f6103bad982dc4daea4186d685bd5a0b3d9387451b2ec74d6893df80fbc2b152406667258449
7
- data.tar.gz: adb0ab27e55c6b2b44ccd1ccfd256a428c1a2a3f3008ea94f9eb84442c397952bbb91fdd1d08baba3700194638bc3889568b790addc7b50d18aeb13931aba090
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
- attr_reader :pending
11
+ DEFAULT_EXTENSION = '.html'
11
12
 
12
- def initialize(options)
13
- @prefix = options.fetch(:prefix)
14
- @prefix = '' if @prefix.blank?
15
- @download = options.fetch(:download)
16
- @pending = options.fetch(:pending)
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 @download
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?(@prefix)
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.html', File.dirname(file))
76
+ File.expand_path(File.basename(file, '.url') + '.source' + extension, File.dirname(file))
60
77
  end
61
78
 
62
79
  def relative_path(path)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aranha
4
4
  module Rails
5
- VERSION = '0.2.1'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -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
- prefix: ENV['PREFIX'],
19
- download: ENV['DOWNLOAD'].present?,
20
- pending: ENV['PENDING'].present?
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.2.1
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-06-28 00:00:00.000000000 Z
11
+ date: 2021-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_scaffold