sutazekarate 0.0.2 → 0.0.4

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: db3b38cd0e8e4f30e8796dfd99d6e7c39bf16e93ac5bee5ee7b73d90b3d0ec72
4
- data.tar.gz: 04f525328de88f9d671f4367f9b21d9f165e3a4d184a3f852fb28cea9139f9d5
3
+ metadata.gz: 678ab912a5edb8966d3d0786498be4a12704fdb4acc88faf17773bd3ca22dfa2
4
+ data.tar.gz: e3d3e9bfcb6b4d91179f277cbd425675c4457ce7dfe75c78c161da02f6bb1361
5
5
  SHA512:
6
- metadata.gz: a9397ff54023e8cfa5b0ff0607ebba550dd602f35fa0d0ed029ab26fa6818540c3896706eecb91a1b5eeb9ad894b80ed171bef7fb88f7f30ec376e5f5ae15eb0
7
- data.tar.gz: 1b6e027d0d888bce41663e45d990f74674cf85058610ddfe78cfe11821055cb7670b02ec300d422e4f7beca6c8bcb790f8c6a9434c261f14dadff077c071660a
6
+ metadata.gz: 5f7ab68644f22ce4437d2b95fbcb566b0b5bb9a47f63b27f1ce0feadc6b573bf268c5cd5da50b93f6d3a66e8ae4f2a5c1c8d060454777bbb8533128d21d86d93
7
+ data.tar.gz: dc3331cb587f9ec83b1f5059773f1b2c602847dc57f4bf58513f5404e0a39b3f7ab70cd171f8a53250a080f88f592f6de628467b479ffa4e1af30e34d8aed901
@@ -15,6 +15,14 @@ module Sutazekarate
15
15
  attribute :location_color
16
16
  attribute :time_range
17
17
 
18
+ def time_begin
19
+ time_range.begin
20
+ end
21
+
22
+ def time_end
23
+ time_range.end
24
+ end
25
+
18
26
  def competitors
19
27
  @competitors ||= begin
20
28
  logger.debug("Fetching competitors for category #{id}")
@@ -86,6 +94,17 @@ module Sutazekarate
86
94
  end
87
95
  end
88
96
 
97
+ def preload
98
+ [
99
+ async.competitors,
100
+ async.ladder,
101
+ ]
102
+ end
103
+
104
+ def preload!
105
+ preload.map(&:value)
106
+ end
107
+
89
108
  def self.build(data)
90
109
  detail_element = Nokogiri::HTML5.fragment(data['detail'])
91
110
  id = Addressable::URI.parse(detail_element.search('a').first.attr('href')).query_values['k']
@@ -5,6 +5,7 @@ module Sutazekarate
5
5
  include ActiveModel::Serializers::JSON
6
6
 
7
7
  include Logging
8
+
8
9
  class << self
9
10
  include Logging
10
11
  end
@@ -31,6 +32,41 @@ module Sutazekarate
31
32
  end
32
33
  end
33
34
 
35
+ def preload
36
+ categories.map do |category|
37
+ category.async.preload
38
+ end.flatten
39
+ end
40
+
41
+ def preload!
42
+ preload.map(&:value)
43
+ end
44
+
45
+ def timetables
46
+ @timetables ||= begin
47
+ categories
48
+ .group_by(&:location)
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
59
+
60
+ Timetable.new(
61
+ location:,
62
+ entries:,
63
+ )
64
+ end
65
+ end
66
+ rescue => ex
67
+ binding.irb
68
+ end
69
+
34
70
  def self.all(year: Date.today.year)
35
71
  logger.debug("Fetching competitions for year #{year}")
36
72
  response = HTTP.get("https://www.sutazekarate.sk/ajax/av_sutaze.php?lang=sk&r=#{year}&sort=datum&order=desc&limit=1000&offset=0")
@@ -0,0 +1,10 @@
1
+ module Sutazekarate
2
+ class Timetable
3
+ include ActiveModel::Model
4
+ include ActiveModel::Attributes
5
+ include ActiveModel::Serializers::JSON
6
+
7
+ attribute :location
8
+ attribute :entries
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ module Sutazekarate
2
+ class TimetableEntry
3
+ include ActiveModel::Model
4
+ include ActiveModel::Attributes
5
+ include ActiveModel::Serializers::JSON
6
+
7
+ attribute :category
8
+ attribute :time_range
9
+
10
+ def time_begin
11
+ time_range.begin
12
+ end
13
+
14
+ def time_end
15
+ time_range.end
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Sutazekarate
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.4'.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.2
4
+ version: 0.0.4
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 00:00:00.000000000 Z
11
+ date: 2024-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -126,6 +126,8 @@ files:
126
126
  - lib/sutazekarate/logging.rb
127
127
  - lib/sutazekarate/pair.rb
128
128
  - lib/sutazekarate/stage.rb
129
+ - lib/sutazekarate/timetable.rb
130
+ - lib/sutazekarate/timetable_entry.rb
129
131
  - lib/sutazekarate/version.rb
130
132
  homepage: https://github.com/alhafoudh/sutazekarate
131
133
  licenses: