hockey_orgs 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2f55643a4d252c3e771a207f8f5a06396d69c4eaa7ccc6c0fee97e83386a53dd
4
+ data.tar.gz: eeb4a3dbb6e3f4431b13fc609edfe5549e071e9e34059d3bb5403a0857841381
5
+ SHA512:
6
+ metadata.gz: 501bb833346797b43a148f2646f75e79961435666c5c02666dd3cc6e9019a1ea1e27a83b9d665ec0ed1807dc13211f68f28ae7cfb055d6397708bb48f800dbc4
7
+ data.tar.gz: 0e2eea4faefae5734abec3251ef30b123e7daace9ec6e063b72c4bc37f0b6dff2cfbf44bd56b8c9b2614cafa53398ef4942e8395eebf66c957d88783f8e8ed1a
Binary file
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mikewilder01@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in hockey_orgs.gemspec
4
+
@@ -0,0 +1,11 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+
5
+ PLATFORMS
6
+ ruby
7
+
8
+ DEPENDENCIES
9
+
10
+ BUNDLED WITH
11
+ 2.0.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Mike Wilder
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.
@@ -0,0 +1,43 @@
1
+ # HockeyOrgs
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/hockey_orgs`. 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 'hockey_orgs'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install hockey_orgs
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
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]/hockey_orgs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the HockeyOrgs project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/hockey_orgs/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "hockey_orgs"
5
+ require_relative "../lib/hockey_orgs.rb"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require '../lib/hockey_orgs/version.rb'
4
+ require '../lib/hockey_orgs/cli'
5
+ require '../lib/hockey_orgs/org.rb'
6
+ require '../lib/hockey_orgs/scraper.rb'
7
+ require 'net/http'
8
+ require 'pry'
9
+ require 'rest-client'
10
+ require 'JSON'
11
+ require 'httparty'
12
+
13
+ Cli.new.call
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
Binary file
@@ -0,0 +1,37 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "hockey_orgs/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hockey_orgs"
8
+ spec.version = HockeyOrgs::VERSION
9
+ spec.authors = ["Mike Wilder"]
10
+ spec.email = ["mikewilder01@gmail.com"]
11
+
12
+ spec.summary = %q{Hockey organizations}
13
+ spec.description = %q{Gathers information about hockey organizations}
14
+ spec.homepage = "http://mygemserver.com"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 2.0"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "pry"
33
+
34
+ spec.add_dependency "nokogiri"
35
+
36
+
37
+ end
Binary file
@@ -0,0 +1,6 @@
1
+ require "hockey_orgs/version"
2
+ require "./hockey_orgs/org"
3
+ require "./hockey_orgs/cli"
4
+ require "./hockey_orgs/scraper"
5
+
6
+ require 'nokogiri'
@@ -0,0 +1,105 @@
1
+
2
+ class Cli
3
+
4
+ def call
5
+ Scraper.create_orgs
6
+ Scraper.list_orgs
7
+ Cli.org_menu
8
+ end
9
+
10
+ def self.org_menu #top level menu, choose an
11
+ puts ""
12
+ puts "Enter the number of the team you would like to learn about(type exit to quit)"
13
+ input = gets.chomp
14
+ @i = input.to_i - 1
15
+ if input.downcase == 'exit'
16
+ self.goodbye
17
+ elsif @i < 0 or @i >= 31
18
+ puts ""
19
+ puts "invalid input"
20
+ else
21
+ puts ""
22
+ self.org_options(@i)
23
+ end
24
+ end
25
+
26
+ def self.org_options(i) #provide options for learning about the organization
27
+ name = Org.all[@i].name
28
+ puts "What would you like to know about the #{name}?(type exit to return to team selection)"
29
+ puts "1. Arena Name 2. Year of founding 3. What division do they play in?"
30
+ self.org_choice
31
+
32
+ end
33
+
34
+ def self.same_founding(input) #check if other teams were founded the same year
35
+ teams = []
36
+ arr = []
37
+ puts "Would you like to see all other teams founded that year?(please type y or n)"
38
+ input = gets.chomp.downcase
39
+ case input
40
+ when 'y'
41
+ Org.all.each do |o|
42
+ #binding.pry
43
+ if o.founding == Org.all[@i].founding && o.name != Org.all[@i].name
44
+ arr << o.name
45
+ end
46
+ end
47
+ if arr.size > 0
48
+ puts arr
49
+ else
50
+ puts "The #{Org.all[@i].name} were the only team founded that year"
51
+ end
52
+ when 'n'
53
+ self.org_options(@i)
54
+ else
55
+ "Please type Y or N"
56
+ end
57
+ end
58
+
59
+ def self.org_choice
60
+ choice = gets.chomp
61
+ if choice == "exit"
62
+ puts ""
63
+ puts "returning you to main menu"
64
+ Scraper.list_orgs
65
+ Cli.org_menu
66
+ elsif choice == '1'
67
+ puts ""
68
+ Org.get_arena(@i)
69
+ self.more_org_options
70
+ elsif choice == '2'
71
+ puts ""
72
+ Org.get_founding(@i)
73
+ self.same_founding(@i)
74
+ self.more_org_options
75
+ elsif choice == '3'
76
+ puts ""
77
+ Org.get_division(@i)
78
+ self.more_org_options
79
+ end
80
+
81
+ end
82
+
83
+ def self.more_org_options
84
+ puts "Would you like more info on The #{Org.all[@i].name}?(Please enter y or n)"
85
+ input = gets.chomp
86
+ case input
87
+ when 'y'
88
+ self.org_options(@i)
89
+ when 'n'
90
+ Scraper.list_orgs
91
+ self.org_menu
92
+ else
93
+ puts "Invalid input! Please enter y or n"
94
+ self.more_org_options
95
+ end
96
+
97
+ end
98
+
99
+ def self.goodbye
100
+ puts ""
101
+ puts "Thank you for your interest in the NHL, it was an honor to serve you."
102
+ end
103
+
104
+ end
105
+
File without changes
File without changes
@@ -0,0 +1,39 @@
1
+ class Org
2
+ attr_accessor :id, :name, :abbreviation, :stadium, :city, :founding, :division
3
+
4
+ @@all = []
5
+
6
+ def initialize(id, name, abbreviation, stadium, city, founding, division)
7
+ @id = id
8
+ @name = name
9
+ @abbreviation = abbreviation
10
+ @stadium = stadium
11
+ @city = city
12
+ @founding = founding
13
+ @division = division
14
+ @@all << self
15
+ end
16
+
17
+ def self.all
18
+ @@all
19
+ end
20
+
21
+ def self.get_arena(input)
22
+ #binding.pry
23
+ puts "The #{self.all[input].name} play at the #{self.all[input].stadium} in #{@@all[input].city}."
24
+ end
25
+
26
+ def self.get_founding(input)
27
+ puts "The #{self.all[input].name} were founded in #{self.all[input].founding}."
28
+ end
29
+
30
+ def self.get_division(input)
31
+ puts "The #{self.all[input].name} play in the #{self.all[input].division} Division."
32
+ end
33
+
34
+
35
+
36
+
37
+
38
+
39
+ end
@@ -0,0 +1,31 @@
1
+
2
+ URL = 'https://statsapi.web.nhl.com/api/v1/teams/'
3
+ class Scraper
4
+
5
+
6
+
7
+ def self.create_orgs #instantiates the organizations
8
+ #binding.pry
9
+ response = RestClient.get(URL)
10
+ data = JSON.parse(response.body)["teams"]
11
+ x = data.sort_by {|o| o["name"]}
12
+ x.each.with_index(1) do |o, i|
13
+ Org.new(i, o["name"], o["abbreviation"], o["venue"]["name"], o["venue"]["city"], o["firstYearOfPlay"], o["division"]["name"])
14
+ end
15
+ end
16
+
17
+ def self.list_orgs #numbered list of organizations for selection
18
+ puts "Hello and welcome to Hockey Orgs! Below you will find a list of all active NHL franchises:"
19
+ sleep(1)
20
+ puts " "
21
+ Org.all.each do |o|
22
+ #binding.pry
23
+ puts "#{o.id}. #{o.name}"
24
+ end
25
+ end
26
+
27
+
28
+
29
+
30
+
31
+ end
@@ -0,0 +1,3 @@
1
+ module HockeyOrgs
2
+ VERSION = "0.1.1"
3
+ end
data/notes ADDED
@@ -0,0 +1,51 @@
1
+ Okay it works but it's gotta get cleaned up big time
2
+
3
+ Instantiate a class you SOB
4
+ that's clearly what they want from you, you just got carried away
5
+ thats fine though it works
6
+
7
+ lol you did that quick
8
+
9
+ need to split up some more of that bs into
10
+ clean little functions or methods or whatever
11
+
12
+ get it going on
13
+
14
+ alphabetized, indexed, enter a number to pick a team
15
+ how to do that
16
+ what is the problem
17
+ that's a question for the morning
18
+
19
+ filter out invalid inputs and the indexed input thing
20
+ those are the big ones
21
+
22
+ don't worry about making it pretty necessarily, who cares
23
+
24
+ org.rb 80 that cannot be input, i don't think
25
+ why not?
26
+ well basically i'd like to get to the point where the list is
27
+ a list of the actual objects, the instances of Org that are generated
28
+ and are selectable based on Org.name(i did this, but Org.id instead)
29
+ it needs to be actually selecting the instance. not just providing
30
+ input which i can use to call the instance.
31
+
32
+ new class called like grabber or something? who cares what it's called
33
+ thats what it will do. it will grab.
34
+ that way the input could be a class variable or i guess an instance variable
35
+ and even when it goes to the next method it would still grab that variable.
36
+
37
+ not sure what that shit above is about.
38
+
39
+ it's broken, basically. something is trying to do too many things
40
+ something is showing up where it shouldn't be
41
+ i assume it has something to do with seperation of concerns. but maybe not
42
+
43
+ take the time tomorrow(or tonight) to draw up a flowchart.
44
+ you absolutely can track this issue down.
45
+
46
+ the problems right now(order of importance)
47
+ 1. it's broken
48
+ 2. filter out invalid inputs
49
+ 3. clean it up, check out seperation of concerns
50
+
51
+ just needs to be done sunday night but tomorrow would be great
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hockey_orgs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Mike Wilder
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-12-13 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
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: Gathers information about hockey organizations
70
+ email:
71
+ - mikewilder01@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".DS_Store"
77
+ - ".gitignore"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - Gemfile.lock
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/hockey_orgs
86
+ - bin/setup
87
+ - hockey_orgs-0.1.0.gem
88
+ - hockey_orgs.gemspec
89
+ - lib/.DS_Store
90
+ - lib/hockey_orgs.rb
91
+ - lib/hockey_orgs/cli.rb
92
+ - lib/hockey_orgs/division.rb
93
+ - lib/hockey_orgs/grabber.rb
94
+ - lib/hockey_orgs/org.rb
95
+ - lib/hockey_orgs/scraper.rb
96
+ - lib/hockey_orgs/version.rb
97
+ - notes
98
+ homepage: http://mygemserver.com
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubygems_version: 3.0.3
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Hockey organizations
121
+ test_files: []