trendster 1.0.7 → 1.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d1069ed9b349e2d8f4b5665a060579939223c0a
4
- data.tar.gz: 7b72a01b70605929d736638fd26d7138d38977e6
3
+ metadata.gz: a40c3649bcdeb0875c82cdb3455a483fa2aab1f5
4
+ data.tar.gz: fc0b64e2da71c8204e90333d8f12a8d0a0444bf0
5
5
  SHA512:
6
- metadata.gz: 53359e7e1cfb846b9b16fcaae6cd71b067081b80bab4767fbab5b5fbb42670a97d7267abbf98f1d594caa9195f2b07e829dfaa06befe19aec53c0202902a84ce
7
- data.tar.gz: 98f961c61bd9d79f7c2f5af2e49082583e0b8ee53df3efbb834bddaab0a12a1526fe8bbb316d0be5df4e95d036469885b685e3f5dde1d85a1900a390ea889aa9
6
+ metadata.gz: ee4c569f55d0db2b884cdb1f7ddc80723cb5668e2f2758a0326b0b4906dd9444f66c67311d9c93b974a2cacce7d58af0c27bde3b7b7d11f8e3f90bada90edddf
7
+ data.tar.gz: d626b0071e63bacbd9a4ba3723d15eaf42edd55dcce7323fc33cce934333ead79a512205a9b9cbc88b79fe0ba36bd17eb08baba056421c7d1f87a4ce086668a4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trendster (1.0.6)
4
+ trendster (1.0.7)
5
5
  nokogiri
6
6
 
7
7
  GEM
@@ -1,11 +1,7 @@
1
1
  require 'open-uri'
2
2
  require 'nokogiri'
3
3
 
4
- require "trendster/version"
5
- require "trendster/scraper"
6
- require "trendster/event"
7
- require "trendster/cli"
8
-
9
- module Trendster
10
-
11
- end
4
+ require_relative "trendster/version"
5
+ require_relative "trendster/scraper"
6
+ require_relative "trendster/event"
7
+ require_relative "trendster/cli"
@@ -18,24 +18,27 @@ class Trendster::CLI
18
18
 
19
19
  def list_events
20
20
  puts "Here are the most recent events at the Cuyahoga County Public Library:"
21
- @events = []
22
- Trendster::Event.all.each{|x| @events << x.name}
23
- counter = 0
24
- @events.each{|event_name| counter +=1; puts "#{counter}. #{event_name}"}
21
+ all_events = Trendster::Event.all
22
+ all_events.each do |event|
23
+ puts "#{all_events.index(event) + 1}. #{event.name}"
24
+ end
25
25
  end
26
26
 
27
27
  def menu
28
28
  input = nil
29
+
29
30
  while input != "exit"
30
- puts "Enter the number of the event you'd like more info on, 'list' to see the events again, or type 'exit'."
31
- input = gets.strip
31
+
32
+ puts "Enter the number of the event you'd like more info on, 'list' to see the events again, or type 'exit'."
33
+ input = gets.strip
32
34
 
33
35
  if input.to_i > 0 && Trendster::Event.all[input.to_i - 1] != nil
34
- puts Trendster::Event.all[input.to_i - 1].name
35
- puts Trendster::Event.all[input.to_i - 1].description
36
- puts Trendster::Event.all[input.to_i - 1].date
37
- puts "Location: #{Trendster::Event.all[input.to_i - 1].location}"
38
- puts "Audience: #{Trendster::Event.all[input.to_i - 1].audience}"
36
+ selected_event = Trendster::Event.all[input.to_i - 1]
37
+ puts selected_event.name
38
+ puts selected_event.description
39
+ puts selected_event.date
40
+ puts "Location: #{selected_event.location}"
41
+ puts "Audience: #{selected_event.audience}"
39
42
  elsif input == "list"
40
43
  list_events
41
44
  elsif input == "exit"
@@ -43,6 +46,7 @@ class Trendster::CLI
43
46
  else
44
47
  puts "Please enter a valid number, 'list' or 'exit'"
45
48
  end
49
+
46
50
  end
47
51
  end
48
52
 
@@ -2,7 +2,7 @@ class Trendster::Event
2
2
 
3
3
  attr_accessor :name, :description, :date, :location, :audience
4
4
 
5
- @@all = []
5
+ @@all = []
6
6
 
7
7
  @events_array = Trendster::Scraper.scrape_library_page
8
8
 
@@ -16,6 +16,7 @@ class Trendster::Event
16
16
  end
17
17
 
18
18
  def self.create_from_collection(events_array)
19
+
19
20
  events_array.each do |event_hash|
20
21
  self.new(event_hash)
21
22
  end
@@ -1,40 +1,29 @@
1
-
2
1
  class Trendster::Scraper
3
2
 
4
- @@all = []
3
+ @@all = []
5
4
 
6
- attr_accessor :name, :description, :date, :location, :audience
5
+ attr_accessor :name, :description, :date, :location, :audience
7
6
 
8
- def self.all
9
- @@all
10
- end
7
+ def self.all
8
+ @@all
9
+ end
11
10
 
12
- def self.scrape_library_page
13
- url_endings = []
14
- index_url = "http://cuyahogalibrary.org/Events/Event-Results.aspx"
15
- index_doc = Nokogiri::HTML(open(index_url))
16
- index_doc.css("article.sixcol").each do |event|
17
- url_endings << event.css("a")[0]['href']
18
- end
19
- event_urls = []
20
- url_endings.each do |url_ending|
21
- event_urls << "http://cuyahogalibrary.org" + url_ending
22
- end
23
- event_doc_array = []
24
- event_urls.each do |event_url|
25
- event_doc = Nokogiri::HTML(open(event_url))
26
- event_doc_array << event_doc
27
- end
11
+ def self.scrape_library_page
28
12
  all_array = []
29
- event_doc_array.each do |event_doc|
30
- all_array << {
31
- name: event_doc.css("h3").text,
32
- description: event_doc.css("p.one-large-content").text || "",
33
- date: event_doc.css("strong").text,
34
- location: event_doc.css("p").css("a").text,
35
- audience: event_doc.css("p").text.match("Adults") || event_doc.css("p").text.match("Children")
36
- }
13
+ index_url = "http://cuyahogalibrary.org/Events/Event-Results.aspx"
14
+ index_doc = Nokogiri::HTML(open(index_url))
15
+ index_doc.css("article.sixcol").each do |event|
16
+ event_url = "http://cuyahogalibrary.org" + event.css("a")[0]['href']
17
+ event_doc = Nokogiri::HTML(open(event_url))
18
+ all_array << {
19
+ name: event_doc.css("h3").text,
20
+ description: event_doc.css("p.one-large-content").text || "",
21
+ date: event_doc.css("strong").text,
22
+ location: event_doc.css("p").css("a").text,
23
+ audience: event_doc.css("p").text.match("Adults") || event_doc.css("p").text.match("Children") || event_doc.css("p").text.match("Families") || event_doc.css("p").text.match("Teens") || event_doc.css("p").text.match("All") || event_doc.css("p").text.match("Preschool")
24
+ }
25
+ end
26
+ all_array
37
27
  end
38
- all_array
39
- end
28
+
40
29
  end
@@ -1,3 +1,3 @@
1
1
  module Trendster
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
@@ -7,11 +7,11 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "trendster"
8
8
  spec.date = '2016-06-07'
9
9
  spec.version = Trendster::VERSION
10
- spec.authors = ["Jason"]
10
+ spec.authors = ["Jason Kwong"]
11
11
  spec.email = ["jasonkwong11@gmail.com"]
12
12
 
13
13
  spec.summary = "CLI interface to Cuyahoga County Public Library events."
14
- spec.description = "Provides details to upcoming events at library with CLI interface."
14
+ spec.description = "Provides details of upcoming events at library with CLI interface."
15
15
  spec.homepage = "https://github.com/jasonkwong11/trendster-cli-gem"
16
16
  spec.license = "MIT"
17
17
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trendster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
- - Jason
7
+ - Jason Kwong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Provides details to upcoming events at library with CLI interface.
55
+ description: Provides details of upcoming events at library with CLI interface.
56
56
  email:
57
57
  - jasonkwong11@gmail.com
58
58
  executables:
@@ -75,7 +75,7 @@ files:
75
75
  - lib/trendster/event.rb
76
76
  - lib/trendster/scraper.rb
77
77
  - lib/trendster/version.rb
78
- - trendster-1.0.6.gem
78
+ - pkg/trendster-1.0.7.gem
79
79
  - trendster.gemspec
80
80
  homepage: https://github.com/jasonkwong11/trendster-cli-gem
81
81
  licenses:
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  requirements: []
99
99
  rubyforge_project:
100
- rubygems_version: 2.6.4
100
+ rubygems_version: 2.6.7
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: CLI interface to Cuyahoga County Public Library events.