sutazekarate 0.0.12 → 0.0.13
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 +38 -0
- data/lib/sutazekarate/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: ec0f9f743ae630e79475e2f4274e6624a5104131ffef05297b4ccb02eb89345a
         | 
| 4 | 
            +
              data.tar.gz: 1104cbb6defe911b214491a357c30cd752bb8f30bc131d65c2193e471c90ecd7
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a7340631e55b884dd85b06b86755220a565df0880f7d0f66ddaeb6befd9760c1677123cc1abc436f19ab4f04e359aee950ebd50281d08c5777c501cbeb4a2e2b
         | 
| 7 | 
            +
              data.tar.gz: '084e29ab431be9e0c3b1f8363122be60ec900040c803e9b60e5a7f110b2f0cac72b36482bb18065bf57d6d16773706f9d014d64c44b19ee443ba2395b8f934ae'
         | 
| @@ -17,6 +17,10 @@ module Sutazekarate | |
| 17 17 | 
             
                attribute :location_color
         | 
| 18 18 | 
             
                attribute :time_range
         | 
| 19 19 |  | 
| 20 | 
            +
                attribute :has_draw_flat
         | 
| 21 | 
            +
                attribute :has_draw_ladder
         | 
| 22 | 
            +
                attribute :has_results_ladder
         | 
| 23 | 
            +
             | 
| 20 24 | 
             
                def serializable_hash(options = nil)
         | 
| 21 25 | 
             
                  super.merge(time_begin:, time_end:).except('time_range')
         | 
| 22 26 | 
             
                end
         | 
| @@ -81,6 +85,22 @@ module Sutazekarate | |
| 81 85 | 
             
                  preload.map(&:value)
         | 
| 82 86 | 
             
                end
         | 
| 83 87 |  | 
| 88 | 
            +
                def self.find(id)
         | 
| 89 | 
            +
                  response = HTTP.get("https://www.sutazekarate.sk/sutaze_kategoriazoz.php?k=#{id}")
         | 
| 90 | 
            +
                  html = Nokogiri::HTML5.fragment(response.body.to_s)
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  competition_link = html.search('a').find do |x|
         | 
| 93 | 
            +
                    x.attr('href').starts_with?('sutaze_sutazinf.php')
         | 
| 94 | 
            +
                  end
         | 
| 95 | 
            +
                  competition_href = competition_link.attr('href')
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                  competition_id = Addressable::URI.parse(competition_href).query_values['sutaz']
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                  Competition.find(competition_id).categories.find do |category|
         | 
| 100 | 
            +
                    category.id.to_s == id.to_s
         | 
| 101 | 
            +
                  end
         | 
| 102 | 
            +
                end
         | 
| 103 | 
            +
             | 
| 84 104 | 
             
                def self.build(data)
         | 
| 85 105 | 
             
                  detail_element = Nokogiri::HTML5.fragment(data['detail'])
         | 
| 86 106 | 
             
                  id = Addressable::URI.parse(detail_element.search('a').first.attr('href')).query_values['k']
         | 
| @@ -110,6 +130,21 @@ module Sutazekarate | |
| 110 130 | 
             
                  end
         | 
| 111 131 | 
             
                  discipline = Nokogiri::HTML5.fragment(data['disciplina']).text.strip
         | 
| 112 132 |  | 
| 133 | 
            +
                  actions_element = Nokogiri::HTML5.fragment(data['detail'])
         | 
| 134 | 
            +
                  action_urls = actions_element.search('a').map do |a|
         | 
| 135 | 
            +
                    a.attr('href')
         | 
| 136 | 
            +
                  end
         | 
| 137 | 
            +
             | 
| 138 | 
            +
                  has_draw_flat = action_urls.any? do |url|
         | 
| 139 | 
            +
                    url.start_with?('pdf_rozlosovanieexportrobin.php')
         | 
| 140 | 
            +
                  end
         | 
| 141 | 
            +
                  has_draw_ladder = action_urls.any? do |url|
         | 
| 142 | 
            +
                    url.start_with?('sutaze_kategoriarozl.php')
         | 
| 143 | 
            +
                  end
         | 
| 144 | 
            +
                  has_results_ladder = action_urls.any? do |url|
         | 
| 145 | 
            +
                    url.start_with?('sutaze_kategoriarec.php')
         | 
| 146 | 
            +
                  end
         | 
| 147 | 
            +
             | 
| 113 148 | 
             
                  new(
         | 
| 114 149 | 
             
                    id:,
         | 
| 115 150 | 
             
                    position: data['pc'],
         | 
| @@ -120,6 +155,9 @@ module Sutazekarate | |
| 120 155 | 
             
                    location:,
         | 
| 121 156 | 
             
                    location_color:,
         | 
| 122 157 | 
             
                    time_range:,
         | 
| 158 | 
            +
                    has_draw_flat:,
         | 
| 159 | 
            +
                    has_draw_ladder:,
         | 
| 160 | 
            +
                    has_results_ladder:,
         | 
| 123 161 | 
             
                  )
         | 
| 124 162 | 
             
                end
         | 
| 125 163 |  | 
    
        data/lib/sutazekarate/version.rb
    CHANGED