ra_events 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9ae3232d04123fa0427d8356f0023c3d23ab49fc
4
+ data.tar.gz: ac8e4b6cf23a28a55a33c131cdd81f369629b8f6
5
+ SHA512:
6
+ metadata.gz: 2c67f6d8913bcf832ddd570ff415b9dc6f6a57d7da0c4faae34fb145f5186310d35f981eadb22fa4521665c5dd75552c8ed060da0935f4daadc717e236c68ed0
7
+ data.tar.gz: 9dac7ed2699f061c23affe81ff08c4f15f2d1c2fa66dcf7bc9d42e8f44d2bd0fc8652ed9a79d84f576c06c9cd35d22528c523287eb9c292949a3d1a9db4adc3e
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ra_events.gemspec
4
+ gemspec
5
+
6
+ # Do I need this pointing to GH?
7
+ # gem 'ra_events', :git => "git://github.com/Mk-Etlinger/ra-events-cli-app.git"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Michael Etlinger
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/NOTES.md ADDED
@@ -0,0 +1,40 @@
1
+ 1. Plan your gem, imagine your interface
2
+ 2. start with the project structure - google
3
+ 3. start with the entry point - the file run
4
+ 4. force that to build the CLI interface
5
+ 5. stub out the interface
6
+ 6. start making things real
7
+ 7. discover objects
8
+ 8. program
9
+
10
+
11
+
12
+
13
+
14
+ - A command line interface for Resident Advisor events.
15
+
16
+ + User types in a state, then list events
17
+
18
+ + Gets a list of events in that state
19
+
20
+ * US New York By week
21
+ Fri, 31 Mar 2017 /
22
+
23
+ 1. Nicky Siano's Native New Yorker B'day Plus Nancy Whang and Jayson Green
24
+ at Good Room
25
+ Nicky Siano's Native New Yorker Bday Extravaga..
26
+
27
+ 2. Blkmarket Membership presents Bill Patrick's Birthday
28
+ at Analog Bkny
29
+ Bill Patrick, Taimur & Fahad
30
+
31
+ + Type "goto ra" to launch website or "exit"
32
+
33
+ What is an event?
34
+
35
+ An event has:
36
+ -Title
37
+ -Location
38
+ -URL
39
+ -Ticket price
40
+
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # RaEvents
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ra_events`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ra_events'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ra_events
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Mk-Etlinger/ra_events.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ra_events"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/ra-events ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/ra_events'
4
+ require "bundler/setup"
5
+ require "ra_events"
6
+
7
+
8
+ RaEvents::CLI.new.call
9
+
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/ra_events.rb ADDED
@@ -0,0 +1,6 @@
1
+ require_relative "./ra_events/version"
2
+ require_relative './ra_events/cli'
3
+ require_relative './ra_events/scraper'
4
+ require_relative './ra_events/event'
5
+
6
+ require 'nokogiri'
@@ -0,0 +1,73 @@
1
+ require 'pry'
2
+
3
+ class RaEvents::CLI
4
+
5
+ STATES_AND_LINKS = {"AL"=>"/events.aspx?ai=108", "AK"=>"/events.aspx?ai=109", "AZ"=>"/events.aspx?ai=102", "AR"=>"/events.aspx?ai=110", "CA"=>"/events.aspx?ai=308", "CO"=>"/events.aspx?ai=82", "CT"=>"/events.aspx?ai=111", "DE"=>"/events.aspx?ai=112", "DC"=>"District of Columbia", "FL"=>"/events.aspx?ai=317", "GA"=>"/events.aspx?ai=64", "HI"=>"/events.aspx?ai=133", "ID"=>"/events.aspx?ai=113", "IL"=>"/events.aspx?ai=359", "IN"=>"/events.aspx?ai=85", "IA"=>"/events.aspx?ai=114", "KS"=>"/events.aspx?ai=90", "KY"=>"/events.aspx?ai=115", "LA"=>"/events.aspx?ai=65", "ME"=>"/events.aspx?ai=116", "MD"=>"/events.aspx?ai=117", "MA"=>"/events.aspx?ai=79", "MI"=>"/events.aspx?ai=360", "MN"=>"/events.aspx?ai=81", "MS"=>"/events.aspx?ai=103", "MO"=>"/events.aspx?ai=118", "MT"=>"/events.aspx?ai=119", "NE"=>"/events.aspx?ai=120", "NV"=>"/events.aspx?ai=47", "NH"=>"/events.aspx?ai=121", "NJ"=>"/events.aspx?ai=48", "NM"=>"/events.aspx?ai=122", "NY"=>"/events.aspx?ai=8", "NC"=>"/events.aspx?ai=123", "ND"=>"/events.aspx?ai=124", "OH"=>"/events.aspx?ai=84", "OK"=>"/events.aspx?ai=104", "OR"=>"/events.aspx?ai=125", "PA"=>"/events.aspx?ai=80", "RI"=>"/events.aspx?ai=127", "SC"=>"/events.aspx?ai=105", "SD"=>"/events.aspx?ai=128", "TN"=>"/events.aspx?ai=72", "TX"=>"/events.aspx?ai=318", "UT"=>"/events.aspx?ai=106", "VT"=>"/events.aspx?ai=129", "VA"=>"/events.aspx?ai=130", "WA"=>"Washington", "WV"=>"/events.aspx?ai=131", "WI"=>"/events.aspx?ai=107", "WY"=>"/events.aspx?ai=132"}
6
+ URL_BASE = "https://www.residentadvisor.net"
7
+
8
+ def call
9
+ welcome
10
+ list_events(user_inputs_state)
11
+ goto_event_url
12
+ exit_program
13
+ end
14
+
15
+ def welcome
16
+ puts "Welcome to ra_events!"
17
+ end
18
+
19
+ def user_inputs_state
20
+ puts "Please enter your state(ex: MI, NY, CA):"
21
+ input = gets.strip
22
+ url = URL_BASE + STATES_AND_LINKS[input]
23
+ end
24
+
25
+ def list_events(user_inputs_state)
26
+
27
+ display_events_this_week_text
28
+
29
+ Event.create_from_collection(Scraper.scrape_events_page(user_inputs_state))
30
+ Event.all.each.with_index(1) do |event, i|
31
+ i -= 1
32
+ if event.title != "" && event.location != ""
33
+ puts "#{i}. #{event.title} "
34
+ puts "Location: #{event.location} " unless event.artists.nil?
35
+ puts "Artists: #{event.artists}" unless event.artists.nil?
36
+ puts "Date: #{event.date.gsub("T00:00", "")}"
37
+ puts
38
+ end
39
+ end
40
+ end
41
+
42
+ def goto_event_url
43
+ input = nil
44
+ while input != "exit"
45
+ puts "Type goto #(ex: goto 18) to view event page in your browser or type exit:"
46
+ input = gets.strip
47
+ if input.include?("goto")
48
+ puts "Opening residentadvisor.net..."
49
+ event = Event.all[input.sub("goto ", "").to_i]
50
+ URL_BASE + event.url
51
+ `open #{URL_BASE + event.url}`
52
+ end
53
+ end
54
+ end
55
+
56
+ def display_events_this_week_text
57
+ puts "Events this week:"
58
+ puts "****************"
59
+ puts "*************"
60
+ puts "**********"
61
+ puts "*******"
62
+ puts "****"
63
+ puts "**"
64
+ end
65
+
66
+ def exit_program
67
+ puts "Bye, See you on the dance floor!"
68
+ end
69
+
70
+ end
71
+
72
+
73
+
@@ -0,0 +1,26 @@
1
+ require 'pry'
2
+
3
+ class Event
4
+
5
+ attr_accessor :date, :title, :location, :artists, :url
6
+
7
+ @@all = []
8
+
9
+ def initialize(event_hash)
10
+ event_hash.each do |attribute, value|
11
+ self.send("#{attribute}=", value)
12
+ end
13
+ @@all << self
14
+ end
15
+
16
+
17
+ def self.create_from_collection(events_array)
18
+ events_array.each do |event_hash|
19
+ Event.new(event_hash)
20
+ end
21
+ end
22
+
23
+ def self.all
24
+ @@all
25
+ end
26
+ end
@@ -0,0 +1,68 @@
1
+ require 'pry'
2
+ require 'open-uri'
3
+ require 'nokogiri'
4
+
5
+ class Scraper
6
+
7
+ attr_accessor
8
+
9
+ def initialize
10
+
11
+ end
12
+
13
+ def self.scrape_links(index_url)
14
+ state_event_page_url = {}
15
+ ra_events_page = Nokogiri::HTML(open("https://www.residentadvisor.net/events.aspx"))
16
+
17
+ ra_events_page.css("li.parent a").each do |e|
18
+ state_event_page_url[e.children.text] = e['href'] unless e.children.text == "Washington DC"
19
+ end
20
+
21
+ state_event_page_url
22
+ binding.pry
23
+ end
24
+
25
+ def self.scrape_events_page(url)
26
+ ra_events_page = Nokogiri::HTML(open(url))
27
+
28
+ events = []
29
+
30
+ ra_events_page.css("#items").each do |event_listing|
31
+
32
+ event_listing.css('li').each do |date| #until date.css('a').text == "Submit event"
33
+ # binding.pry
34
+ event_date = date.css('time').text
35
+ event_title = date.css('div h1 a').text.gsub("#{date.css('span a').text}", "")
36
+ event_location = date.css('span a').text unless date.css('span a').text.empty?
37
+ event_artists = date.css('div div').text unless date.css('div div').text.empty?
38
+ event_url = date.css('a').attr('href').text
39
+
40
+ events << {date: event_date, title: event_title, location: event_location, artists: event_artists, url: event_url}
41
+ # binding.pry
42
+
43
+ end
44
+
45
+ end
46
+ events.compact
47
+ # binding.pry
48
+ end
49
+
50
+ end
51
+
52
+
53
+ # This will grab the Date of all of the listed shows
54
+
55
+ # ra_events_page.css("#event-listing .date").each do |e|
56
+ # puts "#{e.css('a').text}"
57
+ # end
58
+
59
+
60
+ # ra_events_page.css("#items").each do |event_listing|
61
+ #
62
+
63
+ # Title: date.css('a').text || date.css('div h1').text # ex: "Selector Dub Narcotic, This Saxophone Kills Fascists at Babycastles"
64
+ # Artists: date.css('div div').text
65
+ # Url: date.css('a').attr('href').text
66
+
67
+ # unless date.css('a').text == "Submit event"
68
+
@@ -0,0 +1,3 @@
1
+ module RaEvents
2
+ VERSION = "0.0.2"
3
+ end
data/ra_events.gemspec ADDED
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ra_events/version'
5
+ require 'pry'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "ra_events"
9
+ spec.version = RaEvents::VERSION
10
+ spec.authors = ["Mike Etlinger"]
11
+ spec.email = ["mk.etlinger@gmail.com"]
12
+
13
+ spec.summary = %q{ra-events lists Resident Advisor events by state from the comfort of your CLI}
14
+ spec.description = %q{Type in your state, get a list of events by week, and open an event in your browser for more details.}
15
+ spec.homepage = "https://github.com/Mk-Etlinger/ra-events-cli-app"
16
+ spec.license = "MIT"
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ # if spec.respond_to?(:metadata)
21
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
22
+ # else
23
+ # raise "RubyGems 2.0 or newer is required to protect against " \
24
+ # "public gem pushes."
25
+ # end
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ f.match(%r{^(test|spec|features)/})
29
+ end
30
+ spec.bindir = "bin"
31
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_development_dependency "bundler", "~> 1.14"
35
+ spec.add_development_dependency "rake", "~> 10.0"
36
+ spec.add_development_dependency "pry", ">= 0.9.0"
37
+ spec.add_development_dependency "rspec", ">= 3.2.0"
38
+
39
+ spec.add_runtime_dependency "nokogiri", ">= 1.7.0"
40
+
41
+ end
42
+
data/spec.md ADDED
@@ -0,0 +1,6 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [x] Have a CLI for interfacing with the application
5
+ - [x] Pull data from an external source
6
+ - [x] Implement both list and detail views
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ra_events
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Mike Etlinger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-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.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
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.9.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.9.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.2.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.2.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: 1.7.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.7.0
83
+ description: Type in your state, get a list of events by week, and open an event in
84
+ your browser for more details.
85
+ email:
86
+ - mk.etlinger@gmail.com
87
+ executables:
88
+ - console
89
+ - ra-events
90
+ - setup
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - ".gitignore"
95
+ - ".rspec"
96
+ - Gemfile
97
+ - LICENSE.txt
98
+ - NOTES.md
99
+ - README.md
100
+ - Rakefile
101
+ - bin/console
102
+ - bin/ra-events
103
+ - bin/setup
104
+ - lib/ra_events.rb
105
+ - lib/ra_events/cli.rb
106
+ - lib/ra_events/event.rb
107
+ - lib/ra_events/scraper.rb
108
+ - lib/ra_events/version.rb
109
+ - ra_events.gemspec
110
+ - spec.md
111
+ homepage: https://github.com/Mk-Etlinger/ra-events-cli-app
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.4.5.1
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: ra-events lists Resident Advisor events by state from the comfort of your
135
+ CLI
136
+ test_files: []
137
+ has_rdoc: