jukebox-cli-app 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/bin/jukebox +9 -0
- data/lib/jukebox.rb +9 -0
- data/lib/jukebox/cli.rb +56 -0
- data/lib/jukebox/concert.rb +27 -0
- metadata +119 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: d4081a2b4474c3fae500a280c2ec846fd29507db
|
|
4
|
+
data.tar.gz: ab0f1e4ac39ce21d273d87b35a6d7282862b5eec
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 12a410115f9a7716cdd9cdf8de3e0cd284f39f1ee1f32bb6e93c451e4858f251f260a81dd23f0df23da998160e1e35c83add873b00e641de73c19cfa205b428c
|
|
7
|
+
data.tar.gz: 2f59ae586028538d949f28340d6afe1120ffb9d21df6cae7edd054a2c02cc08a562cc9b81e0c65ee29c960582f31c6b4df96ec1d13095a26e10452d6cdea495c
|
data/bin/jukebox
ADDED
data/lib/jukebox.rb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
require 'nokogiri'
|
|
3
|
+
|
|
4
|
+
require_relative "./jukebox/version"
|
|
5
|
+
require_relative './jukebox/cli'
|
|
6
|
+
require_relative './jukebox/concert'
|
|
7
|
+
|
|
8
|
+
#File acts as environment so that it is the file that
|
|
9
|
+
#jukebox can require and it can require everything else
|
data/lib/jukebox/cli.rb
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#CLI Controller
|
|
2
|
+
class Jukebox::CLI
|
|
3
|
+
|
|
4
|
+
def call
|
|
5
|
+
puts "Welcome to Jukebox!"
|
|
6
|
+
list_concerts
|
|
7
|
+
menu
|
|
8
|
+
goodbye
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def list_concerts
|
|
12
|
+
puts "Here is a list of artists coming to the Memphis area:\n\n"
|
|
13
|
+
|
|
14
|
+
#calls the scrape_concerts method and prints each artists name in a list
|
|
15
|
+
@concerts = Jukebox::Concert.scrape_concerts
|
|
16
|
+
@concerts.each.with_index(1) do |concert, i|
|
|
17
|
+
puts "#{i}. #{concert.artist_name}"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def menu
|
|
22
|
+
input = nil
|
|
23
|
+
#As long as the user does not type "exit," they can keep viewing concert info
|
|
24
|
+
while input != "exit"
|
|
25
|
+
puts "\nPlease enter the number corresponding to the concert you\n"\
|
|
26
|
+
"want to hear more about, type list to see the concerts again, or\n"\
|
|
27
|
+
"type exit to leave Jukebox: "
|
|
28
|
+
|
|
29
|
+
input = gets.strip.downcase
|
|
30
|
+
# if the input is a number on the list, information about that concert
|
|
31
|
+
# is printed
|
|
32
|
+
if input.to_i > 0
|
|
33
|
+
if(@concerts[input.to_i - 1] != nil)
|
|
34
|
+
the_concert = @concerts[input.to_i - 1]
|
|
35
|
+
puts "\nArtist name: #{the_concert.artist_name}"
|
|
36
|
+
puts "Date: #{the_concert.date}"
|
|
37
|
+
puts "Location: #{the_concert.location}"
|
|
38
|
+
puts "Buy tickets: #{the_concert.url}"
|
|
39
|
+
else #If their input is a number not on the list, an error message is printed
|
|
40
|
+
puts "\nSorry, but Jukebox doesn't recognize that."
|
|
41
|
+
end
|
|
42
|
+
elsif input == "list" #If they type "list," the list of concerts is printed again
|
|
43
|
+
list_concerts
|
|
44
|
+
elsif input == "exit" #If they type "exit," the program ends
|
|
45
|
+
break
|
|
46
|
+
else
|
|
47
|
+
puts "\nSorry, but Jukebox doesn't recognize that."
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def goodbye
|
|
53
|
+
puts "\nGoodbye! Thanks for using Jukebox! Check back soon for more concerts!"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class Jukebox::Concert
|
|
2
|
+
attr_accessor :artist_name, :location, :date, :url
|
|
3
|
+
|
|
4
|
+
def self.scrape_concerts
|
|
5
|
+
@concert_list = []
|
|
6
|
+
|
|
7
|
+
#Opens the memphis eventful concert website and saves the HTML to doc
|
|
8
|
+
doc = Nokogiri::HTML(open("http://memphis.eventful.com/events/categories/music"))
|
|
9
|
+
|
|
10
|
+
#Saves the list of concerts
|
|
11
|
+
concerts = doc.css("li.clearfix")
|
|
12
|
+
|
|
13
|
+
#Scrapes information about a concert and creates a corresponding object
|
|
14
|
+
concerts.each do |concert|
|
|
15
|
+
new_concert = self.new
|
|
16
|
+
new_concert.artist_name = concert.css("h4").text
|
|
17
|
+
new_concert.date = concert.css(".event-meta strong").text
|
|
18
|
+
new_concert.location = concert.css(".event-meta span").text
|
|
19
|
+
new_concert.url = concert.css("h4 a").attr("href")
|
|
20
|
+
#adds the object to the @concert_list array
|
|
21
|
+
@concert_list << new_concert
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
#Returns the concert_list array
|
|
25
|
+
@concert_list
|
|
26
|
+
end
|
|
27
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: jukebox-cli-app
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- msosborne3
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-10-27 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.13'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.13'
|
|
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: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
description:
|
|
84
|
+
email:
|
|
85
|
+
- msosborne@ymail.com
|
|
86
|
+
executables:
|
|
87
|
+
- jukebox
|
|
88
|
+
extensions: []
|
|
89
|
+
extra_rdoc_files: []
|
|
90
|
+
files:
|
|
91
|
+
- bin/jukebox
|
|
92
|
+
- lib/jukebox.rb
|
|
93
|
+
- lib/jukebox/cli.rb
|
|
94
|
+
- lib/jukebox/concert.rb
|
|
95
|
+
homepage: https://github.com/msosborne3/jukebox-cli-app
|
|
96
|
+
licenses:
|
|
97
|
+
- MIT
|
|
98
|
+
metadata: {}
|
|
99
|
+
post_install_message:
|
|
100
|
+
rdoc_options: []
|
|
101
|
+
require_paths:
|
|
102
|
+
- lib
|
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
|
+
requirements:
|
|
105
|
+
- - ">="
|
|
106
|
+
- !ruby/object:Gem::Version
|
|
107
|
+
version: '0'
|
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
|
+
requirements:
|
|
110
|
+
- - ">="
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: '0'
|
|
113
|
+
requirements: []
|
|
114
|
+
rubyforge_project:
|
|
115
|
+
rubygems_version: 2.6.7
|
|
116
|
+
signing_key:
|
|
117
|
+
specification_version: 4
|
|
118
|
+
summary: View concerts in the Memphis area
|
|
119
|
+
test_files: []
|