skype 0.1.2 → 0.1.3
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 -0
- data/README.md +1 -1
- data/lib/skype.rb +1 -0
- data/lib/skype/platforms/linux.rb +7 -1
- data/lib/skype/platforms/mac.rb +7 -3
- data/lib/skype/register.rb +9 -0
- data/lib/skype/version.rb +1 -1
- data/lib/skype/wrappers/chat.rb +8 -4
- data/samples/chat.rb +1 -1
- data/skype.gemspec +1 -1
- data/test/test_chat.rb +38 -0
- data/test/test_skype.rb +3 -36
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f55fb6515dd62ebcf14675c0baea34a9a7a7d10e
|
4
|
+
data.tar.gz: ced58a4a2c91ec00dce90a431d24810312973c2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeeb14ae23fb7791b40502dc73e2a41c3e18c660625410f747ef72f28547551a02bbd60993e12d1f2729febfe1c6d2493656554eb404b12dfdfda7dc449b1027
|
7
|
+
data.tar.gz: b541ab42b556bfb088dc2c1cefdf32154295e37e4ef9b650a67ef790dc7d2308d5efd66e5f2399d78c7d415e888c50ab71c59357cb3cda2ff7f4d50a15fa0a12
|
data/Gemfile.lock
CHANGED
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Skype
|
2
2
|
=====
|
3
|
-
[Skype Desktop API](http://dev.skype.com/desktop-api-reference) wrapper for
|
3
|
+
[Skype Desktop API](http://dev.skype.com/desktop-api-reference) Ruby wrapper for Mac/Linux.
|
4
4
|
|
5
5
|
- https://github.com/shokai/skype-ruby
|
6
6
|
- http://rubygems.org/gems/skype
|
data/lib/skype.rb
CHANGED
@@ -18,6 +18,12 @@ module Skype
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.exec(command)
|
21
|
-
(@@connection||=Connection.new).invoke command
|
21
|
+
res = (@@connection||=Connection.new).invoke command
|
22
|
+
@@filters.each do |filter, block|
|
23
|
+
next unless res =~ filter
|
24
|
+
res = block.call(res)
|
25
|
+
break
|
26
|
+
end
|
27
|
+
res
|
22
28
|
end
|
23
29
|
end
|
data/lib/skype/platforms/mac.rb
CHANGED
@@ -3,9 +3,13 @@ module Skype
|
|
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
|
-
res = `unset LD_LIBRARY_PATH; unset DYLD_LIBRARY_PATH; /usr/bin/osascript -e '#{script}'`.
|
7
|
-
|
8
|
-
|
6
|
+
res = `unset LD_LIBRARY_PATH; unset DYLD_LIBRARY_PATH; /usr/bin/osascript -e '#{script}'`.strip
|
7
|
+
@@filters.each do |filter, block|
|
8
|
+
next unless res =~ filter
|
9
|
+
res = block.call(res)
|
10
|
+
break
|
11
|
+
end
|
12
|
+
res
|
9
13
|
end
|
10
14
|
|
11
15
|
module Utils
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Skype
|
2
|
+
@@filters = {}
|
3
|
+
|
4
|
+
def self.response_filter(pattern, &block)
|
5
|
+
raise ArgumentError, "pattern must be instance of Regexp" unless pattern.kind_of? Regexp
|
6
|
+
raise ArgumentError, "block not given" unless block_given?
|
7
|
+
@@filters[pattern] = block
|
8
|
+
end
|
9
|
+
end
|
data/lib/skype/version.rb
CHANGED
data/lib/skype/wrappers/chat.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module Skype
|
2
2
|
|
3
|
+
response_filter /^(CHAT)?MESSAGE (\d+) STATUS (SENT|SENDING)$/ do |res|
|
4
|
+
Skype::Chat::Message.new res.scan(/^(CHAT)?MESSAGE (\d+) STATUS (SENT|SENDING)$/)[0][1].to_i
|
5
|
+
end
|
6
|
+
|
3
7
|
def self.chats
|
4
8
|
search("recentchats").
|
5
9
|
scan(/(#[^\s,]+)[\s,]/).
|
@@ -12,9 +16,9 @@ module Skype
|
|
12
16
|
attr_reader :id, :topic, :members
|
13
17
|
|
14
18
|
def initialize(id)
|
15
|
-
@id = id
|
16
|
-
@topic = ::Skype
|
17
|
-
@members = ::Skype
|
19
|
+
@id = id.to_i
|
20
|
+
@topic = ::Skype.exec("GET CHAT #{@id} TOPIC").scan(/TOPIC (.*)$/)[0][0].toutf8 rescue @topic = ""
|
21
|
+
@members = ::Skype.exec("GET CHAT #{@id} MEMBERS").scan(/MEMBERS (.+)$/)[0][0].split(/\s/) rescue @members = []
|
18
22
|
end
|
19
23
|
|
20
24
|
def messages
|
@@ -35,7 +39,7 @@ module Skype
|
|
35
39
|
attr_reader :id, :user, :body, :time
|
36
40
|
|
37
41
|
def initialize(id)
|
38
|
-
@id = id
|
42
|
+
@id = id.to_i
|
39
43
|
@user = ::Skype.exec("GET CHATMESSAGE #{@id} from_handle").split(/\s/).last rescue @user = ""
|
40
44
|
@body = ::Skype.exec("GET CHATMESSAGE #{@id} body").scan(/^(CHAT)?MESSAGE #{@id} BODY (.+)$/)[0][1] rescue @body = ""
|
41
45
|
@time = Time.at ::Skype.exec("GET CHATMESSAGE #{@id} timestamp").split(/\s/).last.to_i
|
data/samples/chat.rb
CHANGED
@@ -6,7 +6,7 @@ require 'skype'
|
|
6
6
|
|
7
7
|
chats = Skype.chats
|
8
8
|
puts "#{chats.length} chats found"
|
9
|
-
chat = chats.find{|c| c.members.include? "shokaishokai" and c.topic =~ /test/}
|
9
|
+
chat = chats.find{|c| c.members.include? "shokaishokai" and c.topic =~ /test/} || chats[0]
|
10
10
|
|
11
11
|
p chat
|
12
12
|
chat.post "test"
|
data/skype.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Skype::VERSION
|
9
9
|
spec.authors = ["Sho Hashimoto"]
|
10
10
|
spec.email = ["hashimoto@shokai.org"]
|
11
|
-
spec.description = %q{Skype Desktop API wrapper for
|
11
|
+
spec.description = %q{Skype Desktop API Ruby wrapper for Mac/Linux.}
|
12
12
|
spec.summary = spec.description
|
13
13
|
spec.homepage = "https://github.com/shokai/skype-ruby"
|
14
14
|
spec.license = "MIT"
|
data/test/test_chat.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path 'test_helper', File.dirname(__FILE__)
|
2
|
+
|
3
|
+
class TestSkype < MiniTest::Test
|
4
|
+
|
5
|
+
SKYPE_FROM = ENV["SKYPE_FROM"]
|
6
|
+
SKYPE_TO = ENV["SKYPE_TO"] || "echo123"
|
7
|
+
|
8
|
+
def test_exec
|
9
|
+
body = "hello exec"
|
10
|
+
msg = Skype.exec "MESSAGE #{SKYPE_TO} #{body}"
|
11
|
+
assert_equal msg.body, body
|
12
|
+
assert_equal msg.time.class, Time
|
13
|
+
assert_equal msg.user, SKYPE_FROM
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_message
|
17
|
+
body = "hello hello"
|
18
|
+
msg = Skype.message SKYPE_TO, body
|
19
|
+
assert_equal msg.body, body
|
20
|
+
assert_equal msg.time.class, Time
|
21
|
+
assert_equal msg.user, SKYPE_FROM
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_message_escape
|
25
|
+
body = "hello \"'$@&()^![]{};*?<>`\\ world"
|
26
|
+
msg = Skype.message SKYPE_TO, body
|
27
|
+
assert_equal msg.body, body
|
28
|
+
assert_equal msg.time.class, Time
|
29
|
+
assert_equal msg.user, SKYPE_FROM
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_chats
|
33
|
+
chat = Skype.chats[0]
|
34
|
+
assert_equal chat.class, Skype::Chat
|
35
|
+
assert_equal chat.topic.class, String
|
36
|
+
assert_equal chat.members.class, Array
|
37
|
+
end
|
38
|
+
end
|
data/test/test_skype.rb
CHANGED
@@ -2,42 +2,9 @@ require File.expand_path 'test_helper', File.dirname(__FILE__)
|
|
2
2
|
|
3
3
|
class TestSkype < MiniTest::Test
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def test_exec
|
9
|
-
body = "hello exec"
|
10
|
-
res = Skype.exec "MESSAGE #{SKYPE_TO} #{body}"
|
11
|
-
assert res =~ /^(CHAT)?MESSAGE \d+ STATUS (SENT|SENDING)$/, "Skype API response error"
|
12
|
-
res_id = res.scan(/(CHAT)?MESSAGE (\d+) STATUS (SENT|SENDING)$/)[0][1].to_i
|
13
|
-
msg = Skype::Chat::Message.new res_id
|
14
|
-
assert_equal msg.id, res_id
|
15
|
-
assert_equal msg.body, body
|
16
|
-
assert_equal msg.time.class, Time
|
17
|
-
assert_equal msg.user, SKYPE_FROM
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_message
|
21
|
-
body = "hello hello"
|
22
|
-
res = Skype.message SKYPE_TO, body
|
23
|
-
assert res =~ /^(CHAT)?MESSAGE \d+ STATUS (SENT|SENDING)$/, "Skype API response error"
|
24
|
-
res_id = res.scan(/(CHAT)?MESSAGE (\d+) STATUS (SENT|SENDING)$/)[0][1].to_i
|
25
|
-
msg = Skype::Chat::Message.new res_id
|
26
|
-
assert_equal msg.id, res_id
|
27
|
-
assert_equal msg.body, body
|
28
|
-
assert_equal msg.time.class, Time
|
29
|
-
assert_equal msg.user, SKYPE_FROM
|
5
|
+
def test_username
|
6
|
+
res = Skype.exec "GET USER echo123 FULLNAME"
|
7
|
+
assert res =~ /Sound Test Service/i, "API response error"
|
30
8
|
end
|
31
9
|
|
32
|
-
def test_message_escape
|
33
|
-
body = "hello \"'$@&()^![]{};*?<>`\\ world"
|
34
|
-
res = Skype.message SKYPE_TO, body
|
35
|
-
assert res =~ /^(CHAT)?MESSAGE \d+ STATUS (SENT|SENDING)$/, "Skype API response error"
|
36
|
-
res_id = res.scan(/(CHAT)?MESSAGE (\d+) STATUS (SENT|SENDING)$/)[0][1].to_i
|
37
|
-
msg = Skype::Chat::Message.new res_id
|
38
|
-
assert_equal msg.id, res_id
|
39
|
-
assert_equal msg.body, body
|
40
|
-
assert_equal msg.time.class, Time
|
41
|
-
assert_equal msg.user, SKYPE_FROM
|
42
|
-
end
|
43
10
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skype
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Hashimoto
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '5.0'
|
69
|
-
description: Skype Desktop API wrapper for
|
69
|
+
description: Skype Desktop API Ruby wrapper for Mac/Linux.
|
70
70
|
email:
|
71
71
|
- hashimoto@shokai.org
|
72
72
|
executables: []
|
@@ -84,12 +84,14 @@ files:
|
|
84
84
|
- lib/skype/main.rb
|
85
85
|
- lib/skype/platforms/linux.rb
|
86
86
|
- lib/skype/platforms/mac.rb
|
87
|
+
- lib/skype/register.rb
|
87
88
|
- lib/skype/version.rb
|
88
89
|
- lib/skype/wrappers/chat.rb
|
89
90
|
- samples/call.rb
|
90
91
|
- samples/chat.rb
|
91
92
|
- samples/send_message.rb
|
92
93
|
- skype.gemspec
|
94
|
+
- test/test_chat.rb
|
93
95
|
- test/test_helper.rb
|
94
96
|
- test/test_skype.rb
|
95
97
|
homepage: https://github.com/shokai/skype-ruby
|
@@ -115,7 +117,8 @@ rubyforge_project:
|
|
115
117
|
rubygems_version: 2.0.3
|
116
118
|
signing_key:
|
117
119
|
specification_version: 4
|
118
|
-
summary: Skype Desktop API wrapper for
|
120
|
+
summary: Skype Desktop API Ruby wrapper for Mac/Linux.
|
119
121
|
test_files:
|
122
|
+
- test/test_chat.rb
|
120
123
|
- test/test_helper.rb
|
121
124
|
- test/test_skype.rb
|