mlb-standings 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/exe/mlb-standings +25 -21
- data/mlb-standings.gemspec +1 -1
- metadata +11 -19
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ee6fe273d6dec0be7ec90bb6e6073c67678a131b
|
4
|
+
data.tar.gz: ce157f7e84691d58471c475fffce4e8a55937df9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ef292da22f406c80132203193e6190299fb28c8f50e5c8a2932ee1d6b9b0dd83e09050e23778cead637609ae554702466c713860a491c6374302c35546d0dcee
|
7
|
+
data.tar.gz: 700d085c9be3f2cbc16cdc0ebfa03d3e53522debc2c337a9dec69adff15dac8f43e11d8a35af414aace0a3d7368fb24ae0e275d1b2c51197601d859e63285ca9
|
data/exe/mlb-standings
CHANGED
@@ -6,46 +6,50 @@ require 'nokogiri'
|
|
6
6
|
def main
|
7
7
|
html = Net::HTTP.get(URI('http://espn.go.com/mlb/standings'))
|
8
8
|
doc = Nokogiri::HTML(html)
|
9
|
-
|
9
|
+
|
10
|
+
standings_tables = doc.css("table.standings")
|
10
11
|
|
11
12
|
x = TableMaker.new
|
12
|
-
|
13
|
-
|
13
|
+
standings_tables.each do |table|
|
14
|
+
league_name = table.at_css("caption").text
|
15
|
+
x.caption league_name
|
16
|
+
table.search("./tr").each do |tr|
|
17
|
+
if "th" == tr.first_element_child.node_name
|
18
|
+
x.th(tr)
|
19
|
+
else
|
20
|
+
x.td(tr)
|
21
|
+
end
|
22
|
+
end
|
14
23
|
end
|
15
24
|
end
|
16
25
|
|
17
26
|
class TableMaker
|
18
|
-
def
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def stathead(tr)
|
23
|
-
puts Divider, tr.text
|
27
|
+
def caption(str)
|
28
|
+
puts Divider, str
|
24
29
|
end
|
25
30
|
|
26
|
-
def
|
31
|
+
def th(tr)
|
27
32
|
puts Underline
|
28
33
|
row(tr)
|
34
|
+
puts Underline
|
29
35
|
end
|
30
36
|
|
31
|
-
def
|
32
|
-
row(tr)
|
33
|
-
end
|
34
|
-
|
35
|
-
def evenrow(tr)
|
37
|
+
def td(tr)
|
36
38
|
row(tr)
|
37
39
|
end
|
38
40
|
|
39
41
|
def row(tr)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
columns = tr.element_children.map { |td| td.text }
|
43
|
+
columns = columns.map { |column| column.rjust(8, ' ') }
|
44
|
+
if abbr = tr.first_element_child.at_css("abbr")
|
45
|
+
columns[0] = abbr.text.rjust(8, ' ')
|
46
|
+
end
|
47
|
+
columns = columns.take((TermWidth - 15) / 8)
|
48
|
+
puts columns.join
|
45
49
|
end
|
46
50
|
|
47
51
|
TermWidth = STDOUT.tty? ? `tput cols`.to_i : 103
|
48
|
-
Divider = '
|
52
|
+
Divider = '=' * TermWidth
|
49
53
|
Underline = '-' * TermWidth
|
50
54
|
end
|
51
55
|
|
data/mlb-standings.gemspec
CHANGED
metadata
CHANGED
@@ -1,36 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mlb-standings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Matt Burke
|
9
8
|
autorequire:
|
10
9
|
bindir: exe
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-04-18 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: nokogiri
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: bundler
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,17 +41,15 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: Get MLB stuffs
|
@@ -77,26 +70,25 @@ files:
|
|
77
70
|
homepage: ''
|
78
71
|
licenses:
|
79
72
|
- MIT
|
73
|
+
metadata: {}
|
80
74
|
post_install_message:
|
81
75
|
rdoc_options: []
|
82
76
|
require_paths:
|
83
77
|
- lib
|
84
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
79
|
requirements:
|
87
|
-
- -
|
80
|
+
- - '>='
|
88
81
|
- !ruby/object:Gem::Version
|
89
82
|
version: '0'
|
90
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
84
|
requirements:
|
93
|
-
- -
|
85
|
+
- - '>='
|
94
86
|
- !ruby/object:Gem::Version
|
95
87
|
version: '0'
|
96
88
|
requirements: []
|
97
89
|
rubyforge_project:
|
98
|
-
rubygems_version:
|
90
|
+
rubygems_version: 2.0.14
|
99
91
|
signing_key:
|
100
|
-
specification_version:
|
92
|
+
specification_version: 4
|
101
93
|
summary: Get MLB stuffs
|
102
94
|
test_files: []
|