yale_bulldogs 0.0.2

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: b0673a2cc78f54adea693388c1c09d3f461529bf
4
+ data.tar.gz: 993ae9d32f335f42aee71dced57c6300dd6d1281
5
+ SHA512:
6
+ metadata.gz: 2c3984dd7e2ee030e1536fc8aaa177cc1017400758d07f80a6bdeb7a59cb005f3b5a424bcbaaacb686b586ff100fc1cc8605cacdf3d4e62798d525a01f6eb716
7
+ data.tar.gz: ea7e3ac8ebc9691936ab10e7c1e88b3e9ffe2d3fd4e0ac016903477978df6420ea5045601d318aa1a62f6d188bccba8145a8cd0152da8840bee3f3b1fb44d20e
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yale_bulldogs.gemspec
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Colton Staab
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,31 @@
1
+ # YaleBulldogs
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'yale_bulldogs'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install yale_bulldogs
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/yale_bulldogs/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/yale-bulldogs ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require './lib/yale_bulldogs'
4
+
5
+ YaleBulldogs::CLI.new.call
@@ -0,0 +1,95 @@
1
+ class YaleBulldogs::CLI
2
+
3
+ def call
4
+ puts "Welcome to the Yale Swimming and Diving CLI app"
5
+ puts "Please enter 'exit' at any time to quit the app"
6
+ meet_information
7
+ goodbye
8
+ end
9
+
10
+ def request_gender
11
+ gender_input = nil
12
+ while gender_input != 'exit'
13
+ puts "Are you looking for information on the men's team or women's team?:"
14
+ gender_input = gets.strip.downcase
15
+ if gender_input == 'm' || gender_input =='men' || gender_input == 'mens' || gender_input == "men's"
16
+ gender = 'm'
17
+ elsif gender_input == 'w' || gender_input == 'women' || gender_input == 'womens' || gender_input == "women's"
18
+ gender = 'w'
19
+ elsif gender_input == 'exit'
20
+ abort("Bulldogs, bulldogs, bow bow bow, Eli Yale!")
21
+ else
22
+ puts "Input invalid. Please try again."
23
+ request_gender
24
+ end
25
+ return gender
26
+ end
27
+ end
28
+
29
+ def request_year
30
+ year = nil
31
+ while year != 'exit'
32
+ puts "What year are you interested in? (input must be in YYYY format):"
33
+ year = gets.strip
34
+ if year.to_s.length != 4
35
+ puts "Input invalid. Please try again."
36
+ request_year
37
+ end
38
+ return year
39
+ end
40
+ end
41
+
42
+ def get_year_range(year)
43
+ year.to_s + '-' + (year.to_i + 1).to_s[2..4]
44
+ end
45
+
46
+ def request_data
47
+ gender = request_gender
48
+ year = request_year
49
+ url = "http://yalebulldogs.com/sports/#{gender}-swim/#{self.get_year_range(year)}/schedule"
50
+ begin
51
+ doc = Nokogiri::HTML(open(url))
52
+ return doc
53
+ rescue
54
+ puts "Data not available for that season. Please try again."
55
+ request_data
56
+ end
57
+ end
58
+
59
+ def display_meets
60
+ doc = request_data
61
+ results = YaleBulldogs::Season.scrape_season(doc)
62
+ puts results[0].text
63
+ results[1].each_with_index do |meet, index|
64
+ puts (index + 1).to_s + ". : " + meet.opponent
65
+ end
66
+ results[1]
67
+ end
68
+
69
+ def meet_information
70
+ meets = display_meets
71
+ input = nil
72
+ while input != 'exit' && input != 'back'
73
+ puts "Which meet are you interested in? (enter meet number):"
74
+ input = gets.strip
75
+ if input.to_i > 0 && input.to_i <= meets.length
76
+ meet = meets[input.to_i - 1]
77
+ puts "Opponent: " + meet.opponent
78
+ puts "Date: " + meet.date
79
+ puts "Time: " + meet.time
80
+ puts "Result: " + meet.result
81
+ elsif input == 'back'
82
+ call
83
+ elsif input == 'exit'
84
+ break
85
+ else
86
+ puts "Number invalid. Please try again:"
87
+ end
88
+ end
89
+ end
90
+
91
+
92
+ def goodbye
93
+ puts "Bulldogs, bulldogs, bow bow bow, Eli Yale!"
94
+ end
95
+ end
@@ -0,0 +1,10 @@
1
+ class YaleBulldogs::Meet
2
+ attr_accessor :date, :opponent, :time, :result
3
+
4
+ def initialize(date=nil, opponent=nil, time=nil, result=nil)
5
+ @date = date
6
+ @opponent = opponent
7
+ @time = time
8
+ @result = result
9
+ end
10
+ end
@@ -0,0 +1,60 @@
1
+ class YaleBulldogs::Season
2
+
3
+ def self.check_availability(gender, year)
4
+ url = "http://yalebulldogs.com/sports/#{gender}-swim/#{self.get_year_range(year)}/schedule"
5
+ begin
6
+ doc = Nokogiri::HTML(open(url))
7
+ end
8
+ rescue
9
+
10
+ end
11
+
12
+ def self.scrape_season(doc)
13
+ season_title = doc.css("#mainbody h1")
14
+
15
+ meets = []
16
+ meet_data = doc.css(".schedule-home, .schedule-away")
17
+ meet_data.each do |row|
18
+ cell_data = row.css('td')
19
+ date = cell_data[0].text.gsub(/\s+/, ' ')
20
+ if date != ""
21
+ opponent = cell_data[1].text.strip.gsub(/\s+/, ' ')
22
+ time = cell_data[2].text.strip.gsub(/\s+/, ' ')
23
+ result = cell_data[3].text.strip.gsub(/\s+/, ' ')
24
+ if time != ''
25
+ meet = YaleBulldogs::Meet.new(date=date, opponent=opponent,time=time,result=result)
26
+ meets << meet
27
+ end
28
+ end
29
+ end
30
+ return [season_title, meets]
31
+ end
32
+
33
+ def self.display_meets(doc)
34
+ results = self.scrape_season(doc)
35
+ puts results[0].text
36
+ results[1].each_with_index do |meet, index|
37
+ puts (index + 1).to_s + ". : " + meet.opponent
38
+ end
39
+ results[1]
40
+ end
41
+
42
+ def self.meet_information(doc)
43
+ meets = self.display_meets(doc)
44
+ input = nil
45
+ while input != 'exit'
46
+ puts "Which meet are you interested in? (enter meet number):"
47
+ input = gets.to_i
48
+ if input > 0
49
+ meet = meets[input - 1]
50
+ puts "Opponent: " + meet.opponent
51
+ puts "Date: " + meet.date
52
+ puts "Time: " + meet.time
53
+ puts "Result: " + meet.result
54
+ else
55
+ puts "Number invalid. Please try again:"
56
+ self.meet_information(doc)
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module YaleBulldogs
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,8 @@
1
+ require_relative "./yale_bulldogs/version"
2
+ require_relative './yale_bulldogs/cli.rb'
3
+ require_relative "./yale_bulldogs/season.rb"
4
+ require_relative "./yale_bulldogs/meet.rb"
5
+
6
+ require 'irb'
7
+ require 'nokogiri'
8
+ require 'open-uri'
data/notes.md ADDED
@@ -0,0 +1,9 @@
1
+ What are we looking to do? We're looking to give the meet schedule for each team
2
+
3
+ Each meet has:
4
+ 1. a date
5
+ 2. an opponent
6
+ 3. the Bulldogs' score
7
+ 4. The competitors' score
8
+ 5. A location
9
+ 6. Bulldogs win/loss
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'yale_bulldogs/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yale_bulldogs"
8
+ spec.version = YaleBulldogs::VERSION
9
+ spec.authors = ["Colton Staab"]
10
+ spec.email = ["colton.staab@gmail.com"]
11
+ spec.summary = "http://yalebulldogs.com/"
12
+ #spec.summary = %q{TODO: Write a short summary. Required.}
13
+ #spec.description = %q{TODO: Write a longer description. Optional.}
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_dependency "nokogiri"
24
+ spec.add_dependency "activerecord"
25
+
26
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yale_bulldogs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Colton Staab
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-08 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: activerecord
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:
70
+ email:
71
+ - colton.staab@gmail.com
72
+ executables:
73
+ - yale-bulldogs
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/yale-bulldogs
83
+ - lib/yale_bulldogs.rb
84
+ - lib/yale_bulldogs/cli.rb
85
+ - lib/yale_bulldogs/meet.rb
86
+ - lib/yale_bulldogs/season.rb
87
+ - lib/yale_bulldogs/version.rb
88
+ - notes.md
89
+ - yale_bulldogs.gemspec
90
+ homepage:
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.2.3
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: http://yalebulldogs.com/
114
+ test_files: []