why_im_broke 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6478ed205ceee395425f2115e74c9c96caf03ee6a56093d36756f8b20709f72c
4
+ data.tar.gz: a2c1d972eec981010d34e6ab0981b9640ddcb5f9b17cfaa9ee30344626b75d7f
5
+ SHA512:
6
+ metadata.gz: c3c65eb06651450a3f227a1146feb5ab9855733acc28c817e032ffba078702be75d3e869474b668b5957fdc4e19a39d02b5aaa910d95f5959abd03dfb937bbde
7
+ data.tar.gz: '09fd1b31947049713f15d8c2c08b03528b751b50ad8553030b7e5f210f76fd4c1788312adfc0d4b36b5299a9ec79757eaadd98b49179ffc14930a8e51887b8b8'
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../config/environment.rb"
4
+
5
+ WhyImBrokeCli::CLI.new.call
@@ -0,0 +1,8 @@
1
+ require "nokogiri"
2
+ require "pry"
3
+ require "open-uri"
4
+
5
+ require_relative "../lib/why_im_broke_cli/version"
6
+ require_relative "../lib/why_im_broke_cli/scraper"
7
+ require_relative "../lib/why_im_broke_cli/item"
8
+ require_relative "../lib/why_im_broke_cli/cli"
@@ -0,0 +1,5 @@
1
+ module WhyImBrokeCli
2
+ class Error < StandardError; end
3
+ end
4
+
5
+ require_relative "../config/environment.rb"
@@ -0,0 +1,68 @@
1
+ class WhyImBrokeCli::CLI
2
+
3
+ def call
4
+ welcome
5
+ menu
6
+ end
7
+
8
+ def welcome
9
+ puts "Welcome to This Is Why I'm Broke."
10
+ puts "These are the 101 best things to do in NYC plus a little extra:"
11
+ WhyImBrokeCli::Scraper.activate
12
+ end
13
+
14
+ def menu
15
+ input = nil
16
+ while input != "exit"
17
+ puts "You can type list, search, or exit:"
18
+ input = gets.strip.downcase
19
+
20
+ if input == "list"
21
+ list
22
+ elsif input == "search"
23
+ search
24
+ else
25
+ puts "Sorry try again" unless input == "exit"
26
+ end
27
+
28
+ end
29
+ goodbye
30
+ end
31
+
32
+ def list
33
+ WhyImBrokeCli::Item.list
34
+ puts "You can enter a number to learn more about an event:"
35
+ input = gets.strip.downcase
36
+ if input.to_i <= 0 || input.to_i > 102
37
+ puts "Sorry try again"
38
+ else
39
+ WhyImBrokeCli::Item.details(input.to_i - 1)
40
+ end
41
+ end
42
+
43
+ def search
44
+ puts "You can search by type of event:"
45
+ puts "(Bars, Attractions, Restaurants, Museums, Movie, Comedy, Theater, Things to do, Music, Sports, Shopping, Nightlife, Health)"
46
+ input = gets.strip.capitalize
47
+
48
+ if WhyImBrokeCli::Item.search_by_type(input) == []
49
+ puts "Sorry try again"
50
+ else
51
+ x = WhyImBrokeCli::Item.search_by_type(input)
52
+ puts "You can enter a number to learn more about an event:"
53
+ input = gets.strip.to_i
54
+
55
+ if input <= 0 || input > x.size
56
+ puts "Sorry try again"
57
+ else
58
+ WhyImBrokeCli::Item.details_for_search(x, input.to_i - 1)
59
+ end
60
+ end
61
+ end
62
+
63
+ def goodbye
64
+ puts "Goodbye Friend"
65
+ end
66
+
67
+
68
+ end
@@ -0,0 +1,66 @@
1
+ class WhyImBrokeCli::Item
2
+
3
+ @@all = []
4
+ attr_accessor :type, :title, :location, :info, :url
5
+
6
+ def initialize(type, title, location, info, url)
7
+ @type = type
8
+ @title = title
9
+ @location = location
10
+ @info = info
11
+ @url = url
12
+ @@all.push(self) unless @@all.include?(self) || self.title == ""
13
+ end
14
+
15
+ def self.all
16
+ @@all
17
+ end
18
+
19
+ def self.list
20
+ @@all.each_with_index do |item, i|
21
+ puts "#{i + 1}. #{item.title}"
22
+ end
23
+ nil
24
+ end
25
+
26
+ def self.details(num)
27
+ x = all[num]
28
+ puts "\n"
29
+ puts "All you need to know for, #{num + 1}. #{x.title}:"
30
+ puts "\n"
31
+ puts "Type of activity: #{x.type}"
32
+ puts "\n"
33
+ puts "Location: #{x.location}"
34
+ puts "\n"
35
+ puts "Description: #{x.info}"
36
+ puts "\n"
37
+ puts "Website: #{x.url}"
38
+ puts "\n"
39
+ end
40
+
41
+ def self.search_by_type(input)
42
+ x = all.select do |item|
43
+ item.type.include?(input)
44
+ end
45
+ x.each_with_index do |item, i|
46
+ puts "#{i + 1}. #{item.title}"
47
+ end
48
+ x
49
+ end
50
+
51
+ def self.details_for_search(array, num)
52
+ x = array[num]
53
+ puts "\n"
54
+ puts "All you need to know for, #{num + 1}. #{x.title}:"
55
+ puts "\n"
56
+ puts "Type of activity: #{x.type}"
57
+ puts "\n"
58
+ puts "Location: #{x.location}"
59
+ puts "\n"
60
+ puts "Description: #{x.info}"
61
+ puts "\n"
62
+ puts "Website: #{x.url}"
63
+ puts "\n"
64
+ end
65
+
66
+ end
@@ -0,0 +1,26 @@
1
+ class WhyImBrokeCli::Scraper
2
+
3
+
4
+ def self.activate
5
+ html = "https://www.timeout.com/newyork/things-to-do/101-things-to-do-in-new-york"
6
+ doc = Nokogiri::HTML(open(html))
7
+
8
+ container = doc.css("article.listCard")
9
+
10
+ container.each do |item|
11
+ type = item.css("div.category").text.strip
12
+ title = item.css("h3.card-title").text.strip.capitalize
13
+ location = item.css("span.bold").text.strip
14
+ info = item.css("div.js-card-desc-content").css("p").text
15
+
16
+ if item.css("a.amp-btn-secondary")[0] == nil
17
+ url = "No link provided for this event."
18
+ else
19
+ url = "https://www.timeout.com" + item.css("a.amp-btn-secondary")[0].attribute("href").value
20
+ end
21
+
22
+ x = WhyImBrokeCli::Item.new(type, title, location, info, url)
23
+ end
24
+ end
25
+
26
+ end
@@ -0,0 +1,3 @@
1
+ module WhyImBrokeCli
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: why_im_broke
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - "'Matt Wright'"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-11-03 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: pry
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: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Program that takes a number of different activities to do in NYC and
70
+ allows users to select an option for a more detailed description.
71
+ email:
72
+ - "'mttwright@gmail.com'"
73
+ executables:
74
+ - why_im_broke
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - bin/why_im_broke
79
+ - config/environment.rb
80
+ - lib/why_im_broke_cli.rb
81
+ - lib/why_im_broke_cli/cli.rb
82
+ - lib/why_im_broke_cli/item.rb
83
+ - lib/why_im_broke_cli/scraper.rb
84
+ - lib/why_im_broke_cli/version.rb
85
+ homepage: https://github.com/mttwright/why_im_broke_cli.git
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubygems_version: 3.0.3
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Program that takes a number of different activities to do in NYC.
108
+ test_files: []