pandata 0.3.1 → 0.3.2

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
  SHA1:
3
- metadata.gz: fb5a92a63800d0ff36db81a216df6e872088e325
4
- data.tar.gz: e4d9e93ceb1cfd76135af22bec7c17d96db2b787
3
+ metadata.gz: 5684ea1131bb37e801e876ee9254aab0c4345181
4
+ data.tar.gz: 389e6e95566908e33af0594b8b23665992eb5656
5
5
  SHA512:
6
- metadata.gz: 33172828630f417b6ab84a6de9e589af8390d9630a052a597ebfa72a475f68028ae2912d3e38a0bae378c21ab5b338c1c94a2ed418d005d4da077d3e8f722719
7
- data.tar.gz: f63b4be008fdcac395c56c4a27a44a26dcd52bf717b38b763b9214842cdfd9bae2c6294a6a020bc9980b52c062d229a744faeaf0310db1733d50b017c969f077
6
+ metadata.gz: 09151cd32fc590f8b5845a420beb755e0e838de347c2646ff6587246f02c8e62cf05d8e0d653cd7a3adb3b16c54d1181a8446eb96a48a6e35e4320ed275b3603
7
+ data.tar.gz: 4f8e3e68fe6a648d8defee3ff39623e9260b9267cd5411f5cbf34583b3a6aba8a3c598db86b0e54cdddae86af047f371f1b55d8c6db6a0f51ffe178ec506f019
data/lib/pandata.rb CHANGED
@@ -11,7 +11,7 @@ module Pandata
11
11
  module Version
12
12
  MAJOR = 0
13
13
  MINOR = 3
14
- PATCH = 1
14
+ PATCH = 2
15
15
  BUILD = nil
16
16
 
17
17
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -10,20 +10,23 @@ module Pandata
10
10
  # A GitHub Gist that contains an updated cookie allowing access to 'login-only' visible data.
11
11
  CONFIG_URL = 'https://gist.github.com/ustasb/596f1ee96d03463fde77/raw/pandata_config.json'
12
12
 
13
- # The cached config hash.
14
- @@config = nil
15
-
16
13
  # Downloads and reads a page from a URL.
17
14
  # @param url [String]
18
15
  # @return [String] contents of page
19
16
  def self.read_page(url)
20
- download(url, get_config['cookie']).read
17
+ download(url, session['cookie']).read
21
18
  end
22
19
 
23
20
  # Returns a pat token needed for mobile requests.
24
21
  # @return [String]
25
22
  def self.get_pat
26
- get_config['pat']
23
+ session['pat']
24
+ end
25
+
26
+ # Manually sets the cached session.
27
+ # @return [Hash]
28
+ def self.set_session(session)
29
+ @@session = session
27
30
  end
28
31
 
29
32
  private
@@ -42,18 +45,18 @@ module Pandata
42
45
  raise PandataError
43
46
  end
44
47
 
45
- def self.get_config
46
- @@config ||= download_config
48
+ def self.session
49
+ @@session ||= get_random_session
47
50
  end
48
51
 
49
- def self.download_config
52
+ def self.get_random_session
50
53
  config = JSON.parse download(CONFIG_URL).read
51
54
 
52
55
  if Gem::Version.new(Pandata::Version::STRING) <= Gem::Version.new(config['required_update_for'])
53
56
  raise PandataError, 'Pandora.com has changed something and you need to update Pandata!'
54
57
  end
55
58
 
56
- config
59
+ config['sessions'].sample
57
60
  end
58
61
 
59
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pandata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Ustas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-05 00:00:00.000000000 Z
11
+ date: 2014-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri