pga_leaderboard 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7037ea0f739207b256f14c2cb27ccb2502283e0d
4
+ data.tar.gz: e9043d0295140af3ad59917b1425ea65e8fc9f7d
5
+ SHA512:
6
+ metadata.gz: 971ea9e57bf2b5d31afc306742effd2259fd366766fd299516fc0f1fa10928bd2dd3942fef72e45f5bdab61501e3974c5992ac44861320d6c5ade0410954614c
7
+ data.tar.gz: d0ff43cc77bb2eb68a99cc04fd469c66b7530bccc6c2585a719d3d3b399230312987c56cf1c280f9bdebc6d8c50eca4f013232720c20b64ceabcfd12de5ae92d
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
4
+ script:
5
+ - "bundle exec rspec"
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pga_leaderboard.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard :rspec, cmd: 'rspec' do
2
+ # Watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # Watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Trevor Reiff
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,56 @@
1
+ [![Build Status](https://travis-ci.org/treiff/pga_leaderboard.svg?branch=master)](https://travis-ci.org/treiff/pga_leaderboard)
2
+ # PGA Leaderboard
3
+ ![Example](https://raw.githubusercontent.com/treiff/pga_leaderboard/master/img.png)
4
+
5
+ Ever wonder how the leaderboard is looking at the current PGA tour event? Here's your answer. A simple executable providing a brief overview of the current tournament, leaderboard automatically updates every 3-minutes.
6
+
7
+ Data is exracted from ESPN® Bottomline as a URI encoded string. Default update from ESPN® is every three minutes.
8
+
9
+ This was the best data feed I could find (for free) for PGA leaderboard data. Feel free to mess around with it and make it better, It does its job for now as long as ESPN® doesn't change their data format.
10
+
11
+ ## Installation
12
+
13
+ Install it yourself as:
14
+
15
+ $ gem install pga_leaderboard
16
+
17
+ ## Usage
18
+
19
+ Simple, once installed run:
20
+
21
+ $ pga leaderboard
22
+
23
+ To exit ```ctrl^c```
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/treiff/pga_leaderboard/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
32
+
33
+ ## License
34
+
35
+ Copyright (c) 2015 Trevor Reiff
36
+
37
+ MIT License
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining
40
+ a copy of this software and associated documentation files (the
41
+ "Software"), to deal in the Software without restriction, including
42
+ without limitation the rights to use, copy, modify, merge, publish,
43
+ distribute, sublicense, and/or sell copies of the Software, and to
44
+ permit persons to whom the Software is furnished to do so, subject to
45
+ the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be
48
+ included in all copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
51
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
53
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
54
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
55
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
56
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |task|
5
+ task.rspec_opts = ['--color']
6
+ end
7
+
8
+ task default: :spec
data/bin/pga ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pga_leaderboard'
3
+
4
+ PgaLeaderboard::CLI.start(ARGV)
data/img.png ADDED
Binary file
@@ -0,0 +1,33 @@
1
+ require 'thor'
2
+
3
+ module PgaLeaderboard
4
+ class CLI < Thor
5
+ require 'colorize'
6
+ include PgaLeaderboard
7
+
8
+ attr_reader :tournament
9
+
10
+ def initialize(*args)
11
+ super
12
+ end
13
+
14
+ desc 'leaderboard', 'see current tournament leaderboard'
15
+ def leaderboard
16
+ run {
17
+ @tournament = PgaLeaderboard::Tournament.new
18
+ output(tournament)
19
+ }
20
+ end
21
+
22
+ private
23
+
24
+ def output(array)
25
+ puts
26
+ tournament.heading
27
+ puts "--------------------------------------------".colorize(:red)
28
+ puts
29
+ tournament.body
30
+ puts
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,38 @@
1
+ module PgaLeaderboard
2
+ class Tournament
3
+ require 'httparty'
4
+ require 'uri'
5
+
6
+ def initialize
7
+ @response = HTTParty.get(ENDPOINT).parsed_response
8
+ end
9
+
10
+ def parsed_array
11
+ resp = @response.split("&")
12
+ resp.shift(4)
13
+ resp.pop(3)
14
+ resp
15
+ end
16
+
17
+ def clean_response
18
+ clean_array = []
19
+ parsed_array.each do |item|
20
+ stripped_item = item.gsub(/^[^=]*=/, "")
21
+ clean_array << URI.decode(stripped_item)
22
+ end
23
+ clean_array
24
+ end
25
+
26
+ def heading
27
+ clean_response[0..1].each do |item|
28
+ puts item.rjust(35)
29
+ end
30
+ end
31
+
32
+ def body
33
+ clean_response[2..clean_response.length].each do |item|
34
+ puts item.gsub(/-\d/) { |score| score.colorize(:red) }
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module PgaLeaderboard
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,15 @@
1
+ require "pga_leaderboard/version"
2
+ require_relative "pga_leaderboard/tournament"
3
+ require_relative "pga_leaderboard/cli"
4
+
5
+ module PgaLeaderboard
6
+ ENDPOINT = "http://sports.espn.go.com/sports/golf/bottomLineGolfLeaderboard"
7
+ INTERVAL = 180
8
+
9
+ def run
10
+ while true
11
+ yield
12
+ sleep INTERVAL
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pga_leaderboard/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pga_leaderboard"
8
+ spec.version = PgaLeaderboard::VERSION
9
+ spec.authors = ["Trevor Reiff"]
10
+ spec.email = ["trevorreiff@gmail.com"]
11
+ spec.summary = %q{Command line PGA leaderboard tool}
12
+ spec.description = %q{View PGA leaderboard in your console, updated every 3-min}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~>3.2.0"
24
+ spec.add_development_dependency "guard", "~>2.12.4"
25
+ spec.add_development_dependency "guard-rspec", "~>4.5.0"
26
+
27
+ spec.add_dependency "httparty", "~>0.13.3"
28
+ spec.add_dependency "thor", "~>0.19.1"
29
+ spec.add_dependency "colorize", "~>0.7.5"
30
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ module PgaLeaderboard
4
+ describe Tournament do
5
+ subject(:tournament) { PgaLeaderboard::Tournament.new }
6
+
7
+ it 'exists as a object' do
8
+ expect(tournament).to be_a(Tournament)
9
+ end
10
+
11
+ describe '#parsed_array' do
12
+ it 'should return an array when parsed' do
13
+ expect(tournament.parsed_array).to be_a(Array)
14
+ end
15
+ end
16
+
17
+ describe '#clean_response' do
18
+ it 'should return a scrubbed array' do
19
+ expect(tournament.clean_response).to be_a(Array)
20
+ end
21
+
22
+ it 'removes any prepended text before = sign' do
23
+ expect(tournament.clean_response[4]).not_to include("=")
24
+ end
25
+
26
+ it 'decodes each item to remove URI encoding' do
27
+ expect(tournament.clean_response[4]).not_to include("%20")
28
+ end
29
+ end
30
+
31
+ describe '#heading' do
32
+ it 'extracts the first two array elements' do
33
+ expect(tournament.heading.length).to eq(2)
34
+ end
35
+ end
36
+
37
+ describe '#body' do
38
+ it 'returns remaining array elements' do
39
+ expect(tournament.body.length).to eq(tournament.clean_response.length - tournament.heading.length)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1 @@
1
+ require 'pga_leaderboard'
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pga_leaderboard
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Trevor Reiff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.2.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.2.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.12.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.12.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 4.5.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 4.5.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: httparty
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.13.3
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.13.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: thor
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.19.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.19.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: colorize
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.7.5
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.7.5
125
+ description: View PGA leaderboard in your console, updated every 3-min
126
+ email:
127
+ - trevorreiff@gmail.com
128
+ executables:
129
+ - pga
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".travis.yml"
135
+ - Gemfile
136
+ - Guardfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - bin/pga
141
+ - img.png
142
+ - lib/pga_leaderboard.rb
143
+ - lib/pga_leaderboard/cli.rb
144
+ - lib/pga_leaderboard/tournament.rb
145
+ - lib/pga_leaderboard/version.rb
146
+ - pga_leaderboard.gemspec
147
+ - spec/pga_leaderboard_spec.rb
148
+ - spec/spec_helper.rb
149
+ homepage: ''
150
+ licenses:
151
+ - MIT
152
+ metadata: {}
153
+ post_install_message:
154
+ rdoc_options: []
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ requirements: []
168
+ rubyforge_project:
169
+ rubygems_version: 2.4.3
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: Command line PGA leaderboard tool
173
+ test_files:
174
+ - spec/pga_leaderboard_spec.rb
175
+ - spec/spec_helper.rb