nyc-theater-discounts 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d553e130a27e2b93ec827b002d94c3ee430a77b2
4
+ data.tar.gz: e865b5d5c0783c2e5ed7201945867898eff981ac
5
+ SHA512:
6
+ metadata.gz: 9749066470951c14cd47c14aedad34f8edd64158997df13572ac55ff01b6853e27a79e1e5c147e02af09972f52cb2142d2af3097ec317da77b6b42f8d3f582ff
7
+ data.tar.gz: 1926aa09346891f57e732e1ec6bcb8b4f7efffcd279efdcd60aef3cd88a9216e180e9fc195d45b603a2341448c7a84880b336505274158a46b09d62fee9c1796
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/
@@ -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 kaileighrose@gmail.com. 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
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nyc-theater-discounts.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Kaileigh McCrea
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,40 @@
1
+ # NYC Theater Discounts
2
+
3
+ Aggregates discounts for theater tickets in New York City.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'nyc-theater-discounts'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install nyc-theater-discounts
20
+
21
+ ## Usage
22
+
23
+ Type the following line into your terminal and then follow the prompts:
24
+
25
+ $ nyc-theater-discounts
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/kaileighrose/nyc-theater-discounts-cli-gem. 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.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
40
+
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_relative "../lib/nyc_theater_discounts.rb"
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
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../config/environment'
4
+
5
+ NYCTheaterDiscounts::CLI.new.call
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
@@ -0,0 +1,8 @@
1
+ require 'nokogiri'
2
+ require 'pry'
3
+
4
+ require_relative '../lib/nyc_theater_discounts/version'
5
+ require_relative '../lib/nyc_theater_discounts/scraper'
6
+ require_relative '../lib/nyc_theater_discounts/cli'
7
+ require_relative '../lib/nyc_theater_discounts/show'
8
+ require_relative '../lib/nyc_theater_discounts/vendor'
@@ -0,0 +1,86 @@
1
+ require 'nokogiri'
2
+ require 'pry'
3
+
4
+ class NYCTheaterDiscounts::CLI
5
+
6
+ def call
7
+ NYCTheaterDiscounts::Scraper.load_TodayTix
8
+ NYCTheaterDiscounts::Scraper.load_Theatermania
9
+ NYCTheaterDiscounts::Scraper.load_BroadwayBox
10
+ puts "Hello theater nerd! Here are the discount sources available:"
11
+ list_vendors
12
+ puts "To see a list of deals for each vendor type the number of the vendor. To search by show type 'by show'. To quit, type 'exit'."
13
+ starting_menu
14
+ goodbye
15
+ end
16
+
17
+ def starting_menu
18
+ input = gets.strip
19
+ if input.to_i == 1 || input.to_i == 2 || input.to_i == 3
20
+ vendor = NYCTheaterDiscounts::Vendor.all[input.to_i-1]
21
+ list_deals(vendor)
22
+ puts "To see more deals search either 'by vendor' or 'by show'. To quit type 'exit'."
23
+ input = gets.strip
24
+ menu(input)
25
+ else
26
+ menu(input)
27
+ end
28
+
29
+ end
30
+
31
+ def menu(input)
32
+ until input.to_s.downcase == "exit"
33
+ if input.to_s.downcase == "by vendor"
34
+ by_vendor_menu
35
+ puts "To see more deals search either 'by vendor' or 'by show'. To quit type 'exit'."
36
+ input = gets.strip
37
+ elsif input.to_s.downcase == "by show"
38
+ by_show_menu
39
+ puts "To see more deals search either 'by vendor' or 'by show'. To quit type 'exit'."
40
+ input = gets.strip
41
+ else
42
+ puts "Please choose either 'by vendor' or 'by show'. To quit type 'exit'."
43
+ input = gets.strip
44
+ end
45
+ end
46
+ end
47
+
48
+ def list_vendors
49
+ NYCTheaterDiscounts::Vendor.all.each_with_index {|value, index| puts "#{index+1}. #{value.name}"}
50
+ end
51
+
52
+ def list_deals(vendor)
53
+ puts "\nTo visit #{vendor.name} go to: #{vendor.url}\n\n"
54
+ vendor.shows.each_with_index do |show, index|
55
+ puts "#{index+1}. #{show.name} -- available from: #{show.price}"
56
+ puts "**to see this offer visit: #{show.deal_url}**\n\n"
57
+ end
58
+ end
59
+
60
+ def by_vendor_menu
61
+ list_vendors
62
+ puts "Please enter the number of the discount source you would like to check:"
63
+ input = gets.to_i
64
+ vendor = NYCTheaterDiscounts::Vendor.all[input-1]
65
+ list_deals(vendor)
66
+ end
67
+
68
+ def by_show_menu
69
+ puts "Please enter the title of the show you would like to check:"
70
+ input = gets.strip
71
+ input.to_s
72
+ NYCTheaterDiscounts::Vendor.all.each do |vendor|
73
+ vendor.shows.each do |show|
74
+ if show.name.downcase.include? input.downcase
75
+ puts "At #{vendor.name}: #{show.name} -- available from: #{show.price}"
76
+ puts "**to see this offer visit: #{show.deal_url}**\n\n"
77
+ end
78
+ end
79
+ end
80
+ puts "We did not find any additional shows associated with your query."
81
+ end
82
+
83
+ def goodbye
84
+ puts "Thank you for using nyc-theater-discounts. Check back again tomorrow!"
85
+ end
86
+ end
@@ -0,0 +1,68 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+ require 'pry'
4
+
5
+ class NYCTheaterDiscounts::Scraper
6
+ attr_accessor :name, :url, :shows, :lowest_price
7
+
8
+ def self.load_TodayTix
9
+ deals_page = Nokogiri::HTML(open('http://www.todaytix.com/us/nyc/shows/'))
10
+
11
+ todaytix = NYCTheaterDiscounts::Vendor.new("TodayTix", "http://www.todaytix.com/us/nyc/shows/")
12
+
13
+ deals_page.css("div.shows_hero_container a.heroTile.grid").each do |show|
14
+
15
+ title = show.css('header span.title').text
16
+ link = "http://www.todaytix.com/" + show['href']
17
+ price = show['data-min-price']
18
+ price = "$" + price.to_s
19
+
20
+ if title.include?("Referral Program") != true && title.include?("Gift Cards") != true
21
+ newshow = NYCTheaterDiscounts::Show.new(title, price, link)
22
+ newshow.vendors << todaytix
23
+ todaytix.shows << newshow
24
+ end
25
+ ##div.shows_hero_container a.heroTile.grid
26
+ ##href
27
+ ##data-min-price **add $**
28
+ ##header span.title
29
+ end
30
+ end
31
+
32
+ def self.load_Theatermania
33
+ deals_page = Nokogiri::HTML(open('http://www.theatermania.com/new-york-city-theater/discount-tickets/'))
34
+
35
+ theatermania = NYCTheaterDiscounts::Vendor.new("Theatermania", "http://www.theatermania.com/new-york-city-theater/discount-tickets/")
36
+
37
+ deals_page.css("div#listings_right div#result div.list div.show.logo").each do |show|
38
+
39
+ title = show.css('a.show-title span.show-name').text
40
+ link = "http://www.theatermania.com/" + show.css('a.show-title')[0]['href']
41
+ price = show.css("div strong").text
42
+
43
+ newshow = NYCTheaterDiscounts::Show.new(title, price, link)
44
+ newshow.vendors << theatermania
45
+ theatermania.shows << newshow
46
+ end
47
+ end
48
+
49
+ def self.load_BroadwayBox
50
+ deals_page = Nokogiri::HTML(open('http://www.broadwaybox.com/shows/tickets/discounts/?v=b'))
51
+
52
+ broadwaybox = NYCTheaterDiscounts::Vendor.new("BroadwayBox", "http://www.broadwaybox.com/shows/tickets/discounts/?v=b")
53
+
54
+ deals_page.css("div.list-group.list-quebec a.list-group-item").each do |show|
55
+
56
+ title = show.css('div.media-body div.event-title').text
57
+ link = "http://www.broadwaybox.com" + show['href']
58
+
59
+ show_page = Nokogiri::HTML(open(link))
60
+ price = show_page.css("div.col-md-6 p.slat-title strong")[0].text
61
+ price.slice!(/Tickets\sjust\s/)
62
+
63
+ newshow = NYCTheaterDiscounts::Show.new(title, price, link)
64
+ newshow.vendors << broadwaybox
65
+ broadwaybox.shows << newshow
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,39 @@
1
+ require 'nokogiri'
2
+ require 'pry'
3
+
4
+ class NYCTheaterDiscounts::Show
5
+
6
+ attr_accessor :name, :price, :vendor, :deal_url
7
+
8
+ @@all = []
9
+
10
+ def initialize(name, price, deal_url)
11
+ @name = name
12
+ @price = price
13
+ @deal_url = deal_url
14
+ @vendors = []
15
+ @@all << self
16
+ end
17
+
18
+ def self.all
19
+ if @@all.uniq == @@all
20
+ @@all
21
+ else
22
+ @@all.uniq!
23
+ end
24
+ end
25
+
26
+ def vendors
27
+ if @vendors.uniq == @vendors
28
+ @vendors
29
+ else
30
+ @vendors.uniq!
31
+ end
32
+ return @vendors
33
+ end
34
+
35
+ def find_by_name(nameval)
36
+ self.all.detect{|a| a.name == nameval}
37
+ end
38
+
39
+ end
@@ -0,0 +1,34 @@
1
+ require 'nokogiri'
2
+ require 'pry'
3
+
4
+ class NYCTheaterDiscounts::Vendor
5
+
6
+ attr_accessor :name, :url, :shows, :lowest_price
7
+
8
+ @@all = []
9
+
10
+ def initialize(name, path)
11
+ @name = name
12
+ @url = path
13
+ @shows = []
14
+ @@all << self
15
+ end
16
+
17
+ def self.all
18
+ if @@all.uniq == @@all
19
+ @@all
20
+ else
21
+ @@all.uniq!
22
+ end
23
+ end
24
+
25
+ def shows
26
+ if @shows.uniq == @shows
27
+ @shows
28
+ else
29
+ @shows.uniq!
30
+ end
31
+ return @shows
32
+ end
33
+
34
+ end
@@ -0,0 +1,3 @@
1
+ module NYCTheaterDiscounts
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require_relative '../lib/nyc_theater_discounts/version'
2
+ require_relative '../config/environment'
3
+
4
+ module NYCTheaterDiscounts
5
+
6
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nyc_theater_discounts/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nyc-theater-discounts"
8
+ spec.version = NYCTheaterDiscounts::VERSION
9
+ spec.authors = ["Kaileigh McCrea"]
10
+ spec.email = ["kaileighrose@gmail.com"]
11
+
12
+ spec.summary = %q{Shows daily discounts for NYC theater tickets}
13
+ spec.description = %q{Aggregates up-to-the-minute discounts for theater tickets in New York City.}
14
+ spec.homepage = "https://github.com/kaileighrose/nyc-theater-discounts-cli-gem"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "pry", ">= 0"
25
+ spec.add_development_dependency "nokogiri", ">= 0"
26
+ spec.add_development_dependency "rspec", ">= 0"
27
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nyc-theater-discounts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kaileigh McCrea
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-02 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: 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: :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: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Aggregates up-to-the-minute discounts for theater tickets in New York
84
+ City.
85
+ email:
86
+ - kaileighrose@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - CODE_OF_CONDUCT.md
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/nyc_theater_discounts
99
+ - bin/setup
100
+ - config/environment.rb
101
+ - lib/nyc_theater_discounts.rb
102
+ - lib/nyc_theater_discounts/cli.rb
103
+ - lib/nyc_theater_discounts/scraper.rb
104
+ - lib/nyc_theater_discounts/show.rb
105
+ - lib/nyc_theater_discounts/vendor.rb
106
+ - lib/nyc_theater_discounts/version.rb
107
+ - nyc-theater-discounts.gemspec
108
+ homepage: https://github.com/kaileighrose/nyc-theater-discounts-cli-gem
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.4.5.1
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Shows daily discounts for NYC theater tickets
132
+ test_files: []