sutazekarate 0.0.9 → 0.0.10

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: d634c436128b74a8c862220ff7b580d25257cae676e63dbec3644fd2b0f13fe8
4
- data.tar.gz: 71c32e15098702df9dc23b2cc9bba33e6ac3d02f11b68fdb6111385519ae429b
3
+ metadata.gz: 4caf8697bf7ba6bfa70a5ea0311069bbc5fe1e0063c176e5f62a92040574280e
4
+ data.tar.gz: 96755e454433675a5f74296bd5e25e4c576ca244cdfe2087ba444ddde1aa0cc9
5
5
  SHA512:
6
- metadata.gz: cf52132698ba781788f20d3b4dfc2dc2a5c90ea5495aacfc9e778303b5df4eb47251f639ea9bc9fc2be31f72d356530f0d5653ee98cd33afc7b33b7c634afd6c
7
- data.tar.gz: bd0e81a7c1e77f38cdaa2333c0c9d6b554427f4cb0febe896dc48441b3c6eee38f08d18afaf8fa94406a97ada1e91204986ac8ffa9407ca71b7b98041031bd4b
6
+ metadata.gz: d75859d0a13c4a56230ce20753545e3cffe38480d9a195e40f87f9274dc63ac7018cd6e76c333dad7264f11a5553fb8345737eaa65dbc4a5b447046a4f08430d
7
+ data.tar.gz: abd7ede1653478ed7ccc13354868269707dc5e3a399d0f53e2bb960b3d5ad2839a6ceaeeb016b971f3838bdfa4193e76d95c07b1790b6ec374ee088a510a9c07
@@ -20,6 +20,7 @@ module Sutazekarate
20
20
  attribute :note
21
21
  attribute :registration_starts_at
22
22
  attribute :registration_ends_at
23
+ attribute :attachments
23
24
 
24
25
  def categories
25
26
  @categories ||= begin
@@ -55,6 +56,42 @@ module Sutazekarate
55
56
  end
56
57
  end
57
58
 
59
+ def self.find(id)
60
+ logger.debug("Fetching competition with id #{id}")
61
+
62
+ response = HTTP.get("https://www.sutazekarate.sk/sutaze_sutazinf.php?sutaz=#{id}")
63
+ html = Nokogiri::HTML5.fragment(response.body.to_s)
64
+
65
+ name = html.search('h3.section-title-inner').text.strip.rpartition(' - ').first
66
+ club = html.search('.table1 tr:nth-child(1) td:nth-child(2)').text.strip
67
+
68
+ starts_at = Date.parse(html.search('.table1 tr:nth-child(2) td:nth-child(2)').text.strip)
69
+
70
+ registration_info = html.search('.table1 tr:nth-child(4) td:nth-child(2)').text.strip
71
+ registration_starts_at, registration_ends_at = registration_info.split(' - ').map do |date|
72
+ Date.parse(date)
73
+ end
74
+
75
+ attachments = html.search('.table1 tr').reduce([]) do |acc, row|
76
+ acc += row.search('td:nth-child(2) a[target="_blank"]').map do |a|
77
+ "https://www.sutazekarate.sk/#{a.attr('href')}"
78
+ end
79
+ .grep_v(/\.php/)
80
+
81
+ acc
82
+ end
83
+
84
+ Competition.new(
85
+ id:,
86
+ starts_at:,
87
+ name:,
88
+ club:,
89
+ registration_starts_at:,
90
+ registration_ends_at:,
91
+ attachments:,
92
+ )
93
+ end
94
+
58
95
  def self.all(year: Date.today.year)
59
96
  logger.debug("Fetching competitions for year #{year}")
60
97
  response = HTTP.get("https://www.sutazekarate.sk/ajax/av_sutaze.php?lang=sk&r=#{year}&sort=datum&order=desc&limit=1000&offset=0")
@@ -1,3 +1,3 @@
1
1
  module Sutazekarate
2
- VERSION = '0.0.9'.freeze
2
+ VERSION = '0.0.10'.freeze
3
3
  end
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.9
4
+ version: 0.0.10
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: 2024-10-05 00:00:00.000000000 Z
11
+ date: 2025-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  - !ruby/object:Gem::Version
151
151
  version: '0'
152
152
  requirements: []
153
- rubygems_version: 3.5.17
153
+ rubygems_version: 3.5.23
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: Web scraper for www.sutazekarate.sk