watchbuffy 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +22 -0
- data/CHANGELOG.md +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/MIT-LICENSE.txt +20 -0
- data/README.md +43 -0
- data/Rakefile +38 -0
- data/bin/watchbuffy +24 -0
- data/data/buffyverse-episodes.json +1561 -0
- data/lib/watchbuffy.rb +40 -0
- data/lib/watchbuffy/version.rb +4 -0
- data/spec/watchbuffy_spec.rb +14 -0
- data/watchbuffy.gemspec +21 -0
- metadata +61 -0
data/lib/watchbuffy.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative "watchbuffy/version"
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Watchbuffy
|
6
|
+
EPISODES = JSON.parse(File.read(__dir__ + "/../data/buffyverse-episodes.json"))["episodes"]
|
7
|
+
BUFFY_SEASONS = [1, 2, 3, 4, 5, 6, 7]
|
8
|
+
ANGEL_SEASONS = [1, 2, 3, 4, 5]
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def pick(show: %w[buffy angel], buffy_season: BUFFY_SEASONS, angel_season: ANGEL_SEASONS)
|
12
|
+
episode = EPISODES.select{ |e|
|
13
|
+
show.include?(e["show"]) &&
|
14
|
+
(
|
15
|
+
e["show"] == "buffy" && Array(buffy_season).include?(e["season"]) ||
|
16
|
+
e["show"] == "angel" && Array(angel_season).include?(e["season"])
|
17
|
+
)
|
18
|
+
}.sample
|
19
|
+
|
20
|
+
if episode
|
21
|
+
watch(episode)
|
22
|
+
else
|
23
|
+
puts "No episode found"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def watch(episode)
|
30
|
+
puts \
|
31
|
+
'▶️ Watch %s episode %s×%s: "%s"' % [
|
32
|
+
episode["show"].capitalize,
|
33
|
+
episode["season"],
|
34
|
+
episode["numberInSeason"],
|
35
|
+
episode["title"],
|
36
|
+
]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative "../lib/watchbuffy"
|
2
|
+
require "minitest/autorun"
|
3
|
+
|
4
|
+
describe Watchbuffy do
|
5
|
+
it "picks a random Buffy or Angel episode" do
|
6
|
+
stdout, error = capture_io do
|
7
|
+
Watchbuffy.pick
|
8
|
+
end
|
9
|
+
|
10
|
+
assert_match /\A▶️ Watch (?:Angel|Buffy) episode \d+×\d+: ".*"\z/, stdout.chomp
|
11
|
+
assert_equal "", error
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
data/watchbuffy.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + "/lib/watchbuffy/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "watchbuffy"
|
7
|
+
gem.version = Watchbuffy::VERSION
|
8
|
+
gem.summary = "Picks a random Buffy episode"
|
9
|
+
gem.description = "Suggests a random Buffy or Angel episode to watch"
|
10
|
+
gem.authors = ["Jan Lelis"]
|
11
|
+
gem.email = ["mail@janlelis.de"]
|
12
|
+
gem.homepage = "https://github.com/janlelis/watchbuffy"
|
13
|
+
gem.license = "MIT"
|
14
|
+
|
15
|
+
gem.files = Dir["{**/}{.*,*}"].select{ |path| File.file?(path) && path !~ /^pkg/ }
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.required_ruby_version = "~> 2.0"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: watchbuffy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Lelis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Suggests a random Buffy or Angel episode to watch
|
14
|
+
email:
|
15
|
+
- mail@janlelis.de
|
16
|
+
executables:
|
17
|
+
- watchbuffy
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- ".travis.yml"
|
23
|
+
- CHANGELOG.md
|
24
|
+
- CODE_OF_CONDUCT.md
|
25
|
+
- Gemfile
|
26
|
+
- Gemfile.lock
|
27
|
+
- MIT-LICENSE.txt
|
28
|
+
- README.md
|
29
|
+
- Rakefile
|
30
|
+
- bin/watchbuffy
|
31
|
+
- data/buffyverse-episodes.json
|
32
|
+
- lib/watchbuffy.rb
|
33
|
+
- lib/watchbuffy/version.rb
|
34
|
+
- spec/watchbuffy_spec.rb
|
35
|
+
- watchbuffy.gemspec
|
36
|
+
homepage: https://github.com/janlelis/watchbuffy
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.7.6
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Picks a random Buffy episode
|
60
|
+
test_files:
|
61
|
+
- spec/watchbuffy_spec.rb
|