espn-fantasy-news 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/espn-fantasy-news.gemspec +15 -17
- data/lib/espn_fantasy_news/parser.rb +16 -13
- metadata +7 -8
- data/.gitignore +0 -9
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/espn-fantasy-news.gemspec
CHANGED
@@ -1,42 +1,40 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{espn-fantasy-news}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Doug Petkanics"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-09-02}
|
13
13
|
s.description = %q{ESPN fantasy football has a list of players in their Universe, and it provides news updates on said players. This is a utility library used to scrape the data for use in other applications}
|
14
14
|
s.email = %q{petkanics@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
"
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
"test/test_parser.rb"
|
19
|
+
"README",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"espn-fantasy-news.gemspec",
|
23
|
+
"lib/espn_fantasy_news.rb",
|
24
|
+
"lib/espn_fantasy_news/news.rb",
|
25
|
+
"lib/espn_fantasy_news/parser.rb",
|
26
|
+
"lib/espn_fantasy_news/player.rb",
|
27
|
+
"lib/espn_fantasy_news/team.rb",
|
28
|
+
"test/suite.rb",
|
29
|
+
"test/test_parser.rb"
|
31
30
|
]
|
32
31
|
s.homepage = %q{http://github.com/dob/espn-fantasy-news}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
34
32
|
s.require_paths = ["lib"]
|
35
33
|
s.rubygems_version = %q{1.3.7}
|
36
34
|
s.summary = %q{Scrapes ESPN Fantasy football news updates and player data}
|
37
35
|
s.test_files = [
|
38
36
|
"test/suite.rb",
|
39
|
-
|
37
|
+
"test/test_parser.rb"
|
40
38
|
]
|
41
39
|
|
42
40
|
if s.respond_to? :specification_version then
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'open-uri'
|
2
|
+
require 'ruby-debug'
|
2
3
|
|
3
4
|
module ESPNFantasyNews
|
4
5
|
|
@@ -20,20 +21,22 @@ module ESPNFantasyNews
|
|
20
21
|
def self.players_from_url(url)
|
21
22
|
doc = Nokogiri::HTML(open(url))
|
22
23
|
player_attributes = doc.css('.pncPlayerRow').collect do |x|
|
23
|
-
cell = x.css('td')[
|
24
|
+
cell = x.css('td')[1]
|
24
25
|
cell_text = cell.text
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
unless cell_text.include?("D/ST")
|
27
|
+
name, teampos = cell_text.split(',')
|
28
|
+
team, pos = self.split_string_on_char_194(teampos.strip)
|
29
|
+
player_id = cell.css('a')[0].get_attribute('playerid').to_i
|
30
|
+
|
31
|
+
pos = self.parse_pos(pos)
|
32
|
+
|
33
|
+
# Remove the asterisk from players who are on the IR
|
34
|
+
name = name[0, name.length - 1] if name[-1, 1] == "*"
|
35
|
+
|
36
|
+
ESPNFantasyNews::Player.new(name, player_id, pos, team)
|
37
|
+
end
|
35
38
|
end
|
36
|
-
player_attributes
|
39
|
+
player_attributes.compact
|
37
40
|
end
|
38
41
|
|
39
42
|
# Return all the latest news stories
|
@@ -72,7 +75,7 @@ module ESPNFantasyNews
|
|
72
75
|
|
73
76
|
# It isn't a space that seperates the team and position, it's ascii char 194 for some reason?
|
74
77
|
def self.split_string_on_char_194(str)
|
75
|
-
return
|
78
|
+
return if (str.nil? || str.length < 4)
|
76
79
|
|
77
80
|
if str[2].to_i == 194
|
78
81
|
return str[0,2], str[4, str.length - 4]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: espn-fantasy-news
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Doug Petkanics
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-09-02 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -41,7 +41,6 @@ extensions: []
|
|
41
41
|
extra_rdoc_files:
|
42
42
|
- README
|
43
43
|
files:
|
44
|
-
- .gitignore
|
45
44
|
- README
|
46
45
|
- Rakefile
|
47
46
|
- VERSION
|
@@ -58,8 +57,8 @@ homepage: http://github.com/dob/espn-fantasy-news
|
|
58
57
|
licenses: []
|
59
58
|
|
60
59
|
post_install_message:
|
61
|
-
rdoc_options:
|
62
|
-
|
60
|
+
rdoc_options: []
|
61
|
+
|
63
62
|
require_paths:
|
64
63
|
- lib
|
65
64
|
required_ruby_version: !ruby/object:Gem::Requirement
|