sutazekarate 0.0.6 → 0.0.8
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 +8 -3
- data/lib/sutazekarate/competition.rb +6 -16
- data/lib/sutazekarate/timetable.rb +13 -0
- data/lib/sutazekarate/timetable_entry.rb +18 -0
- data/lib/sutazekarate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46c5e24e72aee40b8888d2b57ed84a7d37f9bb9888a2b704ae7ac452f079d2fd
|
4
|
+
data.tar.gz: c2b6c9b7f62a6b849c7483b2ea81deac0a36a67e09621c680c5d0e54dddc260e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56750003dfe9b909d58e32bb99c6eb3e6e35757c939f01fdbfc8a14e79d64a44e8011035fc323da998bdd5209f99b88ba12986eb3db41448241c28dc2528dba5
|
7
|
+
data.tar.gz: bd625c28c312ff1ea7b41a2573e9bc3b7630ee796fcaaa899db7d07a094ed8bbd112ccc95cb6be730ea46a62aa542e3c3b5ce519393bcad78aeaf957df99f12a
|
@@ -11,6 +11,7 @@ module Sutazekarate
|
|
11
11
|
attribute :position
|
12
12
|
attribute :name
|
13
13
|
attribute :discipline
|
14
|
+
attribute :duration
|
14
15
|
attribute :location
|
15
16
|
attribute :location_color
|
16
17
|
attribute :time_range
|
@@ -20,11 +21,11 @@ module Sutazekarate
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def time_begin
|
23
|
-
time_range
|
24
|
+
time_range&.begin
|
24
25
|
end
|
25
26
|
|
26
27
|
def time_end
|
27
|
-
time_range
|
28
|
+
time_range&.end
|
28
29
|
end
|
29
30
|
|
30
31
|
def competitors
|
@@ -114,7 +115,10 @@ module Sutazekarate
|
|
114
115
|
id = Addressable::URI.parse(detail_element.search('a').first.attr('href')).query_values['k']
|
115
116
|
category_element = Nokogiri::HTML5.fragment(data['kategoria'])
|
116
117
|
category_span_elements = category_element.search('span')
|
117
|
-
|
118
|
+
name_raw = category_span_elements[0].text.strip
|
119
|
+
name_match = name_raw.match(/^([^(\/]+?)\s*(?:\(([^)]+)\))?\s*(?:\/([^\/]+)\/)?$/)
|
120
|
+
name = name_match[1]
|
121
|
+
duration = name_match[3]
|
118
122
|
detail_element = category_span_elements[1]
|
119
123
|
location = nil
|
120
124
|
location_color = nil
|
@@ -133,6 +137,7 @@ module Sutazekarate
|
|
133
137
|
position: data['pc'],
|
134
138
|
name:,
|
135
139
|
discipline:,
|
140
|
+
duration:,
|
136
141
|
location:,
|
137
142
|
location_color:,
|
138
143
|
time_range:,
|
@@ -44,23 +44,13 @@ module Sutazekarate
|
|
44
44
|
|
45
45
|
def timetables
|
46
46
|
@timetables ||= begin
|
47
|
-
|
48
|
-
|
49
|
-
.map do |location, location_categories|
|
50
|
-
entries = location_categories
|
51
|
-
.select { |category| category.time_range.present? }
|
52
|
-
.sort_by { |category| category.time_range.begin }
|
53
|
-
.map do |location_category|
|
54
|
-
TimetableEntry.new(
|
55
|
-
category: location_category,
|
56
|
-
time_range: location_category.time_range,
|
57
|
-
)
|
58
|
-
end
|
47
|
+
logger.debug("Fetching timetable for competition #{id}")
|
48
|
+
response = HTTP.get("https://sutazekarate.sk/pdf_timetable3.php?sutaz=#{id}")
|
59
49
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
)
|
50
|
+
html = Nokogiri::HTML5.fragment(response.body.to_s)
|
51
|
+
|
52
|
+
html.search('.divttm').map do |location_element|
|
53
|
+
Timetable.build(location_element, categories:)
|
64
54
|
end
|
65
55
|
end
|
66
56
|
end
|
@@ -6,5 +6,18 @@ module Sutazekarate
|
|
6
6
|
|
7
7
|
attribute :location
|
8
8
|
attribute :entries
|
9
|
+
|
10
|
+
def self.build(location_element, categories: [])
|
11
|
+
location = location_element.search('.hlavicka').text.strip
|
12
|
+
|
13
|
+
entries = location_element.search('ul li').map do |entry_element|
|
14
|
+
TimetableEntry.build(entry_element, categories:)
|
15
|
+
end
|
16
|
+
|
17
|
+
Timetable.new(
|
18
|
+
location:,
|
19
|
+
entries:,
|
20
|
+
)
|
21
|
+
end
|
9
22
|
end
|
10
23
|
end
|
@@ -4,6 +4,7 @@ module Sutazekarate
|
|
4
4
|
include ActiveModel::Attributes
|
5
5
|
include ActiveModel::Serializers::JSON
|
6
6
|
|
7
|
+
attribute :title
|
7
8
|
attribute :category
|
8
9
|
attribute :time_range
|
9
10
|
|
@@ -18,5 +19,22 @@ module Sutazekarate
|
|
18
19
|
def time_end
|
19
20
|
time_range.end
|
20
21
|
end
|
22
|
+
|
23
|
+
def self.build(entry_element, categories: [])
|
24
|
+
title = entry_element.children.first.text.strip
|
25
|
+
time_range_raw = entry_element.children.last.text.strip
|
26
|
+
time_range_match = time_range_raw.match(/(\d+:\d+) - (\d+:\d+)/)
|
27
|
+
time_range = Time.zone.parse(time_range_match[1])..Time.zone.parse(time_range_match[2])
|
28
|
+
|
29
|
+
category = categories.find do |category|
|
30
|
+
category.name == title
|
31
|
+
end
|
32
|
+
|
33
|
+
TimetableEntry.new(
|
34
|
+
category:,
|
35
|
+
title:,
|
36
|
+
time_range:,
|
37
|
+
)
|
38
|
+
end
|
21
39
|
end
|
22
40
|
end
|
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.8
|
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-
|
11
|
+
date: 2024-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|