sutazekarate 0.0.12 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sutazekarate/category.rb +39 -1
- data/lib/sutazekarate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baf0e9ec7904fb08d6e6b61a19090848b281b14ce660bbdb8f6ac48f654f71f4
|
4
|
+
data.tar.gz: f1a1466caa8d62eb0abed2208651899dc5c4e65ee1a331cdadf5e6b0539ef12c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eac1714f78149ba110a43d2bc64746c9eb0a2c00cc9aec55936779e5e2eef8a6b2e0b236a6faa97fe36feea8428de3e24e7679a317e1bd64a43037c550b372a6
|
7
|
+
data.tar.gz: 3a88c9e3f8a6e8fadc98867b97d12b345b6f4e1383ae07b618193a61438ffb5d1156b8a65036759dd348a12e8741079da085cf6890eac4a1a99b026429795caa
|
@@ -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
|
@@ -81,6 +85,22 @@ module Sutazekarate
|
|
81
85
|
preload.map(&:value)
|
82
86
|
end
|
83
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
|
+
|
84
104
|
def self.build(data)
|
85
105
|
detail_element = Nokogiri::HTML5.fragment(data['detail'])
|
86
106
|
id = Addressable::URI.parse(detail_element.search('a').first.attr('href')).query_values['k']
|
@@ -110,6 +130,21 @@ module Sutazekarate
|
|
110
130
|
end
|
111
131
|
discipline = Nokogiri::HTML5.fragment(data['disciplina']).text.strip
|
112
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
|
+
|
113
148
|
new(
|
114
149
|
id:,
|
115
150
|
position: data['pc'],
|
@@ -120,6 +155,9 @@ module Sutazekarate
|
|
120
155
|
location:,
|
121
156
|
location_color:,
|
122
157
|
time_range:,
|
158
|
+
has_draw_flat:,
|
159
|
+
has_draw_ladder:,
|
160
|
+
has_results_ladder:,
|
123
161
|
)
|
124
162
|
end
|
125
163
|
|
@@ -137,7 +175,7 @@ module Sutazekarate
|
|
137
175
|
|
138
176
|
stage_index = 0
|
139
177
|
loop do
|
140
|
-
stage_element =
|
178
|
+
stage_element = pool.search(".stlpecn.posun#{stage_index}").first
|
141
179
|
unless stage_element
|
142
180
|
break
|
143
181
|
end
|
data/lib/sutazekarate/version.rb
CHANGED