aranha-parsers 0.14.2 → 0.14.4

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: 470c36e1c85905ccd38da54b446aba51bdc51fe11cac597178ba573351f53d20
4
- data.tar.gz: e282c4da7b6c359bacda51564f0a3e2010a0a7c4f3e523958cab076185bc0193
3
+ metadata.gz: 26e15025c30781eb4fb89a7cffbd4377d4fc3fb9a939ccdc083e02f20a20cc09
4
+ data.tar.gz: 130715bbaba9859d9784dedf59286e5e48201084dc8beb9437ab7c99c3e53ca0
5
5
  SHA512:
6
- metadata.gz: a43cde58b96c66e7cd82ad4b0c209cf6e776ca351f415951a753944b62adff0f2d1f83e141f62050f08d09d5cc0bf2c8904a503f1e614ab460e689dfc52a56bc
7
- data.tar.gz: c244886b27dae17b8afbb2fa82b9d65f87e2e68ea83aeac3a740f76bb763858f57eeed46ec5234e30035b33e9943a6e315bd685fa04d837bd2ffce5371a8fae6
6
+ metadata.gz: eb84b0a5f4d94b08035018de535caf2c864fb14587bc34597e19d19aa2b0633e6ffeb9e14719a74012e5dd1f6c1df377d200f8b7bd3dfa1f288f76f22fa5383d
7
+ data.tar.gz: 488999e54c3b06cc34b93240789b0f21de7b1b2daf19b65a14b647bbce17d390ece6cb064c6ecf3770166efb3e5b87e31784cc3ca54bb14d1beee005893608b3
@@ -1,13 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'aranha/parsers/rspec/source_target_fixtures_controller'
3
4
  require 'aranha/parsers/source_target_fixtures'
4
5
  require 'yaml'
5
6
 
6
7
  RSpec.shared_examples 'source_target_fixtures' do |spec_file| # rubocop:disable Metrics/BlockLength
8
+ fixtures_controller = ::Aranha::Parsers::Rspec::SourceTargetFixturesController
9
+ .new(self, spec_file)
10
+
11
+ let(:fixtures_controller) { fixtures_controller }
7
12
  let(:spec_file) { spec_file }
8
13
 
9
14
  it 'fixtures directory should exist' do
10
- expect(::File.directory?(fixtures_dir)).to be true
15
+ expect(::File.directory?(fixtures_controller.fixtures_dir)).to be true
11
16
  end
12
17
 
13
18
  context 'with fixtures directory' do
@@ -15,30 +20,28 @@ RSpec.shared_examples 'source_target_fixtures' do |spec_file| # rubocop:disable
15
20
  expect(source_target_fixtures.source_target_files.count).to be > 0 # rubocop:disable Style/NumericPredicate
16
21
  end
17
22
 
18
- if ENV['WRITE_TARGET_FIXTURES']
19
- it 'writes target data for all files' do
20
- source_target_fixtures.source_files.each do |source_file|
21
- sd = sort_results(source_data(source_file))
22
- basename = ::Aranha::Parsers::SourceTargetFixtures.source_target_basename(source_file)
23
- target_file = File.expand_path("../#{basename}.target#{target_file_extname}", source_file)
24
- File.write(target_file, target_content(sd))
25
- end
26
- end
27
- else
28
- it 'parses data for all files' do
29
- source_target_fixtures.source_target_files.each do |st|
30
- assert_source_target_complete(st)
31
- sd = source_data(st.source)
32
- td = target_data(st.target)
33
- expect(sort_results(sd)).to eq(sort_results(td))
23
+ fixtures_controller.source_target_fixtures.source_target_files.each do |st|
24
+ context "when source file is \"#{::File.basename(st.source)}\"" do
25
+ if fixtures_controller.write_target_fixtures?
26
+ it 'writes target data' do
27
+ sd = sort_results(source_data(st.source))
28
+ basename = ::Aranha::Parsers::SourceTargetFixtures.source_target_basename(st.source)
29
+ target_file = File.expand_path("../#{basename}.target#{target_file_extname}", st.source)
30
+ File.write(target_file, target_content(sd))
31
+ end
32
+ else
33
+ it 'parses data' do
34
+ assert_source_target_complete(st)
35
+ sd = source_data(st.source)
36
+ td = target_data(st.target)
37
+ expect(sort_results(sd)).to eq(sort_results(td))
38
+ end
34
39
  end
35
40
  end
36
41
  end
37
42
  end
38
43
 
39
- def source_target_fixtures
40
- @source_target_fixtures ||= ::Aranha::Parsers::SourceTargetFixtures.new(fixtures_dir)
41
- end
44
+ delegate :source_target_fixtures, to: :fixtures_controller
42
45
 
43
46
  def assert_source_target_complete(source_target)
44
47
  expect(source_target.source).to(be_truthy, "Source not found (Target: #{source_target.target})")
@@ -53,13 +56,6 @@ RSpec.shared_examples 'source_target_fixtures' do |spec_file| # rubocop:disable
53
56
  "\"#{self}.source_data(source_file)\""
54
57
  end
55
58
 
56
- def fixtures_dir
57
- ::File.join(
58
- ::File.dirname(spec_file),
59
- ::File.basename(spec_file, '.*') + '_files'
60
- )
61
- end
62
-
63
59
  def sort_results(results)
64
60
  results
65
61
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Aranha
6
+ module Parsers
7
+ module Rspec
8
+ class SourceTargetFixturesController
9
+ enable_simple_cache
10
+ common_constructor :example, :spec_file
11
+
12
+ def default_fixtures_dir
13
+ ::File.join(
14
+ ::File.dirname(spec_file),
15
+ ::File.basename(spec_file, '.*') + '_files'
16
+ )
17
+ end
18
+
19
+ def fixtures_dir
20
+ if example.respond_to?(:fixtures_dir)
21
+ example.fixtures_dir
22
+ else
23
+ default_fixtures_dir
24
+ end
25
+ end
26
+
27
+ def write_target_fixtures?
28
+ ENV['WRITE_TARGET_FIXTURES'].to_bool
29
+ end
30
+
31
+ private
32
+
33
+ def source_target_fixtures_uncached
34
+ ::Aranha::Parsers::SourceTargetFixtures.new(fixtures_dir)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aranha
4
+ module Parsers
5
+ class SourceTargetFixtures
6
+ class SourceTargetFile
7
+ common_constructor :owner, :basename
8
+
9
+ def source
10
+ owner.source_file(basename)
11
+ end
12
+
13
+ def target
14
+ owner.target_file(basename)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -7,6 +7,8 @@ module Aranha
7
7
  module Parsers
8
8
  # Lists pairs of source/target files in a directory.
9
9
  class SourceTargetFixtures
10
+ require_sub __FILE__
11
+
10
12
  class << self
11
13
  def source_target_basename(file)
12
14
  m = /^(.+)\.(?:source|target)(?:\..+)?$/.match(File.basename(file))
@@ -22,8 +24,7 @@ module Aranha
22
24
 
23
25
  def source_target_files
24
26
  sources_targets_basenames.map do |basename|
25
- OpenStruct.new(basename: basename, source: source_file(basename),
26
- target: target_file(basename))
27
+ ::Aranha::Parsers::SourceTargetFixtures::SourceTargetFile.new(self, basename)
27
28
  end
28
29
  end
29
30
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aranha
4
4
  module Parsers
5
- VERSION = '0.14.2'
5
+ VERSION = '0.14.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aranha-parsers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.2
4
+ version: 0.14.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-04 00:00:00.000000000 Z
11
+ date: 2022-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 6.1.6
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 6.1.6.1
19
+ version: 4.0.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: 6.1.6
30
24
  - - ">="
31
25
  - !ruby/object:Gem::Version
32
- version: 6.1.6.1
26
+ version: 4.0.0
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: addressable
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -76,20 +70,14 @@ dependencies:
76
70
  requirements:
77
71
  - - "~>"
78
72
  - !ruby/object:Gem::Version
79
- version: '0.102'
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 0.102.1
73
+ version: '0.106'
83
74
  type: :runtime
84
75
  prerelease: false
85
76
  version_requirements: !ruby/object:Gem::Requirement
86
77
  requirements:
87
78
  - - "~>"
88
79
  - !ruby/object:Gem::Version
89
- version: '0.102'
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: 0.102.1
80
+ version: '0.106'
93
81
  - !ruby/object:Gem::Dependency
94
82
  name: faraday-gzip
95
83
  requirement: !ruby/object:Gem::Requirement
@@ -127,7 +115,7 @@ dependencies:
127
115
  version: '1.13'
128
116
  - - ">="
129
117
  - !ruby/object:Gem::Version
130
- version: 1.13.8
118
+ version: 1.13.9
131
119
  type: :runtime
132
120
  prerelease: false
133
121
  version_requirements: !ruby/object:Gem::Requirement
@@ -137,7 +125,7 @@ dependencies:
137
125
  version: '1.13'
138
126
  - - ">="
139
127
  - !ruby/object:Gem::Version
140
- version: 1.13.8
128
+ version: 1.13.9
141
129
  - !ruby/object:Gem::Dependency
142
130
  name: ofx-parser
143
131
  requirement: !ruby/object:Gem::Requirement
@@ -172,7 +160,6 @@ executables: []
172
160
  extensions: []
173
161
  extra_rdoc_files: []
174
162
  files:
175
- - Gemfile
176
163
  - lib/aranha/parsers.rb
177
164
  - lib/aranha/parsers/base.rb
178
165
  - lib/aranha/parsers/html.rb
@@ -192,6 +179,7 @@ files:
192
179
  - lib/aranha/parsers/rspec.rb
193
180
  - lib/aranha/parsers/rspec/setup.rb
194
181
  - lib/aranha/parsers/rspec/shared_examples/source_target_fixtures.rb
182
+ - lib/aranha/parsers/rspec/source_target_fixtures_controller.rb
195
183
  - lib/aranha/parsers/source_address.rb
196
184
  - lib/aranha/parsers/source_address/fetch_content_error.rb
197
185
  - lib/aranha/parsers/source_address/file.rb
@@ -200,6 +188,7 @@ files:
200
188
  - lib/aranha/parsers/source_address/hash_http_post.rb
201
189
  - lib/aranha/parsers/source_address/http_get.rb
202
190
  - lib/aranha/parsers/source_target_fixtures.rb
191
+ - lib/aranha/parsers/source_target_fixtures/source_target_file.rb
203
192
  - lib/aranha/parsers/version.rb
204
193
  homepage:
205
194
  licenses: []
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
6
-
7
- local_gemfile = ::File.join(::File.dirname(__FILE__), 'Gemfile.local')
8
- eval_gemfile local_gemfile if ::File.exist?(local_gemfile)