robut 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +11 -0
- data/Gemfile +2 -3
- data/README.rdoc +38 -19
- data/examples/Chatfile +10 -4
- data/lib/robut.rb +3 -0
- data/lib/robut/connection.rb +10 -72
- data/lib/robut/plugin.rb +94 -13
- data/lib/robut/plugin/echo.rb +3 -13
- data/lib/robut/plugin/google_images.rb +17 -0
- data/lib/robut/plugin/help.rb +7 -15
- data/lib/robut/plugin/meme.rb +22 -53
- data/lib/robut/plugin/pick.rb +18 -0
- data/lib/robut/plugin/ping.rb +3 -9
- data/lib/robut/plugin/quips.rb +60 -0
- data/lib/robut/plugin/say.rb +6 -12
- data/lib/robut/plugin/stock.rb +45 -0
- data/lib/robut/pm.rb +40 -0
- data/lib/robut/presence.rb +35 -0
- data/lib/robut/room.rb +30 -0
- data/lib/robut/version.rb +1 -1
- data/test/mocks/connection_mock.rb +2 -18
- data/test/mocks/presence_mock.rb +25 -0
- data/test/test_helper.rb +3 -1
- data/test/unit/connection_test.rb +58 -25
- data/test/unit/plugin/alias_test.rb +5 -4
- data/test/unit/plugin/echo_test.rb +5 -4
- data/test/unit/plugin/help_test.rb +4 -3
- data/test/unit/plugin/later_test.rb +7 -6
- data/test/unit/plugin/lunch_test.rb +6 -5
- data/test/unit/plugin/pick_test.rb +35 -0
- data/test/unit/plugin/ping_test.rb +4 -3
- data/test/unit/plugin/quips_test.rb +58 -0
- data/test/unit/plugin/say_test.rb +4 -3
- data/test/unit/plugin/weather_test.rb +15 -14
- data/test/unit/plugin_test.rb +62 -1
- data/test/unit/room_test.rb +51 -0
- metadata +28 -20
- data/lib/robut/plugin/rdio.rb +0 -96
- data/lib/robut/plugin/rdio/public/css/rdio.css +0 -141
- data/lib/robut/plugin/rdio/public/css/style.css +0 -79
- data/lib/robut/plugin/rdio/public/css/style_after.css +0 -42
- data/lib/robut/plugin/rdio/public/images/background.png +0 -0
- data/lib/robut/plugin/rdio/public/images/no-album.png +0 -0
- data/lib/robut/plugin/rdio/public/index.html +0 -43
- data/lib/robut/plugin/rdio/public/js/libs/dd_belatedpng.js +0 -13
- data/lib/robut/plugin/rdio/public/js/libs/jquery-1.5.1.min.js +0 -16
- data/lib/robut/plugin/rdio/public/js/libs/modernizr-1.7.min.js +0 -2
- data/lib/robut/plugin/rdio/public/js/rdio.js +0 -129
- data/lib/robut/plugin/rdio/public/js/script.js +0 -3
- data/lib/robut/plugin/rdio/server.rb +0 -57
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'sinatra'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
class Robut::Plugin::Rdio
|
5
|
-
include Robut::Plugin
|
6
|
-
|
7
|
-
# A simple server to communicate new Rdio sources to the Web
|
8
|
-
# Playback API. The client will update
|
9
|
-
# Robut::Plugin::Rdio::Server.queue with any new sources, and a call
|
10
|
-
# to /queue.json will pull those new sources as a json object.
|
11
|
-
class Server < Sinatra::Base
|
12
|
-
|
13
|
-
set :root, File.dirname(__FILE__)
|
14
|
-
|
15
|
-
class << self
|
16
|
-
# A list of items that haven't been fetched by the web playback
|
17
|
-
# API yet.
|
18
|
-
attr_accessor :queue
|
19
|
-
|
20
|
-
# The playback token for +domain+. If you're accessing Rdio over
|
21
|
-
# localhost, you shouldn't need to change this. Otherwise,
|
22
|
-
# download the rdio-python plugin:
|
23
|
-
#
|
24
|
-
# https://github.com/rdio/rdio-python
|
25
|
-
#
|
26
|
-
# and generate a new token for your domain:
|
27
|
-
#
|
28
|
-
# ./rdio-call --consumer-key=YOUR_CONSUMER_KEY --consumer-secret=YOUR_CONSUMER_SECRET getPlaybackToken domain=YOUR_DOMAIN
|
29
|
-
attr_accessor :token
|
30
|
-
|
31
|
-
# The domain associated with +token+. Defaults to localhost.
|
32
|
-
attr_accessor :domain
|
33
|
-
end
|
34
|
-
self.queue = []
|
35
|
-
|
36
|
-
# Renders a simple Rdio web player.
|
37
|
-
get '/' do
|
38
|
-
File.read(File.expand_path('public/index.html', File.dirname(__FILE__)))
|
39
|
-
end
|
40
|
-
|
41
|
-
get '/js/vars.js' do
|
42
|
-
content_type 'text/javascript'
|
43
|
-
<<END
|
44
|
-
var rdio_token = '#{self.class.token}';
|
45
|
-
var rdio_domain = '#{self.class.domain}';
|
46
|
-
END
|
47
|
-
end
|
48
|
-
|
49
|
-
# Returns the sources that haven't been fetched yet.
|
50
|
-
get '/queue.json' do
|
51
|
-
queue = self.class.queue.dup
|
52
|
-
self.class.queue = []
|
53
|
-
queue.to_json
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|