ehbrs_ruby_utils 0.43.0 → 0.44.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehbrs_ruby_utils/bga/session/player_tables_on_game_in_progress.rb +1 -1
- data/lib/ehbrs_ruby_utils/booking/parsers/list.rb +63 -0
- data/lib/ehbrs_ruby_utils/booking/processors/list/build_accommodation.rb +34 -0
- data/lib/ehbrs_ruby_utils/booking/processors/list.rb +82 -0
- data/lib/ehbrs_ruby_utils/version.rb +1 -1
- data/lib/ehbrs_ruby_utils/videos/series/rename/line_result_group.rb +1 -1
- data/lib/ehbrs_ruby_utils/videos2/unsupported/check_set.rb +1 -1
- data/lib/ehbrs_ruby_utils/videos2/unsupported/profiles/samsung.rb +1 -1
- data/lib/ehbrs_ruby_utils/web_utils/instance/finances/bills/consume/file.rb +2 -2
- data/lib/ehbrs_ruby_utils/web_utils/instance/finances/bills/consume.rb +2 -2
- data/lib/ehbrs_ruby_utils/web_utils/instance/finances/bills.rb +2 -2
- data/lib/ehbrs_ruby_utils/web_utils/instance/finances.rb +2 -2
- data/lib/ehbrs_ruby_utils/web_utils/instance/http_request.rb +2 -2
- data/lib/ehbrs_ruby_utils/web_utils/instance.rb +3 -3
- metadata +39 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84117287c2474b8e4afd1bb62995ca8ae8d474e3d71c68a274c77a6426f3a969
|
4
|
+
data.tar.gz: e66e87a6ca223f273a30944428bf5807656a32ca02fe93fd6ac9aee966e042d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a151fde138411b7474943f6f107a929d469d46f51d0587313ee50e0ebb01b40112ab8635c7fcca95aab9432478864a57488ad31004b068a4cecf1e4f1cb0fe46
|
7
|
+
data.tar.gz: 80725bd8cf232be1aca943c3e0fb834528296a6d86fb57bcf82a92bf30737ee61b3bd7bcf4565d0e5425d7368a90396d20e3c8688d9d71005e2fbd2375c138b5
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/parsers/html/item_list'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module EhbrsRubyUtils
|
7
|
+
module Booking
|
8
|
+
module Parsers
|
9
|
+
class List < ::Aranha::Parsers::Html::ItemList
|
10
|
+
class << self
|
11
|
+
def testid_xpath(value, *suffixes)
|
12
|
+
([".//*[@data-testid='#{value}']"] + suffixes).join('/')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
ITEMS_XPATH = '//*[@data-testid="property-card"]'
|
17
|
+
|
18
|
+
field :name, :string, testid_xpath('title', 'text()')
|
19
|
+
field :href, :string, testid_xpath('title-link', '@href')
|
20
|
+
field :price, :float, testid_xpath('price-and-discounted-price', '/text()')
|
21
|
+
field :tax, :float_optional, testid_xpath('taxes-and-charges', 'text()')
|
22
|
+
field :address, :string, testid_xpath('address', 'text()')
|
23
|
+
field :distance, :distance, testid_xpath('distance', 'text()')
|
24
|
+
field :review_score, :float_optional, testid_xpath('review-score', 'div[1]/text()')
|
25
|
+
field :review_count, :integer, testid_xpath('review-score', 'div[2]/div[2]/text()')
|
26
|
+
field :unit_title, :string_recursive, testid_xpath('recommended-units',
|
27
|
+
'/*[@role="link"]')
|
28
|
+
|
29
|
+
def data
|
30
|
+
{ accommodations: items_data, declared_count: declared_count }
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [Integer]
|
34
|
+
def declared_count
|
35
|
+
node_parser.integer_value(nokogiri, '//h1/text()')
|
36
|
+
end
|
37
|
+
|
38
|
+
def items_xpath
|
39
|
+
ITEMS_XPATH
|
40
|
+
end
|
41
|
+
|
42
|
+
def node_parser
|
43
|
+
r = super
|
44
|
+
r.extend(NodeParserExtra)
|
45
|
+
r
|
46
|
+
end
|
47
|
+
|
48
|
+
module NodeParserExtra
|
49
|
+
DISTANCE_PARSER = /\A(\d+)(?:,(\d+))? (m|km)/.to_parser do |m|
|
50
|
+
r = m[1].to_f + m[2].if_present(0) { |v| v.to_f / 10.pow(v.length) }
|
51
|
+
r /= 1000 if m[3] == 'm'
|
52
|
+
r
|
53
|
+
end
|
54
|
+
|
55
|
+
def distance_value(node, xpath)
|
56
|
+
s = string_value(node, xpath)
|
57
|
+
DISTANCE_PARSER.parse!(s)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EhbrsRubyUtils
|
6
|
+
module Booking
|
7
|
+
module Processors
|
8
|
+
class List
|
9
|
+
class BuildAccommodation
|
10
|
+
acts_as_instance_method
|
11
|
+
common_constructor :list, :data
|
12
|
+
|
13
|
+
TOTAL_VALUE = '=index($A:$ZZZ;row();column()-2)+index($A:$ZZZ;row();column()-1)'
|
14
|
+
|
15
|
+
def result
|
16
|
+
%i[link total].inject(data) do |a, e|
|
17
|
+
a.merge(e => send("#{e}_value"))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [String]
|
22
|
+
def link_value
|
23
|
+
"=HYPERLINK(\"#{data.fetch(:href)}\";\"#{data.fetch(:name)}\")"
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [String]
|
27
|
+
def total_value
|
28
|
+
TOTAL_VALUE
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'aranha/selenium/session'
|
4
|
+
require 'ehbrs_ruby_utils/booking/parsers/list'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module EhbrsRubyUtils
|
8
|
+
module Booking
|
9
|
+
module Processors
|
10
|
+
class List
|
11
|
+
enable_simple_cache
|
12
|
+
common_constructor :url
|
13
|
+
|
14
|
+
CLOSE_BANNER_XPATH = '//button[@aria-label = "Ignorar informações de login."]'
|
15
|
+
MORE_RESULTS_XPATH = '//*[text() = "Ver mais resultados"]'
|
16
|
+
SCROLL_DOWN_STEP = 500
|
17
|
+
|
18
|
+
# @return [Array]
|
19
|
+
def accommodations
|
20
|
+
data.fetch(:accommodations).map { |a| build_accommodation(a) }
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Integer]
|
24
|
+
def declared_count
|
25
|
+
data.fetch(:declared_count)
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
# @return [Boolean]
|
31
|
+
def all_accommodations_reached?
|
32
|
+
p = parser
|
33
|
+
p.data.fetch(:accommodations).count >= p.data.fetch(:declared_count)
|
34
|
+
end
|
35
|
+
|
36
|
+
def click_more_results
|
37
|
+
more_results_button.click
|
38
|
+
end
|
39
|
+
|
40
|
+
def close_banner
|
41
|
+
close_banner_button.click
|
42
|
+
end
|
43
|
+
|
44
|
+
# @return [Aranha::Selenium::Session::Element]
|
45
|
+
def close_banner_button
|
46
|
+
session.element(xpath: CLOSE_BANNER_XPATH)
|
47
|
+
end
|
48
|
+
|
49
|
+
def data_uncached
|
50
|
+
session.navigate.to url
|
51
|
+
session.wait(5.minutes).until do
|
52
|
+
close_banner
|
53
|
+
click_more_results
|
54
|
+
scroll_down
|
55
|
+
all_accommodations_reached?
|
56
|
+
end
|
57
|
+
parser.data
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [Aranha::Selenium::Session::Element]
|
61
|
+
def more_results_button
|
62
|
+
session.element(xpath: MORE_RESULTS_XPATH)
|
63
|
+
end
|
64
|
+
|
65
|
+
def parser
|
66
|
+
::EhbrsRubyUtils::Booking::Parsers::List.from_string(session.current_source)
|
67
|
+
end
|
68
|
+
|
69
|
+
# @return [Aranha::Selenium::Session]
|
70
|
+
def session_uncached
|
71
|
+
::Aranha::Selenium::Session.new
|
72
|
+
end
|
73
|
+
|
74
|
+
def scroll_down
|
75
|
+
session.scroll_down_by(SCROLL_DOWN_STEP)
|
76
|
+
end
|
77
|
+
|
78
|
+
require_sub __FILE__, require_mode: :kernel
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'avm/instances/base'
|
3
|
+
require 'avm/eac_rails_base0/instances/base'
|
4
4
|
require 'avm/result'
|
5
5
|
require 'eac_ruby_utils/core_ext'
|
6
6
|
|
7
7
|
module EhbrsRubyUtils
|
8
8
|
module WebUtils
|
9
|
-
class Instance < ::Avm::Instances::Base
|
9
|
+
class Instance < ::Avm::EacRailsBase0::Instances::Base
|
10
10
|
class Finances
|
11
11
|
class Bills
|
12
12
|
class Consume
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'avm/instances/base'
|
3
|
+
require 'avm/eac_rails_base0/instances/base'
|
4
4
|
require 'eac_ruby_utils/core_ext'
|
5
5
|
|
6
6
|
module EhbrsRubyUtils
|
7
7
|
module WebUtils
|
8
|
-
class Instance < ::Avm::Instances::Base
|
8
|
+
class Instance < ::Avm::EacRailsBase0::Instances::Base
|
9
9
|
class Finances
|
10
10
|
class Bills
|
11
11
|
class Consume
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'avm/instances/base'
|
3
|
+
require 'avm/eac_rails_base0/instances/base'
|
4
4
|
require 'eac_ruby_utils/core_ext'
|
5
5
|
|
6
6
|
module EhbrsRubyUtils
|
7
7
|
module WebUtils
|
8
|
-
class Instance < ::Avm::Instances::Base
|
8
|
+
class Instance < ::Avm::EacRailsBase0::Instances::Base
|
9
9
|
class Finances
|
10
10
|
class Bills
|
11
11
|
require_sub __FILE__
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'avm/instances/base'
|
3
|
+
require 'avm/eac_rails_base0/instances/base'
|
4
4
|
require 'eac_ruby_utils/core_ext'
|
5
5
|
|
6
6
|
module EhbrsRubyUtils
|
7
7
|
module WebUtils
|
8
|
-
class Instance < ::Avm::Instances::Base
|
8
|
+
class Instance < ::Avm::EacRailsBase0::Instances::Base
|
9
9
|
class Finances
|
10
10
|
require_sub __FILE__
|
11
11
|
enable_simple_cache
|
@@ -3,11 +3,11 @@
|
|
3
3
|
require 'eac_rest/api'
|
4
4
|
require 'eac_ruby_utils/core_ext'
|
5
5
|
require 'ehbrs_ruby_utils/web_utils/request_error'
|
6
|
-
require 'avm/instances/base'
|
6
|
+
require 'avm/eac_rails_base0/instances/base'
|
7
7
|
|
8
8
|
module EhbrsRubyUtils
|
9
9
|
module WebUtils
|
10
|
-
class Instance < ::Avm::Instances::Base
|
10
|
+
class Instance < ::Avm::EacRailsBase0::Instances::Base
|
11
11
|
class HttpRequest
|
12
12
|
enable_method_class
|
13
13
|
enable_simple_cache
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'eac_rest/api'
|
4
4
|
require 'eac_ruby_utils/core_ext'
|
5
|
-
require 'avm/instances/base'
|
5
|
+
require 'avm/eac_rails_base0/instances/base'
|
6
6
|
|
7
7
|
module EhbrsRubyUtils
|
8
8
|
module WebUtils
|
9
|
-
class Instance < ::Avm::Instances::Base
|
9
|
+
class Instance < ::Avm::EacRailsBase0::Instances::Base
|
10
10
|
require_sub __FILE__, require_dependency: true
|
11
11
|
|
12
12
|
# @return [EacRest::Api]
|
@@ -19,7 +19,7 @@ module EhbrsRubyUtils
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def root_url
|
22
|
-
|
22
|
+
web_url
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ehbrs_ruby_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.44.1
|
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: 2024-05
|
11
|
+
date: 2024-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha
|
@@ -50,34 +50,54 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '0.
|
53
|
+
version: '0.11'
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
56
|
+
version: 0.11.1
|
57
57
|
type: :runtime
|
58
58
|
prerelease: false
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: '0.
|
63
|
+
version: '0.11'
|
64
64
|
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: 0.
|
66
|
+
version: 0.11.1
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: avm
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
71
|
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '0.
|
73
|
+
version: '0.92'
|
74
74
|
type: :runtime
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: '0.
|
80
|
+
version: '0.92'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: avm-eac_rails_base0
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0.11'
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.11.1
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0.11'
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 0.11.1
|
81
101
|
- !ruby/object:Gem::Dependency
|
82
102
|
name: dentaku
|
83
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,14 +124,14 @@ dependencies:
|
|
104
124
|
requirements:
|
105
125
|
- - "~>"
|
106
126
|
- !ruby/object:Gem::Version
|
107
|
-
version: '0.
|
127
|
+
version: '0.18'
|
108
128
|
type: :runtime
|
109
129
|
prerelease: false
|
110
130
|
version_requirements: !ruby/object:Gem::Requirement
|
111
131
|
requirements:
|
112
132
|
- - "~>"
|
113
133
|
- !ruby/object:Gem::Version
|
114
|
-
version: '0.
|
134
|
+
version: '0.18'
|
115
135
|
- !ruby/object:Gem::Dependency
|
116
136
|
name: eac_rest
|
117
137
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,34 +152,28 @@ dependencies:
|
|
132
152
|
requirements:
|
133
153
|
- - "~>"
|
134
154
|
- !ruby/object:Gem::Version
|
135
|
-
version: '0.
|
155
|
+
version: '0.122'
|
136
156
|
type: :runtime
|
137
157
|
prerelease: false
|
138
158
|
version_requirements: !ruby/object:Gem::Requirement
|
139
159
|
requirements:
|
140
160
|
- - "~>"
|
141
161
|
- !ruby/object:Gem::Version
|
142
|
-
version: '0.
|
162
|
+
version: '0.122'
|
143
163
|
- !ruby/object:Gem::Dependency
|
144
164
|
name: eac_templates
|
145
165
|
requirement: !ruby/object:Gem::Requirement
|
146
166
|
requirements:
|
147
167
|
- - "~>"
|
148
168
|
- !ruby/object:Gem::Version
|
149
|
-
version: '0.
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: 0.5.1
|
169
|
+
version: '0.7'
|
153
170
|
type: :runtime
|
154
171
|
prerelease: false
|
155
172
|
version_requirements: !ruby/object:Gem::Requirement
|
156
173
|
requirements:
|
157
174
|
- - "~>"
|
158
175
|
- !ruby/object:Gem::Version
|
159
|
-
version: '0.
|
160
|
-
- - ">="
|
161
|
-
- !ruby/object:Gem::Version
|
162
|
-
version: 0.5.1
|
176
|
+
version: '0.7'
|
163
177
|
- !ruby/object:Gem::Dependency
|
164
178
|
name: inifile
|
165
179
|
requirement: !ruby/object:Gem::Requirement
|
@@ -240,14 +254,14 @@ dependencies:
|
|
240
254
|
requirements:
|
241
255
|
- - "~>"
|
242
256
|
- !ruby/object:Gem::Version
|
243
|
-
version: '0.
|
257
|
+
version: '0.10'
|
244
258
|
type: :development
|
245
259
|
prerelease: false
|
246
260
|
version_requirements: !ruby/object:Gem::Requirement
|
247
261
|
requirements:
|
248
262
|
- - "~>"
|
249
263
|
- !ruby/object:Gem::Version
|
250
|
-
version: '0.
|
264
|
+
version: '0.10'
|
251
265
|
description:
|
252
266
|
email:
|
253
267
|
executables: []
|
@@ -292,6 +306,9 @@ files:
|
|
292
306
|
- lib/ehbrs_ruby_utils/bga/urls.rb
|
293
307
|
- lib/ehbrs_ruby_utils/bga/whatsapp_formatter.rb
|
294
308
|
- lib/ehbrs_ruby_utils/bga/whatsapp_formatter/option.rb
|
309
|
+
- lib/ehbrs_ruby_utils/booking/parsers/list.rb
|
310
|
+
- lib/ehbrs_ruby_utils/booking/processors/list.rb
|
311
|
+
- lib/ehbrs_ruby_utils/booking/processors/list/build_accommodation.rb
|
295
312
|
- lib/ehbrs_ruby_utils/circular_list_spreader.rb
|
296
313
|
- lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
|
297
314
|
- lib/ehbrs_ruby_utils/circular_list_spreader/group_level.rb
|