sutazekarate 0.0.12 → 0.0.13

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: ec0f9f743ae630e79475e2f4274e6624a5104131ffef05297b4ccb02eb89345a
4
+ data.tar.gz: 1104cbb6defe911b214491a357c30cd752bb8f30bc131d65c2193e471c90ecd7
5
5
  SHA512:
6
- metadata.gz: b9d2397871ae1b390a0d8e320a20634af04378d6a9e45d50305bd59fca64c4662d13894b176fd2a4c917fa409382d51a725b93ca603e322c38251caea67fa4d1
7
- data.tar.gz: 30838173feefaeaf8c1688c358caf1713966a9daa43ab10163f9883bbaea59330e20a5413d5b8f05cbb6de6c52ad1be83cbec58493c235216b3e1c45ef3096ec
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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Sutazekarate
2
- VERSION = '0.0.12'.freeze
2
+ VERSION = '0.0.13'.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.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmed Al Hafoudh