sportsbook_ag-feed 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 34288862831da45c64b2c0c84cbb890006dda088
4
+ data.tar.gz: e2db133dbd00bf5bd37a0e87156e49b886d873b7
5
+ SHA512:
6
+ metadata.gz: 7c01cfb6e82ba1e11ec0b8b74dd1111474551c8d1ba0c1158e25c9116014199072ad7f050f85f66040eade882d33e9cf837635a17046d04eddcf92c64627324f
7
+ data.tar.gz: 91f97aaf1bbcf6b2d163d6ea04af852c4ce5bae91e5d9cefba301100d4f94a58fec81e7d2a2d5899200534e6e85e038b77b22faa6648a39197ecdee4f5accc3d
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Dave Nguyen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # SportsbookAg::Feed
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'sportsbook_ag-feed'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install sportsbook_ag-feed
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'SportsbookAg::Feed'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,14 @@
1
+ require 'sportsbook_ag/feed/nfl'
2
+ require 'sportsbook_ag/game'
3
+ require 'sportsbook_ag/line'
4
+ require 'open-uri'
5
+
6
+ module SportsbookAg
7
+ module Feed
8
+ BASE_URL = 'https://www.sportsbook.ag/rss/'
9
+
10
+ ::ActiveSupport::Inflector.inflections do |inflect|
11
+ inflect.acronym 'NFL'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,29 @@
1
+ module SportsbookAg
2
+ module Feed
3
+ class NFL
4
+ FEED_NAME = 'nfl-football'
5
+
6
+ attr_reader :_data, :_xml, :games, :updated_at
7
+
8
+ def initialize(path = nil)
9
+ @_xml = open(path || (BASE_URL + FEED_NAME)).read
10
+ @updated_at = Time.now
11
+ @_data = Hash.from_xml(_xml).deep_symbolize_keys!
12
+ parse
13
+ end
14
+
15
+ private
16
+
17
+ def parse
18
+ parse_games
19
+ end
20
+
21
+ def parse_games
22
+ @games = []
23
+ _data[:rss][:channel][:item].each do |data|
24
+ games << Game.new(data)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,5 @@
1
+ module SportsbookAg
2
+ module Feed
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,56 @@
1
+ module SportsbookAg
2
+ module Feed
3
+ class Game
4
+ attr_reader :_data, :home, :home_moneyline, :home_spread, :over,
5
+ :total, :under, :visitor, :visitor_moneyline, :visitor_spread
6
+
7
+ def initialize(data)
8
+ @_data = data
9
+ @updated_at = Time.now
10
+ parse
11
+ end
12
+
13
+ private
14
+
15
+ def parse
16
+ desc = Nokogiri::HTML(_data[:description])
17
+ @elements = desc.xpath('//body').first.children
18
+
19
+ parse_teams
20
+ parse_lines
21
+ parse_total
22
+ end
23
+
24
+ def parse_lines
25
+ teams = { home: [6, 8], visitor: [2, 4] }
26
+ teams.each do |team, num|
27
+ instance_variable_set("@#{team}_spread", parse_spread(@elements[num[0]]))
28
+ instance_variable_set("@#{team}_moneyline", Line.new(:moneyline, @elements[num[1]].text.to_i))
29
+ end
30
+ end
31
+
32
+ def parse_total
33
+ over = @elements[10].text.split(' ')
34
+ under = @elements[12].text.split(' ')
35
+ @total = over[1].to_d
36
+ @over = Line.new(:total, over[2][1...-1].to_i, @total)
37
+ @under = Line.new(:total, under[2][1...-1].to_i, @total)
38
+ end
39
+
40
+ def parse_moneyline(element)
41
+
42
+ end
43
+
44
+ def parse_spread(element)
45
+ spread = element.text.split(' ')
46
+ Line.new(:spread, spread.last[1...-1].to_i, spread.first.to_d)
47
+ end
48
+
49
+ def parse_teams
50
+ teams = _data[:title].split(' @ ')
51
+ @visitor = teams.first
52
+ @home = teams.last
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,13 @@
1
+ module SportsbookAg
2
+ module Feed
3
+ class Line
4
+ attr_reader :odds, :spread, :type
5
+
6
+ def initialize(type, odds, spread = nil)
7
+ @odds = odds
8
+ @spread = spread
9
+ @type = type
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :sportsbook_ag_feed do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sportsbook_ag-feed
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dave Nguyen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.0.0.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 5.0.0
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.0.0.1
33
+ description: Get sports odds from Sportsbook.ag.
34
+ email:
35
+ - Dave.Nguyen@inthenight.net
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - MIT-LICENSE
41
+ - README.md
42
+ - Rakefile
43
+ - lib/sportsbook_ag/feed.rb
44
+ - lib/sportsbook_ag/feed/nfl.rb
45
+ - lib/sportsbook_ag/feed/version.rb
46
+ - lib/sportsbook_ag/game.rb
47
+ - lib/sportsbook_ag/line.rb
48
+ - lib/tasks/sportsbook_ag/feed_tasks.rake
49
+ homepage: https://github.com/davenguyen/sportsbook_ag-feed
50
+ licenses:
51
+ - MIT
52
+ metadata: {}
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 2.6.8
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Get sports odds from Sportsbook.ag.
73
+ test_files: []