rype 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 +9 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/History.txt +9 -0
- data/LICENSE +22 -0
- data/Rakefile +78 -0
- data/examples/chats/echo_server.rb +16 -0
- data/examples/chats/list_chats.rb +14 -0
- data/examples/chats/send_chat.rb +10 -0
- data/examples/start_skype +9 -0
- data/features/receive_chatmessage.feature +9 -0
- data/features/send_chatmessage.feature +13 -0
- data/features/step_definitions/skype_steps.rb +39 -0
- data/features/support/env.rb +3 -0
- data/features/support/lib/fake_api.rb +22 -0
- data/lib/rype.rb +23 -0
- data/lib/rype/api.rb +121 -0
- data/lib/rype/chat.rb +28 -0
- data/lib/rype/chatmessage.rb +37 -0
- data/lib/rype/events.rb +29 -0
- data/readme.md +70 -0
- data/rype.gemspec +22 -0
- data/spec/lib/rype/chat_spec.rb +39 -0
- data/spec/lib/rype_spec.rb +43 -0
- data/spec/spec_helper.rb +5 -0
- metadata +92 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/History.txt
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
2010/08/12
|
2
|
+
- Added some very basic instructions.
|
3
|
+
|
4
|
+
2010/04/12
|
5
|
+
- Simple class structure for sending chat messages
|
6
|
+
|
7
|
+
2010/04/11
|
8
|
+
- Started development, with a simple file that uses various chat-related aspects of the raw dbus-transported API.
|
9
|
+
- Added dependency: dbus => http://github.com/mvidner/ruby-dbus/downloads
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2010 Niko Felger
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
20
|
+
|
21
|
+
This product uses the Skype API but is not endorsed, certified or otherwise
|
22
|
+
approved in any way by Skype.
|
data/Rakefile
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rake/gempackagetask"
|
3
|
+
require "rake/rdoctask"
|
4
|
+
|
5
|
+
require "spec"
|
6
|
+
require "spec/rake/spectask"
|
7
|
+
Spec::Rake::SpecTask.new do |t|
|
8
|
+
t.spec_opts = %w(--format specdoc --colour)
|
9
|
+
t.libs = ["spec"]
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'cucumber'
|
13
|
+
require 'cucumber/rake/task'
|
14
|
+
Cucumber::Rake::Task.new('features') do |t|
|
15
|
+
t.cucumber_opts = %w{--format pretty}
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => ["spec", "features"]
|
19
|
+
|
20
|
+
# This builds the actual gem. For details of what all these options
|
21
|
+
# mean, and other ones you can add, check the documentation here:
|
22
|
+
#
|
23
|
+
# http://rubygems.org/read/chapter/20
|
24
|
+
#
|
25
|
+
spec = Gem::Specification.new do |s|
|
26
|
+
|
27
|
+
# Change these as appropriate
|
28
|
+
s.name = "rype"
|
29
|
+
s.version = "0.1.0"
|
30
|
+
s.summary = "Skype Api wrapper"
|
31
|
+
s.author = "Niko Felger"
|
32
|
+
s.email = "niko.felger@gmail.com"
|
33
|
+
s.homepage = "http://github.com/nfelger/rype"
|
34
|
+
|
35
|
+
s.has_rdoc = false
|
36
|
+
# You should probably have a README of some kind. Change the filename
|
37
|
+
# as appropriate
|
38
|
+
# s.extra_rdoc_files = %w(README)
|
39
|
+
# s.rdoc_options = %w(--main README)
|
40
|
+
|
41
|
+
# Add any extra files to include in the gem (like your README)
|
42
|
+
s.files = %w(History.txt) + Dir.glob("{bin,spec,lib/**/*}")
|
43
|
+
s.executables = FileList["bin/**"].map { |f| File.basename(f) }
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
|
46
|
+
# If you want to depend on other gems, add them here, along with any
|
47
|
+
# relevant versions
|
48
|
+
# s.add_dependency("some_other_gem", "~> 0.1.0")
|
49
|
+
|
50
|
+
# If your tests use any gems, include them here
|
51
|
+
s.add_development_dependency("rspec")
|
52
|
+
s.add_development_dependency("cucumber")
|
53
|
+
end
|
54
|
+
|
55
|
+
# To publish your gem online, install the 'gemcutter' gem; Read more
|
56
|
+
# about that here: http://gemcutter.org/pages/gem_docs
|
57
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
58
|
+
pkg.gem_spec = spec
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Build the gemspec file #{spec.name}.gemspec"
|
62
|
+
task :gemspec do
|
63
|
+
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
|
64
|
+
File.open(file, "w") {|f| f << spec.to_ruby }
|
65
|
+
end
|
66
|
+
|
67
|
+
task :package => :gemspec
|
68
|
+
|
69
|
+
# Generate documentation
|
70
|
+
Rake::RDocTask.new do |rd|
|
71
|
+
rd.rdoc_files.include("lib/**/*.rb")
|
72
|
+
rd.rdoc_dir = "rdoc"
|
73
|
+
end
|
74
|
+
|
75
|
+
desc 'Clear out RDoc and generated packages'
|
76
|
+
task :clean => [:clobber_rdoc, :clobber_package] do
|
77
|
+
rm "#{spec.name}.gemspec"
|
78
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
4
|
+
|
5
|
+
require 'rype'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
Rype.on(:chatmessage_received) do |chatmessage|
|
9
|
+
chatmessage.chat do |chat|
|
10
|
+
chatmessage.body do |body|
|
11
|
+
chat.send_message(body)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Rype.attach.join
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: Receiving chat messages
|
2
|
+
Background:
|
3
|
+
Given I am using the Skype Api testing fake
|
4
|
+
|
5
|
+
Scenario: Receiving a message
|
6
|
+
Given a client has registered a callback for notifications about "CHATMESSAGE"
|
7
|
+
When Skype issues a notification "CHATMESSAGE 123 STATUS RECEIVED"
|
8
|
+
Then the callback should be called
|
9
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: Send a chat message
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given I am using the Skype Api testing fake
|
5
|
+
|
6
|
+
Scenario: Send message
|
7
|
+
Given there is a chat with id "#test/$echo123;2010fc482c5ce233"
|
8
|
+
When I send a chatmessage "Howdy pal!" to "#test/$echo123;2010fc482c5ce233"
|
9
|
+
Then the Skype Api should receive the message
|
10
|
+
"""
|
11
|
+
CHATMESSAGE #test/$echo123;2010fc482c5ce233 Howdy pal!
|
12
|
+
"""
|
13
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Given /^I am using the Skype Api testing fake$/ do
|
2
|
+
# Silence constant re-assignment warning.
|
3
|
+
original_verbosity = $VERBOSE
|
4
|
+
$VERBOSE = nil
|
5
|
+
Rype::Api = Rype::FakeApi
|
6
|
+
$VERBOSE = original_verbosity
|
7
|
+
end
|
8
|
+
|
9
|
+
Given /^there is a chat with id "([^\"]*)"$/ do |chat_id|
|
10
|
+
# Let's assume it exists.
|
11
|
+
end
|
12
|
+
|
13
|
+
Given /^a client has registered a callback for notifications about "([^\"]*)"$/ do |scope|
|
14
|
+
@callback = lambda do
|
15
|
+
if @called
|
16
|
+
@called
|
17
|
+
else
|
18
|
+
@called = true
|
19
|
+
false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
Rype::Api.on_notification(scope, @callback)
|
23
|
+
end
|
24
|
+
|
25
|
+
When /^I send a chatmessage "([^\"]*)" to "([^\"]*)"$/ do |message_body, chat_id|
|
26
|
+
Rype::Chat.new(chat_id).send_message(message_body)
|
27
|
+
end
|
28
|
+
|
29
|
+
When /^Skype issues a notification "([^\"]*)"$/ do |notification|
|
30
|
+
Rype::Api.notify(notification)
|
31
|
+
end
|
32
|
+
|
33
|
+
Then /^the Skype Api should receive the message$/ do |string|
|
34
|
+
Rype::Api.recorded_messages.should include(string)
|
35
|
+
end
|
36
|
+
|
37
|
+
Then /^the callback should be called$/ do
|
38
|
+
@callback.call.should be_true
|
39
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module Rype
|
4
|
+
class FakeApi < Api
|
5
|
+
class << self
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
def_delegator :instance, :recorded_messages
|
9
|
+
end
|
10
|
+
|
11
|
+
def attach
|
12
|
+
end
|
13
|
+
|
14
|
+
def invoke(message)
|
15
|
+
recorded_messages << message
|
16
|
+
end
|
17
|
+
|
18
|
+
def recorded_messages
|
19
|
+
@recorded_messages ||= []
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/rype.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
require 'rype/api'
|
4
|
+
require 'rype/chat'
|
5
|
+
require 'rype/chatmessage'
|
6
|
+
require 'rype/events'
|
7
|
+
|
8
|
+
module Rype
|
9
|
+
Offline = Class.new StandardError
|
10
|
+
Denied = Class.new StandardError
|
11
|
+
|
12
|
+
class << self
|
13
|
+
extend Forwardable
|
14
|
+
|
15
|
+
def_delegators Rype::Api, :instance, :attach, :thread
|
16
|
+
def_delegator Rype::Chat, :new, :chat
|
17
|
+
def_delegator Rype::Chat, :all, :chats
|
18
|
+
def_delegator Rype::Events, :on
|
19
|
+
|
20
|
+
Rype::Events.initialize_listeners
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
data/lib/rype/api.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'dbus'
|
2
|
+
require 'forwardable'
|
3
|
+
|
4
|
+
module Rype
|
5
|
+
class Notify < DBus::Object
|
6
|
+
dbus_interface "com.Skype.API.Client" do
|
7
|
+
dbus_method :Notify, "in data:s" do |message|
|
8
|
+
Api.notify(message)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Api
|
14
|
+
class << self
|
15
|
+
extend Forwardable
|
16
|
+
def_delegators :instance, :attach, :invoke, :on_notification, :notify, :thread
|
17
|
+
|
18
|
+
def instance
|
19
|
+
@instance ||= new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :thread
|
24
|
+
|
25
|
+
def attach(application_name="rype")
|
26
|
+
raise "Already attached." if attached?
|
27
|
+
|
28
|
+
# Say hi to Skype.
|
29
|
+
status, = api.Invoke "NAME #{application_name}"
|
30
|
+
|
31
|
+
if status == 'CONNSTATUS OFFLINE'
|
32
|
+
raise Rype::Offline
|
33
|
+
elsif status != 'OK'
|
34
|
+
raise Rype::Denied
|
35
|
+
end
|
36
|
+
|
37
|
+
api.Invoke "PROTOCOL 7"
|
38
|
+
|
39
|
+
run_notification_thread
|
40
|
+
end
|
41
|
+
|
42
|
+
def invoke(message, &block)
|
43
|
+
raise "Not attached to Skype. Call Rype::Api.attach first." unless attached?
|
44
|
+
|
45
|
+
log_outgoing message
|
46
|
+
if block_given?
|
47
|
+
api.Invoke(message) do |headers, answer|
|
48
|
+
log_incoming answer
|
49
|
+
block.call(answer)
|
50
|
+
end
|
51
|
+
else
|
52
|
+
answer = api.Invoke(message) do |_, _|
|
53
|
+
# Huh? Without passing in a block, sometimes it hangs...??
|
54
|
+
end
|
55
|
+
log_incoming answer
|
56
|
+
answer
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def on_notification(scope, proc=nil, &block)
|
61
|
+
raise "Need to register callbacks before attaching to Skype." if attached?
|
62
|
+
|
63
|
+
callbacks[scope] ||= []
|
64
|
+
callbacks[scope] << (proc ? proc : block)
|
65
|
+
end
|
66
|
+
|
67
|
+
def notify(message)
|
68
|
+
log_incoming message
|
69
|
+
|
70
|
+
callbacks.keys.each do |key|
|
71
|
+
next unless match = Regexp.new("^#{key}").match(message)
|
72
|
+
callbacks[key].each{ |callback| callback.call(*match.captures) }
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def initialize
|
79
|
+
# 'pu'a says no.
|
80
|
+
end
|
81
|
+
|
82
|
+
def attached?
|
83
|
+
thread and thread.alive?
|
84
|
+
end
|
85
|
+
|
86
|
+
def api
|
87
|
+
@api ||= begin
|
88
|
+
skype_service = bus.service("com.Skype.API")
|
89
|
+
skype_object = skype_service.object('/com/Skype')
|
90
|
+
skype_object.introspect
|
91
|
+
skype_object["com.Skype.API"]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def run_notification_thread
|
96
|
+
@thread ||= Thread.new do
|
97
|
+
receiving_service = bus.request_service("com.nikofelger.ruby-skype")
|
98
|
+
receiving_service.export(Notify.new("/com/Skype/Client"))
|
99
|
+
dbus_event_loop = DBus::Main.new
|
100
|
+
dbus_event_loop << bus
|
101
|
+
dbus_event_loop.run
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def bus
|
106
|
+
DBus::SessionBus.instance
|
107
|
+
end
|
108
|
+
|
109
|
+
def callbacks
|
110
|
+
@callback ||= {}
|
111
|
+
end
|
112
|
+
|
113
|
+
def log_incoming(message)
|
114
|
+
STDERR.puts "<- #{message}"
|
115
|
+
end
|
116
|
+
|
117
|
+
def log_outgoing(message)
|
118
|
+
STDERR.puts "-> #{message}"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/lib/rype/chat.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rype/events'
|
2
|
+
|
3
|
+
module Rype
|
4
|
+
class Chat
|
5
|
+
class << self
|
6
|
+
attr_accessor :chats
|
7
|
+
|
8
|
+
def all
|
9
|
+
chats if chats
|
10
|
+
|
11
|
+
Api.invoke("SEARCH CHATS")
|
12
|
+
sleep 0.01 while chats.nil?
|
13
|
+
|
14
|
+
yield chats
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :chatname
|
19
|
+
|
20
|
+
def initialize(chatname)
|
21
|
+
@chatname = chatname
|
22
|
+
end
|
23
|
+
|
24
|
+
def send_message(message)
|
25
|
+
Api.invoke("CHATMESSAGE #{@chatname} #{message}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Rype
|
2
|
+
class Chatmessage
|
3
|
+
def initialize(id)
|
4
|
+
@chatmessage_id = id
|
5
|
+
end
|
6
|
+
|
7
|
+
def chat(&block)
|
8
|
+
return unless block_given?
|
9
|
+
get_property("CHATNAME") do |chatname|
|
10
|
+
block.call(Chat.new(chatname))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def body(&block)
|
15
|
+
return unless block_given?
|
16
|
+
get_property("BODY", &block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def from(&block)
|
20
|
+
return unless block_given?
|
21
|
+
get_property("FROM_HANDLE", &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def from_name(&block)
|
25
|
+
return unless block_given?
|
26
|
+
get_property("FROM_DISPNAME", &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def get_property(property, &block)
|
31
|
+
return unless block_given?
|
32
|
+
Api.invoke("GET CHATMESSAGE #{@chatmessage_id} #{property}") do |message|
|
33
|
+
yield message.split[3..-1].join(' ')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/rype/events.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
3
|
+
module Rype
|
4
|
+
class Events
|
5
|
+
class << self
|
6
|
+
def on(event)
|
7
|
+
case event
|
8
|
+
|
9
|
+
when :chatmessage_received
|
10
|
+
Rype::Api.instance.on_notification("CHATMESSAGE (.*) STATUS RECEIVED") do |chatmessage_id|
|
11
|
+
yield Chatmessage.new(chatmessage_id)
|
12
|
+
end
|
13
|
+
|
14
|
+
when :chats_received
|
15
|
+
Rype::Api.instance.on_notification("CHATS (.*)") do |chatlist|
|
16
|
+
yield chatlist.split(', ').map { |chatname| Chat.new(chatname) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize_listeners
|
22
|
+
mutex = Mutex.new
|
23
|
+
Rype::Events.on(:chats_received) do |chats|
|
24
|
+
mutex.synchronize { Rype::Chat.chats = chats }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/readme.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# rype – Ruby library to talk to the Skype API
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
This library is a simple wrapper for Skype's dbus-based Linux API.
|
6
|
+
|
7
|
+
Currently, it has the following capabilities:
|
8
|
+
|
9
|
+
* Get a list of your chats,
|
10
|
+
* send chat messages,
|
11
|
+
* receive chat messages,
|
12
|
+
* use the raw Skype protocol via Rype::Api#invoke and Rype::Api#on_notification. More information about the protocol at [developer.skype.com](http://developer.skype.com)
|
13
|
+
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
In order to work with the rype gem, there are a few requirements:
|
18
|
+
|
19
|
+
- You need to be on Linux
|
20
|
+
- You need to have Skype running
|
21
|
+
- You need dbus installed (e.g., via apt on Ubuntu)
|
22
|
+
- You need the ruby-dbus gem:
|
23
|
+
- wget http://github.com/downloads/mvidner/ruby-dbus/ruby-dbus-0.3.1.tgz
|
24
|
+
- tar xzf ruby-dbus-0.3.1.tgz
|
25
|
+
- cd ruby-dbus-0.3.1
|
26
|
+
- follow the instructions in README
|
27
|
+
- You may want Xvfb (if you want to run Skype head-less)
|
28
|
+
|
29
|
+
|
30
|
+
## Verify your installation
|
31
|
+
|
32
|
+
To confirm it's working, start skype and sign in. Then, open an irb session and:
|
33
|
+
|
34
|
+
require 'dbus'
|
35
|
+
bus = DBus::SessionBus.instance
|
36
|
+
skype_service = bus.service("com.Skype.API")
|
37
|
+
client_to_skype = skype_service.object('/com/Skype')
|
38
|
+
client_to_skype.introspect
|
39
|
+
api = client_to_skype["com.Skype.API"]
|
40
|
+
api.Invoke("NAME rype")
|
41
|
+
|
42
|
+
If everything is set up correctly, Skype will now ask whether "rype" should be allowed to connect.
|
43
|
+
|
44
|
+
|
45
|
+
## Usage
|
46
|
+
|
47
|
+
There are a few examples in `examples/` that should give you an idea of how
|
48
|
+
to use the gem.
|
49
|
+
|
50
|
+
|
51
|
+
## Head-less Skype
|
52
|
+
|
53
|
+
Say you want to be running an app that connects to Skype on a box that won't have a display attached. For this use case, Xvfb is quite handy:
|
54
|
+
|
55
|
+
> "Xvfb or X virtual framebuffer is an X11 server that performs all graphical operations in memory, not showing any screen output." (wikipedia)"
|
56
|
+
|
57
|
+
In `examples/start_skype`, there's a shell script that shows how to start Skype and Xvfb.
|
58
|
+
|
59
|
+
You can safely ignore warnings about missing fonts, but if they bother you, try:
|
60
|
+
|
61
|
+
sudo aptitude install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic
|
62
|
+
|
63
|
+
If Xvfb won't start at all, more drastic measures may be required:
|
64
|
+
|
65
|
+
sudo apt-get install xserver-xorg-core
|
66
|
+
|
67
|
+
## small print
|
68
|
+
|
69
|
+
This product uses the Skype API but is not endorsed, certified or otherwise
|
70
|
+
approved in any way by Skype.
|
data/rype.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.version = "0.0.1"
|
6
|
+
s.name = "rype"
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Niko Felger"]
|
9
|
+
s.email = ["niko.felger@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/nfelger/rype"
|
11
|
+
s.summary = %q{Unofficial Skype Api wrapper}
|
12
|
+
s.description = %q{Unofficial Skype Api wrapper}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.has_rdoc = false
|
19
|
+
s.rubygems_version = %q{1.3.7}
|
20
|
+
s.add_dependency("ruby-dbus", [">= 0.6"])
|
21
|
+
s.add_development_dependency("rspec")
|
22
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rype/chat'
|
2
|
+
|
3
|
+
# describe Rype::Chat, '.all' do
|
4
|
+
# subject { Rype::Chat }
|
5
|
+
#
|
6
|
+
# it "should get the list of chats from the api" do
|
7
|
+
# Rype.instance.should_receive(:invoke).with("SEARCH CHATS") do
|
8
|
+
# Rype.instance.notify("CHATS")
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# subject.all
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# context "when the response contains chats" do
|
15
|
+
# before(:each) do
|
16
|
+
# Rype.instance.stub!(:invoke).with("SEARCH CHATS") do
|
17
|
+
# Rype.instance.notify("CHATS #bitman/$jessy;eb06e65612353279, #bitman/$jdenton;9244e98f82d7d391")
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# it "should return a new Chat object for each chat id in the response" do
|
22
|
+
# subject.all do |chats|
|
23
|
+
# chats.all?{|chat| chat.should be_a(Rype::Chat)}
|
24
|
+
# chats.map{|chat| chat.chatname}.should == ["#bitman/$jessy;eb06e65612353279", "#bitman/$jdenton;9244e98f82d7d391"]
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
|
30
|
+
describe Rype::Chat, '#send_message' do
|
31
|
+
subject { Rype::Chat.new('#test/$echo123;2010fc482c5ce233') }
|
32
|
+
|
33
|
+
it "should tell the api to send the message" do
|
34
|
+
Rype.instance.should_receive(:invoke).
|
35
|
+
with("CHATMESSAGE #test/$echo123;2010fc482c5ce233 ohai Zkaip")
|
36
|
+
|
37
|
+
subject.send_message("ohai Zkaip")
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rype'
|
3
|
+
|
4
|
+
describe Rype do
|
5
|
+
describe '.instance' do
|
6
|
+
subject { Rype.instance }
|
7
|
+
it { should be_a(Rype::Api) }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.attach' do
|
11
|
+
it "should delegate to Rype::Api" do
|
12
|
+
Rype::Api.should_receive(:attach).with("chat id")
|
13
|
+
Rype.attach("chat id")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '.chat' do
|
18
|
+
subject { Rype.chat('chat id') }
|
19
|
+
it { should be_a(Rype::Chat) }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.chats' do
|
23
|
+
it "should delegate to Rype::Chat" do
|
24
|
+
Rype::Chat.should_receive(:all)
|
25
|
+
Rype.chats
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.on' do
|
30
|
+
it "should delegate to Rype::Events" do
|
31
|
+
Rype::Events.should_receive(:on)
|
32
|
+
Rype.on
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '.thread' do
|
37
|
+
it 'should delegate to Rype::Api' do
|
38
|
+
Rype::Api.should_receive(:thread)
|
39
|
+
Rype.thread
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rype
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Niko Felger
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-22 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ruby-dbus
|
16
|
+
requirement: &7610360 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.6'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *7610360
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &7609960 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *7609960
|
36
|
+
description: Unofficial Skype Api wrapper
|
37
|
+
email:
|
38
|
+
- niko.felger@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- .travis.yml
|
45
|
+
- Gemfile
|
46
|
+
- History.txt
|
47
|
+
- LICENSE
|
48
|
+
- Rakefile
|
49
|
+
- examples/chats/echo_server.rb
|
50
|
+
- examples/chats/list_chats.rb
|
51
|
+
- examples/chats/send_chat.rb
|
52
|
+
- examples/start_skype
|
53
|
+
- features/receive_chatmessage.feature
|
54
|
+
- features/send_chatmessage.feature
|
55
|
+
- features/step_definitions/skype_steps.rb
|
56
|
+
- features/support/env.rb
|
57
|
+
- features/support/lib/fake_api.rb
|
58
|
+
- lib/rype.rb
|
59
|
+
- lib/rype/api.rb
|
60
|
+
- lib/rype/chat.rb
|
61
|
+
- lib/rype/chatmessage.rb
|
62
|
+
- lib/rype/events.rb
|
63
|
+
- readme.md
|
64
|
+
- rype.gemspec
|
65
|
+
- spec/lib/rype/chat_spec.rb
|
66
|
+
- spec/lib/rype_spec.rb
|
67
|
+
- spec/spec_helper.rb
|
68
|
+
homepage: https://github.com/nfelger/rype
|
69
|
+
licenses: []
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.8.10
|
89
|
+
signing_key:
|
90
|
+
specification_version: 3
|
91
|
+
summary: Unofficial Skype Api wrapper
|
92
|
+
test_files: []
|