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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bdf26806118aeff69b17673329ef6fdd83c5cb0b7d7a8c35e77deea83b6add5
4
- data.tar.gz: 7c84a9798b04fc02ebbd4682e2d72f9f868a8c222f6530861579384cf00f24d4
3
+ metadata.gz: baf0e9ec7904fb08d6e6b61a19090848b281b14ce660bbdb8f6ac48f654f71f4
4
+ data.tar.gz: f1a1466caa8d62eb0abed2208651899dc5c4e65ee1a331cdadf5e6b0539ef12c
5
5
  SHA512:
6
- metadata.gz: b9d2397871ae1b390a0d8e320a20634af04378d6a9e45d50305bd59fca64c4662d13894b176fd2a4c917fa409382d51a725b93ca603e322c38251caea67fa4d1
7
- data.tar.gz: 30838173feefaeaf8c1688c358caf1713966a9daa43ab10163f9883bbaea59330e20a5413d5b8f05cbb6de6c52ad1be83cbec58493c235216b3e1c45ef3096ec
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 = html.search(".stlpecn.posun#{stage_index}").first
178
+ stage_element = pool.search(".stlpecn.posun#{stage_index}").first
141
179
  unless stage_element
142
180
  break
143
181
  end
@@ -1,3 +1,3 @@
1
1
  module Sutazekarate
2
- VERSION = '0.0.12'.freeze
2
+ VERSION = '0.0.14'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sutazekarate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmed Al Hafoudh