marvel_best_superheroes 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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/marvel_best_superheroes +4 -0
- data/bin/setup +8 -0
- data/config/environment.rb +10 -0
- data/lib/marvel_best_superheroes.rb +9 -0
- data/lib/marvel_best_superheroes/allSuperheroes.rb +33 -0
- data/lib/marvel_best_superheroes/cli.rb +127 -0
- data/lib/marvel_best_superheroes/superhero.rb +55 -0
- data/lib/marvel_best_superheroes/version.rb +5 -0
- data/marvel_best_superheroes.gemspec +42 -0
- data/spec.md +6 -0
- metadata +149 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e96da69c00493a51c71a701f562777386481b21dee4f704176474f3542234bf0
|
|
4
|
+
data.tar.gz: f308329dbdc0ce6345d56269b356920f34a5d55c73c0b359ff496c9ea49521d7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c60f7209a4fad29858664100ef033a4a6811d72122cde7879f6ac471d89bac17edd980e0339b92d25581b7d63f390ee8579740c6927e9a4ad187d079a72a72a8
|
|
7
|
+
data.tar.gz: 046a2e4b8380004a83906940dddbcd1363ebf1bcbe5cb8a691a2accbd5b5f15234500cac6a6f3a9a887df34b7f17323d11c9720c1dfd842ab002563d5b80ac74
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -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 TODO: Write your email address. 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
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
marvel_best_superheroes (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
coderay (1.1.2)
|
|
10
|
+
colorize (0.8.1)
|
|
11
|
+
diff-lcs (1.3)
|
|
12
|
+
method_source (0.9.0)
|
|
13
|
+
mini_portile2 (2.3.0)
|
|
14
|
+
nokogiri (1.8.4)
|
|
15
|
+
mini_portile2 (~> 2.3.0)
|
|
16
|
+
pry (0.11.3)
|
|
17
|
+
coderay (~> 1.1.0)
|
|
18
|
+
method_source (~> 0.9.0)
|
|
19
|
+
rake (10.5.0)
|
|
20
|
+
rspec (3.7.0)
|
|
21
|
+
rspec-core (~> 3.7.0)
|
|
22
|
+
rspec-expectations (~> 3.7.0)
|
|
23
|
+
rspec-mocks (~> 3.7.0)
|
|
24
|
+
rspec-core (3.7.1)
|
|
25
|
+
rspec-support (~> 3.7.0)
|
|
26
|
+
rspec-expectations (3.7.0)
|
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
28
|
+
rspec-support (~> 3.7.0)
|
|
29
|
+
rspec-mocks (3.7.0)
|
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
31
|
+
rspec-support (~> 3.7.0)
|
|
32
|
+
rspec-support (3.7.1)
|
|
33
|
+
|
|
34
|
+
PLATFORMS
|
|
35
|
+
ruby
|
|
36
|
+
|
|
37
|
+
DEPENDENCIES
|
|
38
|
+
bundler (~> 1.16)
|
|
39
|
+
colorize
|
|
40
|
+
marvel_best_superheroes!
|
|
41
|
+
nokogiri
|
|
42
|
+
pry
|
|
43
|
+
rake (~> 10.0)
|
|
44
|
+
rspec (~> 3.0)
|
|
45
|
+
|
|
46
|
+
BUNDLED WITH
|
|
47
|
+
1.16.2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 TODO: Write your name
|
|
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,46 @@
|
|
|
1
|
+
# MarvelBestSuperheroes
|
|
2
|
+
|
|
3
|
+
Welcome to _Nhinh_Dao_ first ruby gem :D. I wanted to make this CLI gem because I have been so into Marvel Superheroes movies lately. In my opinion, the webpage I scraped didn't have the most accurate rank but at least they have all the informations of individual superheroes. For the thorough sources, please visit https://www.marvel.com/characters
|
|
4
|
+
|
|
5
|
+
This gem provides a CLI to view top 100 Marvels superheroes of all time with informations included super name, real name, birthday, died, character type, gender, and powers.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'marvel_best_superheroes'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install marvel_best_superheroes
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Type the command below and follow screen prompts
|
|
26
|
+
|
|
27
|
+
$ marvel_best_superheroes
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Development
|
|
31
|
+
|
|
32
|
+
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.
|
|
33
|
+
|
|
34
|
+
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).
|
|
35
|
+
|
|
36
|
+
## Contributing
|
|
37
|
+
|
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[nhinhdao]/marvel_best_superheroes. 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.
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
43
|
+
|
|
44
|
+
## Code of Conduct
|
|
45
|
+
|
|
46
|
+
Everyone interacting in the MarvelBestSuperheroes project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[nhinhdao]/marvel_best_superheroes/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "marvel_best_superheroes"
|
|
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__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
Bundler.require
|
|
3
|
+
require 'pry'
|
|
4
|
+
require 'nokogiri'
|
|
5
|
+
require 'open-uri'
|
|
6
|
+
|
|
7
|
+
require_relative '../lib/marvel_best_superheroes/allSuperheroes'
|
|
8
|
+
require_relative '../lib/marvel_best_superheroes/cli'
|
|
9
|
+
require_relative '../lib/marvel_best_superheroes/superhero'
|
|
10
|
+
require_relative '../lib/marvel_best_superheroes/version'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'pry'
|
|
2
|
+
require "nokogiri"
|
|
3
|
+
require 'open-uri'
|
|
4
|
+
|
|
5
|
+
class AllSuperheroes
|
|
6
|
+
|
|
7
|
+
attr_accessor :name, :url
|
|
8
|
+
|
|
9
|
+
SITE = "https://comicvine.gamespot.com/profile/noahmaximillion/lists/top-100-marvel-superheroes/48749/"
|
|
10
|
+
|
|
11
|
+
#array contains all superheroes information
|
|
12
|
+
@@all = []
|
|
13
|
+
|
|
14
|
+
def initialize(name = nil, url = nil)
|
|
15
|
+
@name = name
|
|
16
|
+
@url = url
|
|
17
|
+
@@all << self
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def self.create_all_superheroes
|
|
22
|
+
Nokogiri::HTML(open(SITE)).css("ul.editorial").css("li").map do |hero|
|
|
23
|
+
name = hero.css("h3").text
|
|
24
|
+
url = hero.css("a").attribute("href").value
|
|
25
|
+
self.new(name, url)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.all
|
|
30
|
+
@@all
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
require_relative "./allSuperheroes.rb"
|
|
2
|
+
require_relative "./superhero.rb"
|
|
3
|
+
require 'nokogiri'
|
|
4
|
+
require 'colorize'
|
|
5
|
+
require 'pry'
|
|
6
|
+
|
|
7
|
+
class CommandLineInterface
|
|
8
|
+
|
|
9
|
+
BASEPATH = "https://comicvine.gamespot.com"
|
|
10
|
+
|
|
11
|
+
def display
|
|
12
|
+
AllSuperheroes.create_all_superheroes
|
|
13
|
+
|
|
14
|
+
puts "\nHere shows TOP 100 MARVEL SUPERHEROES of all time: ".colorize(:blue)
|
|
15
|
+
puts "....................................................\n"
|
|
16
|
+
puts "\nWhat BADGE you are interested in:\n".colorize(:blue)
|
|
17
|
+
puts "1. OP - TOP 10 MOST BADASS SUPERHEROES".colorize(:blue)
|
|
18
|
+
puts "2. LEGENDARY - SUPERHEROES RANKED 11-25".colorize(:blue)
|
|
19
|
+
puts "3. SUPER-DUPER - SUPERHEROES RANKED 26-50".colorize(:blue)
|
|
20
|
+
puts "4. INCREDIBLE - SUPERHEROES RANKED 51-100".colorize(:blue)
|
|
21
|
+
|
|
22
|
+
get_badge
|
|
23
|
+
|
|
24
|
+
get_superhero_site
|
|
25
|
+
|
|
26
|
+
display_superhero
|
|
27
|
+
|
|
28
|
+
get_other_input
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def get_other_input
|
|
32
|
+
puts "Do you want to learn more about other Superheroes?"
|
|
33
|
+
puts "Type 'Y/Yes' or type 'Exit/No' to end the program"
|
|
34
|
+
input = gets.strip
|
|
35
|
+
if input.upcase == "Y" or input.upcase == "YES"
|
|
36
|
+
get_badge
|
|
37
|
+
get_superhero_site
|
|
38
|
+
display_superhero
|
|
39
|
+
get_other_input
|
|
40
|
+
elsif input.upcase == "EXIT" || input.upcase == "N" || input.upcase == "NO"
|
|
41
|
+
puts "\n___May the FORCE be with you!!!___\n".colorize(:blue)
|
|
42
|
+
else
|
|
43
|
+
puts "\n Invalid input"
|
|
44
|
+
get_other_input
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def get_badge
|
|
50
|
+
puts "\nPlease type in the Badge number to access: "
|
|
51
|
+
input = gets.strip
|
|
52
|
+
case input
|
|
53
|
+
when "1"
|
|
54
|
+
puts "\n Here comes TOP 10 MOST BADASS/OP SUPERHEROES \n".colorize(:blue)
|
|
55
|
+
list_all_superheroes(AllSuperheroes.all[0..9])
|
|
56
|
+
when "2"
|
|
57
|
+
puts "\n Here comes the Legendary Superheroes \n".colorize(:blue)
|
|
58
|
+
list_all_superheroes(AllSuperheroes.all[10..24])
|
|
59
|
+
when "3"
|
|
60
|
+
puts "\n Here comes the Super-duper Superheroes \n".colorize(:blue)
|
|
61
|
+
list_all_superheroes(AllSuperheroes.all[25..49])
|
|
62
|
+
when "4"
|
|
63
|
+
puts "\n Here comes the Incredible Superheroes \n".colorize(:blue)
|
|
64
|
+
list_all_superheroes(AllSuperheroes.all[50..100])
|
|
65
|
+
else
|
|
66
|
+
puts "Invalid input"
|
|
67
|
+
get_badge
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def get_superhero_site
|
|
72
|
+
puts "\nWhich superhero do you want to learn more about? "
|
|
73
|
+
puts "Please type in superhero number:"
|
|
74
|
+
input = gets.strip.to_i-1
|
|
75
|
+
if input >= 0 && input < all_superheroes_sites.size
|
|
76
|
+
puts "\nPlease wait while we evoke #{all_superheroes_names[input]}...\n"
|
|
77
|
+
Superheroes.get_superhero_infos(all_superheroes_sites[input])
|
|
78
|
+
else
|
|
79
|
+
puts "Invalid input"
|
|
80
|
+
puts "Please enter number in above selection"
|
|
81
|
+
get_superhero_site
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def list_all_superheroes(heroes)
|
|
87
|
+
heroes.each do |hero|
|
|
88
|
+
puts "#{hero.name}"
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
#collect each hero website from AllSuperheroes
|
|
93
|
+
def all_superheroes_sites
|
|
94
|
+
AllSuperheroes.all.map { |e| "#{BASEPATH}#{e.url}"}
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
#this method is called when program evokes individual superhero
|
|
98
|
+
def all_superheroes_names
|
|
99
|
+
AllSuperheroes.all.map { |e| "#{e.name}".split(". ")[1]}
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
#create a superhero base on user input
|
|
103
|
+
def create_superhero(site)
|
|
104
|
+
Superheroes.get_superhero_infos(site)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
#Print out each Superhero's informations in desired format
|
|
108
|
+
def display_superhero
|
|
109
|
+
Superheroes.all.each do |hero|
|
|
110
|
+
puts "\n#{hero.name.upcase}".colorize(:blue)
|
|
111
|
+
puts ""
|
|
112
|
+
puts " <> Biography:".colorize(:blue)
|
|
113
|
+
puts ""
|
|
114
|
+
puts "#{hero.biography}"
|
|
115
|
+
puts ""
|
|
116
|
+
puts " <> General Information:".colorize(:blue)
|
|
117
|
+
puts "\n - Super name:".colorize(:blue) + " #{hero.supername}"
|
|
118
|
+
puts "\n - Real name:".colorize(:blue) + " #{hero.realname}"
|
|
119
|
+
puts "\n - Aliases:".colorize(:blue) + " #{hero.aliases}"
|
|
120
|
+
puts "\n - Gender:".colorize(:blue) + " #{hero.gender}"
|
|
121
|
+
puts "\n - Character Type:".colorize(:blue) + " #{hero.charactertype}"
|
|
122
|
+
puts "\n - Birthday:".colorize(:blue) + " #{hero.birthday}"
|
|
123
|
+
puts "\n - Powers:".colorize(:blue) +" #{hero.powers}"
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require "nokogiri"
|
|
2
|
+
require "open-uri"
|
|
3
|
+
require "pry"
|
|
4
|
+
require_relative "./allSuperheroes.rb"
|
|
5
|
+
|
|
6
|
+
class Superheroes
|
|
7
|
+
|
|
8
|
+
attr_accessor :name, :biography, :supername, :realname, :aliases, :gender, :charactertype, :birthday, :powers
|
|
9
|
+
|
|
10
|
+
@@all = []
|
|
11
|
+
|
|
12
|
+
def initialize(name = nil, biography = nil, supername = nil, realname = nil, aliases = nil, gender = nil, charactertype = nil, birthday = nil, powers = nil)
|
|
13
|
+
@name = name
|
|
14
|
+
@biography = biography
|
|
15
|
+
@supername = supername
|
|
16
|
+
@realname = realname
|
|
17
|
+
@aliases = aliases
|
|
18
|
+
@gender = gender
|
|
19
|
+
@charactertype = charactertype
|
|
20
|
+
@birthday = birthday
|
|
21
|
+
@powers = powers
|
|
22
|
+
@@all << self
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def allsites
|
|
26
|
+
AllSuperheroes.all.map { |e| "#{BASEPATH}#{e.url}"}
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.get_superhero_infos(site)
|
|
30
|
+
|
|
31
|
+
Superheroes.reset
|
|
32
|
+
|
|
33
|
+
doc = Nokogiri::HTML(open(site)).css("table.table tbody")
|
|
34
|
+
name = Nokogiri::HTML(open(site)).css("h1").text.strip
|
|
35
|
+
biography = Nokogiri::HTML(open(site)).css("h3.display-view").text
|
|
36
|
+
supername = doc.css("div[data-field='realName']").text.strip.split(/\n/).first
|
|
37
|
+
aliases = doc.css("div[data-field='aliases']").text.strip.split("\r\n").map{|i| "\n #{i}"}.join
|
|
38
|
+
realname = doc.css("div[data-field='realName']").text.strip.split(/\n/).last.strip
|
|
39
|
+
gender = doc.css("div[data-field='gender']").text.strip
|
|
40
|
+
charactertype = doc.css("div[data-field='origin']").text.strip
|
|
41
|
+
birthday = doc.css("div[data-field='birthday']").text.strip
|
|
42
|
+
powers = doc.css("div[data-field='powers']").text
|
|
43
|
+
|
|
44
|
+
self.new(name, biography, supername, realname, aliases, gender, charactertype, birthday, powers)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.all
|
|
48
|
+
@@all
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def self.reset
|
|
52
|
+
@@all = []
|
|
53
|
+
end
|
|
54
|
+
# binding.pry
|
|
55
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "marvel_best_superheroes/version"
|
|
5
|
+
# require_relative './lib/marvel_best_superheroes/version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "marvel_best_superheroes"
|
|
9
|
+
spec.version = MarvelBestSuperheroes::VERSION
|
|
10
|
+
spec.date = "2018-07-13"
|
|
11
|
+
spec.authors = ["Nhinh Dao"]
|
|
12
|
+
spec.email = ["nhinhdao.vn@gmail.com"]
|
|
13
|
+
|
|
14
|
+
spec.summary = "Top 100 Marvel Best Superheroes"
|
|
15
|
+
spec.description = "Provide details on the top 100 Marvel Best Superheroes of all time"
|
|
16
|
+
spec.homepage = "http://rubygems.org/gems/marvel_best_superheroes"
|
|
17
|
+
spec.license = "MIT"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
22
|
+
# spec.files = ["lib/marvel_best_superheroes/allSuperheroes.rb",
|
|
23
|
+
# "lib/marvel_best_superheroes/superhero.rb",
|
|
24
|
+
# "lib/marvel_best_superheroes/cli.rb",
|
|
25
|
+
# "lib/marvel_best_superheroes.rb"]
|
|
26
|
+
# "config/environment.rb"]
|
|
27
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
29
|
+
end
|
|
30
|
+
# spec.bindir = "exe"
|
|
31
|
+
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
32
|
+
spec.executables << 'marvel_best_superheroes'
|
|
33
|
+
spec.require_paths = ["lib"]
|
|
34
|
+
|
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
38
|
+
spec.add_development_dependency "nokogiri", '~> 0'
|
|
39
|
+
spec.add_development_dependency "pry", "~> 0"
|
|
40
|
+
spec.add_development_dependency "colorize", "~> 0"
|
|
41
|
+
|
|
42
|
+
end
|
data/spec.md
ADDED
metadata
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: marvel_best_superheroes
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Nhinh Dao
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-07-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: '1.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
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: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.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: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: pry
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: colorize
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description: Provide details on the top 100 Marvel Best Superheroes of all time
|
|
98
|
+
email:
|
|
99
|
+
- nhinhdao.vn@gmail.com
|
|
100
|
+
executables:
|
|
101
|
+
- marvel_best_superheroes
|
|
102
|
+
extensions: []
|
|
103
|
+
extra_rdoc_files: []
|
|
104
|
+
files:
|
|
105
|
+
- ".gitignore"
|
|
106
|
+
- ".rspec"
|
|
107
|
+
- ".travis.yml"
|
|
108
|
+
- CODE_OF_CONDUCT.md
|
|
109
|
+
- Gemfile
|
|
110
|
+
- Gemfile.lock
|
|
111
|
+
- LICENSE.txt
|
|
112
|
+
- README.md
|
|
113
|
+
- Rakefile
|
|
114
|
+
- bin/console
|
|
115
|
+
- bin/marvel_best_superheroes
|
|
116
|
+
- bin/setup
|
|
117
|
+
- config/environment.rb
|
|
118
|
+
- lib/marvel_best_superheroes.rb
|
|
119
|
+
- lib/marvel_best_superheroes/allSuperheroes.rb
|
|
120
|
+
- lib/marvel_best_superheroes/cli.rb
|
|
121
|
+
- lib/marvel_best_superheroes/superhero.rb
|
|
122
|
+
- lib/marvel_best_superheroes/version.rb
|
|
123
|
+
- marvel_best_superheroes.gemspec
|
|
124
|
+
- spec.md
|
|
125
|
+
homepage: http://rubygems.org/gems/marvel_best_superheroes
|
|
126
|
+
licenses:
|
|
127
|
+
- MIT
|
|
128
|
+
metadata: {}
|
|
129
|
+
post_install_message:
|
|
130
|
+
rdoc_options: []
|
|
131
|
+
require_paths:
|
|
132
|
+
- lib
|
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - ">="
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: '0'
|
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
|
+
requirements:
|
|
140
|
+
- - ">="
|
|
141
|
+
- !ruby/object:Gem::Version
|
|
142
|
+
version: '0'
|
|
143
|
+
requirements: []
|
|
144
|
+
rubyforge_project:
|
|
145
|
+
rubygems_version: 2.7.7
|
|
146
|
+
signing_key:
|
|
147
|
+
specification_version: 4
|
|
148
|
+
summary: Top 100 Marvel Best Superheroes
|
|
149
|
+
test_files: []
|