ow_heroes_roster 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f778b4d2ebe8fe0329bf9486d6bffd43445c9ae7
4
+ data.tar.gz: f60d87f3b5ae7ef7fc975cdb2cccc3b7c8192213
5
+ SHA512:
6
+ metadata.gz: 117cf642338860a0fd36b954f364e335fe116ebf7cfb83cbab08c73b64215d1bd8b9d88cc39564c7a57d9e869b99785be9c5169db58bfc7b7084470acb9563f1
7
+ data.tar.gz: 4498ac3d402c01b8e8e8b8304811940473a5d77f82d6bd89a5d0e5af84e74c3c86e8ba3b69e24cb79ea3292b50de156fa415c1ad90c0cde247908955f177272c
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.15.2
@@ -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 jennimacklin@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,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in ow_heroes_roster.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 jlmack13
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
+ # OwHeroesRoster
2
+
3
+ Welcome to the Overwatch Heroes Roster Gem! This gem will show you a list of all the current heroes available in the video game Overwatch. You can also see more detailed information about each individual hero if you wish.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ow_heroes_roster'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ow_heroes_roster
20
+
21
+ ## Usage
22
+
23
+ When you run the program you will see a list of instructions and the current roster of heroes. To view more information about a hero, type their name when prompted (alternatively, you can also type 'roster' to see the list again, or 'exit' if you are done with the program).
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jlmack13/ow_heroes_roster. 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.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
38
+
39
+ ## Code of Conduct
40
+
41
+ Everyone interacting in the OwHeroesRoster project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/jlmack13/ow_heroes_roster/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ow_heroes_roster"
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(__FILE__)
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require "./lib/ow_heroes_roster"
3
+
4
+ OwHeroesRoster::CLI.new.call
data/bin/setup ADDED
@@ -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
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,4 @@
1
+ require_relative "ow_heroes_roster/version"
2
+ require_relative "ow_heroes_roster/roster.rb"
3
+ require_relative "ow_heroes_roster/hero.rb"
4
+ require_relative "./ow_heroes_roster/cli"
Binary file
@@ -0,0 +1,54 @@
1
+ require 'colorize'
2
+
3
+ class OwHeroesRoster::CLI
4
+
5
+ def call
6
+ puts "\nWELCOME TO THE OVERWATCH HEROES ROSTER GEM!".colorize(:green)
7
+ puts "\n----***------ INSTRUCTIONS ------***----".colorize(:white)
8
+ puts "\n1. Enter a hero's name to see their details.".colorize(:white)
9
+ puts "2. To see the roster again, type 'roster'.".colorize(:white)
10
+ puts "3. To exit the program, type 'exit'.".colorize(:white)
11
+ puts "\n----------------------------------------".colorize(:white)
12
+ Roster.scrape_roster_page
13
+ list_heroes
14
+ menu
15
+ end
16
+
17
+ #print the list of heroes scraped from the site
18
+ def list_heroes
19
+ puts "\n---***------ HEROES ------***---".colorize(:yellow)
20
+ @heroes = Hero.all
21
+ Hero.all.each do |hero|
22
+ print " --- ".colorize(:magenta)
23
+ puts "#{hero.name}".colorize(:white)
24
+ end
25
+ menu
26
+ end
27
+
28
+ #ask user if they'd like to select a hero (by name or number?) for more details, reprint the list, or exit the program
29
+ def menu
30
+ print "\nWhat would you like to do? ".colorize(:green)
31
+ input = gets.strip.upcase
32
+ if input == 'ROSTER'
33
+ list_heroes
34
+ elsif input == 'EXIT'
35
+ exit
36
+ else
37
+ display_hero(input)
38
+ end
39
+ end
40
+
41
+ #display the details of the requested hero. do I want this here?
42
+ def display_hero(input)
43
+ #use a find by name method to get the right hero and then display the information
44
+ if Hero.find_by_name(input)
45
+ hero = Hero.find_by_name(input)
46
+ hero.display_information
47
+ menu
48
+ else
49
+ puts "\nSorry could not find a hero by that name. Please try again.".colorize(:green)
50
+ menu
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,85 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'pry'
4
+ require 'colorize'
5
+
6
+ class Hero
7
+ attr_accessor :name, :role, :url, :path, :overview, :abilities, :biography, :quote
8
+
9
+ @@all = []
10
+
11
+ def initialize(name, path)
12
+ @name = name
13
+ @url = "https://playoverwatch.com#{path}"
14
+ @@all << self
15
+ end
16
+
17
+ def self.find_by_name(name)
18
+ self.all.find{|hero| hero.name == name}
19
+ end
20
+
21
+ #get details by scraping hero page
22
+ def get_details(index_url)
23
+ html = open(index_url)
24
+ doc = Nokogiri::HTML(html)
25
+
26
+ #role
27
+ @role = doc.css(".hero-detail-role-name").text
28
+
29
+ #overview
30
+ @overview = doc.css("#overview .hero-detail-description").text
31
+
32
+ #abilities
33
+ @abilities = []
34
+ doc.css(".hero-ability").each do |ability|
35
+ hero_ability = ability.css(".hero-ability-descriptor .h5").text
36
+ hero_description = ability.css(".hero-ability-descriptor p").text
37
+ @abilities << {ability: hero_ability, description: hero_description}
38
+ end
39
+
40
+ #biography
41
+ @biography = {}
42
+ doc.css("#story .hero-bio").each do |info|
43
+ hero_real_name = info.css(".name .hero-bio-copy").text
44
+ hero_occupation = info.css(".occupation .hero-bio-copy").text
45
+ hero_base = info.css(".base .hero-bio-copy").text
46
+ hero_affiliation = info.css(".affiliation").text
47
+ @biography = {real_name: hero_real_name, occupation: hero_occupation, base: hero_base, affiliation: hero_affiliation}
48
+ end
49
+
50
+ #quote
51
+ @quote = doc.css("#story p.h4").text
52
+ end
53
+
54
+ #display hero details
55
+ def display_information
56
+ get_details(url)
57
+ puts "\n--------------------------------".colorize(:yellow)
58
+ print "\n**".colorize(:magenta)
59
+ print " #{self.name.upcase}".colorize(:white)
60
+ puts " **".colorize(:magenta)
61
+ puts "\n--------------------------------".colorize(:yellow)
62
+ puts "\nROLE: #{self.role}".colorize(:yellow)
63
+ puts "--------------------------------".colorize(:magenta)
64
+ puts "OVERVIEW:".colorize(:yellow)
65
+ puts "#{self.overview}".colorize(:white)
66
+ puts "--------------------------------".colorize(:magenta)
67
+ puts "ABILITIES:\n".colorize(:yellow)
68
+ self.abilities.each do |ability|
69
+ puts "*#{ability[:ability]}: #{ability[:description]}".colorize(:white)
70
+ end
71
+ puts "--------------------------------".colorize(:magenta)
72
+ puts "BIOGRAPHY:\n".colorize(:yellow)
73
+ self.biography.each_value {|value| puts "\t*#{value}".colorize(:white) }
74
+ puts "\n--------------------------------".colorize(:magenta)
75
+ if self.quote != ""
76
+ puts "QUOTE: #{self.quote}".colorize(:yellow)
77
+ puts "--------------------------------".colorize(:magenta)
78
+ end
79
+ end
80
+
81
+ def self.all
82
+ @@all
83
+ end
84
+
85
+ end
@@ -0,0 +1,29 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'pry'
4
+ require_relative './hero.rb'
5
+
6
+ class Roster
7
+
8
+ def self.scrape_roster_page
9
+ html = open("https://playoverwatch.com/en-us/heroes/")
10
+ heroes = []
11
+ doc = Nokogiri::HTML(html)
12
+ doc.css(".hero-portrait-detailed-container").each do |card|
13
+ hero_name = card.css(".container .portrait-title").text
14
+ if hero_name.include?("ú")
15
+ hero_name = hero_name.gsub(/ú/, 'u')
16
+ elsif hero_name.include?("ö")
17
+ hero_name = hero_name.gsub(/ö/, 'o')
18
+ end
19
+ hero_url = card.css("a").attr("href").value
20
+ heroes << {name: hero_name.upcase, url: hero_url}
21
+ end
22
+ heroes.each do |hero|
23
+ hero = Hero.new(hero[:name], hero[:url])
24
+ end
25
+
26
+ end
27
+
28
+
29
+ end
@@ -0,0 +1,3 @@
1
+ module OwHeroesRoster
2
+ VERSION = "0.1.2"
3
+ end
Binary file
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ow_heroes_roster/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ow_heroes_roster"
8
+ spec.version = OwHeroesRoster::VERSION
9
+ spec.authors = ["jlmack13"]
10
+ spec.email = ["jennimacklin@hotmail.com"]
11
+
12
+ spec.summary = %q{Roster of all the heroes in Overwatch.}
13
+ spec.description = %q{This gem scrapes the Overwatch website and provides a roster of all current heroes and their details.}
14
+ spec.homepage = "https://github.com/jlmack13/jennifer-macklin-cli-app"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "colorize"
25
+ spec.add_development_dependency "bundler", "~> 1.15"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
data/spec.md ADDED
@@ -0,0 +1,6 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [x] Have a CLI for interfacing with the application : I created a CLI that shows the user a roster of heroes and allows them to either see more information about a specific hero, see the list again, or exit the program.
5
+ - [x] Pull data from an external source : I've pulled data from both the page that has the main list of heroes on the Overwatch site, and data from the individual hero pages that provides detailed information about each of the heroes (different pages for each hero).
6
+ - [x] Implement both list and detail views : My program starts by pulling a list of current heroes from the Overwatch website and displaying it to the user. It also shows the user detail views for each of the heroes, which was also scraped from the Overwatch site.
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ow_heroes_roster
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - jlmack13
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: This gem scrapes the Overwatch website and provides a roster of all current
70
+ heroes and their details.
71
+ email:
72
+ - jennimacklin@hotmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".DS_Store"
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - CODE_OF_CONDUCT.md
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/ow-heroes-roster
88
+ - bin/setup
89
+ - lib/.DS_Store
90
+ - lib/ow_heroes_roster.rb
91
+ - lib/ow_heroes_roster/.DS_Store
92
+ - lib/ow_heroes_roster/cli.rb
93
+ - lib/ow_heroes_roster/hero.rb
94
+ - lib/ow_heroes_roster/roster.rb
95
+ - lib/ow_heroes_roster/version.rb
96
+ - ow_heroes_roster-0.1.0.gem
97
+ - ow_heroes_roster.gemspec
98
+ - spec.md
99
+ homepage: https://github.com/jlmack13/jennifer-macklin-cli-app
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.6.12
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Roster of all the heroes in Overwatch.
123
+ test_files: []