nba_drilldown 0.1.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: dc9b847e9ba450b0e891af929d8546053a921a11
4
+ data.tar.gz: ed2ebe5d6ac9330d1baae60b5d05fa52d2fd93ff
5
+ SHA512:
6
+ metadata.gz: 5cb22edcd2d24a5a15f43343b83e921748d0f851f406537d3168b3bec3b177c5471bf378fc17ceb798844fc46cec216617c497b4d391290bf97ea8b575d30b65
7
+ data.tar.gz: f21c84c54136189994b1d6ee1110323343e831902126521f61569c5c6c336308c16f789d84c17210ef5d26dd1b7eae8fcb664a54c8b177015a3d28508f95ee30
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nba_drilldown.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 tuckerbohman5
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # NbaDrilldown
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/nba_drilldown`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'nba_drilldown'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install nba_drilldown
22
+
23
+ ## Usage
24
+
25
+ After installation of gem. Type nba-drilldown in the prompt and enjoy the app.
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/nba_drilldown. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nba_drilldown"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/nba-drilldown ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nba_drilldown"
5
+
6
+ NbaDrilldown::CLI.new.call
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,65 @@
1
+ require "pry"
2
+ require "nokogiri"
3
+ require "open-uri"
4
+ class Team
5
+ attr_accessor :name, :url
6
+
7
+ @@all = []
8
+
9
+ def self.create_teams
10
+ doc = Nokogiri::HTML(open("http://espn.go.com/nba/teams"))
11
+ doc.search("a.bi").each do |team|
12
+ new_team = Team.new
13
+ new_team.name = team.text
14
+ new_team.url = team["href"]
15
+ @@all << new_team
16
+ end
17
+
18
+ end
19
+
20
+ def self.all
21
+ @@all
22
+ end
23
+
24
+ def create_players_from_team
25
+ doc = Nokogiri::HTML(open("#{self.url}"))
26
+ binding.pry
27
+ doc.search("a.text='Roster'")
28
+ end
29
+
30
+ end
31
+
32
+
33
+ #Alright so this creating teams works. Teams now have a "name" and "url"
34
+ #Teams will have many players and also belong to a conference. How can we assign the teams to a conference?
35
+
36
+ #doc.search("a.bi").first["href"] #Get first team url
37
+
38
+ #doc.search("a.bi") #returns all teams
39
+
40
+ http://espn.go.com/nba/team/roster/_/name/bos = Roster URL
41
+ a = "http://espn.go.com/nba/team/_/name/bos/boston-celtics" = Team.url
42
+
43
+
44
+ a array_words = ["http:", "", "espn.go.com", "nba", "team", "_", "name", "bos",]
45
+
46
+
47
+ a.split("/")
48
+ new_array = []
49
+ a.each do |text|
50
+ if text == "_"
51
+ text = "roster"
52
+ new_array << text
53
+ else
54
+ new_array << text
55
+ end
56
+ end
57
+ new_array.pop
58
+ new_array.insert(6,"_")
59
+ new_array.join("/")
60
+
61
+ #Array.insert()
62
+
63
+
64
+
65
+ How can we automatically create this???
@@ -0,0 +1,51 @@
1
+ class NbaDrilldown::CLI
2
+
3
+ def call
4
+ NbaDrilldown::Team.create_teams if NbaDrilldown::Team.all.empty?
5
+
6
+ #scrape_website
7
+ puts "Welcome to NBA Drilldown!"
8
+
9
+ puts "Please enter the number for a team to see its players or type 31 to exit"
10
+ NbaDrilldown::Team.list_teams
11
+ puts "31. Exit!!!"
12
+
13
+ input = gets.chomp.to_i
14
+ if input == 31
15
+ puts "Goodbye!"
16
+ elsif (1..30).include?(input)
17
+ team = NbaDrilldown::Team.find_team(input)
18
+ team.create_players_from_team
19
+ puts "The players of the #{team.name}"
20
+ team.list_players
21
+ continue?
22
+ else
23
+ puts "I am sorry please enter a valid team number"
24
+
25
+
26
+ end
27
+
28
+
29
+
30
+ end
31
+
32
+
33
+
34
+ def continue?
35
+ puts "Would you like to look at another team? Yes to return or No to exit."
36
+ input = gets.chomp
37
+ if input.downcase.capitalize == "Yes"
38
+ call
39
+ else
40
+ puts "Goodbye!"
41
+ end
42
+ end
43
+
44
+ def scrape_website
45
+ #NbaDrilldown::Conference.create_by_scraping
46
+ NbaDrilldown::Team.create_teams
47
+ NbaDrilldown::Team.create_players_from_team_url
48
+ end
49
+
50
+
51
+ end
@@ -0,0 +1,35 @@
1
+ class NbaDrilldown::Conference
2
+ attr_accessor :name
3
+
4
+ @@all = []
5
+
6
+ def initialize
7
+ @teams = []
8
+
9
+ end
10
+
11
+
12
+ def self.create_by_scraping
13
+ doc = Nokogiri::HTML(open("http://www.nba.com/standings/team_record_comparison/conferenceNew_Std_Cnf.html?ls=iref:nba:gnav"))
14
+
15
+ doc.search("td.confTitle").each do |conf|
16
+
17
+ c = NbaDrilldown::Conference.new
18
+ c.name = conf.text
19
+ @@all << c
20
+ end
21
+
22
+
23
+ end
24
+
25
+ def
26
+
27
+ def self.all
28
+ puts @@all
29
+ end
30
+
31
+ def self.list_standings
32
+ @@all.each {|conference| puts conference.name}
33
+ end
34
+
35
+ end
@@ -0,0 +1,44 @@
1
+ class NbaDrilldown::Player
2
+ attr_accessor :name, :team, :conference, :position, :number, :url
3
+
4
+ @@all = []
5
+
6
+ def initialize
7
+
8
+ end
9
+
10
+
11
+ def self.create_from_data(player)
12
+
13
+
14
+ #doc.search("td.sortcell a").each do |player|
15
+ new_player = NbaDrilldown::Player.new
16
+ new_player.name = player.text
17
+
18
+ new_player.url = player['href']
19
+ @@all << new_player
20
+ new_player
21
+
22
+
23
+
24
+ end
25
+
26
+ def add_player_info
27
+ doc = Nokogiri::HTML(open(self.url))
28
+
29
+ self.number = doc.search("ul.general-info li").first.text.match(/\d+/)
30
+ self.position = doc.search("ul.general-info li").first.text.match(/[A-Z]+/)
31
+
32
+
33
+
34
+ end
35
+
36
+ def self.list_players
37
+ @@all.each do |player|
38
+ puts player.name
39
+ end
40
+ end
41
+
42
+
43
+
44
+ end
@@ -0,0 +1,98 @@
1
+ class NbaDrilldown::Team
2
+ attr_accessor :name, :conference, :players, :url
3
+
4
+ @@all = []
5
+
6
+ def initialize
7
+ @players = []
8
+
9
+
10
+ end
11
+
12
+
13
+ def self.create_teams
14
+ doc = Nokogiri::HTML(open("http://espn.go.com/nba/teams"))
15
+ doc.search("a.bi").each do |team|
16
+ new_team = NbaDrilldown::Team.new
17
+ new_team.name = team.text
18
+ new_team.url = team["href"]
19
+ @@all << new_team
20
+ end
21
+
22
+ end
23
+
24
+ def list_players
25
+ puts "Name|Number|Position"
26
+ self.players.each do |player|
27
+ puts "#{player.name}|#{player.number}|#{player.position}"
28
+ end
29
+ end
30
+
31
+ def self.find_team(input)
32
+ team = @@all[input-1]
33
+ team
34
+ end
35
+
36
+ def self.list_teams
37
+ @@all.each_with_index do |team, index|
38
+ puts "#{index + 1}. #{team.name}"
39
+ end
40
+ end
41
+
42
+ def self.all
43
+ @@all
44
+ end
45
+
46
+ #def self.create_players_from_team_url
47
+ #self.all.each do |team|
48
+
49
+ # team.url = team.format_team_url
50
+
51
+ # doc = Nokogiri::HTML(open(team.url))
52
+ # doc.search("td.sortcell a").each do |player|
53
+ # new_player = NbaDrilldown::Player.create_from_data(player)
54
+
55
+ # new_player.add_player_info
56
+ # new_player.team = self
57
+
58
+ #team.players << new_player
59
+ #end
60
+ #end
61
+
62
+ #end
63
+
64
+ def create_players_from_team
65
+ self.url = self.format_team_url
66
+
67
+ doc = Nokogiri::HTML(open(self.url))
68
+ doc.search("td.sortcell a").each do |player|
69
+ new_player = NbaDrilldown::Player.create_from_data(player)
70
+
71
+ new_player.add_player_info
72
+ new_player.team = self
73
+
74
+ self.players << new_player
75
+ end
76
+
77
+ end
78
+
79
+
80
+
81
+ def format_team_url
82
+ split_array = self.url.split("/")
83
+ new_array = []
84
+ split_array.each do |text|
85
+ if text == "_"
86
+ text = "roster"
87
+ new_array << text
88
+ else
89
+ new_array << text
90
+ end
91
+ end
92
+ new_array.pop
93
+ new_array.insert(6,"_")
94
+ new_array.join("/")
95
+ end
96
+
97
+
98
+ end
@@ -0,0 +1,3 @@
1
+ module NbaDrilldown
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,13 @@
1
+ require "pry"
2
+ require "nokogiri"
3
+ require "open-uri"
4
+
5
+ require_relative './nba_drilldown/cli'
6
+ require_relative './nba_drilldown/version'
7
+ require_relative './nba_drilldown/team'
8
+ #require_relative './nba_drilldown/conference'
9
+ require_relative './nba_drilldown/player'
10
+
11
+ module NbaDrilldown
12
+ # Your code goes here...
13
+ end
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nba_drilldown/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nba_drilldown"
8
+ spec.version = NbaDrilldown::VERSION
9
+ spec.authors = ["tuckerbohman5"]
10
+ spec.email = ["tucker.bohman@gmail.com"]
11
+
12
+ spec.summary = "A gem to learn about NBA teams and players"
13
+ spec.description = "A gem to learn about NBA teams and players more functionaility to come."
14
+ spec.homepage = "http://github.com/tuckerbohman5"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ #if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ #else
22
+ #raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ #end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "bin"
27
+ #spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.executables = ["nba-drilldown"]
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.10"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+
34
+ spec.add_development_dependency "pry"
35
+
36
+ spec.add_dependency "nokogiri"
37
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nba_drilldown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - tuckerbohman5
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-29 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A gem to learn about NBA teams and players more functionaility to come.
70
+ email:
71
+ - tucker.bohman@gmail.com
72
+ executables:
73
+ - nba-drilldown
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/nba-drilldown
85
+ - bin/setup
86
+ - lib/EspnPracticeScraping.rb
87
+ - lib/nba_drilldown.rb
88
+ - lib/nba_drilldown/cli.rb
89
+ - lib/nba_drilldown/conference.rb
90
+ - lib/nba_drilldown/player.rb
91
+ - lib/nba_drilldown/team.rb
92
+ - lib/nba_drilldown/version.rb
93
+ - nba_drilldown.gemspec
94
+ homepage: http://github.com/tuckerbohman5
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.4.6
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: A gem to learn about NBA teams and players
118
+ test_files: []