sutazekarate 0.0.1 → 0.0.3

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: eae254383108ccb05e4697c0c45278a5f89516b69dfcd7d030460bbcd64d32ec
4
- data.tar.gz: 9dd2c18dd3460b48f4114104f283511ce628e0d3cb88f0690c2408de841d0095
3
+ metadata.gz: be750e224efbe31f18b5f39a8257cbe564adccfce9b0b33955cd3c8df3ad5249
4
+ data.tar.gz: 27211570c97e08a89f519dacee0f74fffab5b918d915ec87c12b2b3c0d2f7c43
5
5
  SHA512:
6
- metadata.gz: b440cb40afe838d89f231324e526243173ffeba1533c4743d64ab1105134dce1d002094f0747886c3f4e89d10f0f0bc50abf30bdb8cc4ee163d527e74f26c629
7
- data.tar.gz: 537289598cbeebf9d35d00509d98bfe30f7eb1625b11e57ec2550df636af0278fdafc67577b857a41ac76b0c60d670667e35987296fd24a36d857de7f33a9094
6
+ metadata.gz: b2d769a966c44209609d3ed92f412c53418751a3e34e0539226ff265e96f7b9049c2356ca7c7c9c7c583ded0676371c505646bbde6ca10e1669526153cb952c1
7
+ data.tar.gz: 45e5c29858a4cc0adcf8f08bb947542c75b978d9dde8c3c798bb818422f63cccb01f8d84d73e9bea836ae3145a22b91ac799d56470e9156cbba8813e0ca45794
data/README.md CHANGED
@@ -18,6 +18,16 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install sutazekarate
20
20
 
21
+ ## Usage
22
+
23
+ List all competitions
24
+
25
+ puts Sutazekarate::Competition.all
26
+
27
+ List all categories for competition
28
+
29
+ puts competition.categories
30
+
21
31
  ## Development
22
32
 
23
33
  After checking out the repo, run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -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.1'.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.1
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,12 +126,14 @@ 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
- homepage: https://www.freevision.sk
132
+ homepage: https://github.com/alhafoudh/sutazekarate
131
133
  licenses:
132
134
  - MIT
133
135
  metadata:
134
- homepage_uri: https://www.freevision.sk
136
+ homepage_uri: https://github.com/alhafoudh/sutazekarate
135
137
  rubygems_mfa_required: 'true'
136
138
  post_install_message:
137
139
  rdoc_options: []