skype 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/History.txt +5 -1
- data/README.md +17 -0
- data/bin/skype-chat +2 -0
- data/lib/skype.rb +1 -0
- data/lib/skype/platforms/linux.rb +4 -2
- data/lib/skype/platforms/mac.rb +4 -2
- data/lib/skype/version.rb +1 -1
- data/lib/skype/wrappers/call.rb +30 -0
- data/samples/call.rb +16 -1
- data/test/test_call.rb +18 -0
- data/test/test_chat.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e68ed01cb9d2602a623e54a3b5e8aa2c76f87221
|
4
|
+
data.tar.gz: 1e09a51e82d16821366472e523e52d99769121c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d928b372617006a58bd30a512ea1a72925c4f0cf865a9ca71961370d2da93d3ce513cc97823fdefe64e648963f2f30d5f9fbfe236ba913eb16823298c38b5e5b
|
7
|
+
data.tar.gz: 5208227f716a88cfee3487968a510e72fed98db77d28867b5293bb9f528d783fa74f49f66944363f51f556838243b87c81d55c2e6bf569e909aaa60aeb1bb17b
|
data/Gemfile.lock
CHANGED
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -76,6 +76,23 @@ chat.messages.each do |m|
|
|
76
76
|
end
|
77
77
|
```
|
78
78
|
|
79
|
+
### Call API
|
80
|
+
|
81
|
+
call
|
82
|
+
```ruby
|
83
|
+
c = Skype.call "shokaishokai"
|
84
|
+
```
|
85
|
+
|
86
|
+
check status
|
87
|
+
```ruby
|
88
|
+
puts c.status # => :routing, :ringing, :inprogress, :finished, :missed, :cancelled
|
89
|
+
```
|
90
|
+
|
91
|
+
hangup
|
92
|
+
```ruby
|
93
|
+
c.hangup
|
94
|
+
```
|
95
|
+
|
79
96
|
Samples
|
80
97
|
-------
|
81
98
|
https://github.com/shokai/skype-ruby/tree/master/samples
|
data/bin/skype-chat
CHANGED
data/lib/skype.rb
CHANGED
@@ -17,7 +17,9 @@ module Skype
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.exec(command)
|
21
|
-
|
20
|
+
def self.exec(command, opts={:response_filter => true})
|
21
|
+
res = (@@connection||=Connection.new).invoke command
|
22
|
+
res = filter_response res if opts[:response_filter]
|
23
|
+
res
|
22
24
|
end
|
23
25
|
end
|
data/lib/skype/platforms/mac.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
module Skype
|
2
|
-
def self.exec(command)
|
2
|
+
def self.exec(command, opts={:response_filter => true})
|
3
3
|
script = %Q{tell application "Skype"
|
4
4
|
send command "#{Utils.escape command}" script name "#{self.config[:app_name]}"
|
5
5
|
end tell}
|
6
|
-
|
6
|
+
res = `unset LD_LIBRARY_PATH; unset DYLD_LIBRARY_PATH; /usr/bin/osascript -e '#{script}'`.strip
|
7
|
+
res = filter_response res if opts[:response_filter]
|
8
|
+
res
|
7
9
|
end
|
8
10
|
|
9
11
|
module Utils
|
data/lib/skype/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Skype
|
2
|
+
|
3
|
+
response_filter /^CALL \d+ STATUS [A-Z]+$/ do |res|
|
4
|
+
Skype::Call.new res.scan(/CALL (\d+)/)[0][0]
|
5
|
+
end
|
6
|
+
|
7
|
+
class Call
|
8
|
+
|
9
|
+
attr_reader :id, :time, :to
|
10
|
+
|
11
|
+
def initialize(id)
|
12
|
+
@id = id.to_i
|
13
|
+
@time = Time.at ::Skype.exec("GET CALL #{id} TIMESTAMP").split(/\s/).last.to_i
|
14
|
+
@to = ::Skype.exec("GET CALL #{id} PARTNER_HANDLE").scan(/PARTNER_HANDLE (.+)$/)[0][0] rescue @to = ""
|
15
|
+
end
|
16
|
+
|
17
|
+
def status
|
18
|
+
begin
|
19
|
+
return ::Skype.exec("GET CALL #{@id} STATUS", :response_filter => false).scan(/([A-Z]+)$/)[0][0].downcase.to_sym
|
20
|
+
rescue
|
21
|
+
return :api_error
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def hangup
|
26
|
+
::Skype.exec "ALTER CALL #{@id} HANGUP"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/samples/call.rb
CHANGED
@@ -6,4 +6,19 @@ require 'skype'
|
|
6
6
|
puts "please put the username to call"
|
7
7
|
print "> "
|
8
8
|
to = STDIN.gets.strip
|
9
|
-
|
9
|
+
call = Skype.call to
|
10
|
+
|
11
|
+
loop do
|
12
|
+
puts s = call.status
|
13
|
+
break if s == :inprogress
|
14
|
+
sleep 1
|
15
|
+
end
|
16
|
+
|
17
|
+
5.downto(0) do |i|
|
18
|
+
puts "#{i} - #{call.status}"
|
19
|
+
sleep 1
|
20
|
+
end
|
21
|
+
|
22
|
+
call.hangup
|
23
|
+
|
24
|
+
puts call.status
|
data/test/test_call.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path 'test_helper', File.dirname(__FILE__)
|
2
|
+
|
3
|
+
class TestSkypeCall < MiniTest::Test
|
4
|
+
|
5
|
+
SKYPE_FROM = ENV["SKYPE_FROM"]
|
6
|
+
SKYPE_TO = ENV["SKYPE_TO"] || "echo123"
|
7
|
+
|
8
|
+
def test_call
|
9
|
+
call = Skype.call SKYPE_TO
|
10
|
+
STDERR.puts call if call.kind_of? String
|
11
|
+
assert_equal call.class, Skype::Call
|
12
|
+
assert_equal call.to, SKYPE_TO
|
13
|
+
sleep 1
|
14
|
+
call.hangup
|
15
|
+
assert [:finished, :missed, :cancelled].include? call.status
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/test/test_chat.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skype
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Hashimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tmp_cache
|
@@ -88,10 +88,12 @@ files:
|
|
88
88
|
- lib/skype/platforms/linux.rb
|
89
89
|
- lib/skype/platforms/mac.rb
|
90
90
|
- lib/skype/version.rb
|
91
|
+
- lib/skype/wrappers/call.rb
|
91
92
|
- lib/skype/wrappers/chat.rb
|
92
93
|
- samples/call.rb
|
93
94
|
- samples/send_message.rb
|
94
95
|
- skype.gemspec
|
96
|
+
- test/test_call.rb
|
95
97
|
- test/test_chat.rb
|
96
98
|
- test/test_helper.rb
|
97
99
|
- test/test_skype.rb
|
@@ -120,6 +122,7 @@ signing_key:
|
|
120
122
|
specification_version: 4
|
121
123
|
summary: Skype Desktop API Ruby wrapper for Mac/Linux.
|
122
124
|
test_files:
|
125
|
+
- test/test_call.rb
|
123
126
|
- test/test_chat.rb
|
124
127
|
- test/test_helper.rb
|
125
128
|
- test/test_skype.rb
|