StarTrekCLI 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: d73b04c5d60e5e4fd7bc624f418da5068425f391
4
+ data.tar.gz: 918285d381b2427163870b7e6ec7d2fd8e5b0120
5
+ SHA512:
6
+ metadata.gz: 4faf0a75952d21f7c23d878649a95f0387d58d0965a1f27cc48239e7add6908088746d47887bcccabf03e7e8a250badd4ab169ecb72907f264e1fa307eb6b82c
7
+ data.tar.gz: 2925fa0e947e589db3718c873098e6841b9a8fdc17ba781c10da94c4b57522cbc85cde59900319eb1820deaf88f40813e97b11f781c692f6c8d38c26eed138e1
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at kjwittig@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in StarTrekCLI.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 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,41 @@
1
+ # StarTrekCLI
2
+
3
+ A CLI tool to query Star Trek info! Happy searching trekkies.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'StarTrekCLI'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install StarTrekCLI
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/StarTrekCLI. 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.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
38
+
39
+ ## Code of Conduct
40
+
41
+ Everyone interacting in the StarTrekCLI project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/StarTrekCLI/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "StarTrekCLI/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "StarTrekCLI"
8
+ spec.version = StarTrekCLI::VERSION
9
+ spec.authors = ["Kachel Wittig"]
10
+ spec.email = ["kjwittig@gmail.com"]
11
+
12
+ spec.summary = %q{A CLI tool to query Star Trek info.}
13
+ spec.description = %q{Use flags to navigate!}
14
+ spec.homepage = "https://github.com/scrptktty/StarTrekCLI"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "bin"
30
+ spec.executables << 'startrek'
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler"
34
+ spec.add_development_dependency "rake"
35
+ spec.add_development_dependency "pry"
36
+ spec.add_development_dependency "rspec"
37
+ spec.add_development_dependency "byebug"
38
+ spec.add_development_dependency "nokogiri"
39
+ spec.add_development_dependency "rb-readline"
40
+ spec.add_runtime_dependency "colorize"
41
+ spec.add_runtime_dependency "open-uri-cached"
42
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "StarTrekCLI"
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/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/bin/startrek ADDED
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'StarTrekCLI'
5
+ require 'optparse'
6
+ require 'rb-readline'
7
+ require 'colorize'
8
+
9
+ # stateless interface, the user can type a specific episode or start with a series
10
+ # and then choose a season and then choose an episode!
11
+ # optparse is a part of the ruby standardlibrary
12
+ instructions = {}
13
+
14
+ parser = OptionParser.new do |opts|
15
+ opts.banner = <<-HEREDOC
16
+ Welcome, ensign, to #{"StarTrekCLI".colorize(:red)}!
17
+
18
+ Usage: startrek <command> <arg> [<command2> <arg2>]
19
+
20
+ Example:
21
+ startrek --list-episode-info '#{"Deep Space Nine".colorize(:cyan)}':#{"3".colorize(:green)}:#{"460".colorize(:yellow)}
22
+
23
+ COMMANDS:
24
+ HEREDOC
25
+
26
+
27
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
28
+ instructions[:verbose] = v
29
+ end
30
+
31
+ opts.on("-h", "--help", "Print this help") do |h|
32
+ puts opts
33
+ exit 1
34
+ end
35
+
36
+ opts.on("--list-series", "List series") do |bool|
37
+ # either true or false hence the |bool|
38
+ instructions[:list_series] = bool
39
+ end
40
+
41
+ opts.on("--list-seasons SERIES", "List seasons for " + "SERIES".colorize(:cyan)) do |series|
42
+ # list seasons *for* this series
43
+ instructions[:list_seasons] = series
44
+ end
45
+
46
+ # list episodes for a season
47
+ opts.on("--list-episodes SERIES:SEASON_NUM", "List episodes for " + "SEASON_NUM".colorize(:green) + " of " + "SERIES".colorize(:cyan) ) do |spec|
48
+ raise "COMPUTER: Do not forget your colon. You typed '#{spec}'" unless spec.include?(":")
49
+ instructions[:list_episodes] = spec.split(":")
50
+ end
51
+
52
+ opts.on("--list-episode-info SERIES:SEASON_NUM:PRODUCTION_NUM", "Detail episode " + "PRODUCTION_NUM".colorize(:yellow) + " from " + "SEASON_NUM".colorize(:green) + " of " + "SERIES".colorize(:cyan) ) do |spec|
53
+ raise "COMPUTER: Do not forget your colon. You typed '#{spec}'" unless spec.include?(":")
54
+
55
+ # FIXME
56
+ instructions[:list_episode_info] = spec.split(":")
57
+ end
58
+ end # parser
59
+
60
+ parser.parse!
61
+
62
+ controller = StarTrekCLI::Controller.new(instructions[:verbose])
63
+
64
+ if instructions[:list_series]
65
+ puts "Found Star Trek series:"
66
+ controller.list_series
67
+ puts " "
68
+ puts "Now try:"
69
+ puts " startrek --list-seasons " + "SERIES".colorize(:cyan)
70
+
71
+ elsif instructions[:list_seasons]
72
+ puts "Found season numbers for '#{instructions[:list_seasons].colorize(:cyan)}':"
73
+ controller.list_seasons(instructions[:list_seasons])
74
+ puts " "
75
+ puts "Now try:"
76
+ puts " startrek --list-episodes '#{instructions[:list_seasons].colorize(:cyan)}':" + "SEASON_NUM".colorize(:green)
77
+
78
+ elsif instructions[:list_episodes]
79
+ puts "Found episodes' production numbers for season #{instructions[:list_episodes][1].colorize(:green)} of '#{instructions[:list_episodes][0].colorize(:cyan)}':"
80
+ controller.list_episodes(instructions[:list_episodes][0], instructions[:list_episodes][1])
81
+ puts " "
82
+ puts "Now try:"
83
+ puts " startrek --list-episode-info '#{instructions[:list_episodes][0].colorize(:cyan)}':#{instructions[:list_episodes][1].colorize(:green)}:" + "PRODUCTION_NUM".colorize(:yellow)
84
+
85
+ elsif instructions[:list_episode_info]
86
+ a, b, c = instructions[:list_episode_info]
87
+ puts "Found episode #{c.colorize(:yellow)} from season #{b.colorize(:green)} of '#{a.colorize(:cyan)}':"
88
+ controller.list_episode_info(a, b, c)
89
+
90
+ else
91
+ puts parser
92
+ exit 1
93
+ end
@@ -0,0 +1,10 @@
1
+ require "StarTrekCLI/version"
2
+ require "StarTrekCLI/scraper"
3
+ require "StarTrekCLI/series"
4
+ require "StarTrekCLI/episode"
5
+ require "StarTrekCLI/season"
6
+ require "StarTrekCLI/controller"
7
+
8
+ module StarTrekCLI
9
+ # Your code goes here...
10
+ end
@@ -0,0 +1,110 @@
1
+ require 'pry'
2
+ require 'byebug'
3
+ require 'rb-readline'
4
+ require 'uri'
5
+ require 'colorize'
6
+
7
+ class StarTrekCLI::Controller
8
+
9
+ # I am a constant <3
10
+ INDEX_URL = "http://chakoteya.net/StarTrek/index.html"
11
+
12
+ def initialize(print_progress)
13
+ @scraper = StarTrekCLI::Scraper.new
14
+
15
+ @scraper.each_index_group(INDEX_URL) do |group|
16
+ print "!" if print_progress
17
+ # special case: Orginal series title has that weird new line hence the ternary
18
+ title = group[:title] == "Original\nand Animated Series" ? "Star Trek" : group[:title]
19
+
20
+ series = StarTrekCLI::Series.new(title)
21
+
22
+ # this uses uri which is built into the ruby standardlibrary
23
+ series_url = URI.join(INDEX_URL, group[:page_url])
24
+
25
+ current_season = 0
26
+ @scraper.each_series_page(series_url) do |episode_row|
27
+ # for debugging purposes / caching
28
+ if print_progress
29
+ print "?" if current_season != episode_row[:season_number]
30
+ current_season = episode_row[:season_number]
31
+ end
32
+
33
+ season = series.season(episode_row[:season_number])
34
+
35
+ episode_url = URI.join(INDEX_URL, group[:page_url], episode_row[:episode_url])
36
+
37
+ # FIXME: this method needs some work!
38
+ @scraper.episode_page_header(episode_url) do |episode|
39
+ print "." if print_progress
40
+ StarTrekCLI::Episode.new(
41
+ season,
42
+ episode_row[:production_number],
43
+ episode_row[:episode_name],
44
+ episode[:star_date],
45
+ episode[:air_date]
46
+ )
47
+
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ def list_series
54
+ StarTrekCLI::Series.all.each do |series|
55
+ puts "#{series.name}".colorize(:cyan)
56
+ end
57
+ end
58
+
59
+ def list_seasons(series_string)
60
+ series = StarTrekCLI::Series.find_series_by_name(series_string)
61
+ raise "This series is not scraped: '#{series_string}'" unless series
62
+ series.seasons.each do |season|
63
+ if season
64
+ puts season.season_number.to_s.colorize(:green)
65
+ end
66
+ end
67
+ end
68
+
69
+ def list_episodes(series_string, season_string)
70
+ raise "series must be an string" unless series_string.is_a? String
71
+ season_int = season_string.to_i
72
+
73
+ unless season_int > 0
74
+ raise "You must enter an integer for season number. You entered '#{season_string}'"
75
+ end
76
+
77
+ series = StarTrekCLI::Series.find_series_by_name(series_string)
78
+ season = series.season(season_int)
79
+
80
+ ## working on season.episodes
81
+ season.episodes.each do |production_number, episode|
82
+ puts "#{production_number.colorize(:yellow)}: #{episode.name}"
83
+ end
84
+ end
85
+
86
+
87
+ def list_episode_info(series_string, season_string, production_number)
88
+
89
+ raise "series must be an string" unless series_string.is_a? String
90
+ series = StarTrekCLI::Series.find_series_by_name(series_string)
91
+
92
+ season_int = season_string.to_i
93
+ unless season_int > 0
94
+ raise "COMPUTER: You must enter an integer for season number. You entered '#{season_string}'"
95
+ end
96
+ season = series.season(season_int)
97
+
98
+ production_number_int = production_number.to_i
99
+ unless production_number_int > 0
100
+ raise "COMPUTER: You must enter an integer for production number. You entered '#{production_number}'"
101
+ end
102
+
103
+ episode = season.episodes[production_number_int.to_s]
104
+
105
+ puts "Air date: #{episode.air_date}"
106
+ puts "Star date: #{episode.star_date}"
107
+
108
+ end
109
+
110
+ end # StarTrekCLI::StarTrekController
@@ -0,0 +1,24 @@
1
+ require 'pry'
2
+ require 'byebug'
3
+
4
+ class StarTrekCLI::Episode
5
+ attr_reader :name, :air_date, :star_date, :production_number, :season
6
+
7
+ @@all = []
8
+
9
+ def initialize(season, production_number, name, star_date, air_date, script = nil)
10
+ @season = season
11
+ @name = name
12
+ @production_number = production_number
13
+ @star_date = star_date
14
+ @air_date = air_date
15
+ @@all << self
16
+ raise "episode.new was called with an int and not a string" unless production_number.is_a? String
17
+ season.episodes[production_number] = self
18
+ end
19
+
20
+ def self.all
21
+ @@all
22
+ end
23
+
24
+ end
@@ -0,0 +1,104 @@
1
+ require 'open-uri/cached'
2
+ require 'pry'
3
+ require 'nokogiri'
4
+ require 'rb-readline'
5
+
6
+ module StarTrekCLI
7
+ class Scraper
8
+
9
+ DATE_REGEX = /Stardate:\s*(?<stardate>[\d.]+)\s*Original\s*Airdate:\s*(?<airdate>[^\n]+)/i
10
+
11
+ # This method pulls information from the Chakoteya index for each Star Trek
12
+ # series using an iterator. The data is constructed as a hash with
13
+ # `image_url`, `page_url`, and `title` properties. This is yielded as a
14
+ # block argument.
15
+ def each_index_group(index_url)
16
+ # FIXME: there might be a ghost tbody hanging around
17
+ doc = Nokogiri::HTML(open(index_url))
18
+ table = doc.css("tbody")
19
+
20
+ row1 = table.css("tr")[0].css("td a img") # images
21
+ row2 = table.css("tr")[1].css("a") # links
22
+
23
+ # works like a do loop
24
+ (0..3).each do |column|
25
+ cell_group = {
26
+ :image_url => row1[column].attr("src"),
27
+ :page_url => row2[column].attr("href"),
28
+ :title => row2[column].children.first.content.strip
29
+ }
30
+ yield cell_group
31
+ end
32
+ end
33
+ # TODO: FUCKING ENTERPRISE THE GARBAGE SERIESSSS
34
+
35
+ # This method pulls information from the scraped series using an iterator.
36
+ # The data is constructed as a hash with `episode_name`, `star_date`, and
37
+ # `air_date` properties. This is yielded as a block argument.
38
+ def each_series_page(series_url)
39
+ html_source = open(series_url)
40
+ doc = Nokogiri::HTML(html_source)
41
+ sub_tables = doc.css("body > table table")
42
+
43
+ # FIXME: seasons will have some problems like 101 + 102 or the animated
44
+ # series as season "4"
45
+ if sub_tables.empty?
46
+ doc.css("body > div table").each_with_index do |table, index|
47
+ rows = table.css("tr")
48
+ rows.shift
49
+ rows.each do |row|
50
+ link = row.css("td")[0].css("a")
51
+
52
+ episode_row = {
53
+ :season_number => index + 1,
54
+ :episode_name => link.children.text.strip,
55
+ :episode_url => link.attr("href").value,
56
+ # I am using to_i to truncate any second set of production numbers
57
+ :production_number => row.css("td")[1].text.strip.to_i.to_s,
58
+ }
59
+ yield episode_row
60
+ end # rows.each
61
+ end # body > div table
62
+
63
+ else # sub_tables is not empty
64
+ sub_tables.each_with_index do |table, index|
65
+ rows = table.css("tr")
66
+ rows.shift
67
+ rows.each do |row|
68
+ link = row.css("td").css("a")
69
+
70
+ episode_row = {
71
+ :season_number => index + 1,
72
+ :episode_name => link.children.text.strip,
73
+ :episode_url => link.attr("href").value,
74
+ :production_number => row.css("td")[1].text.strip.to_i.to_s,
75
+ }
76
+ yield episode_row
77
+ end # rows.each
78
+ end # subtables.each
79
+ end # if / else
80
+ end # def each_series_page
81
+
82
+ # This method pulls information from the scraped episodes using an iterator.
83
+ # The data is constructed as a hash with `episode_name`, `star_date`, and
84
+ # `air_date` properties. This is yielded as a block argument.
85
+ def episode_page_header(episode_url)
86
+
87
+ html_source = open(episode_url)
88
+ doc = Nokogiri::HTML(html_source)
89
+ header = doc.css("body > p").first
90
+ dates = header.children.last.text.match(DATE_REGEX)
91
+
92
+ # the star trek pilot does *not* have any dates... it will return
93
+ # nil to the user.
94
+ episode_stuff = {
95
+ :episode_name => header.css("b").text.strip,
96
+ :star_date => dates ? dates[1].strip : nil,
97
+ :air_date => dates ? dates[2].strip : nil
98
+ }
99
+ yield episode_stuff
100
+ end
101
+
102
+
103
+ end # Scraper
104
+ end # module StarTrekCLI
@@ -0,0 +1,25 @@
1
+ require 'pry'
2
+ require 'byebug'
3
+ require 'rb-readline'
4
+
5
+ class StarTrekCLI::Season
6
+ attr_reader :season_number, :episodes, :series
7
+
8
+ @@all = []
9
+
10
+ # series is an instance of Series and also gives it a relationship
11
+ def initialize(series, season_number)
12
+ raise "season must be an integer" unless season_number.is_a? Integer
13
+ raise "series must be a Series instance" unless series.is_a? StarTrekCLI::Series
14
+ @series = series
15
+ @season_number = season_number
16
+ @episodes = {}
17
+ @@all << self
18
+ series.seasons[season_number] = self
19
+ end
20
+
21
+ def self.all
22
+ @@all
23
+ end
24
+
25
+ end
@@ -0,0 +1,33 @@
1
+ require 'pry'
2
+ require 'byebug'
3
+ require 'rb-readline'
4
+
5
+ class StarTrekCLI::Series
6
+ attr_reader :name, :seasons, :title_card
7
+
8
+ @@all = []
9
+
10
+ def initialize(name)
11
+ @name = name
12
+ @seasons = []
13
+ @@all << self
14
+ end
15
+
16
+ def self.all
17
+ @@all
18
+ end
19
+
20
+ def self.find_series_by_name(series_name)
21
+ @@all.find do |n|
22
+ n.name == series_name
23
+ end
24
+ end
25
+
26
+
27
+ # NYI: url not fucking used, how is the url going to get to season.new?
28
+ def season(season_number)
29
+ @seasons[season_number] || StarTrekCLI::Season.new(self, season_number)
30
+ end
31
+
32
+
33
+ end
@@ -0,0 +1,3 @@
1
+ module StarTrekCLI
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: StarTrekCLI
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kachel Wittig
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-06-11 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: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '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: '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'
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: rspec
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: byebug
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
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rb-readline
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: colorize
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: open-uri-cached
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Use flags to navigate!
140
+ email:
141
+ - kjwittig@gmail.com
142
+ executables:
143
+ - startrek
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - ".gitignore"
148
+ - ".rspec"
149
+ - CODE_OF_CONDUCT.md
150
+ - Gemfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - StarTrekCLI.gemspec
155
+ - bin/console
156
+ - bin/setup
157
+ - bin/startrek
158
+ - lib/StarTrekCLI.rb
159
+ - lib/StarTrekCLI/controller.rb
160
+ - lib/StarTrekCLI/episode.rb
161
+ - lib/StarTrekCLI/scraper.rb
162
+ - lib/StarTrekCLI/season.rb
163
+ - lib/StarTrekCLI/series.rb
164
+ - lib/StarTrekCLI/version.rb
165
+ homepage: https://github.com/scrptktty/StarTrekCLI
166
+ licenses:
167
+ - MIT
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.5.1
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: A CLI tool to query Star Trek info.
189
+ test_files: []