sutazekarate 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db3b38cd0e8e4f30e8796dfd99d6e7c39bf16e93ac5bee5ee7b73d90b3d0ec72
4
- data.tar.gz: 04f525328de88f9d671f4367f9b21d9f165e3a4d184a3f852fb28cea9139f9d5
3
+ metadata.gz: be750e224efbe31f18b5f39a8257cbe564adccfce9b0b33955cd3c8df3ad5249
4
+ data.tar.gz: 27211570c97e08a89f519dacee0f74fffab5b918d915ec87c12b2b3c0d2f7c43
5
5
  SHA512:
6
- metadata.gz: a9397ff54023e8cfa5b0ff0607ebba550dd602f35fa0d0ed029ab26fa6818540c3896706eecb91a1b5eeb9ad894b80ed171bef7fb88f7f30ec376e5f5ae15eb0
7
- data.tar.gz: 1b6e027d0d888bce41663e45d990f74674cf85058610ddfe78cfe11821055cb7670b02ec300d422e4f7beca6c8bcb790f8c6a9434c261f14dadff077c071660a
6
+ metadata.gz: b2d769a966c44209609d3ed92f412c53418751a3e34e0539226ff265e96f7b9049c2356ca7c7c9c7c583ded0676371c505646bbde6ca10e1669526153cb952c1
7
+ data.tar.gz: 45e5c29858a4cc0adcf8f08bb947542c75b978d9dde8c3c798bb818422f63cccb01f8d84d73e9bea836ae3145a22b91ac799d56470e9156cbba8813e0ca45794
@@ -86,6 +86,17 @@ module Sutazekarate
86
86
  end
87
87
  end
88
88
 
89
+ def preload
90
+ [
91
+ async.competitors,
92
+ async.ladder,
93
+ ]
94
+ end
95
+
96
+ def preload!
97
+ preload.map(&:value)
98
+ end
99
+
89
100
  def self.build(data)
90
101
  detail_element = Nokogiri::HTML5.fragment(data['detail'])
91
102
  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,10 @@
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
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Sutazekarate
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.0.3'.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.3
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: