sutazekarate 0.0.6 → 0.0.7
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 +6 -1
- 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: 4fe3b7751ee725981c6ca1c168f2d1453d1af0ed9732c891ad5c29a37a2b9766
|
4
|
+
data.tar.gz: 3c97f7ac6de44a2835938f66823dc7631fc1a308000205977fd634d6d28e065e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39b5978a5036822560c1bf91b9cbf1f940b8681bfb0dd2d4dc31035f9a8e5c243566df1e9c18ff933761010412d99bca16fa90f7cff18d40825343eefaa7bc33
|
7
|
+
data.tar.gz: 11b94fea3be8b6ff9197700f88307f5f56651b57c63195f968f348d5bd00500b8a6ab6a24ad180fbd739ebbeb5e62c7dd4c7d42a23e2127f581f1f2fde7ce09a
|
@@ -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
|
@@ -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.7
|
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-09-
|
11
|
+
date: 2024-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|