twitchus 0.0.1
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.
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +25 -0
- data/Rakefile +18 -0
- data/bin/twitchus +4 -0
- data/config.example.yml +6 -0
- data/features/config.feature +21 -0
- data/features/support/env.rb +1 -0
- data/lib/twitchus/checker.rb +26 -0
- data/lib/twitchus/cli.rb +62 -0
- data/lib/twitchus/config.rb +30 -0
- data/lib/twitchus/storage.rb +22 -0
- data/lib/twitchus/version.rb +3 -0
- data/lib/twitchus/worker.rb +21 -0
- data/lib/twitchus.rb +10 -0
- data/spec/fixtures/vcr/justin_tv.yml +136 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/twitchus/checker_spec.rb +32 -0
- data/spec/twitchus/cli_spec.rb +60 -0
- data/spec/twitchus/config_spec.rb +21 -0
- data/spec/twitchus/storage_spec.rb +39 -0
- data/spec/twitchus_spec.rb +4 -0
- data/tmp/.gitkeep +0 -0
- data/twitchus.gemspec +30 -0
- metadata +231 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Jakub Arnold
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Twitchus [](http://travis-ci.org/#!/darthdeus/twitchus) [](https://codeclimate.com/github/darthdeus/twitchus)
|
2
|
+
|
3
|
+
Twitchus is a gem for managing a list of Twitch.tv streams.
|
4
|
+
You just give it a list of streams and it will check their status
|
5
|
+
and additional infromation and save all the data into Redis.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
$ gem install twitchus
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Twitchus is designed to be run via cron on a regular basis. For that
|
14
|
+
it needs a config file which lists all the stream names.
|
15
|
+
|
16
|
+
Then simply run `twitchus -c config.yml`
|
17
|
+
|
18
|
+
## Contributing
|
19
|
+
|
20
|
+
1. Fork it
|
21
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
22
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
23
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
24
|
+
5. Create new Pull Request
|
25
|
+
6. Be happy!
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "cucumber"
|
4
|
+
require "cucumber/rake/task"
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new
|
7
|
+
|
8
|
+
Cucumber::Rake::Task.new :features do |t|
|
9
|
+
t.cucumber_opts = "features --format pretty"
|
10
|
+
t.fork = false
|
11
|
+
end
|
12
|
+
|
13
|
+
task :test => :speed
|
14
|
+
|
15
|
+
task :default do
|
16
|
+
Rake::Task["spec"].invoke
|
17
|
+
end
|
18
|
+
|
data/bin/twitchus
ADDED
data/config.example.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Feature: Configuration file
|
2
|
+
As a user
|
3
|
+
I want to be able to specify a configuration file
|
4
|
+
In order to tell twitchus where to load and store the data.
|
5
|
+
|
6
|
+
Scenario: run the binary without any argumetns
|
7
|
+
When I run `twitchus`
|
8
|
+
Then the exit status should be 1
|
9
|
+
|
10
|
+
Scenario: pass non-existent config file
|
11
|
+
When I run `twitchus -c foo.yml`
|
12
|
+
Then the exit status should be 1
|
13
|
+
|
14
|
+
Scenario: pass an existing file
|
15
|
+
Given a file named "config.yml" with:
|
16
|
+
"""
|
17
|
+
foo
|
18
|
+
"""
|
19
|
+
When I run `twitchus -c config.yml`
|
20
|
+
Then the exit status should be 0
|
21
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require "aruba/cucumber"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "rest-client"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module Twitchus
|
5
|
+
class Checker
|
6
|
+
|
7
|
+
def check_all(channels)
|
8
|
+
channels.select { |channel| online?(channel) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def check(channel)
|
12
|
+
raise ArgumentError, "Channel is required." unless channel
|
13
|
+
response = JSON.parse(RestClient.get(base_url + channel))
|
14
|
+
|
15
|
+
return response.first
|
16
|
+
end
|
17
|
+
|
18
|
+
def online?(channel)
|
19
|
+
!check(channel).nil?
|
20
|
+
end
|
21
|
+
|
22
|
+
def base_url
|
23
|
+
"http://api.justin.tv/api/stream/list.json?channel="
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/twitchus/cli.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require "optparse"
|
2
|
+
|
3
|
+
module Twitchus
|
4
|
+
class Cli
|
5
|
+
|
6
|
+
attr_reader :options
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@options = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def parser
|
13
|
+
@parser ||= OptionParser.new do |opts|
|
14
|
+
|
15
|
+
opts.on("-c CONFIG", "Specify a config file.") do |config|
|
16
|
+
@options[:config] = config
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on( "-h", "--help", "Display this message.") do |h|
|
20
|
+
$stdout.puts opts.to_s
|
21
|
+
exit 0
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on( "-v", "--version", "Output the version of Twitchus.") do |v|
|
25
|
+
$stdout.puts "Twitchus version #{Twitchus::VERSION}"
|
26
|
+
exit 0
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse(argv, env)
|
33
|
+
parser.parse! argv
|
34
|
+
|
35
|
+
if @options[:config]
|
36
|
+
if File.exists? @options[:config]
|
37
|
+
worker = Twitchus::Worker.new(@options[:config])
|
38
|
+
worker.run
|
39
|
+
|
40
|
+
exit 0
|
41
|
+
else
|
42
|
+
raise OptionParser::ParseError, "The config file you specified doesn't exist"
|
43
|
+
end
|
44
|
+
else
|
45
|
+
raise OptionParser::ParseError, "You must specify a config file."
|
46
|
+
end
|
47
|
+
|
48
|
+
return true
|
49
|
+
rescue OptionParser::ParseError => e
|
50
|
+
$stderr.puts e
|
51
|
+
$stderr.puts
|
52
|
+
$stderr.puts parser.help
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
|
56
|
+
def run(argv = ARGV, env = ENV)
|
57
|
+
parse(argv, env)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module Twitchus
|
4
|
+
class Config
|
5
|
+
attr_reader :streams
|
6
|
+
|
7
|
+
def load(file)
|
8
|
+
@data = YAML.load_file(file)
|
9
|
+
@streams = @data["streams"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def host
|
13
|
+
@data["host"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def port
|
17
|
+
@data["port"]
|
18
|
+
end
|
19
|
+
|
20
|
+
def key
|
21
|
+
@data["key"]
|
22
|
+
end
|
23
|
+
|
24
|
+
# TODO - remove duplication
|
25
|
+
def channels
|
26
|
+
@streams
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "redis"
|
2
|
+
require "pry"
|
3
|
+
|
4
|
+
module Twitchus
|
5
|
+
class Storage
|
6
|
+
|
7
|
+
def initialize(host, port, key)
|
8
|
+
@client = Redis.new(host: host, port: port)
|
9
|
+
@key = key
|
10
|
+
end
|
11
|
+
|
12
|
+
# Add an item to the list specified in config
|
13
|
+
def push(item)
|
14
|
+
@client.lpush(@key, item) if item
|
15
|
+
end
|
16
|
+
|
17
|
+
def clear
|
18
|
+
@client.expire @key, -1
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Twitchus
|
2
|
+
class Worker
|
3
|
+
def initialize(config_file)
|
4
|
+
@config = Twitchus::Config.new
|
5
|
+
@config.load(config_file)
|
6
|
+
@checker = Twitchus::Checker.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
@storage = Twitchus::Storage.new(@config.host, @config.port, @config.key)
|
11
|
+
# Empty the online channel list first
|
12
|
+
@storage.clear
|
13
|
+
|
14
|
+
online_channels = @checker.check_all(@config.channels)
|
15
|
+
online_channels.each do |channel|
|
16
|
+
@storage.push channel
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/lib/twitchus.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://api.justin.tv/api/stream/list.json?channel=dreamhacktv
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*; q=0.5, application/xml'
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: !binary |-
|
20
|
+
T0s=
|
21
|
+
headers:
|
22
|
+
!binary "U2VydmVy":
|
23
|
+
- !binary |-
|
24
|
+
bmdpbng=
|
25
|
+
!binary "RGF0ZQ==":
|
26
|
+
- !binary |-
|
27
|
+
U3VuLCAyMyBTZXAgMjAxMiAxNTo1MDozMiBHTVQ=
|
28
|
+
!binary "Q29udGVudC1UeXBl":
|
29
|
+
- !binary |-
|
30
|
+
YXBwbGljYXRpb24vanNvbg==
|
31
|
+
!binary "VHJhbnNmZXItRW5jb2Rpbmc=":
|
32
|
+
- !binary |-
|
33
|
+
Y2h1bmtlZA==
|
34
|
+
!binary "Q29ubmVjdGlvbg==":
|
35
|
+
- !binary |-
|
36
|
+
Y2xvc2U=
|
37
|
+
!binary "U3RhdHVz":
|
38
|
+
- !binary |-
|
39
|
+
MjAwIE9L
|
40
|
+
!binary "Vmlh":
|
41
|
+
- !binary |-
|
42
|
+
VHdpY2UgMC4yIHdlYjExOjMzNDc=
|
43
|
+
!binary "WC1SdW50aW1l":
|
44
|
+
- !binary |-
|
45
|
+
MC4wMjQ4NjA=
|
46
|
+
!binary "WC1VYS1Db21wYXRpYmxl":
|
47
|
+
- !binary |-
|
48
|
+
SUU9RWRnZSxjaHJvbWU9MQ==
|
49
|
+
!binary "Q2FjaGUtQ29udHJvbA==":
|
50
|
+
- !binary |-
|
51
|
+
bWF4LWFnZT0wLCBwcml2YXRlLCBtdXN0LXJldmFsaWRhdGU=
|
52
|
+
!binary "WC1HZW8=":
|
53
|
+
- !binary |-
|
54
|
+
Q1o=
|
55
|
+
!binary "RnJvbnQtRW5kLUh0dHBz":
|
56
|
+
- !binary |-
|
57
|
+
b2Zm
|
58
|
+
!binary "Q29udGVudC1FbmNvZGluZw==":
|
59
|
+
- !binary |-
|
60
|
+
Z3ppcA==
|
61
|
+
body:
|
62
|
+
encoding: ASCII-8BIT
|
63
|
+
string: !binary |-
|
64
|
+
H4sIAAAAAAAAA7VWbW/bNhD+KwIH9JNtvdmWLTQdgr5sAYrlg7EO2zIIlHSS
|
65
|
+
mFKkQJGWvaH/fUcpipQsWFMENSDAlO6Od8899/LnPwTqFPIkk0ZoEpOtt16T
|
66
|
+
BRG0BjxxdoTEtKCSXAGtK5p91kf83Gp7vFfyg2gb4OuMaiilOqNmSWsmSnxX
|
67
|
+
SFVTa9nasjIVFQL4qLvZ+n60IJppbi98Z+3+jNc476/+uHauGxCx84lyEBmj
|
68
|
+
zoerXy4/Ou8uf7d2gWqjICexVgbQJaZhiiLydyhDU/Q9UdBIpa1kQXmLoncu
|
69
|
+
kHgMHgRN+cxUpgBEktEmMYonNeTM1OhcpXUTu26rqWbZMsvF6lYfRbcSoN1G
|
70
|
+
wZFB17pPQrb0N97J98PVbWMxGaO9LgqGcXFnCvvQI4syCBqGR2JhOJ+QTUbV
|
71
|
+
n0Z8W5NOsD8UnqdhzHJuUXbw91qmt5BpR58buLghtGk4Q0NMCve0bCuZfe7o
|
72
|
+
EZYFp211Q5wKWFlpFAz2Gzx2LNcVnsJNiCeW498+8OGahtMzcmbUzammKHAH
|
73
|
+
X9d1q1vTaiZW+uiioRL0HWxz7VXbFT/eZepixj68Li0zyaVCkz94/e+GvHnd
|
74
|
+
UEVrx/LWRsO57D4gcoc+lahzpNzYL5YseHSfUmgzxRpNswzadqZCeUfP9sVj
|
75
|
+
pVpiymeC3x7gE0Z70I5UPfDAaJlYUC96Br96ApZXyEqlk6PkBhEIbI7QXXdI
|
76
|
+
8psbgYzC8Oa0bmtE6WWsjrzTZuQ0q2mJvQLr5TmGsXCGvtKwzPK8dWcpXjZK
|
77
|
+
FoxD0ttcbmC/XYdB5EOR5Wm4X+K1kYelBLaWbDWa9ptah2Y1/C2FrYT3RskG
|
78
|
+
3INGvleS28KbFdRYbUNZTRFWprTK/9cPXhTg1vNO+IwhIhy5yUCNrW5yBIvI
|
79
|
+
Ntvv5gh2rc29Gww7aOCH3hZbwIJMTnCqvi8cIcKBzwjHOEGQa1PsD7vKo2n1
|
80
|
+
kPjPyN5Xuvk29E7raGQ+p6I0SFR0Bmyd9XNgmo17LwiitY8fJsieNVJeRKF+
|
81
|
+
4Ey5e1T7z0nZVzAIA+8UrG1S+olGS6zBoU64LJlAMOZJ+GJhyUEmwxwhcRR4
|
82
|
+
C/Jf5KxIyrTCRQLJtg3DVeB7+zCyhEP6kXC3Cfz1Pth5eGkNmia4aFjkD9j+
|
83
|
+
3ipaaOfqKnZ+w92jdWThfGQpKH1G4VRJmme01baOSIFKs3cJTg/cUUJcGUzO
|
84
|
+
JCYvhwzF6iZEMdNgIxhuMcI5QOMEoeNt4rUXr/dO4Pl29xnC6+ciiX10cEFK
|
85
|
+
kGjj1wN+HTlruTFSw99tvV24w+1n/IqtZ5hBOIXvt5VhKD5eUYYFzA5vvOJu
|
86
|
+
tRpcGH2//PSWfPnrX1m4nUXhCQAA
|
87
|
+
http_version:
|
88
|
+
recorded_at: Sun, 23 Sep 2012 15:50:32 GMT
|
89
|
+
- request:
|
90
|
+
method: get
|
91
|
+
uri: http://api.justin.tv/api/stream/list.json?channel=scvrush1
|
92
|
+
body:
|
93
|
+
encoding: US-ASCII
|
94
|
+
string: ''
|
95
|
+
headers:
|
96
|
+
Accept:
|
97
|
+
- ! '*/*; q=0.5, application/xml'
|
98
|
+
Accept-Encoding:
|
99
|
+
- gzip, deflate
|
100
|
+
User-Agent:
|
101
|
+
- Ruby
|
102
|
+
response:
|
103
|
+
status:
|
104
|
+
code: 200
|
105
|
+
message: OK
|
106
|
+
headers:
|
107
|
+
Server:
|
108
|
+
- nginx
|
109
|
+
Date:
|
110
|
+
- Sun, 23 Sep 2012 15:51:43 GMT
|
111
|
+
Content-Type:
|
112
|
+
- application/json
|
113
|
+
Content-Length:
|
114
|
+
- '2'
|
115
|
+
Connection:
|
116
|
+
- close
|
117
|
+
Status:
|
118
|
+
- 200 OK
|
119
|
+
Via:
|
120
|
+
- Twice 0.2 web9:3347
|
121
|
+
X-Runtime:
|
122
|
+
- '0.014319'
|
123
|
+
X-Ua-Compatible:
|
124
|
+
- IE=Edge,chrome=1
|
125
|
+
Cache-Control:
|
126
|
+
- max-age=0, private, must-revalidate
|
127
|
+
X-Geo:
|
128
|
+
- CZ
|
129
|
+
Front-End-Https:
|
130
|
+
- 'off'
|
131
|
+
body:
|
132
|
+
encoding: US-ASCII
|
133
|
+
string: ! '[]'
|
134
|
+
http_version:
|
135
|
+
recorded_at: Sun, 23 Sep 2012 15:51:44 GMT
|
136
|
+
recorded_with: VCR 2.2.5
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Twitchus
|
4
|
+
|
5
|
+
describe Checker do
|
6
|
+
|
7
|
+
let(:c) { Checker.new }
|
8
|
+
|
9
|
+
it "can tell if a channel is online" do
|
10
|
+
VCR.use_cassette "justin.tv", record: :new_episodes do
|
11
|
+
c.should be_online("dreamhacktv")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "can tell if a channel is offline" do
|
16
|
+
VCR.use_cassette "justin.tv", record: :new_episodes do
|
17
|
+
c.should_not be_online("scvrush1")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#check_all" do
|
22
|
+
|
23
|
+
it "selects only those channels which are online" do
|
24
|
+
VCR.use_cassette "justin.tv", record: :new_episodes do
|
25
|
+
c.check_all(%w{dreamhacktv scvrush1}).should == ["dreamhacktv"]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Twitchus
|
4
|
+
|
5
|
+
describe Cli do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@old_stderr = $stderr
|
9
|
+
$stderr = StringIO.new
|
10
|
+
|
11
|
+
@old_stdout = $stdout
|
12
|
+
$stdout = StringIO.new
|
13
|
+
# Twitchus.reset_global_options
|
14
|
+
end
|
15
|
+
|
16
|
+
after do
|
17
|
+
# Twitchus.reset_global_options
|
18
|
+
$stderr = @old_stderr
|
19
|
+
$stdout = @old_stdout
|
20
|
+
end
|
21
|
+
|
22
|
+
def cli_test(argv, env, exit_val, stderr_regex = nil, stdout_regex = nil)
|
23
|
+
begin
|
24
|
+
cli = Cli.new
|
25
|
+
cli.run(argv, env)
|
26
|
+
return cli
|
27
|
+
rescue SystemExit => e
|
28
|
+
e.status.should == exit_val
|
29
|
+
$stderr.string.should match stderr_regex if stderr_regex
|
30
|
+
$stdout.string.should match stdout_regex if stdout_regex
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "exits with 1 with invalid options" do
|
35
|
+
cli_test(%w{-w}, {}, 1, /invalid option/)
|
36
|
+
cli_test(%w{-g foo}, {}, 1, /invalid option/)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "exits with 1 if no config is given" do
|
40
|
+
cli_test([], {}, 1, /specify a config file/)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "exits with 1 if the config file doesn't exist" do
|
44
|
+
cli_test(%w{-c foo.yml}, {}, 1, /file you specified doesn't exist/)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "exits with 0 if an existing config file is given" do
|
48
|
+
file =<<YAML
|
49
|
+
streams:
|
50
|
+
- scvrush2
|
51
|
+
YAML
|
52
|
+
File.write("./tmp/config.yml", file)
|
53
|
+
Twitchus::Worker.stub(:new) { stub.as_null_object }
|
54
|
+
|
55
|
+
cli_test(%w{-c ./tmp/config.yml}, {}, 0)
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
|
4
|
+
module Twitchus
|
5
|
+
describe Config do
|
6
|
+
|
7
|
+
let(:config) { Config.new }
|
8
|
+
|
9
|
+
it "can load config with multiple streams" do
|
10
|
+
file =<<YAML
|
11
|
+
streams:
|
12
|
+
- scvrush1
|
13
|
+
- scvrush2
|
14
|
+
YAML
|
15
|
+
File.write("./tmp/config.yml", file)
|
16
|
+
config.load("./tmp/config.yml")
|
17
|
+
config.streams.should == %w{scvrush1 scvrush2}
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Twitchus
|
4
|
+
|
5
|
+
describe Storage do
|
6
|
+
|
7
|
+
it "will add things to the given key" do
|
8
|
+
client = mock(:redis)
|
9
|
+
client.should_receive(:lpush).with(:key, :item)
|
10
|
+
|
11
|
+
Redis.should_receive(:new) { client }
|
12
|
+
|
13
|
+
storage = Storage.new(1, 1, :key)
|
14
|
+
storage.push :item
|
15
|
+
end
|
16
|
+
|
17
|
+
it "won't add empty items to the list" do
|
18
|
+
client = mock(:redis)
|
19
|
+
client.should_not_receive(:lpush).with(:key, nil)
|
20
|
+
|
21
|
+
Redis.should_receive(:new) { client }
|
22
|
+
|
23
|
+
storage = Storage.new(1, 1, :key)
|
24
|
+
storage.push nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "can empty the storage" do
|
28
|
+
client = mock(:redis)
|
29
|
+
client.should_receive(:expire).with(:key, -1)
|
30
|
+
|
31
|
+
Redis.should_receive(:new) { client }
|
32
|
+
|
33
|
+
storage = Storage.new(1, 1, :key)
|
34
|
+
storage.clear
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
data/tmp/.gitkeep
ADDED
File without changes
|
data/twitchus.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'twitchus/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "twitchus"
|
8
|
+
gem.version = Twitchus::VERSION
|
9
|
+
gem.authors = ["Jakub Arnold"]
|
10
|
+
gem.email = ["darthdeus@gmail.com"]
|
11
|
+
gem.description = %q{Twitchus is a gem for managing a list of Twitch.tv streams}
|
12
|
+
gem.summary = %q{Twitchus is a gem for managing a list of Twitch.tv streams}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
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.add_dependency "rest-client", "~> 1.6.7"
|
21
|
+
gem.add_dependency "redis", "~> 3.0.1"
|
22
|
+
|
23
|
+
gem.add_development_dependency "webmock", "~> 1.8.10"
|
24
|
+
gem.add_development_dependency "vcr", "~> 2.2.5"
|
25
|
+
gem.add_development_dependency "pry", "~> 0.9.10"
|
26
|
+
gem.add_development_dependency "rake", "~> 0.9.2.2"
|
27
|
+
gem.add_development_dependency "rspec", "~> 2.11.0"
|
28
|
+
gem.add_development_dependency "cucumber", "~> 1.2.1"
|
29
|
+
gem.add_development_dependency "aruba", "~> 0.4.11"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,231 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twitchus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jakub Arnold
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.6.7
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.6.7
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: redis
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 3.0.1
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.0.1
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: webmock
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.8.10
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.10
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: vcr
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.2.5
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.2.5
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: pry
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.9.10
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.9.10
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rake
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 0.9.2.2
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.9.2.2
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rspec
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 2.11.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 2.11.0
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: cucumber
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 1.2.1
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 1.2.1
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: aruba
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ~>
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 0.4.11
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ~>
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 0.4.11
|
158
|
+
description: Twitchus is a gem for managing a list of Twitch.tv streams
|
159
|
+
email:
|
160
|
+
- darthdeus@gmail.com
|
161
|
+
executables:
|
162
|
+
- twitchus
|
163
|
+
extensions: []
|
164
|
+
extra_rdoc_files: []
|
165
|
+
files:
|
166
|
+
- .gitignore
|
167
|
+
- .rspec
|
168
|
+
- Gemfile
|
169
|
+
- LICENSE.txt
|
170
|
+
- README.md
|
171
|
+
- Rakefile
|
172
|
+
- bin/twitchus
|
173
|
+
- config.example.yml
|
174
|
+
- features/config.feature
|
175
|
+
- features/support/env.rb
|
176
|
+
- lib/twitchus.rb
|
177
|
+
- lib/twitchus/checker.rb
|
178
|
+
- lib/twitchus/cli.rb
|
179
|
+
- lib/twitchus/config.rb
|
180
|
+
- lib/twitchus/storage.rb
|
181
|
+
- lib/twitchus/version.rb
|
182
|
+
- lib/twitchus/worker.rb
|
183
|
+
- spec/fixtures/vcr/justin_tv.yml
|
184
|
+
- spec/spec_helper.rb
|
185
|
+
- spec/twitchus/checker_spec.rb
|
186
|
+
- spec/twitchus/cli_spec.rb
|
187
|
+
- spec/twitchus/config_spec.rb
|
188
|
+
- spec/twitchus/storage_spec.rb
|
189
|
+
- spec/twitchus_spec.rb
|
190
|
+
- tmp/.gitkeep
|
191
|
+
- twitchus.gemspec
|
192
|
+
homepage: ''
|
193
|
+
licenses: []
|
194
|
+
post_install_message:
|
195
|
+
rdoc_options: []
|
196
|
+
require_paths:
|
197
|
+
- lib
|
198
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
199
|
+
none: false
|
200
|
+
requirements:
|
201
|
+
- - ! '>='
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '0'
|
204
|
+
segments:
|
205
|
+
- 0
|
206
|
+
hash: 1599783581367613971
|
207
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
|
+
none: false
|
209
|
+
requirements:
|
210
|
+
- - ! '>='
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
213
|
+
segments:
|
214
|
+
- 0
|
215
|
+
hash: 1599783581367613971
|
216
|
+
requirements: []
|
217
|
+
rubyforge_project:
|
218
|
+
rubygems_version: 1.8.24
|
219
|
+
signing_key:
|
220
|
+
specification_version: 3
|
221
|
+
summary: Twitchus is a gem for managing a list of Twitch.tv streams
|
222
|
+
test_files:
|
223
|
+
- features/config.feature
|
224
|
+
- features/support/env.rb
|
225
|
+
- spec/fixtures/vcr/justin_tv.yml
|
226
|
+
- spec/spec_helper.rb
|
227
|
+
- spec/twitchus/checker_spec.rb
|
228
|
+
- spec/twitchus/cli_spec.rb
|
229
|
+
- spec/twitchus/config_spec.rb
|
230
|
+
- spec/twitchus/storage_spec.rb
|
231
|
+
- spec/twitchus_spec.rb
|