sutazekarate 0.0.10 → 0.0.12
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 +84 -51
- data/lib/sutazekarate/competition.rb +8 -0
- 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: 1bdf26806118aeff69b17673329ef6fdd83c5cb0b7d7a8c35e77deea83b6add5
|
4
|
+
data.tar.gz: 7c84a9798b04fc02ebbd4682e2d72f9f868a8c222f6530861579384cf00f24d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9d2397871ae1b390a0d8e320a20634af04378d6a9e45d50305bd59fca64c4662d13894b176fd2a4c917fa409382d51a725b93ca603e322c38251caea67fa4d1
|
7
|
+
data.tar.gz: 30838173feefaeaf8c1688c358caf1713966a9daa43ab10163f9883bbaea59330e20a5413d5b8f05cbb6de6c52ad1be83cbec58493c235216b3e1c45ef3096ec
|
@@ -41,62 +41,32 @@ module Sutazekarate
|
|
41
41
|
end
|
42
42
|
|
43
43
|
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
|
44
|
+
draw_ladder
|
45
|
+
end
|
73
46
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
club: Club.new(name: club),
|
78
|
-
)
|
79
|
-
end
|
47
|
+
def draw_ladder_url
|
48
|
+
"https://www.sutazekarate.sk/sutaze_kategoriarozl.php?k=#{id}"
|
49
|
+
end
|
80
50
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
competitor2: competitors[1],
|
85
|
-
)
|
86
|
-
end
|
51
|
+
def draw_ladder_export_url
|
52
|
+
"https://www.sutazekarate.sk/pdf_rozlosovanieexport.php?id=#{id}"
|
53
|
+
end
|
87
54
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
55
|
+
def draw_ladder
|
56
|
+
@draw_ladder ||= begin
|
57
|
+
logger.debug("Fetching draw ladder for category #{id}")
|
58
|
+
parse_ladder(draw_ladder_url)
|
59
|
+
end
|
60
|
+
end
|
92
61
|
|
93
|
-
|
94
|
-
|
62
|
+
def results_ladder_url
|
63
|
+
"https://www.sutazekarate.sk/sutaze_kategoriarec.php?k=#{id}"
|
64
|
+
end
|
95
65
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
)
|
66
|
+
def results_ladder
|
67
|
+
@results_ladder ||= begin
|
68
|
+
logger.debug("Fetching results ladder for category #{id}")
|
69
|
+
parse_ladder(results_ladder_url)
|
100
70
|
end
|
101
71
|
end
|
102
72
|
|
@@ -152,5 +122,68 @@ module Sutazekarate
|
|
152
122
|
time_range:,
|
153
123
|
)
|
154
124
|
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
def parse_ladder(url)
|
129
|
+
response = HTTP.get(url)
|
130
|
+
html = Nokogiri::HTML5(response.body.to_s)
|
131
|
+
|
132
|
+
pools = []
|
133
|
+
html.search('.pool').map do |pool|
|
134
|
+
title = pool.search('h5,h6').first.text.strip
|
135
|
+
|
136
|
+
stages = []
|
137
|
+
|
138
|
+
stage_index = 0
|
139
|
+
loop do
|
140
|
+
stage_element = html.search(".stlpecn.posun#{stage_index}").first
|
141
|
+
unless stage_element
|
142
|
+
break
|
143
|
+
end
|
144
|
+
|
145
|
+
pairs = stage_element.search('.obalao').map.with_index do |pair_element, pair_index|
|
146
|
+
competitors = pair_element.search('.okienkopavukR').map do |competitor_element|
|
147
|
+
id_element = competitor_element.search('#sutaziaci').first
|
148
|
+
unless id_element
|
149
|
+
next nil
|
150
|
+
end
|
151
|
+
|
152
|
+
id = competitor_element.search('#sutaziaci').first.attr('value')
|
153
|
+
name = competitor_element.search('.meno').text.strip
|
154
|
+
club = competitor_element.search('.klub').text.strip
|
155
|
+
|
156
|
+
Competitor.new(
|
157
|
+
id: id,
|
158
|
+
name: name,
|
159
|
+
club: Club.new(name: club),
|
160
|
+
)
|
161
|
+
end
|
162
|
+
|
163
|
+
Pair.new(
|
164
|
+
index: pair_index,
|
165
|
+
competitor1: competitors[0],
|
166
|
+
competitor2: competitors[1],
|
167
|
+
)
|
168
|
+
end
|
169
|
+
|
170
|
+
stages << Stage.new(
|
171
|
+
index: stage_index,
|
172
|
+
pairs:,
|
173
|
+
)
|
174
|
+
|
175
|
+
stage_index += 1
|
176
|
+
end
|
177
|
+
|
178
|
+
pools << Pool.new(
|
179
|
+
title:,
|
180
|
+
stages:,
|
181
|
+
)
|
182
|
+
end
|
183
|
+
|
184
|
+
Ladder.new(
|
185
|
+
pools:,
|
186
|
+
)
|
187
|
+
end
|
155
188
|
end
|
156
189
|
end
|
@@ -13,6 +13,7 @@ module Sutazekarate
|
|
13
13
|
include Concurrent::Async
|
14
14
|
|
15
15
|
attribute :id
|
16
|
+
attribute :image_url
|
16
17
|
attribute :starts_at
|
17
18
|
attribute :name
|
18
19
|
attribute :club
|
@@ -62,6 +63,8 @@ module Sutazekarate
|
|
62
63
|
response = HTTP.get("https://www.sutazekarate.sk/sutaze_sutazinf.php?sutaz=#{id}")
|
63
64
|
html = Nokogiri::HTML5.fragment(response.body.to_s)
|
64
65
|
|
66
|
+
image_path = html.search('img.img-responsive.no-margin').attr('src').value
|
67
|
+
image_url = "https://www.sutazekarate.sk/#{image_path}"
|
65
68
|
name = html.search('h3.section-title-inner').text.strip.rpartition(' - ').first
|
66
69
|
club = html.search('.table1 tr:nth-child(1) td:nth-child(2)').text.strip
|
67
70
|
|
@@ -83,6 +86,7 @@ module Sutazekarate
|
|
83
86
|
|
84
87
|
Competition.new(
|
85
88
|
id:,
|
89
|
+
image_url:,
|
86
90
|
starts_at:,
|
87
91
|
name:,
|
88
92
|
club:,
|
@@ -99,7 +103,10 @@ module Sutazekarate
|
|
99
103
|
rows.map do |row|
|
100
104
|
starts_at = Date.parse(row['datum'])
|
101
105
|
content = Nokogiri::HTML5.fragment(row['obsah'])
|
106
|
+
image = Nokogiri::HTML5.fragment(row['obrazok'])
|
102
107
|
|
108
|
+
image_path = image.search('img').attr('src').value
|
109
|
+
image_url = "https://www.sutazekarate.sk/#{image_path}"
|
103
110
|
name = content.search('h4').first.text.strip
|
104
111
|
club_element = content.search('h5').first
|
105
112
|
club = club_element.text.strip
|
@@ -122,6 +129,7 @@ module Sutazekarate
|
|
122
129
|
|
123
130
|
Competition.new(
|
124
131
|
id:,
|
132
|
+
image_url:,
|
125
133
|
starts_at:,
|
126
134
|
name:,
|
127
135
|
club:,
|
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.12
|
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
|