sd_events 0.1.2 → 0.1.3
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 +4 -4
- data/lib/sd_events/cli.rb +43 -36
- data/lib/sd_events/events.rb +6 -22
- data/lib/sd_events/scraper.rb +11 -46
- data/lib/sd_events/version.rb +1 -1
- data/lib/sd_events.rb +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6beaa3861f362715184d88a5edb21708d3b5342d208f2e7753f4d778b006436b
|
|
4
|
+
data.tar.gz: a7c46e39b8aada0a5a7d5f94e576a7fad24d447f7985c55a78e91bd84f27402c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad4005e22a30e0625f11b7d3db5b01690510e9e66d5db93085795bd9b6ae4e7c47f8c019aeea2e4d0e4c263ab365117c7de4d4fd258203aaf22a960d852a95b0
|
|
7
|
+
data.tar.gz: ce9740c895b86a8c7bc18a75e9321d509a94ef5770bb6a659685b5970c415f8d737890012563b292466b76b4b1c3840a627917710f3319b6653487fd2edc59c0
|
data/lib/sd_events/cli.rb
CHANGED
|
@@ -6,41 +6,40 @@ class SdEvents::CLI
|
|
|
6
6
|
|
|
7
7
|
def start
|
|
8
8
|
puts ""
|
|
9
|
-
puts "******* Events Happening Now in San Diego *******"
|
|
9
|
+
puts "******* Events Happening Now in San Diego *******".colorize(:blue)
|
|
10
10
|
puts ""
|
|
11
11
|
list_menu
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def list_menu
|
|
15
|
-
|
|
16
|
-
puts "
|
|
17
|
-
puts "Please select which events you would like to see or type 'exit'"
|
|
15
|
+
puts "Hello, the time is now #{Time.now}.".colorize(:light_blue)
|
|
16
|
+
puts "Please select which events you would like to see or type 'exit'".colorize(:red)
|
|
18
17
|
puts ""
|
|
19
|
-
puts "1. Morning Events"
|
|
20
|
-
puts "2. Afternoon Events"
|
|
21
|
-
puts "3. Evening Events"
|
|
22
|
-
puts "4. Late Night Events"
|
|
18
|
+
puts "1. Morning Events".colorize(:green)
|
|
19
|
+
puts "2. Afternoon Events".colorize(:green)
|
|
20
|
+
puts "3. Evening Events".colorize(:green)
|
|
21
|
+
puts "4. Late Night Events".colorize(:green)
|
|
23
22
|
puts ""
|
|
24
23
|
|
|
25
24
|
input = gets.strip.downcase
|
|
26
25
|
|
|
27
26
|
if input == "1"
|
|
28
|
-
SdEvents::Events.
|
|
27
|
+
SdEvents::Events.create_daypart("morning")
|
|
29
28
|
display_events
|
|
30
29
|
event_menu
|
|
31
30
|
|
|
32
31
|
elsif input == "2"
|
|
33
|
-
SdEvents::Events.
|
|
32
|
+
SdEvents::Events.create_daypart("afternoon")
|
|
34
33
|
display_events
|
|
35
34
|
event_menu
|
|
36
35
|
|
|
37
36
|
elsif input == "3"
|
|
38
|
-
SdEvents::Events.
|
|
37
|
+
SdEvents::Events.create_daypart("evening")
|
|
39
38
|
display_events
|
|
40
39
|
event_menu
|
|
41
40
|
|
|
42
41
|
elsif input == "4"
|
|
43
|
-
SdEvents::Events.
|
|
42
|
+
SdEvents::Events.create_daypart("night")
|
|
44
43
|
display_events
|
|
45
44
|
event_menu
|
|
46
45
|
|
|
@@ -48,61 +47,69 @@ class SdEvents::CLI
|
|
|
48
47
|
goodbye
|
|
49
48
|
|
|
50
49
|
else
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
puts "Not sure what you're asking, here is the menu again:".colorize(:red)
|
|
51
|
+
list_menu
|
|
53
52
|
end
|
|
54
|
-
|
|
55
53
|
end
|
|
56
54
|
|
|
57
55
|
def display_events
|
|
58
56
|
SdEvents::Events.all.each.with_index(1) do |event, i|
|
|
59
57
|
puts "#{i}."
|
|
60
|
-
puts "Event: #{event.name.upcase}"
|
|
61
|
-
puts "Venue: #{event.venue}"
|
|
62
|
-
puts "Time: #{event.time}"
|
|
58
|
+
puts "Event: #{event.name.upcase}".colorize(:magenta)
|
|
59
|
+
puts "Venue: #{event.venue}".colorize(:magenta)
|
|
60
|
+
puts "Time: #{event.time}".colorize(:magenta)
|
|
63
61
|
puts ""
|
|
64
62
|
end
|
|
65
63
|
end
|
|
66
64
|
|
|
67
65
|
def event_menu
|
|
66
|
+
input = nil
|
|
67
|
+
while input != "exit"
|
|
68
|
+
puts ""
|
|
69
|
+
puts "To see more info about an event, please select the number of the event".colorize(:red)
|
|
68
70
|
puts ""
|
|
69
|
-
puts "
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
puts "OR type 'menu' to see the menu again".colorize(:red)
|
|
72
|
+
puts "OR type 'exit' to exit the program".colorize(:red)
|
|
73
|
+
puts ""
|
|
74
|
+
input = gets.strip
|
|
75
|
+
if input == "menu"
|
|
76
|
+
list_menu
|
|
77
|
+
elsif input.to_i.between?(1, SdEvents::Events.all.size)
|
|
78
|
+
event = SdEvents::Events.find(input)
|
|
72
79
|
puts ""
|
|
73
|
-
puts "Event: #{
|
|
74
|
-
puts "
|
|
75
|
-
puts "Category: #{
|
|
80
|
+
puts "Event: #{event.name}".colorize(:magenta)
|
|
81
|
+
puts "Location: #{event.location}".colorize(:magenta)
|
|
82
|
+
puts "Category: #{event.category}".colorize(:magenta)
|
|
76
83
|
puts ""
|
|
77
|
-
puts "To see the menu again, type 'menu' or to exit type 'exit':"
|
|
78
84
|
SdEvents::Events.all.clear
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
elsif input == "exit"
|
|
86
|
+
goodbye
|
|
87
|
+
else
|
|
88
|
+
puts "Not sure what you're asking, here is the menu again:".colorize(:red)
|
|
89
|
+
list_menu
|
|
90
|
+
end
|
|
85
91
|
end
|
|
92
|
+
end
|
|
86
93
|
|
|
87
94
|
def self.no_events
|
|
88
95
|
puts ""
|
|
89
|
-
puts "Uh oh, looks like there are no events for that time..."
|
|
90
|
-
puts "Please return tomorrow for more events."
|
|
96
|
+
puts "Uh oh, looks like there are no events for that time...".colorize(:magenta)
|
|
97
|
+
puts "Please return tomorrow for more events.".colorize(:magenta)
|
|
91
98
|
puts ""
|
|
92
|
-
puts "To see the menu again, type 'menu' or type 'exit':"
|
|
99
|
+
puts "To see the menu again, type 'menu' or type 'exit':".colorize(:red)
|
|
93
100
|
input = gets.downcase.strip
|
|
94
101
|
if input == "menu"
|
|
95
102
|
self.new.list_menu
|
|
96
103
|
elsif input == "exit"
|
|
97
104
|
self.new.goodbye
|
|
98
105
|
else
|
|
99
|
-
"Not sure what you're asking, here is the menu again:"
|
|
106
|
+
"Not sure what you're asking, here is the menu again:".colorize(:red)
|
|
100
107
|
self.new.list_menu
|
|
101
108
|
end
|
|
102
109
|
end
|
|
103
110
|
|
|
104
111
|
def goodbye
|
|
105
|
-
puts "Thanks for visiting SD Events!"
|
|
112
|
+
puts "Thanks for visiting SD Events!".colorize(:blue)
|
|
106
113
|
exit
|
|
107
114
|
end
|
|
108
115
|
|
data/lib/sd_events/events.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class SdEvents::Events
|
|
2
|
-
attr_accessor :name, :venue, :
|
|
2
|
+
attr_accessor :name, :venue, :location, :category, :time
|
|
3
3
|
@@all = []
|
|
4
4
|
|
|
5
5
|
def initialize
|
|
@@ -15,35 +15,19 @@ class SdEvents::Events
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def self.find(id)
|
|
18
|
-
self.all[id-1]
|
|
18
|
+
self.all[id.to_i-1]
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def self.
|
|
22
|
-
SdEvents::Scraper.scrape_morning
|
|
21
|
+
def self.empty?
|
|
23
22
|
if @@all.empty?
|
|
24
23
|
SdEvents::CLI.no_events
|
|
25
24
|
end
|
|
26
25
|
end
|
|
27
26
|
|
|
28
|
-
def self.
|
|
29
|
-
SdEvents::Scraper.
|
|
30
|
-
|
|
31
|
-
SdEvents::CLI.no_events
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def self.create_evening_events
|
|
36
|
-
SdEvents::Scraper.scrape_evening
|
|
37
|
-
if @@all.empty?
|
|
38
|
-
SdEvents::CLI.no_events
|
|
39
|
-
end
|
|
27
|
+
def self.create_daypart(event_time) #=> "afternoon"
|
|
28
|
+
SdEvents::Scraper.scrape_daypart(event_time) #=> "SdEvents::Scraper.scrape_daypart("afternoon")"
|
|
29
|
+
self.empty?
|
|
40
30
|
end
|
|
41
31
|
|
|
42
|
-
def self.create_night_events
|
|
43
|
-
SdEvents::Scraper.scrape_night
|
|
44
|
-
if @@all.empty?
|
|
45
|
-
SdEvents::CLI.no_events
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
32
|
|
|
49
33
|
end
|
data/lib/sd_events/scraper.rb
CHANGED
|
@@ -1,57 +1,22 @@
|
|
|
1
1
|
class SdEvents::Scraper
|
|
2
2
|
|
|
3
3
|
def self.scrape
|
|
4
|
-
|
|
4
|
+
Nokogiri::HTML(open("https://www.sandiegoreader.com/events/#"))
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
def self.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
new_event.city = attribute.css("td.city").text.strip
|
|
15
|
-
new_event.category = attribute.css("td.category").text.strip
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def self.scrape_afternoon
|
|
21
|
-
self.scrape.css("div#body div#content.content div.daypart_afternoon .event_list").each do |event|
|
|
22
|
-
event.css("tr").collect do |attribute|
|
|
23
|
-
new_event = SdEvents::Events.new
|
|
24
|
-
new_event.name = attribute.css(".title").css("h4").text.strip
|
|
25
|
-
new_event.venue = attribute.css(".title").css("h5").text.strip
|
|
26
|
-
new_event.time = attribute.css("td.time").text.strip
|
|
27
|
-
new_event.city = attribute.css("td.city").text.strip
|
|
28
|
-
new_event.category = attribute.css("td.category").text.strip
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def self.scrape_evening
|
|
34
|
-
self.scrape.css("div#body div#content.content div.daypart_evening .event_list").each do |event|
|
|
35
|
-
event.css("tr").collect do |attribute|
|
|
36
|
-
new_event = SdEvents::Events.new
|
|
37
|
-
new_event.name = attribute.css(".title").css("h4").text.strip
|
|
38
|
-
new_event.venue = attribute.css(".title").css("h5").text.strip
|
|
39
|
-
new_event.time = attribute.css("td.time").text.strip
|
|
40
|
-
new_event.city = attribute.css("td.city").text.strip
|
|
41
|
-
new_event.category = attribute.css("td.category").text.strip
|
|
42
|
-
end
|
|
43
|
-
end
|
|
7
|
+
def self.scrape_events(attribute)
|
|
8
|
+
new_event = SdEvents::Events.new
|
|
9
|
+
new_event.name = attribute.css(".title").css("h4").text.strip
|
|
10
|
+
new_event.venue = attribute.css(".title").css("h5").text.strip
|
|
11
|
+
new_event.time = attribute.css("td.time").text.strip
|
|
12
|
+
new_event.location = attribute.css("td.city").text.strip
|
|
13
|
+
new_event.category = attribute.css("td.category").text.strip
|
|
44
14
|
end
|
|
45
15
|
|
|
46
|
-
def self.
|
|
47
|
-
self.scrape.css("div#body div#content.content div.
|
|
16
|
+
def self.scrape_daypart(event_time)
|
|
17
|
+
self.scrape.css("div#body div#content.content div.daypart_#{event_time} .event_list").each do |event|
|
|
48
18
|
event.css("tr").collect do |attribute|
|
|
49
|
-
|
|
50
|
-
new_event.name = attribute.css(".title").css("h4").text.strip
|
|
51
|
-
new_event.venue = attribute.css(".title").css("h5").text.strip
|
|
52
|
-
new_event.time = attribute.css("td.time").text.strip
|
|
53
|
-
new_event.city = attribute.css("td.city").text.strip
|
|
54
|
-
new_event.category = attribute.css("td.category").text.strip
|
|
19
|
+
self.scrape_events(attribute)
|
|
55
20
|
end
|
|
56
21
|
end
|
|
57
22
|
end
|
data/lib/sd_events/version.rb
CHANGED
data/lib/sd_events.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sd_events
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kayla Hansen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-03-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -80,6 +80,20 @@ dependencies:
|
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
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'
|
|
83
97
|
description:
|
|
84
98
|
email: shiverr@gmail.com
|
|
85
99
|
executables:
|