mlb-standings 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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +58 -0
- data/Rakefile +1 -0
- data/exe/mlb-standings +52 -0
- data/mlb-standings.gemspec +24 -0
- metadata +102 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Matt Burke
|
|
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,58 @@
|
|
|
1
|
+
# List MLB standings in your command prompt
|
|
2
|
+
|
|
3
|
+
$ gem install mlb-standings
|
|
4
|
+
$ mlb-standings
|
|
5
|
+
-------------------------------------------------------------------------------------------------------
|
|
6
|
+
American League
|
|
7
|
+
-------------------------------------------------------------------------------------------------------
|
|
8
|
+
EAST W L PCT GB HOME ROAD RS RA DIFF STRK L10
|
|
9
|
+
Boston 5 2 .714 - 1-0 4-2 39 20 +19 Won 2 5-2
|
|
10
|
+
NY Yankees 4 4 .500 1.5 1-2 3-2 49 40 +9 Won 3 4-4
|
|
11
|
+
Baltimore 3 4 .429 2 1-2 2-2 38 33 +5 Lost 3 3-4
|
|
12
|
+
Tampa Bay 3 5 .375 2.5 3-3 0-2 30 44 -14 Lost 3 3-5
|
|
13
|
+
Toronto 2 5 .286 3 2-4 0-1 25 41 -16 Lost 2 2-5
|
|
14
|
+
-------------------------------------------------------------------------------------------------------
|
|
15
|
+
CENTRAL W L PCT GB HOME ROAD RS RA DIFF STRK L10
|
|
16
|
+
Kansas City 5 3 .625 - 2-0 3-3 40 28 +12 Won 3 5-3
|
|
17
|
+
Chicago Sox 4 3 .571 .5 4-2 0-1 29 27 +2 Lost 1 4-3
|
|
18
|
+
Detroit 4 3 .571 .5 3-1 1-2 31 30 +1 Won 1 4-3
|
|
19
|
+
Minnesota 4 4 .500 1 2-1 2-3 33 35 -2 Lost 2 4-4
|
|
20
|
+
Cleveland 3 5 .375 2 0-2 3-3 35 48 -13 Lost 2 3-5
|
|
21
|
+
-------------------------------------------------------------------------------------------------------
|
|
22
|
+
WEST W L PCT GB HOME ROAD RS RA DIFF STRK L10
|
|
23
|
+
Oakland 6 2 .750 - 2-2 4-0 47 27 +20 Won 6 6-2
|
|
24
|
+
Texas 6 2 .750 - 4-1 2-1 38 26 +12 Won 3 6-2
|
|
25
|
+
Seattle 4 5 .444 2.5 1-1 3-4 39 46 -7 Lost 1 4-5
|
|
26
|
+
LA Angels 2 5 .286 3.5 0-1 2-4 29 34 -5 Lost 2 2-5
|
|
27
|
+
Houston 2 6 .250 4 1-5 1-1 33 48 -15 Won 1 2-6
|
|
28
|
+
-------------------------------------------------------------------------------------------------------
|
|
29
|
+
National League
|
|
30
|
+
-------------------------------------------------------------------------------------------------------
|
|
31
|
+
EAST W L PCT GB HOME ROAD RS RA DIFF STRK L10
|
|
32
|
+
Atlanta 7 1 .875 - 5-1 2-0 36 18 +18 Won 5 7-1
|
|
33
|
+
Washington 5 2 .714 1.5 4-0 1-2 29 35 -6 Won 1 5-2
|
|
34
|
+
NY Mets 5 3 .625 2 4-2 1-1 46 31 +15 Lost 1 5-3
|
|
35
|
+
Philadelphia 3 5 .375 4 2-3 1-2 35 51 -16 Won 1 3-5
|
|
36
|
+
Miami 1 7 .125 6 0-2 1-5 16 32 -16 Lost 4 1-7
|
|
37
|
+
-------------------------------------------------------------------------------------------------------
|
|
38
|
+
CENTRAL W L PCT GB HOME ROAD RS RA DIFF STRK L10
|
|
39
|
+
St. Louis 5 4 .556 - 2-1 3-3 56 38 +18 Won 2 5-4
|
|
40
|
+
Cincinnati 5 4 .556 - 4-2 1-2 52 40 +12 Lost 2 5-4
|
|
41
|
+
Chicago Cubs 3 5 .375 1.5 1-1 2-4 23 31 -8 Won 1 3-5
|
|
42
|
+
Pittsburgh 3 5 .375 1.5 1-2 2-3 19 24 -5 Won 2 3-5
|
|
43
|
+
Milwaukee 2 6 .250 2.5 1-5 1-1 32 49 -17 Lost 1 2-6
|
|
44
|
+
-------------------------------------------------------------------------------------------------------
|
|
45
|
+
WEST W L PCT GB HOME ROAD RS RA DIFF STRK L10
|
|
46
|
+
San Francisco 5 3 .625 - 3-2 2-1 28 35 -7 Won 2 5-3
|
|
47
|
+
Colorado 5 3 .625 - 3-0 2-3 47 31 +16 Lost 2 5-3
|
|
48
|
+
Arizona 5 3 .625 - 2-3 3-0 45 38 +7 Lost 2 5-3
|
|
49
|
+
LA Dodgers 4 3 .571 .5 4-2 0-1 20 19 +1 Lost 1 4-3
|
|
50
|
+
San Diego 2 5 .286 2.5 1-0 1-5 23 43 -20 Won 1 2-5
|
|
51
|
+
|
|
52
|
+
## Contributing
|
|
53
|
+
|
|
54
|
+
1. Fork it
|
|
55
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
56
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
57
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
58
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/exe/mlb-standings
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'net/http'
|
|
4
|
+
require 'nokogiri'
|
|
5
|
+
|
|
6
|
+
def main
|
|
7
|
+
html = Net::HTTP.get(URI('http://espn.go.com/mlb/standings'))
|
|
8
|
+
doc = Nokogiri::HTML(html)
|
|
9
|
+
standings = doc.at_css('table')
|
|
10
|
+
|
|
11
|
+
x = TableMaker.new
|
|
12
|
+
standings.search('./tr').each do |tr|
|
|
13
|
+
x.format(tr)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class TableMaker
|
|
18
|
+
def format(tr)
|
|
19
|
+
send(tr['class'].split(' ').first, tr)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def stathead(tr)
|
|
23
|
+
puts Divider, tr.text
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def colhead(tr)
|
|
27
|
+
puts Underline
|
|
28
|
+
row(tr)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def oddrow(tr)
|
|
32
|
+
row(tr)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def evenrow(tr)
|
|
36
|
+
row(tr)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def row(tr)
|
|
40
|
+
division_name, *columns = tr.search('./td').map { |td| td.text }
|
|
41
|
+
division_name = division_name.ljust(15, ' ')
|
|
42
|
+
columns = columns.map { |column| column.rjust(8, ' ') }
|
|
43
|
+
columns = columns.take((TermWidth - 15) / 8)
|
|
44
|
+
puts "#{division_name}#{columns.join}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
TermWidth = STDOUT.tty? ? `tput cols`.to_i : 103
|
|
48
|
+
Divider = '-' * TermWidth
|
|
49
|
+
Underline = '-' * TermWidth
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
main
|
|
@@ -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
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "mlb-standings"
|
|
7
|
+
spec.version = '0.0.1'
|
|
8
|
+
spec.authors = ["Matt Burke"]
|
|
9
|
+
spec.email = ["spraints@gmail.com"]
|
|
10
|
+
spec.description =
|
|
11
|
+
spec.summary = %q{Get MLB stuffs}
|
|
12
|
+
spec.homepage = ""
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
|
|
15
|
+
spec.files = `git ls-files`.split($/)
|
|
16
|
+
spec.executables = ['mlb-standings']
|
|
17
|
+
spec.bindir = 'exe'
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_dependency "nokogiri"
|
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
|
23
|
+
spec.add_development_dependency "rake"
|
|
24
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mlb-standings
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Matt Burke
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: exe
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: nokogiri
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: bundler
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ~>
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '1.3'
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ~>
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '1.3'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: rake
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ! '>='
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ! '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
description: Get MLB stuffs
|
|
63
|
+
email:
|
|
64
|
+
- spraints@gmail.com
|
|
65
|
+
executables:
|
|
66
|
+
- mlb-standings
|
|
67
|
+
extensions: []
|
|
68
|
+
extra_rdoc_files: []
|
|
69
|
+
files:
|
|
70
|
+
- .gitignore
|
|
71
|
+
- Gemfile
|
|
72
|
+
- LICENSE.txt
|
|
73
|
+
- README.md
|
|
74
|
+
- Rakefile
|
|
75
|
+
- exe/mlb-standings
|
|
76
|
+
- mlb-standings.gemspec
|
|
77
|
+
homepage: ''
|
|
78
|
+
licenses:
|
|
79
|
+
- MIT
|
|
80
|
+
post_install_message:
|
|
81
|
+
rdoc_options: []
|
|
82
|
+
require_paths:
|
|
83
|
+
- lib
|
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
|
+
none: false
|
|
86
|
+
requirements:
|
|
87
|
+
- - ! '>='
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
|
+
none: false
|
|
92
|
+
requirements:
|
|
93
|
+
- - ! '>='
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
requirements: []
|
|
97
|
+
rubyforge_project:
|
|
98
|
+
rubygems_version: 1.8.23
|
|
99
|
+
signing_key:
|
|
100
|
+
specification_version: 3
|
|
101
|
+
summary: Get MLB stuffs
|
|
102
|
+
test_files: []
|