indoor_jungle_builder 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +46 -0
- data/LICENSE +21 -0
- data/Notes +6 -0
- data/README.md +2 -0
- data/bin/console +9 -0
- data/bin/indoor-jungle +9 -0
- data/bin/setup +5 -0
- data/indoor_jungle_builder.gemspec +38 -0
- data/lib/indoor_jungle.rb +13 -0
- data/lib/indoor_jungle/plant.rb +30 -0
- data/lib/indoor_jungle/plant_assistant.rb +319 -0
- data/lib/indoor_jungle/scraper.rb +29 -0
- data/lib/indoor_jungle/version.rb +3 -0
- metadata +158 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a8fb04e50f3c9d8120d43c8417961d1fd632ea3669ed493f239079baa3b6e86e
|
4
|
+
data.tar.gz: 5eee1c3d5f2d4447062a927a657a9efc1dbbef55e4d530ca54bd31966e4afa8e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8440a22933b049f1c4cc90a3134648f438437d2cde1275e758a4f3eb692a989ff779632b1a58530d4c69dfab317291dc3b91a82e5d6e675147f1e51b689068f9
|
7
|
+
data.tar.gz: 00a92404b8177b2b6f239a2ad9784eebc58424b7f413b83fa6d7d3e7a914a53c7f02e9b101bdf46b8d8b64822c4100c796668154bb1e44c7d1f4caef6f50c5ee
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
coderay (1.1.3)
|
5
|
+
colorize (0.8.1)
|
6
|
+
diff-lcs (1.4.4)
|
7
|
+
gemoji (3.0.1)
|
8
|
+
method_source (1.0.0)
|
9
|
+
mini_portile2 (2.5.0)
|
10
|
+
nokogiri (1.11.1)
|
11
|
+
mini_portile2 (~> 2.5.0)
|
12
|
+
racc (~> 1.4)
|
13
|
+
open-uri (0.1.0)
|
14
|
+
pry (0.14.0)
|
15
|
+
coderay (~> 1.1)
|
16
|
+
method_source (~> 1.0)
|
17
|
+
racc (1.5.2)
|
18
|
+
require_all (3.0.0)
|
19
|
+
rspec (3.10.0)
|
20
|
+
rspec-core (~> 3.10.0)
|
21
|
+
rspec-expectations (~> 3.10.0)
|
22
|
+
rspec-mocks (~> 3.10.0)
|
23
|
+
rspec-core (3.10.1)
|
24
|
+
rspec-support (~> 3.10.0)
|
25
|
+
rspec-expectations (3.10.1)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.10.0)
|
28
|
+
rspec-mocks (3.10.2)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.10.0)
|
31
|
+
rspec-support (3.10.2)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
colorize
|
38
|
+
gemoji
|
39
|
+
nokogiri
|
40
|
+
open-uri
|
41
|
+
pry
|
42
|
+
require_all
|
43
|
+
rspec
|
44
|
+
|
45
|
+
BUNDLED WITH
|
46
|
+
1.17.1
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Shami Tomita
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/Notes
ADDED
data/README.md
ADDED
data/bin/console
ADDED
data/bin/indoor-jungle
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'indoor_jungle/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "indoor_jungle_builder"
|
8
|
+
spec.version = IndoorJungle::Version
|
9
|
+
spec.authors = ["shamitomita"]
|
10
|
+
spec.email = ["shamitomita@gmail.com.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Plant Scraper}
|
13
|
+
spec.description = %q{Enter user information to receive a list of suitable plants from Plants.com}
|
14
|
+
spec.homepage = "https://github.com/ShamiTomita/Personal-Indoor-Jungle-Builder"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
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", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec"
|
33
|
+
spec.add_development_dependency "pry", "~> 0.14.0"
|
34
|
+
|
35
|
+
spec.add_dependency "open-uri", "~> 0.1.0"
|
36
|
+
spec.add_dependency "colorize", "~> 0.8.1"
|
37
|
+
spec.add_dependency "nokogiri"
|
38
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#enviornment file
|
2
|
+
require 'bundler'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'pry'
|
5
|
+
require 'open-uri'
|
6
|
+
require 'gemoji'
|
7
|
+
require 'colorize'
|
8
|
+
require_relative './indoor_jungle/version.rb'
|
9
|
+
require_relative './indoor_jungle/plant_assistant.rb'
|
10
|
+
require_relative './indoor_jungle/plant.rb'
|
11
|
+
require_relative './indoor_jungle/scraper.rb'
|
12
|
+
|
13
|
+
puts "Enviornment Loaded"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
class IndoorJungle::Plant
|
3
|
+
#modeling after the student creator, I will need a place to store all the plants and then each plant's attributes
|
4
|
+
#
|
5
|
+
attr_accessor :name, :price_range, :plant_url, :sunlight, :water, :temperature, :plant
|
6
|
+
|
7
|
+
@@all = []
|
8
|
+
@@plants = []
|
9
|
+
|
10
|
+
def initialize(plant_hash)
|
11
|
+
plant_hash.each {|key, value| self.send(("#{key}="), value)}
|
12
|
+
@@all << self
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.all
|
16
|
+
@@all
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.create_from_collection(plants_array)
|
20
|
+
plants_array.each do |plant|
|
21
|
+
plant = self.new(plant)
|
22
|
+
@@plants << plant
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_plant_attributes(attributes_hash)
|
27
|
+
attributes_hash.each {|key, value| self.send(("#{key}="), value)}
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,319 @@
|
|
1
|
+
#CLI Controller
|
2
|
+
|
3
|
+
class IndoorJungle::PlantAssistant
|
4
|
+
BASE_PATH = "https://www.plants.com/c/all-plants"
|
5
|
+
|
6
|
+
@@cold = [] #house the least amount of plants
|
7
|
+
@@room_temp = [] #should house the most plants
|
8
|
+
@@warm = [] #house most plants
|
9
|
+
@@low_light = [] #should house least amount
|
10
|
+
@@medium_light = [] #should house most
|
11
|
+
@@high_light = [] #should house all except ones that cant take bright sun
|
12
|
+
@@low_maintenance = [] #when soil is dry "drought tolerant"
|
13
|
+
@@medium_maintenance = [] #water once a week "moderate"
|
14
|
+
@@high_maintenance = [] #"keep humidity tray full" "saturated" "ambient humidity" "do not"
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
make_plants
|
18
|
+
add_attributes_to_plants
|
19
|
+
sort_plants
|
20
|
+
end
|
21
|
+
|
22
|
+
def make_plants
|
23
|
+
plants_array = IndoorJungle::Scraper.scrape_site(BASE_PATH)
|
24
|
+
IndoorJungle::Plant.create_from_collection(plants_array)
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_attributes_to_plants
|
28
|
+
IndoorJungle::Plant.all.each do |plant|
|
29
|
+
attributes = IndoorJungle::Scraper.scrape_plant(plant.plant_url)
|
30
|
+
plant.add_plant_attributes(attributes)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def call
|
35
|
+
#cold, low_light, low_maintenance
|
36
|
+
switch = nil
|
37
|
+
plants = []
|
38
|
+
temp = nil
|
39
|
+
light = nil
|
40
|
+
attention = nil
|
41
|
+
temp_input = nil
|
42
|
+
light_input = nil
|
43
|
+
attention_input = nil
|
44
|
+
input_2 = nil
|
45
|
+
|
46
|
+
|
47
|
+
puts "To get started, we need to get some more information about you"
|
48
|
+
sleep(1)
|
49
|
+
puts "Would you describe your home temperature to as: cool(around 60F), room temp(around 70F), or warm? (around or above 80F)"
|
50
|
+
|
51
|
+
until temp_input == "cool" || temp_input == "cold" || temp_input == "colder" || temp_input == "room temp" || temp_input == "room" || temp_input == "average" || temp_input == "warm" || temp_input == "tropical" || temp_input == "hot"
|
52
|
+
temp_input = gets.chomp
|
53
|
+
end
|
54
|
+
|
55
|
+
if temp_input == "cool" || temp_input == "cold" || temp_input == "colder"
|
56
|
+
temp = @@cold
|
57
|
+
elsif temp_input == "room temp" || temp_input == "room" || temp_input == "average"
|
58
|
+
temp = @@room_temp
|
59
|
+
elsif temp_input == "warm" || temp_input == "hot" || temp_input == "tropical"
|
60
|
+
temp = @@warm
|
61
|
+
end
|
62
|
+
|
63
|
+
puts "Would you describe the light sources in your home as: low light, medium light, or bright?"
|
64
|
+
|
65
|
+
until light_input == "low light" || light_input == "low" || light_input == "medium light" || light_input == "medium" || light_input == "average" || light_input == "bright" || light_input == "hight light" || light_input == "sunny"
|
66
|
+
light_input = gets.chomp
|
67
|
+
end
|
68
|
+
|
69
|
+
if light_input == "low light" || light_input == "low"
|
70
|
+
light = @@low_light
|
71
|
+
elsif light_input == "medium light" || light_input == "medium" || light_input == "average"
|
72
|
+
light = @@medium_light
|
73
|
+
elsif light_input == "bright" || light_input == "high light" || light_input == "sunny"
|
74
|
+
light = @@high_light
|
75
|
+
end
|
76
|
+
|
77
|
+
puts "Finally, would you describe your attention to plant care as: relaxed, average, or vigilant?"
|
78
|
+
|
79
|
+
until attention_input == "relaxed" || attention_input == "lazy" || attention_input == "average" || attention_input == "medium" || attention_input == "vigilant" || attention_input == "above average"
|
80
|
+
attention_input = gets.chomp
|
81
|
+
end
|
82
|
+
|
83
|
+
if attention_input == "relaxed" || attention_input == "lazy"
|
84
|
+
attention = @@low_maintenance
|
85
|
+
elsif attention_input == "average" ||attention_input == "medium"
|
86
|
+
attention = @@medium_maintenance
|
87
|
+
elsif attention_input == "vigilant" || attention_input == "above average"
|
88
|
+
attention = @@high_maintenance
|
89
|
+
end
|
90
|
+
|
91
|
+
IndoorJungle::Plant.all.each do |plant|
|
92
|
+
if temp.include?(plant) && light.include?(plant) && attention.include?(plant)
|
93
|
+
plants << plant
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
puts "Thank you for your input! Based on your responses, your ideal plant matches are: "
|
98
|
+
sleep(2)
|
99
|
+
puts "-----------------------".green
|
100
|
+
plants.each do |x|
|
101
|
+
if plants.empty?
|
102
|
+
puts "I'm sorry but your answers did not result in a match."
|
103
|
+
else
|
104
|
+
display_plant(x)
|
105
|
+
sleep(2.5)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
puts "Would you like to 'redo' your ansers or see the full 'list of plants'? Or 'exit'? "
|
110
|
+
|
111
|
+
until input_2 == "redo" || input_2 == "try again" || input_2 == "list" || input_2 == "list of plants" || input_2 == "plants" || input_2 == "exit" || input_2 == "Exit"
|
112
|
+
input_2 = gets.chomp
|
113
|
+
end
|
114
|
+
|
115
|
+
if input_2 == "redo" || input_2 == "try again"
|
116
|
+
call
|
117
|
+
elsif input_2 == "list" || input_2 == "list of plants" || input_2 == "plants"
|
118
|
+
display_plants
|
119
|
+
else
|
120
|
+
puts "Thank you for using your Indoor Jungle Builder!"
|
121
|
+
puts "Please Like & Subscribe"
|
122
|
+
sleep(3)
|
123
|
+
exit
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def display_plant(plant)
|
128
|
+
puts "Plant Name: #{plant.name}".light_green
|
129
|
+
puts "Sunlight: #{plant.sunlight[0]}."
|
130
|
+
puts "Water: #{plant.water}."
|
131
|
+
puts "Temperature: " + "#{plant.temperature}.".capitalize
|
132
|
+
puts "#{plant.plant_url}"
|
133
|
+
puts "-----------------------".green
|
134
|
+
end
|
135
|
+
|
136
|
+
def display_plants
|
137
|
+
IndoorJungle::Plant.all.each do |plant|
|
138
|
+
puts "Plant Name: #{plant.name}".light_green
|
139
|
+
puts "#{plant.price_range}".magenta
|
140
|
+
puts "Sunlight: #{plant.sunlight[0]}."
|
141
|
+
puts "Water: #{plant.water}."
|
142
|
+
puts "Temperature: " + "#{plant.temperature}.".capitalize
|
143
|
+
puts "#{plant.plant_url}"
|
144
|
+
puts "-----------------------".green
|
145
|
+
end
|
146
|
+
puts "Would you like to 'redo' your ansers or see the full 'list of plants'? "
|
147
|
+
input_2 = gets.chomp
|
148
|
+
if input_2 == "redo" || input_2 == "try again"
|
149
|
+
call
|
150
|
+
elsif input_2 == "list" || input_2 == "list of plants" || input_2 == "plants"
|
151
|
+
display_plants
|
152
|
+
else "Thank you for using your Indoor Jungle Builder!"
|
153
|
+
exit
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def library(klass = IndoorJungle::Plant ) #importing the Song class into this class so we can create a library of all the songs
|
158
|
+
sorted_library = klass.all.collect{|obj| obj if obj.class == klass}
|
159
|
+
sorted_library = sorted_library.delete_if {|obj| obj == nil}
|
160
|
+
sorted_library.uniq
|
161
|
+
end
|
162
|
+
|
163
|
+
def sort_plants
|
164
|
+
sort_plants_by_light
|
165
|
+
sort_plants_by_temp
|
166
|
+
sort_plants_by_maintenance
|
167
|
+
end
|
168
|
+
|
169
|
+
def sort_plants_by_light
|
170
|
+
#====> plant instances can be in all three
|
171
|
+
sorted_plants = self.library
|
172
|
+
sorted_plants.each do |plant|
|
173
|
+
if plant.sunlight[0].include?("tolerate") || plant.sunlight[0].include?("handle") || plant.sunlight[0].include?("low") || plant.sunlight[0].include?("soft")
|
174
|
+
@@low_light << plant
|
175
|
+
end
|
176
|
+
if !plant.sunlight[0].include?("medium") || plant.sunlight[0].include?("bright")|| plant.sunlight[0].include?("sunny") || plant.sunlight[0].include?("full")
|
177
|
+
@@high_light << plant
|
178
|
+
end
|
179
|
+
if !plant.sunlight[0].include?("Full") || !plant.sunlight[0].include?("sunny")
|
180
|
+
@@medium_light << plant
|
181
|
+
end
|
182
|
+
end
|
183
|
+
@@low_light
|
184
|
+
@@medium_light
|
185
|
+
@@high_light
|
186
|
+
end
|
187
|
+
|
188
|
+
def sort_plants_by_temp
|
189
|
+
sorted_plants = self.library
|
190
|
+
sorted_plants.each do |plant|
|
191
|
+
if plant.temperature.include?("60-65") || plant.temperature.include?("60") || plant.temperature.include?("60-80") || plant.temperature.include?("Cooler") || plant.temperature.include?("cooler")
|
192
|
+
@@cold << plant
|
193
|
+
end
|
194
|
+
if plant.temperature.include?("60-80") || plant.temperature.include?("70") ||plant.temperature.include?("75") || plant.temperature.include?("65-90") || plant.temperature.include?("65 - 90") || plant.temperature.include?("65-85")
|
195
|
+
@@room_temp << plant
|
196
|
+
end
|
197
|
+
if plant.temperature.include?("tropical") || plant.temperature.include?("warm") || plant.temperature.include?("80") || plant.temperature.include?("90") || plant.temperature.include?("65-85")
|
198
|
+
@@warm << plant
|
199
|
+
end
|
200
|
+
end
|
201
|
+
@@cold
|
202
|
+
@@room_temp
|
203
|
+
@@warm
|
204
|
+
end
|
205
|
+
|
206
|
+
def sort_plants_by_maintenance
|
207
|
+
sorted_plants = self.library
|
208
|
+
sorted_plants.each do |plant|
|
209
|
+
if plant.water.include?("Drought") || plant.water.include?("tolerant") || plant.water.include?("tolerate") || plant.water.include?("soil is dry") && !plant.water.include?("do not") && !plant.water.include?("keep")
|
210
|
+
@@low_maintenance << plant
|
211
|
+
end
|
212
|
+
if true
|
213
|
+
@@high_maintenance << plant
|
214
|
+
end
|
215
|
+
if !plant.water.include?("never") && !plant.water.include?("not") && !plant.water.include?("overwater")
|
216
|
+
@@medium_maintenance << plant
|
217
|
+
end
|
218
|
+
end
|
219
|
+
@@low_maintenance
|
220
|
+
@@medium_maintenance
|
221
|
+
@@high_maintenance
|
222
|
+
end
|
223
|
+
|
224
|
+
#######################################
|
225
|
+
|
226
|
+
|
227
|
+
def self.cold
|
228
|
+
puts "-----------------------".green
|
229
|
+
@@cold.each do |plant|
|
230
|
+
puts plant.name
|
231
|
+
puts plant.temperature
|
232
|
+
puts "-----------------------".green
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def self.room_temp
|
237
|
+
puts "-----------------------".green
|
238
|
+
@@room_temp.each do |plant|
|
239
|
+
puts plant.name
|
240
|
+
puts plant.temperature
|
241
|
+
puts "-----------------------".green
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def self.warm
|
246
|
+
puts "-----------------------".green
|
247
|
+
@@warm.each do |plant|
|
248
|
+
puts plant.name
|
249
|
+
puts plant.temperature
|
250
|
+
puts "-----------------------".green
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def self.low_light
|
255
|
+
puts "-----------------------".green
|
256
|
+
@@low_light.each do |plant|
|
257
|
+
puts plant.name
|
258
|
+
puts plant.sunlight[0]
|
259
|
+
puts "-----------------------".green
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def self.medium_light
|
264
|
+
puts "-----------------------".green
|
265
|
+
@@medium_light.each do |plant|
|
266
|
+
puts plant.name
|
267
|
+
puts plant.sunlight[0]
|
268
|
+
puts "-----------------------".green
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
def self.high_light
|
273
|
+
puts "-----------------------".green
|
274
|
+
@@high_light.each do |plant|
|
275
|
+
puts plant.name
|
276
|
+
puts plant.sunlight[0]
|
277
|
+
puts "-----------------------".green
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
def self.low_maintenance
|
282
|
+
puts "-----------------------".green
|
283
|
+
@@low_maintenance.each do |plant|
|
284
|
+
puts plant.name
|
285
|
+
puts plant.water
|
286
|
+
puts "-----------------------".green
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def self.medium_maintenance
|
291
|
+
puts "-----------------------".green
|
292
|
+
@@medium_maintenance.each do |plant|
|
293
|
+
puts plant.name
|
294
|
+
puts plant.water
|
295
|
+
puts "-----------------------".green
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
def self.high_maintenance
|
300
|
+
puts "-----------------------".green
|
301
|
+
@@high_maintenance.each do |plant|
|
302
|
+
puts plant.name
|
303
|
+
puts plant.water
|
304
|
+
puts "-----------------------".green
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
#iterate through Plant.all
|
315
|
+
#Plant.all.sunlight if include? "bright" || "indirect"
|
316
|
+
# Highlgiht <<
|
317
|
+
# Mediumlight <<
|
318
|
+
# Lowlight <<
|
319
|
+
# Temperature within different ranges
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
#Scraper.scrape_site('https://www.plants.com/c/all-plants')
|
3
|
+
#Scraper.scrape_plant('https://www.plants.com/p/snake-plant-157646?c=all-plants')
|
4
|
+
class IndoorJungle::Scraper
|
5
|
+
def self.scrape_site(site)
|
6
|
+
page = Nokogiri::HTML(URI.open(site))
|
7
|
+
plants_lumped = []
|
8
|
+
page.css('div.ProductList_productItem__HxDc2').each do |plants|
|
9
|
+
plants_lumped << {
|
10
|
+
:name => plants.css('div.col-12').text,
|
11
|
+
:price_range => plants.css("a span").children[1].text,
|
12
|
+
:plant_url => "https://www.plants.com" + (plants.css("a")[0].attributes["href"].value)
|
13
|
+
}
|
14
|
+
end
|
15
|
+
plants_lumped
|
16
|
+
end
|
17
|
+
|
18
|
+
##here lies my mess
|
19
|
+
def self.scrape_plant(plant_url)
|
20
|
+
page = Nokogiri::HTML(URI.open(plant_url))
|
21
|
+
plant = {}
|
22
|
+
element = page.css('div.product-layout-')
|
23
|
+
plant[:sunlight] = element.css('p.condition-text.mb-0').first.text,
|
24
|
+
plant[:water] = element.css('div.image-card p')[1].text,
|
25
|
+
plant[:temperature] = element.css('div.image-card p')[2].text.delete("\u00B0F")
|
26
|
+
plant #currently this whole hash is being applied to sunlight
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: indoor_jungle_builder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- shamitomita
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-03-09 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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
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: '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: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.14.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.14.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: open-uri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.1.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.1.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.8.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.8.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: nokogiri
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Enter user information to receive a list of suitable plants from Plants.com
|
112
|
+
email:
|
113
|
+
- shamitomita@gmail.com.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- CODE_OF_CONDUCT.md
|
119
|
+
- Gemfile
|
120
|
+
- Gemfile.lock
|
121
|
+
- LICENSE
|
122
|
+
- Notes
|
123
|
+
- README.md
|
124
|
+
- bin/console
|
125
|
+
- bin/indoor-jungle
|
126
|
+
- bin/setup
|
127
|
+
- indoor_jungle_builder.gemspec
|
128
|
+
- lib/indoor_jungle.rb
|
129
|
+
- lib/indoor_jungle/plant.rb
|
130
|
+
- lib/indoor_jungle/plant_assistant.rb
|
131
|
+
- lib/indoor_jungle/scraper.rb
|
132
|
+
- lib/indoor_jungle/version.rb
|
133
|
+
homepage: https://github.com/ShamiTomita/Personal-Indoor-Jungle-Builder
|
134
|
+
licenses:
|
135
|
+
- MIT
|
136
|
+
metadata:
|
137
|
+
allowed_push_host: https://rubygems.org
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.7.8
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: Plant Scraper
|
158
|
+
test_files: []
|