events_nearby 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/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/bin/console +21 -0
- data/bin/events_nearby +6 -0
- data/bin/setup +8 -0
- data/config/environment.rb +8 -0
- data/events_nearby.gemspec +23 -0
- data/lib/events_nearby/cli.rb +81 -0
- data/lib/events_nearby/events.rb +35 -0
- data/lib/events_nearby/scraper.rb +47 -0
- data/lib/events_nearby/version.rb +3 -0
- data/lib/events_nearby.rb +4 -0
- data/spec.md +7 -0
- metadata +103 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 2c75f592a260fb0503a0145f323e688d9d954bf0
|
|
4
|
+
data.tar.gz: ad8be8978d4d039f4348317149f704e8aab55b49
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a22619193d34593bbe2b0ef5a0078b1d4c2d115f4a907c10ba08818ae3b76c735f76d967437c2caacbbb525ca397699a2687d75f23fd676fbdc87b1644342a76
|
|
7
|
+
data.tar.gz: e035f08703ad39d4e98de22c57b725ebf4ef2039b73e97eec580fa6b2e0dc9349b884bdb44cfe68f73e48f5c26e76e65ce43fafbd151421d3b97ef0cddb53773
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at TODO: Write your email address. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 TODO: Write your name
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# EventsNearby
|
|
2
|
+
|
|
3
|
+
Welcome to 'Events Nearby'! In this directory, you'll find a CLI Ruby Gem. 'Events Nearby' lets you enter any location to retrieve a list of events that are near that location. Displayed will be the name of the events, when they are taking place, where exactly they are, and how much they cost. You can then choose one of the listed events to see details about that event and even open it in your browser.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'events_nearby'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install events_nearby
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
- Start the program
|
|
24
|
+
- Enter the location you want to see events nearby
|
|
25
|
+
- Enter a number to see more details about a specific event
|
|
26
|
+
- Open the chosen event in your browser if you wish or start over
|
|
27
|
+
|
|
28
|
+
## Contributing
|
|
29
|
+
|
|
30
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/events_nearby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# require "bundler/setup"
|
|
4
|
+
# require "events_nearby"
|
|
5
|
+
require_relative '../config/environment'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
10
|
+
|
|
11
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
12
|
+
# require "pry"
|
|
13
|
+
# Pry.start
|
|
14
|
+
|
|
15
|
+
# Method to reload environment
|
|
16
|
+
def reload!
|
|
17
|
+
load_all './lib'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
require "irb"
|
|
21
|
+
IRB.start
|
data/bin/events_nearby
ADDED
data/bin/setup
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'events_nearby/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "events_nearby"
|
|
8
|
+
spec.version = EventsNearby::VERSION
|
|
9
|
+
spec.authors = ["amelieoller"]
|
|
10
|
+
spec.email = ["amelieoller@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Events Nearby will show you events nearby based on the location you enter.}
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
|
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
16
|
+
spec.bindir = "exe"
|
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
18
|
+
spec.require_paths = ["lib"]
|
|
19
|
+
|
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
22
|
+
spec.add_dependency "nokogiri", "~> 1.8"
|
|
23
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# CLI Controller
|
|
2
|
+
|
|
3
|
+
class EventsNearby::CLI
|
|
4
|
+
|
|
5
|
+
def call
|
|
6
|
+
choose_city
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def choose_city
|
|
10
|
+
puts "What city would you like to see events nearby? (e.g. 'San Francisco, CA')"
|
|
11
|
+
input = gets.strip.downcase
|
|
12
|
+
EventsNearby::Events.destroy_all
|
|
13
|
+
EventsNearby::Events.today(input)
|
|
14
|
+
input == "exit" ? goodbye : list_events(input)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def list_events(city)
|
|
18
|
+
puts "These are the upcoming events for #{city}:"
|
|
19
|
+
|
|
20
|
+
EventsNearby::Events.all.each_with_index do |event, i|
|
|
21
|
+
puts "#{i+1}. #{event.formatted_event}"
|
|
22
|
+
end
|
|
23
|
+
menu
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def menu
|
|
27
|
+
puts "Which event would you like to know more about? Enter a number, 'start' to start over, or 'exit'."
|
|
28
|
+
input = gets.strip
|
|
29
|
+
if input.to_i.between?(1, EventsNearby::Events.all.size)
|
|
30
|
+
event = EventsNearby::Events.all[input.to_i - 1]
|
|
31
|
+
show_details(event)
|
|
32
|
+
else
|
|
33
|
+
decision(input)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def show_details(event)
|
|
38
|
+
puts ""
|
|
39
|
+
puts "--- #{event.formatted_event} ---"
|
|
40
|
+
if event.content != ""
|
|
41
|
+
puts event.content
|
|
42
|
+
puts ""
|
|
43
|
+
puts "Would you like to open this event in your browser? Enter 'yes' to open, 'menu' to pick another event, 'start' to start over, or 'exit'."
|
|
44
|
+
input = gets.strip
|
|
45
|
+
open_in_browser_decision(input, event)
|
|
46
|
+
else
|
|
47
|
+
puts "There seems to be no description of this event. Would you like to open this event in your browser? Enter 'yes' to open, 'menu' to pick another event, 'start' to start over, or 'exit'."
|
|
48
|
+
input = gets.strip
|
|
49
|
+
open_in_browser_decision(input, event)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def open_in_browser_decision(input, event)
|
|
54
|
+
if ['y', 'yes', 'open'].include?(input.downcase)
|
|
55
|
+
event.open_in_browser
|
|
56
|
+
puts ""
|
|
57
|
+
menu
|
|
58
|
+
else
|
|
59
|
+
decision(input)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def decision(input)
|
|
64
|
+
case input
|
|
65
|
+
when "exit"
|
|
66
|
+
goodbye
|
|
67
|
+
when "menu"
|
|
68
|
+
menu
|
|
69
|
+
when "start"
|
|
70
|
+
choose_city
|
|
71
|
+
else
|
|
72
|
+
puts "Not sure what you mean. Enter 'menu' to pick another event, 'start' to start over, or 'exit'."
|
|
73
|
+
decision(gets.strip)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def goodbye
|
|
78
|
+
puts "See you later!"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
class EventsNearby::Events
|
|
2
|
+
|
|
3
|
+
attr_accessor :name, :date, :price, :url, :content
|
|
4
|
+
|
|
5
|
+
@@all = []
|
|
6
|
+
|
|
7
|
+
def save
|
|
8
|
+
@@all << self
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.all
|
|
12
|
+
@@all
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.destroy_all
|
|
16
|
+
self.all.clear
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.today(input)
|
|
20
|
+
EventsNearby::Scraper.new.scrape_events(input)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def content
|
|
24
|
+
@content ||= EventsNearby::Scraper.new(url).scrape_event
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def formatted_event
|
|
28
|
+
"#{self.name} | #{self.date} | #{self.price}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def open_in_browser
|
|
32
|
+
system("xdg-open '#{url}'")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require_relative '../../config/environment'
|
|
2
|
+
|
|
3
|
+
class EventsNearby::Scraper
|
|
4
|
+
|
|
5
|
+
def initialize(url = nil)
|
|
6
|
+
@url = url
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def scrape_event
|
|
10
|
+
@doc = Nokogiri::HTML(open(@url))
|
|
11
|
+
@doc.search(".js-xd-read-more-contents p").text.strip[0..300].gsub(/\s\w+\s*$/,'...')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def scrape_events(location)
|
|
15
|
+
url = include_location_in_url(location)
|
|
16
|
+
@doc = Nokogiri::HTML(open("#{url}"))
|
|
17
|
+
@doc.search("div.js-event-list-container div.list-card-v2").each do |event_item|
|
|
18
|
+
event = EventsNearby::Events.new
|
|
19
|
+
|
|
20
|
+
event.name = event_item.search(".list-card__title").first.text.gsub("\n", "").strip
|
|
21
|
+
event.date = event_item.search(".list-card__date").first.text.gsub("\n", "").strip.split.join(" ")
|
|
22
|
+
event.price = event_item.search(".list-card__label").first.text.strip
|
|
23
|
+
event.url = event_item.attr("data-share-url").strip
|
|
24
|
+
|
|
25
|
+
event.save
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def include_location_in_url(location)
|
|
30
|
+
data = location.split(/[\s,]+/)
|
|
31
|
+
|
|
32
|
+
if location.include?(",")
|
|
33
|
+
state = data.last.gsub(/[^0-9A-Za-z]/, '')
|
|
34
|
+
city_array = data.first data.size - 1
|
|
35
|
+
else
|
|
36
|
+
city_array = data
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
city = city_array.collect do |item|
|
|
40
|
+
item.gsub(/[^0-9A-Za-z]/, '')
|
|
41
|
+
end.join("-")
|
|
42
|
+
|
|
43
|
+
url = "https://www.eventbrite.com/d/#{state}--#{city}/events/"
|
|
44
|
+
url
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
data/spec.md
ADDED
metadata
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: events_nearby
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- amelieoller
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-09-04 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.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
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: nokogiri
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.8'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.8'
|
|
55
|
+
description:
|
|
56
|
+
email:
|
|
57
|
+
- amelieoller@gmail.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- CODE_OF_CONDUCT.md
|
|
64
|
+
- Gemfile
|
|
65
|
+
- LICENSE.txt
|
|
66
|
+
- README.md
|
|
67
|
+
- Rakefile
|
|
68
|
+
- bin/console
|
|
69
|
+
- bin/events_nearby
|
|
70
|
+
- bin/setup
|
|
71
|
+
- config/environment.rb
|
|
72
|
+
- events_nearby.gemspec
|
|
73
|
+
- lib/events_nearby.rb
|
|
74
|
+
- lib/events_nearby/cli.rb
|
|
75
|
+
- lib/events_nearby/events.rb
|
|
76
|
+
- lib/events_nearby/scraper.rb
|
|
77
|
+
- lib/events_nearby/version.rb
|
|
78
|
+
- spec.md
|
|
79
|
+
homepage:
|
|
80
|
+
licenses:
|
|
81
|
+
- MIT
|
|
82
|
+
metadata: {}
|
|
83
|
+
post_install_message:
|
|
84
|
+
rdoc_options: []
|
|
85
|
+
require_paths:
|
|
86
|
+
- lib
|
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
requirements: []
|
|
98
|
+
rubyforge_project:
|
|
99
|
+
rubygems_version: 2.5.1
|
|
100
|
+
signing_key:
|
|
101
|
+
specification_version: 4
|
|
102
|
+
summary: Events Nearby will show you events nearby based on the location you enter.
|
|
103
|
+
test_files: []
|