sutazekarate 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sutazekarate/category.rb +122 -51
- data/lib/sutazekarate/ladder.rb +1 -1
- data/lib/sutazekarate/pool.rb +10 -0
- data/lib/sutazekarate/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec0f9f743ae630e79475e2f4274e6624a5104131ffef05297b4ccb02eb89345a
|
4
|
+
data.tar.gz: 1104cbb6defe911b214491a357c30cd752bb8f30bc131d65c2193e471c90ecd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7340631e55b884dd85b06b86755220a565df0880f7d0f66ddaeb6befd9760c1677123cc1abc436f19ab4f04e359aee950ebd50281d08c5777c501cbeb4a2e2b
|
7
|
+
data.tar.gz: '084e29ab431be9e0c3b1f8363122be60ec900040c803e9b60e5a7f110b2f0cac72b36482bb18065bf57d6d16773706f9d014d64c44b19ee443ba2395b8f934ae'
|
@@ -17,6 +17,10 @@ module Sutazekarate
|
|
17
17
|
attribute :location_color
|
18
18
|
attribute :time_range
|
19
19
|
|
20
|
+
attribute :has_draw_flat
|
21
|
+
attribute :has_draw_ladder
|
22
|
+
attribute :has_results_ladder
|
23
|
+
|
20
24
|
def serializable_hash(options = nil)
|
21
25
|
super.merge(time_begin:, time_end:).except('time_range')
|
22
26
|
end
|
@@ -41,62 +45,32 @@ module Sutazekarate
|
|
41
45
|
end
|
42
46
|
|
43
47
|
def ladder
|
44
|
-
|
45
|
-
|
46
|
-
response = HTTP.get("https://www.sutazekarate.sk/sutaze_kategoriarozl.php?k=#{id}")
|
47
|
-
html = Nokogiri::HTML5(response.body.to_s)
|
48
|
-
|
49
|
-
export_element = html.search('a').find do |elem|
|
50
|
-
elem.attr('href').start_with?('pdf_rozlosovanieexport.php')
|
51
|
-
end
|
52
|
-
export_url = "https://www.sutazekarate.sk/#{export_element.attr('href')}"
|
53
|
-
|
54
|
-
stages = []
|
55
|
-
|
56
|
-
stage_index = 0
|
57
|
-
loop do
|
58
|
-
stage_element = html.search(".stlpecn.posun#{stage_index}").first
|
59
|
-
unless stage_element
|
60
|
-
break
|
61
|
-
end
|
62
|
-
|
63
|
-
pairs = stage_element.search('.obalao').map.with_index do |pair_element, pair_index|
|
64
|
-
competitors = pair_element.search('.okienkopavukR').map do |competitor_element|
|
65
|
-
id_element = competitor_element.search('#sutaziaci').first
|
66
|
-
unless id_element
|
67
|
-
next nil
|
68
|
-
end
|
69
|
-
|
70
|
-
id = competitor_element.search('#sutaziaci').first.attr('value')
|
71
|
-
name = competitor_element.search('.meno').text.strip
|
72
|
-
club = competitor_element.search('.klub').text.strip
|
48
|
+
draw_ladder
|
49
|
+
end
|
73
50
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
club: Club.new(name: club),
|
78
|
-
)
|
79
|
-
end
|
51
|
+
def draw_ladder_url
|
52
|
+
"https://www.sutazekarate.sk/sutaze_kategoriarozl.php?k=#{id}"
|
53
|
+
end
|
80
54
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
competitor2: competitors[1],
|
85
|
-
)
|
86
|
-
end
|
55
|
+
def draw_ladder_export_url
|
56
|
+
"https://www.sutazekarate.sk/pdf_rozlosovanieexport.php?id=#{id}"
|
57
|
+
end
|
87
58
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
59
|
+
def draw_ladder
|
60
|
+
@draw_ladder ||= begin
|
61
|
+
logger.debug("Fetching draw ladder for category #{id}")
|
62
|
+
parse_ladder(draw_ladder_url)
|
63
|
+
end
|
64
|
+
end
|
92
65
|
|
93
|
-
|
94
|
-
|
66
|
+
def results_ladder_url
|
67
|
+
"https://www.sutazekarate.sk/sutaze_kategoriarec.php?k=#{id}"
|
68
|
+
end
|
95
69
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
)
|
70
|
+
def results_ladder
|
71
|
+
@results_ladder ||= begin
|
72
|
+
logger.debug("Fetching results ladder for category #{id}")
|
73
|
+
parse_ladder(results_ladder_url)
|
100
74
|
end
|
101
75
|
end
|
102
76
|
|
@@ -111,6 +85,22 @@ module Sutazekarate
|
|
111
85
|
preload.map(&:value)
|
112
86
|
end
|
113
87
|
|
88
|
+
def self.find(id)
|
89
|
+
response = HTTP.get("https://www.sutazekarate.sk/sutaze_kategoriazoz.php?k=#{id}")
|
90
|
+
html = Nokogiri::HTML5.fragment(response.body.to_s)
|
91
|
+
|
92
|
+
competition_link = html.search('a').find do |x|
|
93
|
+
x.attr('href').starts_with?('sutaze_sutazinf.php')
|
94
|
+
end
|
95
|
+
competition_href = competition_link.attr('href')
|
96
|
+
|
97
|
+
competition_id = Addressable::URI.parse(competition_href).query_values['sutaz']
|
98
|
+
|
99
|
+
Competition.find(competition_id).categories.find do |category|
|
100
|
+
category.id.to_s == id.to_s
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
114
104
|
def self.build(data)
|
115
105
|
detail_element = Nokogiri::HTML5.fragment(data['detail'])
|
116
106
|
id = Addressable::URI.parse(detail_element.search('a').first.attr('href')).query_values['k']
|
@@ -140,6 +130,21 @@ module Sutazekarate
|
|
140
130
|
end
|
141
131
|
discipline = Nokogiri::HTML5.fragment(data['disciplina']).text.strip
|
142
132
|
|
133
|
+
actions_element = Nokogiri::HTML5.fragment(data['detail'])
|
134
|
+
action_urls = actions_element.search('a').map do |a|
|
135
|
+
a.attr('href')
|
136
|
+
end
|
137
|
+
|
138
|
+
has_draw_flat = action_urls.any? do |url|
|
139
|
+
url.start_with?('pdf_rozlosovanieexportrobin.php')
|
140
|
+
end
|
141
|
+
has_draw_ladder = action_urls.any? do |url|
|
142
|
+
url.start_with?('sutaze_kategoriarozl.php')
|
143
|
+
end
|
144
|
+
has_results_ladder = action_urls.any? do |url|
|
145
|
+
url.start_with?('sutaze_kategoriarec.php')
|
146
|
+
end
|
147
|
+
|
143
148
|
new(
|
144
149
|
id:,
|
145
150
|
position: data['pc'],
|
@@ -150,6 +155,72 @@ module Sutazekarate
|
|
150
155
|
location:,
|
151
156
|
location_color:,
|
152
157
|
time_range:,
|
158
|
+
has_draw_flat:,
|
159
|
+
has_draw_ladder:,
|
160
|
+
has_results_ladder:,
|
161
|
+
)
|
162
|
+
end
|
163
|
+
|
164
|
+
private
|
165
|
+
|
166
|
+
def parse_ladder(url)
|
167
|
+
response = HTTP.get(url)
|
168
|
+
html = Nokogiri::HTML5(response.body.to_s)
|
169
|
+
|
170
|
+
pools = []
|
171
|
+
html.search('.pool').map do |pool|
|
172
|
+
title = pool.search('h5,h6').first.text.strip
|
173
|
+
|
174
|
+
stages = []
|
175
|
+
|
176
|
+
stage_index = 0
|
177
|
+
loop do
|
178
|
+
stage_element = html.search(".stlpecn.posun#{stage_index}").first
|
179
|
+
unless stage_element
|
180
|
+
break
|
181
|
+
end
|
182
|
+
|
183
|
+
pairs = stage_element.search('.obalao').map.with_index do |pair_element, pair_index|
|
184
|
+
competitors = pair_element.search('.okienkopavukR').map do |competitor_element|
|
185
|
+
id_element = competitor_element.search('#sutaziaci').first
|
186
|
+
unless id_element
|
187
|
+
next nil
|
188
|
+
end
|
189
|
+
|
190
|
+
id = competitor_element.search('#sutaziaci').first.attr('value')
|
191
|
+
name = competitor_element.search('.meno').text.strip
|
192
|
+
club = competitor_element.search('.klub').text.strip
|
193
|
+
|
194
|
+
Competitor.new(
|
195
|
+
id: id,
|
196
|
+
name: name,
|
197
|
+
club: Club.new(name: club),
|
198
|
+
)
|
199
|
+
end
|
200
|
+
|
201
|
+
Pair.new(
|
202
|
+
index: pair_index,
|
203
|
+
competitor1: competitors[0],
|
204
|
+
competitor2: competitors[1],
|
205
|
+
)
|
206
|
+
end
|
207
|
+
|
208
|
+
stages << Stage.new(
|
209
|
+
index: stage_index,
|
210
|
+
pairs:,
|
211
|
+
)
|
212
|
+
|
213
|
+
stage_index += 1
|
214
|
+
end
|
215
|
+
|
216
|
+
pools << Pool.new(
|
217
|
+
title:,
|
218
|
+
stages:,
|
219
|
+
)
|
220
|
+
end
|
221
|
+
|
222
|
+
Ladder.new(
|
223
|
+
pools:,
|
153
224
|
)
|
154
225
|
end
|
155
226
|
end
|
data/lib/sutazekarate/ladder.rb
CHANGED
data/lib/sutazekarate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sutazekarate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmed Al Hafoudh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- lib/sutazekarate/ladder.rb
|
126
126
|
- lib/sutazekarate/logging.rb
|
127
127
|
- lib/sutazekarate/pair.rb
|
128
|
+
- lib/sutazekarate/pool.rb
|
128
129
|
- lib/sutazekarate/stage.rb
|
129
130
|
- lib/sutazekarate/timetable.rb
|
130
131
|
- lib/sutazekarate/timetable_entry.rb
|