stranger_things_directory 0.2.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/bin/stranger_things_directory +11 -0
- data/config/environment.rb +11 -0
- data/lib/stranger_things_directory.rb +7 -0
- data/lib/stranger_things_directory/character_scraper.rb +19 -0
- data/lib/stranger_things_directory/characters.rb +73 -0
- data/lib/stranger_things_directory/cli.rb +137 -0
- data/lib/stranger_things_directory/location_scraper.rb +26 -0
- data/lib/stranger_things_directory/locations.rb +49 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7d1fd429be2e8012c4637e692c9446f8125fa25411065305b5eed4698d644ac6
|
4
|
+
data.tar.gz: 0b0acb3c1537c5beb7c289d546707ee87ecccf4910b68e2beacb5d7bfd63f4eb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c873b6d9c45be308492a7598ef607eb7e9b68f73d7e8a0f29d85afa2b9f373aeab23c3e5eca733120d2ed3c348a1148125d41e46e4e0d0bd001e06280921b8bd
|
7
|
+
data.tar.gz: bbe3dc1e3d267aa105b20ae0fae0a10b3401374a0c200ab1b4f0b0d8e15245711d1f9b5906aa9bee0280443236f2d83683440fd348668948ece28d9833d7636e
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
|
5
|
+
require_relative '../lib/stranger_things_directory'
|
6
|
+
|
7
|
+
#We don't want any real logic or programming to go here, that could cause issues/a broken program.. so we want to call another file that has the logic within it
|
8
|
+
# we don't have this file yet, but I want to kind of have an idea of what I want the program to look like, and it would make the most sense to have a CLI class that does the running for me
|
9
|
+
|
10
|
+
|
11
|
+
StrangerThingsDirectory::CLI.new.call
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
|
6
|
+
require_relative '../lib/stranger_things_directory/cli'
|
7
|
+
require_relative '../lib/stranger_things_directory/location_scraper'
|
8
|
+
require_relative '../lib/stranger_things_directory/locations'
|
9
|
+
require_relative '../lib/stranger_things_directory/character_scraper'
|
10
|
+
require_relative '../lib/stranger_things_directory/characters'
|
11
|
+
require_relative '../lib/stranger_things_directory/version'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class StrangerThingsDirectory::CharacterScraper
|
2
|
+
|
3
|
+
def open_page
|
4
|
+
Nokogiri::HTML(open("https://strangerthings.fandom.com/wiki/Category:Characters"))
|
5
|
+
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_characters
|
9
|
+
self.open_page.css("div#WikiaArticle.WikiaArticle ul.category-page__trending-pages li.category-page__trending-page")
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def send_characters
|
14
|
+
self.get_characters.each do |character|
|
15
|
+
StrangerThingsDirectory::Characters.new_character(character)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class StrangerThingsDirectory::Characters
|
2
|
+
attr_accessor :url, :name, :gender, :status, :age, :born, :aliases, :residence, :family, :affiliation, :occupation, :actor
|
3
|
+
|
4
|
+
@@all = []
|
5
|
+
|
6
|
+
def self.new_character(char)
|
7
|
+
self.new(
|
8
|
+
char.css("a figure figcaption.category-page__trending-page-title").text,
|
9
|
+
"https://strangerthings.fandom.com#{char.css("a").attribute("href").text}"
|
10
|
+
)
|
11
|
+
end
|
12
|
+
def initialize(name=nil, url=nil)
|
13
|
+
@name = name
|
14
|
+
@url = url
|
15
|
+
@@all << self
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.all
|
19
|
+
@@all
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.find(index)
|
23
|
+
@@all[index -1]
|
24
|
+
end
|
25
|
+
|
26
|
+
def doc
|
27
|
+
@doc ||= Nokogiri::HTML(open(self.url))
|
28
|
+
end
|
29
|
+
|
30
|
+
def gender
|
31
|
+
@gender ||= doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=gender] div.pi-data-value.pi-font").text
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def actor
|
36
|
+
@actor ||= doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=portrayer] a").text
|
37
|
+
end
|
38
|
+
|
39
|
+
def status
|
40
|
+
@status ||= doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=status] div.pi-data-value.pi-font").text
|
41
|
+
end
|
42
|
+
|
43
|
+
def born
|
44
|
+
@born ||= doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=born] div.pi-data-value.pi-font").text
|
45
|
+
end
|
46
|
+
|
47
|
+
def aliases
|
48
|
+
@aliases ||= doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=aliases] div.pi-data-value.pi-font").collect {|p| p.children.text}
|
49
|
+
end
|
50
|
+
|
51
|
+
def residence
|
52
|
+
@residence ||= doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=residence] div.pi-data-value.pi-font a").collect {|a| a.text}
|
53
|
+
end
|
54
|
+
|
55
|
+
def affiliation
|
56
|
+
@affiliation ||= doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=affiliation] div.pi-data-value.pi-font a").collect {|a| a.text}
|
57
|
+
end
|
58
|
+
|
59
|
+
def age
|
60
|
+
@age ||= doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=age] div.pi-data-value.pi-font").collect {|a| a.text}
|
61
|
+
end
|
62
|
+
|
63
|
+
def occupation
|
64
|
+
@occupation ||= doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=occupation] div.pi-data-value.pi-font").collect {|a| a.text}
|
65
|
+
end
|
66
|
+
|
67
|
+
def family
|
68
|
+
@family ||= doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=relatives] div.pi-data-value.pi-font").collect {|a| a.text}
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
class StrangerThingsDirectory::CLI
|
2
|
+
|
3
|
+
def call
|
4
|
+
StrangerThingsDirectory::LocationScraper.new.send_locations
|
5
|
+
StrangerThingsDirectory::CharacterScraper.new.send_characters
|
6
|
+
welcome_message
|
7
|
+
end
|
8
|
+
|
9
|
+
def welcome_message
|
10
|
+
|
11
|
+
puts " . * . . "
|
12
|
+
puts " * -0- "
|
13
|
+
puts " . . * - )-"
|
14
|
+
puts " . * o . *"
|
15
|
+
puts " o |"
|
16
|
+
puts " . -O-"
|
17
|
+
puts ". | * . -0-"
|
18
|
+
puts " * o . ' * . o"
|
19
|
+
puts " . . | *"
|
20
|
+
puts " * * -O- ."
|
21
|
+
puts " . * | ,"
|
22
|
+
puts " . o"
|
23
|
+
puts " .---."
|
24
|
+
puts " = _/__~0_\_ . * o '"
|
25
|
+
puts " = = (_________) ."
|
26
|
+
puts " . *"
|
27
|
+
puts " * - ) - * "
|
28
|
+
puts ""
|
29
|
+
|
30
|
+
puts ""
|
31
|
+
puts "Welcome to the Stranger Things character and location directory!"
|
32
|
+
puts ""
|
33
|
+
|
34
|
+
play
|
35
|
+
end
|
36
|
+
|
37
|
+
def play
|
38
|
+
puts ""
|
39
|
+
puts "If you would like to see a list of trending characters enter 1, for locations enter 2. Or if you would like to exit, enter exit: "
|
40
|
+
|
41
|
+
input = gets.strip
|
42
|
+
|
43
|
+
case input
|
44
|
+
when "1"
|
45
|
+
character_list
|
46
|
+
when "2"
|
47
|
+
location_list
|
48
|
+
when "exit"
|
49
|
+
exit_message
|
50
|
+
else
|
51
|
+
puts "I'm sorry, that didn't work. Try again!"
|
52
|
+
play
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def location_list
|
58
|
+
puts ""
|
59
|
+
puts "A list of popular locations from the show will appear below. After, pick a number to learn more about that location!"
|
60
|
+
puts ""
|
61
|
+
puts "------Stranger Things Locations:------"
|
62
|
+
StrangerThingsDirectory::Locations.all.each_with_index do |location, index|
|
63
|
+
puts "#{index +1}. #{location.name}"
|
64
|
+
end
|
65
|
+
pick_location
|
66
|
+
end
|
67
|
+
|
68
|
+
def pick_location
|
69
|
+
puts "What location would you like to learn more about? Enter the number: "
|
70
|
+
input = gets.strip
|
71
|
+
|
72
|
+
location = StrangerThingsDirectory::Locations.find(input.to_i)
|
73
|
+
|
74
|
+
location_info(location)
|
75
|
+
end
|
76
|
+
|
77
|
+
def location_info(location)
|
78
|
+
puts ""
|
79
|
+
puts "*************** #{location.name} ***************"
|
80
|
+
puts ""
|
81
|
+
puts "Type: #{location.type.join(" ")}"
|
82
|
+
puts "Inhabitants: #{location.inhabitants.join(", ")}"
|
83
|
+
puts "Area: #{location.area.join(", ")}"
|
84
|
+
puts "To learn more: #{location.url}"
|
85
|
+
puts ""
|
86
|
+
puts "About: #{location.description}"
|
87
|
+
puts "****************************************************"
|
88
|
+
|
89
|
+
play
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
def character_list
|
94
|
+
puts ""
|
95
|
+
puts "A list of characters currently trending will appear below. After, pick a number to learn more about that character in particular!"
|
96
|
+
puts ""
|
97
|
+
puts ">>>>>>>>>> Stranger Things Characters: <<<<<<<<<<<<<"
|
98
|
+
StrangerThingsDirectory::Characters.all.each_with_index do |char, index|
|
99
|
+
puts "#{index +1 }. #{char.name}"
|
100
|
+
end
|
101
|
+
pick_character
|
102
|
+
end
|
103
|
+
|
104
|
+
def pick_character
|
105
|
+
puts ""
|
106
|
+
puts "What character would you like to learn more about? Enter their number: "
|
107
|
+
|
108
|
+
input = gets.strip
|
109
|
+
character = StrangerThingsDirectory::Characters.find(input.to_i)
|
110
|
+
|
111
|
+
character_info(character)
|
112
|
+
end
|
113
|
+
|
114
|
+
def character_info(character)
|
115
|
+
puts ""
|
116
|
+
puts "************ #{character.name} **************"
|
117
|
+
puts ""
|
118
|
+
puts "Status: #{character.status}"
|
119
|
+
puts "Gender: #{character.gender}"
|
120
|
+
puts "Age: #{character.age.join(" ")}"
|
121
|
+
puts "Year Born: #{character.born}"
|
122
|
+
puts "Portrayed By: #{character.actor}"
|
123
|
+
puts "Residence(s): #{character.residence.join(", ")}"
|
124
|
+
puts "Affiliation(s): #{character.affiliation.join(", ")}"
|
125
|
+
puts "Occupation: #{character.occupation.join(", ")}"
|
126
|
+
puts "Family: #{character.family.join(", ")}"
|
127
|
+
puts "To learn more: #{character.url}"
|
128
|
+
puts "**********************************************"
|
129
|
+
|
130
|
+
play
|
131
|
+
end
|
132
|
+
|
133
|
+
def exit_message
|
134
|
+
puts "Thanks for dropping in. Until next time "
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class StrangerThingsDirectory::LocationScraper
|
2
|
+
attr_accessor :locations, :urls_list, :doc
|
3
|
+
|
4
|
+
@locations = []
|
5
|
+
@urls_list = []
|
6
|
+
def open_page
|
7
|
+
Nokogiri::HTML(open("https://strangerthings.fandom.com/wiki/Category:Locations"))
|
8
|
+
#binding.pry
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_locations
|
12
|
+
self.open_page.css("div#WikiaArticle.WikiaArticle ul.category-page__trending-pages li.category-page__trending-page")
|
13
|
+
#binding.pry
|
14
|
+
|
15
|
+
end
|
16
|
+
def send_locations
|
17
|
+
|
18
|
+
get_locations.each do |location|
|
19
|
+
StrangerThingsDirectory::Locations.new_location(location)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class StrangerThingsDirectory::Locations
|
2
|
+
attr_accessor :name, :url, :description, :type, :inhabitants, :area
|
3
|
+
|
4
|
+
@@all = []
|
5
|
+
def self.new_location(location)
|
6
|
+
self.new(
|
7
|
+
location.css("a figure figcaption.category-page__trending-page-title").text,
|
8
|
+
"https://strangerthings.fandom.com#{location.css("a").attribute("href").text}"
|
9
|
+
)
|
10
|
+
end
|
11
|
+
def initialize(name=nil, url=nil)
|
12
|
+
@name = name
|
13
|
+
@url = url
|
14
|
+
@@all << self
|
15
|
+
end
|
16
|
+
|
17
|
+
def doc
|
18
|
+
@doc ||= Nokogiri::HTML(open(self.url))
|
19
|
+
end
|
20
|
+
|
21
|
+
def description
|
22
|
+
@description ||= doc.css("div#WikiaMainContentContainer.WikiaMainContentContainer div#WikiaArticle.WikiaArticle div#mw-content-text.mw-content-ltr.mw-content-text p").text
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.all
|
27
|
+
@@all
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.find(id)
|
31
|
+
self.all[id-1]
|
32
|
+
end
|
33
|
+
|
34
|
+
def inhabitants
|
35
|
+
@inhabitants ||=
|
36
|
+
doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=inhabitants] a").collect {|a| a.text }
|
37
|
+
end
|
38
|
+
|
39
|
+
def area
|
40
|
+
@area ||= doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=location] a").collect {|a| a.text}
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
def type
|
45
|
+
@type ||= doc.css("div.pi-item.pi-data.pi-item-spacing.pi-border-color[data-source=type] div.pi-data-value.pi-font").collect {|a| a.text}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stranger_things_directory
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alethia Quintero
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-12 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: 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: pry
|
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: nokogiri
|
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
|
+
description: A user will choose between a list of trending Stranger Things characters
|
84
|
+
or locations, the list will be shown, the user will choose a number representing
|
85
|
+
an item, then information about that item will appear
|
86
|
+
email:
|
87
|
+
- alethiaq22@gmail.com
|
88
|
+
executables:
|
89
|
+
- stranger_things_directory
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files: []
|
92
|
+
files:
|
93
|
+
- bin/stranger_things_directory
|
94
|
+
- config/environment.rb
|
95
|
+
- lib/stranger_things_directory.rb
|
96
|
+
- lib/stranger_things_directory/character_scraper.rb
|
97
|
+
- lib/stranger_things_directory/characters.rb
|
98
|
+
- lib/stranger_things_directory/cli.rb
|
99
|
+
- lib/stranger_things_directory/location_scraper.rb
|
100
|
+
- lib/stranger_things_directory/locations.rb
|
101
|
+
homepage: http://rubygems.org/gems/stranger_things_directory
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubygems_version: 3.0.4
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: A Stranger Things Character and Location information guide
|
124
|
+
test_files: []
|