ehbrs-tools 0.27.0 → 0.28.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +91 -38
- data/lib/ehbrs/tools/runner/fs/selected.rb +2 -6
- data/lib/ehbrs/tools/runner/music/lyrics.rb +3 -4
- data/lib/ehbrs/tools/runner/music/lyrics_book.rb +41 -0
- data/lib/ehbrs/tools/runner/music/selected.rb +6 -6
- data/lib/ehbrs/tools/runner/vg/wii.rb +2 -2
- data/lib/ehbrs/tools/runner/videos/series/rename.rb +1 -1
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/user_dirs.rb +2 -2
- data/lib/ehbrs/videos/unsupported/search.rb +2 -2
- data/spec/lib/ehbrs/tools/runner/fs/used_space_spec.rb +2 -1
- data/vendor/aranha-parsers/aranha-parsers.gemspec +1 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/base.rb +3 -1
- data/vendor/aranha-parsers/lib/aranha/parsers/html/node/default/numeric_support.rb +70 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/node/default/string_support.rb +77 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/html/node/default.rb +2 -94
- data/vendor/aranha-parsers/lib/aranha/parsers/json/base.rb +20 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/json.rb +11 -0
- data/vendor/aranha-parsers/lib/aranha/parsers/source_address/http_get.rb +12 -15
- data/vendor/aranha-parsers/lib/aranha/parsers/version.rb +1 -1
- data/vendor/eac_cli/lib/eac_cli/config.rb +6 -3
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_fs/Gemfile +5 -0
- data/vendor/eac_fs/eac_fs.gemspec +20 -0
- data/vendor/{eac_ruby_utils/lib/eac_ruby_utils/filesystem_cache.rb → eac_fs/lib/eac_fs/cache.rb} +7 -2
- data/vendor/eac_fs/lib/eac_fs/cached_download.rb +39 -0
- data/vendor/eac_fs/lib/eac_fs/file_info.rb +29 -0
- data/vendor/eac_fs/lib/eac_fs/patches/module/fs_cache.rb +10 -0
- data/vendor/eac_fs/lib/eac_fs/patches/module.rb +4 -0
- data/vendor/eac_fs/lib/eac_fs/patches/object/fs_cache.rb +17 -0
- data/vendor/eac_fs/lib/eac_fs/patches/object.rb +4 -0
- data/vendor/eac_fs/lib/eac_fs/patches/pathname/info.rb +12 -0
- data/vendor/eac_fs/lib/eac_fs/patches/pathname.rb +4 -0
- data/vendor/eac_fs/lib/eac_fs/patches.rb +4 -0
- data/vendor/eac_fs/lib/eac_fs/traversable.rb +45 -0
- data/vendor/eac_fs/lib/eac_fs/traverser.rb +76 -0
- data/vendor/eac_fs/lib/eac_fs/version.rb +5 -0
- data/vendor/eac_fs/lib/eac_fs.rb +7 -0
- data/vendor/{eac_ruby_utils/spec/lib/eac_ruby_utils/filesystem_cache_spec.rb → eac_fs/spec/lib/eac_fs/cache_spec.rb} +2 -2
- data/vendor/eac_fs/spec/rubocop_spec.rb +3 -0
- data/vendor/eac_fs/spec/spec_helper.rb +4 -0
- data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +2 -1
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +5 -5
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/core_ext.rb +1 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +16 -7
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/confirmation.rb +0 -1
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner_with/filesystem_traverser.rb +2 -2
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
- data/vendor/eac_ruby_gems_utils/Gemfile +5 -0
- data/vendor/eac_ruby_gems_utils/LICENCE +16 -0
- data/vendor/eac_ruby_gems_utils/README.rdoc +3 -0
- data/vendor/eac_ruby_gems_utils/eac_ruby_gems_utils.gemspec +30 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/command.rb +33 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +41 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +97 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb +57 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/minitest.rb +25 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb +48 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/result.rb +25 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +84 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/rspec.rb +21 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests.rb +9 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +5 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils.rb +7 -0
- data/vendor/eac_ruby_gems_utils/spec/code/rubocop_check_spec.rb +3 -0
- data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb +14 -0
- data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb +7 -0
- data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem_spec.rb +20 -0
- data/vendor/eac_ruby_gems_utils/spec/spec_helper.rb +4 -0
- data/vendor/eac_ruby_gems_utils/spec/support/mygem/Gemfile +5 -0
- data/vendor/eac_ruby_gems_utils/spec/support/mygem/Gemfile.lock +19 -0
- data/vendor/eac_ruby_gems_utils/spec/support/mygem/Rakefile +14 -0
- data/vendor/eac_ruby_gems_utils/spec/support/mygem/exe/myrunner +5 -0
- data/vendor/eac_ruby_gems_utils/spec/support/mygem/lib/mygem/version.rb +5 -0
- data/vendor/eac_ruby_gems_utils/spec/support/mygem/lib/mygem.rb +5 -0
- data/vendor/eac_ruby_gems_utils/spec/support/mygem/mygem.gemspec +16 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/abstract_methods.rb +7 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/core_ext.rb +1 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/gems_registry/gem.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/gems_registry.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/class/abstract.rb +9 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/class/self_included_modules.rb +7 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/i18n_translate.rb +32 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/call_if_proc.rb +11 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/i18n_translate.rb +13 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/speaker/receiver.rb +10 -10
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/abstract_spec.rb +25 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/class/self_included_modules_spec.rb +30 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/call_if_proc_spec.rb +11 -0
- data/vendor/eac_templates/Gemfile +5 -0
- data/vendor/eac_templates/eac_templates.gemspec +19 -0
- data/vendor/eac_templates/lib/eac_templates/directory.rb +108 -0
- data/vendor/eac_templates/lib/eac_templates/file.rb +48 -0
- data/vendor/eac_templates/lib/eac_templates/patches/module/erb_template.rb +9 -0
- data/vendor/eac_templates/lib/eac_templates/patches/module/template.rb +10 -0
- data/vendor/eac_templates/lib/eac_templates/patches/module.rb +4 -0
- data/vendor/eac_templates/lib/eac_templates/patches/object/erb_template.rb +9 -0
- data/vendor/eac_templates/lib/eac_templates/patches/object/template.rb +9 -0
- data/vendor/eac_templates/lib/eac_templates/patches/object.rb +4 -0
- data/vendor/eac_templates/lib/eac_templates/patches.rb +4 -0
- data/vendor/eac_templates/lib/eac_templates/searcher.rb +53 -0
- data/vendor/eac_templates/lib/eac_templates/variable_not_found_error.rb +5 -0
- data/vendor/eac_templates/lib/eac_templates/variable_providers/base.rb +21 -0
- data/vendor/eac_templates/lib/eac_templates/variable_providers/config_reader.rb +27 -0
- data/vendor/eac_templates/lib/eac_templates/variable_providers/entries_reader.rb +23 -0
- data/vendor/eac_templates/lib/eac_templates/variable_providers/generic.rb +23 -0
- data/vendor/eac_templates/lib/eac_templates/variable_providers/hash.rb +27 -0
- data/vendor/eac_templates/lib/eac_templates/variable_providers.rb +23 -0
- data/vendor/eac_templates/lib/eac_templates/version.rb +5 -0
- data/vendor/eac_templates/lib/eac_templates.rb +7 -0
- data/vendor/eac_templates/spec/lib/eac_templates/file_spec.rb +35 -0
- data/vendor/eac_templates/spec/lib/eac_templates/file_spec_files/expected_content +2 -0
- data/vendor/eac_templates/spec/lib/eac_templates/file_spec_files/source.template +2 -0
- data/vendor/eac_templates/spec/lib/eac_templates/searcher_spec.rb +30 -0
- data/vendor/eac_templates/spec/lib/eac_templates/searcher_spec_files/path1/subdir1/file1.template +1 -0
- data/vendor/eac_templates/spec/lib/eac_templates/searcher_spec_files/path1/subdir1/file2 +1 -0
- data/vendor/eac_templates/spec/lib/eac_templates/searcher_spec_files/path2/subdir1/file3.template +1 -0
- data/vendor/eac_templates/spec/lib/object/template_spec.rb +23 -0
- data/vendor/eac_templates/spec/lib/object/template_spec_files/path/my_stub_with_template +1 -0
- data/vendor/eac_templates/spec/rubocop_spec.rb +3 -0
- data/vendor/eac_templates/spec/spec_helper.rb +4 -0
- data/vendor/ehbrs_ruby_utils/ehbrs_ruby_utils.gemspec +1 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/core_ext.rb +5 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/compressed_package.rb +2 -2
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/selected/build.rb +1 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/selected/build_file.rb +1 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/fs/selected.rb +13 -3
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/album.rb +42 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/resource.rb +64 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book/song.rb +68 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/music/lyrics_book.rb +65 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/patches/object.rb +4 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/patches.rb +4 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
- data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/album/inner.html.erb +3 -0
- data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/custom_style.css +15 -0
- data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/index.html.erb +14 -0
- data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/main.html.erb +24 -0
- data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/resource/main.html.erb +8 -0
- data/vendor/ehbrs_ruby_utils/template/ehbrs_ruby_utils/music/lyrics_book/song/inner.html.erb +9 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider.rb +4 -0
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/provider_search.rb +1 -1
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/providers_data.xml +2 -1
- data/vendor/ultimate_lyrics/lib/ultimate_lyrics/version.rb +1 -1
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__michael_jackson_thriller.target.yaml +1 -1
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/encyclopaedia_metallum__milton_nascimento_rouxinol.target.yaml +1 -1
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.source.html +18 -18
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__michael_jackson_thriller.target.yaml +1 -1
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.source.html +18 -18
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/hindilyrics_net_bollywood_songs__milton_nascimento_rouxinol.target.yaml +1 -1
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyrics_com__milton_nascimento_rouxinol.target.yaml +1 -3
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__michael_jackson_thriller.target.yaml +1 -1
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsplugin_com__milton_nascimento_rouxinol.target.yaml +1 -1
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.source.html +3 -3
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/lyricsreg_com__milton_nascimento_rouxinol.target.yaml +1 -1
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.source.html +3 -3
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__michael_jackson_thriller.target.yaml +1 -1
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.source.html +3 -3
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/mp3lyrics_org__milton_nascimento_rouxinol.target.yaml +1 -1
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.source.html +15 -12
- data/vendor/ultimate_lyrics/spec/lib/ultimate_lyrics/parser_spec_files/songlyrics_com__michael_jackson_thriller.target.yaml +1 -1
- metadata +107 -10
- data/lib/ehbrs/patches/module/erb_template.rb +0 -11
- data/lib/ehbrs/patches/object/erb_template.rb +0 -9
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb +0 -47
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traverser.rb +0 -72
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs_cache.rb +0 -12
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/on_clean_ruby_environment.rb +0 -12
@@ -1,71 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'aranha/parsers/html/node/base'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
4
5
|
|
5
6
|
module Aranha
|
6
7
|
module Parsers
|
7
8
|
module Html
|
8
9
|
module Node
|
9
10
|
class Default < ::Aranha::Parsers::Html::Node::Base
|
10
|
-
|
11
|
-
if node.at_xpath(xpath)
|
12
|
-
sanitize_string(node.at_xpath(xpath).text)
|
13
|
-
else
|
14
|
-
''
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def string_recursive_value(node, xpath, required = true)
|
19
|
-
root = node.at_xpath(xpath)
|
20
|
-
if root.blank?
|
21
|
-
return nil unless required
|
22
|
-
|
23
|
-
raise "No node found (Xpath: #{xpath})"
|
24
|
-
end
|
25
|
-
result = string_recursive(root)
|
26
|
-
return result if result.present?
|
27
|
-
return nil unless required
|
28
|
-
|
29
|
-
raise "String blank (Xpath: #{xpath})"
|
30
|
-
end
|
31
|
-
|
32
|
-
def string_recursive_optional_value(node, xpath)
|
33
|
-
string_recursive_value(node, xpath, false)
|
34
|
-
end
|
35
|
-
|
36
|
-
def quoted_value(node, xpath)
|
37
|
-
s = string_value(node, xpath)
|
38
|
-
return '' unless s
|
39
|
-
|
40
|
-
m = /\"([^\"]+)\"/.match(s)
|
41
|
-
return m[1] if m
|
42
|
-
|
43
|
-
''
|
44
|
-
end
|
45
|
-
|
46
|
-
def integer_value(node, xpath)
|
47
|
-
r = string_value(node, xpath)
|
48
|
-
return nil if r.blank?
|
49
|
-
|
50
|
-
m = /\d+/.match(r)
|
51
|
-
raise "Integer not found in \"#{r}\"" unless m
|
52
|
-
|
53
|
-
m[0].to_i
|
54
|
-
end
|
55
|
-
|
56
|
-
def integer_optional_value(node, xpath)
|
57
|
-
r = string_value(node, xpath)
|
58
|
-
m = /\d+/.match(r)
|
59
|
-
m ? m[0].to_i : nil
|
60
|
-
end
|
61
|
-
|
62
|
-
def float_value(node, xpath)
|
63
|
-
parse_float(node, xpath, true)
|
64
|
-
end
|
65
|
-
|
66
|
-
def float_optional_value(node, xpath)
|
67
|
-
parse_float(node, xpath, false)
|
68
|
-
end
|
11
|
+
require_sub __FILE__, include_modules: true
|
69
12
|
|
70
13
|
def array_value(node, xpath)
|
71
14
|
r = node.xpath(xpath).map { |n| n.text.strip }
|
@@ -84,41 +27,6 @@ module Aranha
|
|
84
27
|
m = /(\d+) m/.match(join_value(node, xpath))
|
85
28
|
m ? m[1].to_i : nil
|
86
29
|
end
|
87
|
-
|
88
|
-
def regxep(node, xpath, pattern)
|
89
|
-
s = string_value(node, xpath)
|
90
|
-
m = pattern.match(s)
|
91
|
-
return m if m
|
92
|
-
|
93
|
-
raise "Pattern \"#{pattern}\" not found in string \"#{s}\""
|
94
|
-
end
|
95
|
-
|
96
|
-
private
|
97
|
-
|
98
|
-
def parse_float(node, xpath, required)
|
99
|
-
s = string_value(node, xpath)
|
100
|
-
m = /\d+(?:[\.\,](\d+))?/.match(s)
|
101
|
-
if m
|
102
|
-
m[0].delete('.').tr(',', '.').to_f
|
103
|
-
elsif required
|
104
|
-
raise "Float value not found in \"#{s}\""
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def sanitize_string(obj)
|
109
|
-
obj.to_s.tr("\u00A0", ' ').strip
|
110
|
-
end
|
111
|
-
|
112
|
-
def string_recursive(node)
|
113
|
-
return sanitize_string(node.text) if node.is_a?(::Nokogiri::XML::Text)
|
114
|
-
|
115
|
-
s = ''
|
116
|
-
node.children.each do |child|
|
117
|
-
child_s = string_recursive(child)
|
118
|
-
s += ' ' + child_s if child_s.present?
|
119
|
-
end
|
120
|
-
sanitize_string(s)
|
121
|
-
end
|
122
30
|
end
|
123
31
|
end
|
124
32
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/base'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Aranha
|
7
|
+
module Parsers
|
8
|
+
module Json
|
9
|
+
class Base < ::Aranha::Parsers::Base
|
10
|
+
def data
|
11
|
+
default_data
|
12
|
+
end
|
13
|
+
|
14
|
+
def default_data
|
15
|
+
::JSON.parse(content)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'addressable'
|
4
4
|
require 'curb'
|
5
5
|
require 'aranha/parsers/source_address/fetch_content_error'
|
6
|
+
require 'faraday_middleware'
|
6
7
|
|
7
8
|
module Aranha
|
8
9
|
module Parsers
|
@@ -32,11 +33,18 @@ module Aranha
|
|
32
33
|
source
|
33
34
|
end
|
34
35
|
|
36
|
+
def final_url
|
37
|
+
content unless @final_url
|
38
|
+
@final_url
|
39
|
+
end
|
40
|
+
|
35
41
|
def content
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
42
|
+
conn = ::Faraday.new do |f|
|
43
|
+
f.request :retry # retry transient failures
|
44
|
+
f.response :follow_redirects # follow redirects
|
45
|
+
end
|
46
|
+
c = conn.get(url)
|
47
|
+
return c.body if c.status == 200
|
40
48
|
|
41
49
|
raise ::Aranha::Parsers::SourceAddress::FetchContentError,
|
42
50
|
"Get #{url} returned #{c.status.to_i}"
|
@@ -45,17 +53,6 @@ module Aranha
|
|
45
53
|
def serialize
|
46
54
|
url
|
47
55
|
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def curl_perform(curl)
|
52
|
-
unless curl.perform
|
53
|
-
raise(::Aranha::Parsers::SourceAddress::FetchContentError,
|
54
|
-
"Curl perform failed (URL: #{url})")
|
55
|
-
end
|
56
|
-
rescue Curl::Err::CurlError => e
|
57
|
-
raise ::Aranha::Parsers::SourceAddress::FetchContentError, "CURL error: #{e.class.name}"
|
58
|
-
end
|
59
56
|
end
|
60
57
|
end
|
61
58
|
end
|
@@ -3,16 +3,19 @@
|
|
3
3
|
require 'eac_ruby_utils/core_ext'
|
4
4
|
|
5
5
|
module EacCli
|
6
|
-
class Config
|
6
|
+
class Config < ::SimpleDelegator
|
7
7
|
require_sub __FILE__
|
8
|
-
attr_reader :sub
|
9
8
|
|
10
9
|
def initialize(sub_node)
|
11
|
-
|
10
|
+
super(sub_node)
|
12
11
|
end
|
13
12
|
|
14
13
|
def entry(path, options = {})
|
15
14
|
::EacCli::Config::Entry.new(self, path, options)
|
16
15
|
end
|
16
|
+
|
17
|
+
def sub
|
18
|
+
__getobj__
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
|
+
|
5
|
+
require 'eac_fs/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'eac_fs'
|
9
|
+
s.version = EacFs::VERSION
|
10
|
+
s.authors = ['Put here the authors']
|
11
|
+
s.summary = 'Put here de description.'
|
12
|
+
|
13
|
+
s.files = Dir['{lib}/**/*']
|
14
|
+
|
15
|
+
s.add_dependency 'content-type'
|
16
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.70'
|
17
|
+
s.add_dependency 'ruby-filemagic'
|
18
|
+
|
19
|
+
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3'
|
20
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_fs/patches'
|
4
|
+
require 'eac_ruby_utils/fs/temp'
|
5
|
+
|
6
|
+
module Avm
|
7
|
+
class CachedDownload
|
8
|
+
attr_reader :url, :fs_cache
|
9
|
+
|
10
|
+
def initialize(url, parent_fs_cache = nil)
|
11
|
+
@url = url
|
12
|
+
@fs_cache = (parent_fs_cache || fs_cache).child(url.parameterize)
|
13
|
+
end
|
14
|
+
|
15
|
+
def assert
|
16
|
+
download unless fs_cache.cached?
|
17
|
+
end
|
18
|
+
|
19
|
+
def download
|
20
|
+
::EacRubyUtils::Fs::Temp.on_file do |temp|
|
21
|
+
download_to(temp)
|
22
|
+
fs_cache.content_path.to_pathname.dirname.mkpath
|
23
|
+
::FileUtils.mv(temp.to_path, fs_cache.content_path)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def path
|
28
|
+
fs_cache.content_path.to_pathname
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def download_to(local_file)
|
34
|
+
::URI.parse(url).open do |remote|
|
35
|
+
local_file.open('wb') { |handle| handle.write(remote.read) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'content-type'
|
5
|
+
require 'filemagic'
|
6
|
+
|
7
|
+
module EacFs
|
8
|
+
class FileInfo
|
9
|
+
UNKNOWN_CONTENT_TYPE_STRING = 'application/octet-stream'
|
10
|
+
UNKNOWN_CONTENT_TYPE = ::ContentType.parse(UNKNOWN_CONTENT_TYPE_STRING)
|
11
|
+
|
12
|
+
enable_simple_cache
|
13
|
+
attr_reader :magic_string
|
14
|
+
|
15
|
+
def initialize(path)
|
16
|
+
@magic_string = ::FileMagic.new(FileMagic::MAGIC_MIME).file(path.to_pathname.to_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
delegate :charset, :mime_type, :subtype, :type, to: :content_type
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def content_type_uncached
|
24
|
+
::ContentType.parse(magic_string)
|
25
|
+
rescue ::Parslet::ParseFailed
|
26
|
+
UNKNOWN_CONTENT_TYPE
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_fs/patches/module/fs_cache'
|
4
|
+
|
5
|
+
class Object
|
6
|
+
# @return [EacFs::Cache]
|
7
|
+
def fs_cache
|
8
|
+
oid = fs_cache_object_id
|
9
|
+
oid = [oid.to_s] unless oid.is_a?(::Enumerable)
|
10
|
+
oid.inject(self.class.fs_cache) { |a, e| a.child(e.to_s) }
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [String, Array<String>]
|
14
|
+
def fs_cache_object_id
|
15
|
+
raise 'Abstract method hit'
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_fs/traverser'
|
4
|
+
|
5
|
+
module EacFs
|
6
|
+
module Traversable
|
7
|
+
PROP_METHOD_PREFIX = 'traverser_'
|
8
|
+
BOOLEAN_PROPS = %i[hidden_directories recursive sort].freeze
|
9
|
+
PATH_PROPS = %i[check_directory check_file].freeze
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def prop_method_name(prop)
|
13
|
+
"#{PROP_METHOD_PREFIX}#{prop}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
PATH_PROPS.each do |method|
|
18
|
+
define_method(::EacFs::Traversable.prop_method_name(method)) do |_path|
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
BOOLEAN_PROPS.each do |method|
|
24
|
+
define_method(::EacFs::Traversable.prop_method_name(method)) do
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
28
|
+
define_method("#{::EacFs::Traversable.prop_method_name(method)}?") do
|
29
|
+
send(method_name)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def traverser_check_path(path)
|
34
|
+
traverser_new.check_path(path)
|
35
|
+
end
|
36
|
+
|
37
|
+
def traverser_new
|
38
|
+
r = ::EacFs::Traverser.new
|
39
|
+
(BOOLEAN_PROPS + PATH_PROPS).each do |prop|
|
40
|
+
r.send("#{prop}=", method(::EacFs::Traversable.prop_method_name(prop)))
|
41
|
+
end
|
42
|
+
r
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacFs
|
4
|
+
class Traverser
|
5
|
+
attr_accessor :check_directory, :check_file, :recursive, :hidden_directories, :sort
|
6
|
+
|
7
|
+
def initialize(options = {})
|
8
|
+
options.each do |accessor, value|
|
9
|
+
send("#{accessor}=", value)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def check_path(path)
|
14
|
+
path = ::Pathname.new(path.to_s) unless path.is_a?(::Pathname)
|
15
|
+
internal_check_path(path, 0)
|
16
|
+
end
|
17
|
+
|
18
|
+
def hidden_directories?
|
19
|
+
boolean_value(hidden_directories)
|
20
|
+
end
|
21
|
+
|
22
|
+
def recursive?
|
23
|
+
boolean_value(recursive)
|
24
|
+
end
|
25
|
+
|
26
|
+
def sort?
|
27
|
+
boolean_value(sort)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def boolean_value(source_value)
|
33
|
+
source_value = source_value.call if source_value.respond_to?(:call)
|
34
|
+
source_value ? true : false
|
35
|
+
end
|
36
|
+
|
37
|
+
def each_child(dir, &block)
|
38
|
+
if sort?
|
39
|
+
dir.each_child.sort_by { |p| [p.to_s] }.each(&block)
|
40
|
+
else
|
41
|
+
dir.each_child(&block)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def process_directory?(level)
|
46
|
+
level.zero? || recursive?
|
47
|
+
end
|
48
|
+
|
49
|
+
def inner_check_directory(dir, level)
|
50
|
+
return unless process_directory?(level)
|
51
|
+
|
52
|
+
user_check_directory(dir)
|
53
|
+
each_child(dir) do |e|
|
54
|
+
next unless !e.basename.to_s.start_with?('.') || hidden_directories?
|
55
|
+
|
56
|
+
internal_check_path(e, level + 1)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def internal_check_path(path, level)
|
61
|
+
if path.file?
|
62
|
+
user_check_file(path)
|
63
|
+
elsif path.directory?
|
64
|
+
inner_check_directory(path, level)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def user_check_file(path)
|
69
|
+
check_file&.call(path)
|
70
|
+
end
|
71
|
+
|
72
|
+
def user_check_directory(path)
|
73
|
+
check_directory&.call(path)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/core_ext/object/blank'
|
4
|
-
require '
|
4
|
+
require 'eac_fs/cache'
|
5
5
|
|
6
|
-
RSpec.describe ::
|
6
|
+
RSpec.describe ::EacFs::Cache do
|
7
7
|
let(:tmpdir) { ::Dir.mktmpdir }
|
8
8
|
let(:instance) { described_class.new(tmpdir, 'instance') }
|
9
9
|
|
@@ -13,7 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.files = Dir['{lib}/**/*']
|
14
14
|
|
15
15
|
s.add_dependency 'eac_cli', '~> 0.22', '>= 0.22.2'
|
16
|
-
s.add_dependency '
|
16
|
+
s.add_dependency 'eac_fs', '~> 0.3'
|
17
|
+
s.add_dependency 'eac_ruby_gems_utils', '~> 0.9', '~> 0.9.6'
|
17
18
|
s.add_dependency 'eac_ruby_utils', '~> 0.70'
|
18
19
|
|
19
20
|
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.3'
|
@@ -3,10 +3,10 @@
|
|
3
3
|
require 'eac_cli/config'
|
4
4
|
require 'eac_config/envvars_node'
|
5
5
|
require 'eac_config/yaml_file_node'
|
6
|
+
require 'eac_fs/cache'
|
6
7
|
require 'eac_ruby_base0/application_xdg'
|
7
8
|
require 'eac_ruby_gems_utils/gem'
|
8
9
|
require 'eac_ruby_utils/core_ext'
|
9
|
-
require 'eac_ruby_utils/filesystem_cache'
|
10
10
|
|
11
11
|
module EacRubyBase0
|
12
12
|
class Application
|
@@ -43,9 +43,9 @@ module EacRubyBase0
|
|
43
43
|
delegate "#{item}_xdg_env", "#{item}_dir", to: :app_xdg
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
47
|
-
@
|
48
|
-
cache_dir.join(::
|
46
|
+
def self_fs_cache
|
47
|
+
@self_fs_cache ||= ::EacFs::Cache.new(
|
48
|
+
cache_dir.join(::EacFs::Cache.name.parameterize)
|
49
49
|
)
|
50
50
|
end
|
51
51
|
|
@@ -58,7 +58,7 @@ module EacRubyBase0
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def vendor_dir
|
61
|
-
gemspec_dir.join('
|
61
|
+
gemspec_dir.join('sub')
|
62
62
|
end
|
63
63
|
|
64
64
|
private
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'eac_cli/core_ext'
|
4
4
|
require 'eac_cli/speaker'
|
5
5
|
require 'eac_config/node'
|
6
|
+
require 'eac_fs/cache'
|
6
7
|
require 'eac_ruby_utils/speaker'
|
7
8
|
|
8
9
|
module EacRubyBase0
|
@@ -23,13 +24,11 @@ module EacRubyBase0
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def run
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
run_with_subcommand
|
32
|
-
end
|
27
|
+
on_context do
|
28
|
+
if parsed.version?
|
29
|
+
show_version
|
30
|
+
else
|
31
|
+
run_with_subcommand
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
@@ -38,6 +37,16 @@ module EacRubyBase0
|
|
38
37
|
runner_context.call(:application).version.to_s
|
39
38
|
end
|
40
39
|
|
40
|
+
def on_context
|
41
|
+
::EacRubyUtils::Speaker.context.on(build_speaker) do
|
42
|
+
::EacConfig::Node.context.on(runner_context.call(:application).build_config) do
|
43
|
+
::EacFs::Cache.context.on(application.self_fs_cache) do
|
44
|
+
yield
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
41
50
|
def show_version
|
42
51
|
out("#{application_version}\n")
|
43
52
|
end
|