Theatre_Explorer 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
+ SHA256:
3
+ metadata.gz: 5aae833f32fec06731527b8e610052a5e7317a9cd5947c5f8c3397774d685fe7
4
+ data.tar.gz: 7aac63df863f03ab521e79d84bbccf319e2f2be766c836db13888e6063af4dda
5
+ SHA512:
6
+ metadata.gz: c7a5a604a9c4bb78b40bc5ea2bc2b1dec56a58018c1cc84163dd7ea6fd191d6be29ba0f50e398631e0dadaed3c52ae510da53b976c8386bbf1e46b3bde6831d3
7
+ data.tar.gz: 4fca341c3bbb1e21e0b14c2e0dfe48bb713b3560fdb2774b2967542385d82d9941a1c543ba6c6fba0179f97d098519b8543acee6d04cfae1e452777810ce6f66
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at thedrewkeat@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify gem dependencies in Theatre_Explorer.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,60 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ Theatre_Explorer (0.1.0)
5
+ mechanize
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ coderay (1.1.3)
13
+ connection_pool (2.2.5)
14
+ domain_name (0.5.20190701)
15
+ unf (>= 0.0.5, < 1.0.0)
16
+ http-cookie (1.0.3)
17
+ domain_name (~> 0.5)
18
+ mechanize (2.8.1)
19
+ addressable (~> 2.7)
20
+ domain_name (~> 0.5, >= 0.5.20190701)
21
+ http-cookie (~> 1.0, >= 1.0.3)
22
+ mime-types (~> 3.0)
23
+ net-http-digest_auth (~> 1.4, >= 1.4.1)
24
+ net-http-persistent (>= 2.5.2, < 5.0.dev)
25
+ nokogiri (~> 1.11, >= 1.11.2)
26
+ rubyntlm (~> 0.6, >= 0.6.3)
27
+ webrick (~> 1.7)
28
+ webrobots (~> 0.1.2)
29
+ method_source (1.0.0)
30
+ mime-types (3.3.1)
31
+ mime-types-data (~> 3.2015)
32
+ mime-types-data (3.2021.0225)
33
+ net-http-digest_auth (1.4.1)
34
+ net-http-persistent (4.0.1)
35
+ connection_pool (~> 2.2)
36
+ nokogiri (1.11.6-x86_64-darwin)
37
+ racc (~> 1.4)
38
+ pry (0.14.1)
39
+ coderay (~> 1.1)
40
+ method_source (~> 1.0)
41
+ public_suffix (4.0.6)
42
+ racc (1.5.2)
43
+ rake (13.0.3)
44
+ rubyntlm (0.6.3)
45
+ unf (0.1.4)
46
+ unf_ext
47
+ unf_ext (0.0.7.7)
48
+ webrick (1.7.0)
49
+ webrobots (0.1.2)
50
+
51
+ PLATFORMS
52
+ x86_64-darwin-20
53
+
54
+ DEPENDENCIES
55
+ Theatre_Explorer!
56
+ pry
57
+ rake (~> 13.0)
58
+
59
+ BUNDLED WITH
60
+ 2.2.17
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Drew Keat
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,38 @@
1
+ # Theatre_Explorer
2
+
3
+ Theatre Explorer provides a CLI for users to interact with production information from the website www.broadwayworld.com. The user experience begins with selecting whether to search for productions by name or by year. After that selection, specific aspects of a chosen production can be viewed in greater detail.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'Theatre_Explorer'
11
+ ```
12
+ To use this gem, type the following command into your terminal:
13
+
14
+ $ gem install Theatre_Explore
15
+
16
+ Once the gem has been added to your system, use the command `Explore!` to initiate the user interface.
17
+
18
+ ## Usage
19
+
20
+ After running the interface by entering the command `Explore!`, simply follow the prompts and enter the appropriate information for your search.
21
+
22
+ ## Development
23
+
24
+ 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.
25
+
26
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
27
+
28
+ ## Contributing
29
+
30
+ Bug reports and pull requests are welcome on GitHub at https://github.com/<github username>/Theatre_Explorer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/<github username>/Theatre_Explorer/blob/master/CODE_OF_CONDUCT.md).
31
+
32
+ ## License
33
+
34
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
35
+
36
+ ## Code of Conduct
37
+
38
+ Everyone interacting in the TheatreExplorer project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<github username>/Theatre_Explorer/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/Theatre_Explorer/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "Theatre_Explorer"
7
+ spec.version = TheatreExplorer::VERSION
8
+ spec.authors = ["Drew Keat"]
9
+ spec.email = ["drewjkeat@gmail.com"]
10
+
11
+ spec.summary = "Theatre_Explorer uses a command line interface to reference information from the website broadwayworld.com."
12
+ spec.description = "Theatre Explorer provides a CLI for users to interact with production information from the website www.broadwayworld.com. The user experience begins with selecting whether to search for productions by name or by year. After that selection, specific aspects of a chosen production can be viewed in greater detail."
13
+ spec.homepage = "https://github.com/drewkeat/Theatre_Explorer"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
16
+
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "bin"
21
+ spec.executables = ["Explore!"]
22
+ spec.require_paths = ["lib"]
23
+
24
+ # Uncomment to register a new dependency of your gem
25
+ # spec.add_dependency "example-gem", "~> 1.0"
26
+ spec.add_dependency "mechanize", "~> 2.8"
27
+ spec.add_development_dependency "pry", "~> 0.14.0"
28
+
29
+ # For more information and examples about making a new gem, checkout our
30
+ # guide at: https://bundler.io/guides/creating_gem.html
31
+ end
data/bin/Explore! ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/Theatre_Explorer"
4
+
5
+ CLI.new.call
data/bin/console ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "Theatre_Explorer"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+
11
+ # (If you use this, don't forget to add pry to your Gemfile!)
12
+ require "pry"
13
+
14
+ require "irb"
15
+
16
+ def reload!(print = true)
17
+ puts 'Reloading ...' if print
18
+ # Main project directory.
19
+ root_dir = File.expand_path('..', __dir__)
20
+ # Directories within the project that should be reloaded.
21
+ reload_dirs = %w{lib}
22
+ # Loop through and reload every file in all relevant project directories.
23
+ reload_dirs.each do |dir|
24
+ Dir.glob("#{root_dir}/#{dir}/**/*.rb").each { |f| load(f) }
25
+ end
26
+ # Return true when complete.
27
+ true
28
+ end
29
+
30
+
31
+ IRB.start(__FILE__)
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,17 @@
1
+ # frozen_string_literal: true
2
+ require "mechanize"
3
+ require "pry"
4
+
5
+ require_relative "Theatre_Explorer/version"
6
+ require_relative "Theatre_Explorer/shared_modules"
7
+ require_relative "Theatre_Explorer/cli"
8
+ require_relative "Theatre_Explorer/year"
9
+ require_relative "Theatre_Explorer/production"
10
+ require_relative "Theatre_Explorer/show"
11
+ require_relative "Theatre_Explorer/scraper"
12
+
13
+
14
+ module TheatreExplorer
15
+
16
+ end
17
+
@@ -0,0 +1,133 @@
1
+ class CLI
2
+ #Initiates the CLI and prompts user for initial exploration preferences
3
+ def call
4
+ system("clear")
5
+ puts "
6
+ =====================================
7
+ || Welcome to Theatre Explore! ||
8
+ =====================================
9
+ "
10
+ initial_prompt
11
+ end
12
+
13
+ #Prompts user for initial exploration preferences
14
+ def initial_prompt
15
+ puts "How would you like to explore?"
16
+ puts "---------------------------------"
17
+ puts ""
18
+ puts "1) Search by Year"
19
+ puts "2) Search by production title"
20
+ puts "\n\t ** or type Exit **"
21
+ input = gets.strip.downcase
22
+ case input
23
+ when "exit"
24
+ goodbye
25
+ when "1"
26
+ year_search
27
+ when "2"
28
+ production_search
29
+ else
30
+ unclear
31
+ end
32
+ end
33
+
34
+ #Prompts user for year input. Creates/finds year based on input, and displays scraped list of productions from that year (rather than creating production instances for all productions associated with that year).
35
+ def year_search
36
+ system("clear")
37
+ puts "========================"
38
+ puts "What year would you like to explore?"
39
+ puts "I can pull records dating back to 1832."
40
+ puts "========================"
41
+ puts ""
42
+
43
+ input = gets.strip.downcase
44
+ current_year = Time.now.year
45
+
46
+ if input == "exit"
47
+
48
+ goodbye
49
+
50
+ elsif input.to_i.between?(1832, current_year - 1)
51
+
52
+ #Scrapes production titles and urls for year
53
+ year = Year.find_or_create(input)
54
+ #Displays scraped production list
55
+ year.display_productions
56
+ puts "**Select a production by # to see more details**"
57
+ input = gets.strip.to_i
58
+ #Returns the url for the associated production
59
+ selection = year.scraped_list[year.scraped_list.keys[input - 1]]
60
+ system("clear")
61
+ #Scrapes and instantiates a new production based on selection
62
+ show = Scraper.new.production(selection)
63
+ show.print
64
+ continue_prompt
65
+
66
+ else
67
+
68
+ unclear
69
+
70
+ end
71
+
72
+ end
73
+
74
+ #Prompts user to search for a production by title. Scrapes query results based on input, and displays results for selection. Instantiates new production based on selection
75
+ def production_search
76
+ system("clear")
77
+ puts "===================================="
78
+ puts "What show would you like to explore?"
79
+ puts "===================================="
80
+ puts ""
81
+ input = gets.strip
82
+ if input == "exit"
83
+ goodbye
84
+ else
85
+ #Creates hash with query results as keys and urls as values
86
+ options = Scraper.new.show_search(input)
87
+ #Displays query results
88
+ options.keys.each.with_index(1) {|option, index| puts "#{index}) \t #{option}"}
89
+ puts "Which result would you like to explore?"
90
+ input = gets.strip.to_i
91
+ selection = options[options.keys[input - 1]]
92
+ #Scrapes and instantiates production object based on selection.
93
+ show = Scraper.new.production("https://www.broadwayworld.com#{selection}")
94
+ show.print
95
+ continue_prompt
96
+ end
97
+ end
98
+
99
+ #Sequence for repeated searches
100
+ def continue_prompt
101
+ puts "\nWould you like to explore more?"
102
+ input = gets.strip.downcase
103
+ if input == "n" || input == "no" || input == "exit"
104
+ goodbye
105
+ else
106
+ system("clear")
107
+ initial_prompt
108
+ end
109
+ end
110
+
111
+ #Sequence for invalid/unclear input
112
+ def unclear
113
+ system("clear")
114
+ puts "I'm sorry. That seems to be invalid input.\n
115
+ Please try again."
116
+ sleep(1)
117
+ system("clear")
118
+ initial_prompt
119
+ end
120
+
121
+ #Exit sequence
122
+ def goodbye
123
+
124
+ system("clear")
125
+ puts "==========================="
126
+ puts "|| Thanks for exploring! ||"
127
+ puts "---------------------------"
128
+ puts "|| Goodbye! ||"
129
+ puts "==========================="
130
+ binding.pry
131
+ exit
132
+ end
133
+ end
@@ -0,0 +1,54 @@
1
+ class Production
2
+ attr_accessor :label, :year, :show, :details
3
+ @@all = []
4
+ extend Shared::Findable
5
+
6
+ def initialize(attributes)
7
+ unless Production.find(attributes["label"])
8
+ @label = label
9
+ attributes.each {|k,v| self.send("#{k}=", v)}
10
+ join_year(year) if year
11
+ join_show(show) if show
12
+ @@all << self
13
+ end
14
+ end
15
+
16
+ def self.all
17
+ @@all
18
+ end
19
+
20
+ def join_year(year_label)
21
+ year_label = Time.now.year.to_s if year_label == ""
22
+ year = Year.find_or_create(year_label)
23
+ self.year = year
24
+ year.productions << self
25
+ end
26
+
27
+ def join_show(show_label)
28
+ show = Show.find_or_create(show_label)
29
+ show.type = details["Show type"]
30
+ self.show = show
31
+ show.productions << self
32
+ end
33
+
34
+ def print
35
+ puts "========================"
36
+ puts "#{label}"
37
+ puts "========================"
38
+ puts "Show type: #{details["Show type"]}"
39
+ if details["summary"]
40
+ puts ""
41
+ puts "Summary: \t #{details["summary"]}\n"
42
+ puts ""
43
+ else
44
+ puts ""
45
+ puts "Summary: Not available for this production\n"
46
+ puts ""
47
+ end
48
+
49
+ details.each do |k,v|
50
+ puts "#{k} \t #{v}" unless k == "summary" || k == "Show type"
51
+ end
52
+
53
+ end
54
+ end
@@ -0,0 +1,69 @@
1
+ class Scraper
2
+
3
+ def year(year_label)
4
+ final = {}
5
+ page = Mechanize.new.get("https://www.broadwayworld.com/browseshows.cfm?showtype=BR&open_yr=#{year_label}")
6
+ list = page.search("p+ ul li")
7
+ list.each do |item|
8
+ label = item.text
9
+ link = item.children.attribute("href").value
10
+ final[label] = link
11
+ end
12
+ final
13
+ end
14
+
15
+ def production(url)
16
+ landing = Mechanize.new.get(url)
17
+ @page = landing.link_with(:href => /backstage.php/).click
18
+ attributes = pull_attrs
19
+ Production.new(attributes) unless Production.find(attributes["label"])
20
+ Production.find(attributes["label"])
21
+ end
22
+
23
+ def pull_attrs
24
+ attributes = {}
25
+ attributes["show"] = @page.at("h2").text.gsub(" Show Information","")
26
+ attributes["year"] = @page.at("tr:nth-child(1) td+ td span").text.match(/\d{4}/).to_s
27
+ attributes["label"] = "#{attributes["show"]} - #{attributes["year"]}"
28
+ attributes["details"] = {}
29
+ prod_information = @page.search(".production-table span")
30
+ prod_information.each.with_index do |e,i|
31
+ case e.text.strip
32
+ when "Previews:"
33
+ attributes["details"][e.text] = prod_information[i + 1].text
34
+ when "Opening:"
35
+ attributes["details"][e.text] = prod_information[i + 1].text
36
+ when "Closing:"
37
+ attributes["details"][e.text] = prod_information[i + 1].text
38
+ when "Theatres:"
39
+ attributes["details"][e.text] = prod_information[i + 1].text
40
+ when "Production Type:"
41
+ attributes["details"][e.text] = prod_information[i + 1].text
42
+ when "Run Type:"
43
+ attributes["details"][e.text] = prod_information[i + 1].text
44
+ when "Market:"
45
+ attributes["details"][e.text] = prod_information[i + 1].text
46
+ when "Running Time:"
47
+ attributes["details"][e.text] = prod_information[i + 1].text
48
+ when "Intermissions:"
49
+ attributes["details"][e.text] = prod_information[i + 1].text
50
+ when "Version:"
51
+ attributes["details"][e.text] = prod_information[i + 1].text
52
+ when "Official Website"
53
+ attributes["details"][e.text] = prod_information[i + 1].text
54
+ when "Show type"
55
+ attributes["details"][e.text] = prod_information[i + 1].text
56
+ end
57
+ end
58
+ summary = @page.link_with(:href => /\d*.html/).click.at("style+ .col-12").text[/; (\w.*\.)\w/]
59
+ attributes["details"]["summary"] = /; (\w.*\.)\w/.match(summary)[1].strip if summary
60
+ attributes
61
+ end
62
+
63
+ def show_search(query)
64
+ landing = Mechanize.new.get("https://www.broadwayworld.com")
65
+ landing.forms.first.field(:name => "q").value = query
66
+ search_page = landing.forms.first.submit
67
+ options = search_page.search("td span").map {|item| [item.text, item.children.attribute("href").value]}.to_h
68
+ end
69
+ end
@@ -0,0 +1,21 @@
1
+ module Shared
2
+
3
+ module Findable
4
+
5
+ def find(label)
6
+ object = self.all.detect {|inst| inst.label == label}
7
+ end
8
+
9
+ def find_or_create(label)
10
+ object = self.find(label)
11
+ if object
12
+ object
13
+ else
14
+ self.new(label)
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+
@@ -0,0 +1,18 @@
1
+ class Show
2
+ attr_accessor :label, :type, :productions
3
+ @@all = []
4
+ extend Shared::Findable
5
+
6
+ def initialize(label, type = "Unknown", productions = [])
7
+ unless Show.find(label)
8
+ @label = label
9
+ @type = type
10
+ @productions = productions
11
+ @@all << self
12
+ end
13
+ end
14
+
15
+ def self.all
16
+ @@all
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TheatreExplorer
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,29 @@
1
+
2
+ class Year
3
+ attr_accessor :label, :productions, :scraped_list
4
+ @@all = []
5
+ extend Shared::Findable
6
+
7
+ def initialize(label, productions = [])
8
+ unless Year.find(label)
9
+ @label = label
10
+ @productions = productions
11
+ @scraped_list = Scraper.new.year(self.label)
12
+ @@all << self
13
+ end
14
+ end
15
+
16
+ def self.all
17
+ @@all
18
+ end
19
+
20
+ def display_productions
21
+ system("clear")
22
+ puts "Broadway productions from #{@label}"
23
+ puts "-------------------------------------------------"
24
+ scraped_list.keys.each.with_index(1) do |production, i|
25
+ puts "#{i}) \t#{production}"
26
+ end
27
+ puts "-------------------------------------------------"
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Theatre_Explorer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Drew Keat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-05-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mechanize
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.14.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.14.0
41
+ description: Theatre Explorer provides a CLI for users to interact with production
42
+ information from the website www.broadwayworld.com. The user experience begins
43
+ with selecting whether to search for productions by name or by year. After that
44
+ selection, specific aspects of a chosen production can be viewed in greater detail.
45
+ email:
46
+ - drewjkeat@gmail.com
47
+ executables:
48
+ - Explore!
49
+ extensions: []
50
+ extra_rdoc_files: []
51
+ files:
52
+ - ".gitignore"
53
+ - CODE_OF_CONDUCT.md
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - Theatre_Explorer.gemspec
60
+ - bin/Explore!
61
+ - bin/console
62
+ - bin/setup
63
+ - lib/Theatre_Explorer.rb
64
+ - lib/Theatre_Explorer/cli.rb
65
+ - lib/Theatre_Explorer/production.rb
66
+ - lib/Theatre_Explorer/scraper.rb
67
+ - lib/Theatre_Explorer/shared_modules.rb
68
+ - lib/Theatre_Explorer/show.rb
69
+ - lib/Theatre_Explorer/version.rb
70
+ - lib/Theatre_Explorer/year.rb
71
+ homepage: https://github.com/drewkeat/Theatre_Explorer
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 2.4.0
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubygems_version: 3.2.15
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Theatre_Explorer uses a command line interface to reference information from
94
+ the website broadwayworld.com.
95
+ test_files: []