epicmix 0.0.1 → 0.0.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: da2ead05f84353d93f5fb91d99fb2171a5ef503c
4
- data.tar.gz: ec90436db7b4327b512f9bd7fa85987e244fe376
3
+ metadata.gz: 4038947f18b886ab07057c5de5a92a175dc1581c
4
+ data.tar.gz: 5758a06abdcb0d6ca34145288c90970b81963d0d
5
5
  SHA512:
6
- metadata.gz: aca5f9f1984ce68126ed37d80caddf0617d443c8f9244448310f3d45546a91c365a1bd374bd073daaa6eb7469d860418ecb8854f6179150ab915dc8460c2fcf8
7
- data.tar.gz: 3f844e571fd02cf4e5b2b6cc8e5c60c230907eb685134695f864326fcb36d53da75c3639ac5ab64e207f2119bea823fa85f99407340841056fd7703923b9e234
6
+ metadata.gz: 2b463525c08d283aa0fe6057b86ac7847d3e4a7903ccfc58a1c0018ad2bdd2f4ab2e0a17d416479e7da9cc021637bbc65d26ae31106ec9d2f0f6ef54f594767a
7
+ data.tar.gz: e2a48c9c850e0555e1b38e2b279c1ada5f4c7a7fd3cbae0c69c81ca52a690982bd87ef2a8eaa5b4b3b33036cf85bcf0fc2eb849def71785876ccb92d73aa0d4f
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ # - 1.9.3
4
+ # - 1.9.2
5
+ # - jruby-18mode
6
+ # - jruby-19mode
7
+ # - rbx-2.1.1
8
+ - ruby-head
9
+ - jruby-head
10
+ # - 1.8.7
11
+ # - ree
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in limitless_led.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ epicmix (0.0.1)
5
+ httparty
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ httparty (0.12.0)
11
+ json (~> 1.8)
12
+ multi_xml (>= 0.5.2)
13
+ json (1.8.1)
14
+ multi_xml (0.5.5)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ epicmix!
data/README.md CHANGED
@@ -2,3 +2,62 @@ EpicMix Gem
2
2
  ===========
3
3
 
4
4
  A Ruby gem for accessing your EpicMix data.
5
+
6
+ ### Usage
7
+
8
+ gem install epicmix
9
+
10
+ Or add it to your Gemfile
11
+
12
+ gem 'epicmix'
13
+
14
+
15
+ ### Example
16
+
17
+ ``` ruby
18
+ # require the gem
19
+ require 'epicmix'
20
+
21
+ # connect using your epic mix username and password
22
+ client = Epicmix::Client.new('username', 'password')
23
+
24
+ # display your stats for each season
25
+ puts client.season_stats
26
+
27
+ [{
28
+ "year" => 2011,
29
+ "yearString" => "2011/12",
30
+ "verticalFeet" => 61810,
31
+ "lifts" => 52,
32
+ "photos" => 40,
33
+ "pins" => 17,
34
+ "points" => 1457,
35
+ "checkins" => 6,
36
+ "daysOnMountain" => 6,
37
+ "mostVisitedMountainID" => 5,
38
+ "timeTagID" => 780,
39
+ "isCurrentSeason" => false,
40
+ "medals" => 0,
41
+ "lessons" => 0,
42
+ "academyLevel" => 0,
43
+ "academyDiscipline" => "Ski"
44
+ }, {
45
+ "year" => 2012,
46
+ "yearString" => "2012/13",
47
+ "verticalFeet" => 41554,
48
+ "lifts" => 29,
49
+ "photos" => 4,
50
+ "pins" => 12,
51
+ "points" => 907,
52
+ "checkins" => 5,
53
+ "daysOnMountain" => 5,
54
+ "mostVisitedMountainID" => 5,
55
+ "timeTagID" => 1269,
56
+ "isCurrentSeason" => false,
57
+ "medals" => 0,
58
+ "lessons" => 0,
59
+ "academyLevel" => 0,
60
+ "academyDiscipline" => "Ski"
61
+ }]
62
+
63
+ ```
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'epicmix/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "epicmix"
9
+ spec.version = Epicmix::VERSION
10
+ spec.authors = ["Joseph Silvashy"]
11
+ spec.email = ["jpsilvashy@gmail.com"]
12
+ spec.summary = %q{A Ruby gem for accessing your EpicMix data.}
13
+ spec.description = %q{A Ruby gem for accessing your EpicMix data.}
14
+ spec.homepage = "https://github.com/jpsilvashy/epicmix"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "httparty"
23
+
24
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'epicmix'
4
+
5
+ client = Epicmix::Client.new('username', 'password')
6
+ client.season_stats
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/ruby
2
+ # require "epicmix/version"
3
+ require 'httparty'
4
+
5
+ module Epicmix
6
+ class Client
7
+
8
+ attr_accessor :username, :password, :token
9
+
10
+ # Initializes and logs in to Epicmix
11
+ def initialize(username, password)
12
+ @username, @password = username, password
13
+ @token = login
14
+ end
15
+
16
+ # Login to epic mix
17
+ def login
18
+ url = 'https://www.epicmix.com/vailresorts/sites/epicmix/api/mobile/authenticate.ashx'
19
+
20
+ options = { :query => { :loginID => username, :password => password }}
21
+ response = HTTParty.post(url, options)
22
+
23
+ token_from(response) # if response.instance_of? Net::HTTPOK
24
+ end
25
+
26
+ # Gets all your season stats
27
+ def season_stats
28
+ url = 'https://www.epicmix.com/vailresorts/sites/epicmix/api/mobile/userstats.ashx'
29
+
30
+ options = { :timetype => 'season', :token => token }
31
+ response = HTTParty.get(url, :query => options, :headers => headers)
32
+
33
+ JSON.parse(response.body)['seasonStats']
34
+ end
35
+
36
+ # Gets token out of response cookies
37
+ def token_from(response)
38
+ response.headers['Set-Cookie'][%r{ASP.NET_SessionId=([^;]+);}, 1]
39
+ end
40
+
41
+ # Sets headers
42
+ def headers(extra = {})
43
+ extra.merge 'Cookie' => [session_id, website, session_id].join('; '),
44
+ 'Accept-Encoding' => 'gzip',
45
+ 'User-Agent' => 'EpicMix 15880 rv:2.1 (iPhone; iPhone OS 5.0.1; en_US)',
46
+ 'Host' => 'www.epicmix.com'
47
+ end
48
+
49
+ # Get the sesson id, to be inserted into the cookies in the header
50
+ def session_id
51
+ "ASP.NET_SessionId=#{token}"
52
+ end
53
+
54
+ def website
55
+ "website#sc_wede=1"
56
+ end
57
+
58
+ end
59
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/ruby
2
+
3
+ module Epicmix
4
+ VERSION = "0.0.2"
5
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'epicmix'
5
+
6
+ RSpec.configure do |config|
7
+ # some (optional) config here
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epicmix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Silvashy
@@ -32,8 +32,18 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - .gitignore
35
+ - .rspec
36
+ - .travis.yml
37
+ - Gemfile
38
+ - Gemfile.lock
35
39
  - LICENSE
36
40
  - README.md
41
+ - Rakefile
42
+ - epicmix.gemspec
43
+ - examples/demo.rb
44
+ - lib/epicmix.rb
45
+ - lib/epicmix/version.rb
46
+ - spec/spec_helper.rb
37
47
  homepage: https://github.com/jpsilvashy/epicmix
38
48
  licenses:
39
49
  - MIT
@@ -58,5 +68,6 @@ rubygems_version: 2.1.1
58
68
  signing_key:
59
69
  specification_version: 4
60
70
  summary: A Ruby gem for accessing your EpicMix data.
61
- test_files: []
71
+ test_files:
72
+ - spec/spec_helper.rb
62
73
  has_rdoc: