espn_rb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in espn_rb.gemspec
4
+ gemspec
5
+
6
+ gem 'rspec', '~> 2.8.0'
7
+
8
+ group :development do
9
+ gem 'pry'
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jonathan Jackson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # EspnRb
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'espn_rb'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install espn_rb
18
+
19
+ ## Usage
20
+
21
+ Currently this doesn't do much. I am actively work on this. Check the commit log to see where I'm at, and check the issues to see how you can contribute.
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/espn_rb.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/espn_rb/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jonathan Jackson"]
6
+ gem.email = ["jonj@promedicalinc.com"]
7
+ gem.description = %q{A Ruby wrapper for ESPN's api.}
8
+ gem.summary = %q{A Ruby wrapper for ESPN's api.}
9
+ gem.homepage = ""
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "espn_rb"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = EspnRb::VERSION
17
+ end
@@ -0,0 +1,23 @@
1
+ module EspnRb
2
+ module Headline
3
+ def resources
4
+ YAML::load(File.read('lib/espn_rb/headline_resources.yaml'))
5
+ end
6
+
7
+ def methods
8
+ YAML::load(File.read('lib/espn_rb/headline_methods.yaml'))
9
+ end
10
+
11
+ def get_results(resource, method)
12
+ http = Net::HTTP.new("api.espn.com")
13
+ request = Net::HTTP::Get.new("#{resource}#{method}?apikey=#{EspnRb.api_key}")
14
+ http.request(request)
15
+ end
16
+
17
+ def all_headlines
18
+ get_results(resources[:professional][:coed][:all][:relative_url], methods[:news][:relative_url])
19
+ end
20
+
21
+ extend self
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ ---
2
+ :news:
3
+ :relative_url: /news
4
+ :description: Retrieves a stream of all news for current date.
5
+ :news_headlines:
6
+ :relative_path: /news/headlines
7
+ :description: Retrieves top stories as selected by ESPN editorial staff.
8
+ :top:
9
+ :relative_path: news/headlines/top
10
+ :description: Retrieves top stories as shown on ESPN.com home page. Only applicable to /sports/ resource.
@@ -0,0 +1,56 @@
1
+ ---
2
+ :professional:
3
+ :coed:
4
+ :all:
5
+ :relative_url: /sports
6
+ :description: News across all sports/sections
7
+ :golf:
8
+ :relative_url: /sports/golf
9
+ :description: Golf
10
+ :boxing:
11
+ :relative_url: /sports/boxing
12
+ :description: Boxing
13
+ :mma:
14
+ :relative_url: /sports/mma
15
+ :description: Mixed Martial Arts
16
+ :racing:
17
+ :relative_url: /sports/racing
18
+ :description: Auto Racing
19
+ :soccer:
20
+ :relative_url: /sports/soccer
21
+ :description: Professional soccer (US focus)
22
+ :tennis:
23
+ :relative_url: /sports/tennis
24
+ :description: Tennis
25
+ :mens:
26
+ :baseball:
27
+ :relative_url: /sports/baseball/mlb
28
+ :description: Major League Baseball (MLB)
29
+ :basketball:
30
+ :relative_url: /sports/basketball/nba
31
+ :description: National Basketball Association (NBA)
32
+ :football:
33
+ :relative_url: /sports/football/nfl
34
+ :description: National Football League (NFL)
35
+ :hockey:
36
+ :relative_url: /sports/hockey/nhl
37
+ :description: National Hockey League (NHL)
38
+ :nascar:
39
+ :relative_url: /sports/racing/nascar
40
+ :description: NASCAR racing
41
+ :womens:
42
+ :basketball:
43
+ :realtive_url: /sports/basketball/wnba
44
+ :description: Women's National Basketball Association (WNBA)
45
+ :collegiate:
46
+ :mens:
47
+ :basketball:
48
+ :relative_url: /sports/basketball/mens-college-basketball
49
+ :description: NCAA Men's College Basketball
50
+ :football:
51
+ :relative_url: /sports/football/college-football
52
+ :description: NCAA College Football
53
+ :womens:
54
+ :basketball:
55
+ :relative_url: /sports/basketball/womens-college-basketball
56
+ :description: NCAA Women's College Basketball
@@ -0,0 +1,3 @@
1
+ module EspnRb
2
+ VERSION = "0.0.1"
3
+ end
data/lib/espn_rb.rb ADDED
@@ -0,0 +1,18 @@
1
+ require "espn_rb/version"
2
+ require "espn_rb/headline.rb"
3
+ require "net/http"
4
+
5
+ module EspnRb
6
+ attr_writer :api_key
7
+
8
+ def api_key
9
+ raise StandardError, "You must specify an API key." unless ENV['espn_api_key']
10
+ ENV['espn_api_key']
11
+ end
12
+
13
+ def headline
14
+ EspnRb::Headline if api_key
15
+ end
16
+
17
+ extend self
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe EspnRb::Headline do
4
+ it "#all_headlines should return 200 response." do
5
+ described_class.all_headlines.code.should eq("200")
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'espn_rb'
5
+
6
+ RSpec.configure do |config|
7
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: espn_rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jonathan Jackson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-07 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A Ruby wrapper for ESPN's api.
15
+ email:
16
+ - jonj@promedicalinc.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - .rspec
23
+ - Gemfile
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - espn_rb.gemspec
28
+ - lib/espn_rb.rb
29
+ - lib/espn_rb/headline.rb
30
+ - lib/espn_rb/headline_methods.yaml
31
+ - lib/espn_rb/headline_resources.yaml
32
+ - lib/espn_rb/version.rb
33
+ - spec/espn_rb_spec.rb
34
+ - spec/spec_helper.rb
35
+ homepage: ''
36
+ licenses: []
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ! '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 1.8.10
56
+ signing_key:
57
+ specification_version: 3
58
+ summary: A Ruby wrapper for ESPN's api.
59
+ test_files:
60
+ - spec/espn_rb_spec.rb
61
+ - spec/spec_helper.rb