livescore-parser 0.2.4 → 0.2.5

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
  SHA1:
3
- metadata.gz: 2a9e6cd30830480b169ee638e5aed2ede8e7cb7e
4
- data.tar.gz: 2344222e314be4c29c7069308692ca547a2ab796
3
+ metadata.gz: d7db526d0ec94e4ee859201037f7d4a4466e2a41
4
+ data.tar.gz: 7dd7195331e6a18efff8269a892cf299bdcd1b8c
5
5
  SHA512:
6
- metadata.gz: 8245c7787aaad32c3d5f7e0aea1970910b4a3e8341dcacd237ae2e24b1ff96d739ed5407f368ba5ec0fab60868a3bbff25ac8def7e52967a5b4d7e0e4f43205a
7
- data.tar.gz: bfb49f003dc2d990eb7eefc8e0dc0d70b4a5860aceb54acb2b84d6b977b9be75f7ff6a89b30fd563a610c320e1e4f2a392bfcb4acf1e88e32142547363116927
6
+ metadata.gz: aef5d5beced4cf93140158c2b64dc25ccc31f62ab1d29ee68788dfbeff398c0b924b14c1e2c635cc649804e4d5fb4a48d074d53d39f417a9b2fe9b8ad0288919
7
+ data.tar.gz: e9efb185ff54878104e2cc08cfaa7dd1a3ff2382f484cac437ffdc1472c7b52653e249587fb510af10620ade1ff9df5ea331dd2de94e32c5d33e404b6718162c
@@ -5,7 +5,7 @@ module LivescoreParser
5
5
 
6
6
  def initialize
7
7
  @agent = Mechanize.new
8
- @offset = Time.new.utc_offset + (7 * 3600)
8
+ @offset = Time.new.utc_offset + (5 * 3600)
9
9
  cookie = Mechanize::Cookie.new('tz', (@offset / 3600).to_s)
10
10
  cookie.path = '/'
11
11
  cookie.domain = '.www.livescore.com'
@@ -41,21 +41,23 @@ module LivescoreParser
41
41
  if row.attr('class').match 'row-gray'
42
42
  index += 1
43
43
  time_raw = row.css('.min').text.strip
44
+ local_time = Time.parse(time_raw) + Time.new.utc_offset - @offset
45
+ local_date = local_time.hour >= 19 ? @date.clone - 1 : @date.clone
44
46
  {
45
47
  wiersz: index,
46
- czas: (time_raw.match(/[0-9]+:[0-9]+/)) ? (Time.parse(time_raw) + Time.new.utc_offset - @offset).strftime('%H:%M') : time_raw,
48
+ czas: (time_raw.match(/[0-9]+:[0-9]+/)) ? local_time.strftime('%H:%M') : time_raw,
47
49
  gracz1: row.css('.ply.tright').text.strip,
48
50
  wynik1: row.css('.sco').text.strip.match(/^[0-9\?]+/).to_s,
49
51
  gracz2: row.css('.sco + .ply').text.strip,
50
52
  wynik2: row.css('.sco').text.strip.match(/[0-9\?]+$/).to_s,
51
- data: @date.clone,
53
+ data: local_date.strftime('%B %d'),
52
54
  kraj: @country.clone,
53
55
  liga: @league.clone
54
56
  }
55
57
  elsif row.attr('class').match 'row-tall'
56
58
  @country = row.css('.left a:first').text.strip
57
59
  @league = row.css('.left a:last').text.strip
58
- @date = row.css('.right').text.strip
60
+ @date = Date.parse(row.css('.right').text.strip)
59
61
  next
60
62
  end
61
63
  end.compact
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: livescore-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Walusiak