skype 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/Gemfile.lock +21 -0
- data/History.txt +5 -0
- data/README.md +12 -2
- data/Rakefile +7 -0
- data/lib/skype/platforms/mac.rb +13 -3
- data/lib/skype/version.rb +1 -1
- data/lib/skype/wrappers/chat.rb +2 -2
- data/skype.gemspec +1 -0
- data/test/test_helper.rb +5 -0
- data/test/test_skype.rb +43 -0
- metadata +22 -5
- data/chat.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a374dd4707ba6ebcd367220c2acb71eeb1fbe56
|
4
|
+
data.tar.gz: c2a6cd4dc9e31794a60ce5b1cc0fa33dedfba53f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70bcedf70842e5f9cb7fa127febfa815bf563e7914bcda542d7615ac4d3b96db793f7d9358d912f517ec95f752ae71115e7764a1ca9b9773b5250748ab02a58d
|
7
|
+
data.tar.gz: c0a1fb7f01c9bb8dda17151749601ca6a378a0cb2a66133e61c4e11f09437f4396b8828409b09073b9e2190cc084ef79e11dc35aa491856f861ae1c0f59072c9
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
skype (0.1.1)
|
5
|
+
tmp_cache
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
minitest (5.0.6)
|
11
|
+
rake (10.1.0)
|
12
|
+
tmp_cache (0.1.1)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
bundler (~> 1.3)
|
19
|
+
minitest (~> 5.0)
|
20
|
+
rake
|
21
|
+
skype!
|
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -17,7 +17,7 @@ Installation
|
|
17
17
|
|
18
18
|
for Mac
|
19
19
|
|
20
|
-
% gem install skype
|
20
|
+
% gem install skype
|
21
21
|
|
22
22
|
for Linux
|
23
23
|
|
@@ -26,7 +26,6 @@ for Linux
|
|
26
26
|
Gemfile
|
27
27
|
```ruby
|
28
28
|
gem "skype"
|
29
|
-
gem "rb-appscript" if RUBY_PLATFORM =~ /darwin/i
|
30
29
|
gem "ruby-dbus" if RUBY_PLATFORM =~ /linux/i
|
31
30
|
```
|
32
31
|
|
@@ -80,6 +79,17 @@ Samples
|
|
80
79
|
https://github.com/shokai/skype-ruby/tree/master/samples
|
81
80
|
|
82
81
|
|
82
|
+
Test
|
83
|
+
----
|
84
|
+
test requires 2 skype accounts.
|
85
|
+
|
86
|
+
% gem install bundler
|
87
|
+
% bundle install
|
88
|
+
% export SKYPE_FROM=your_skype_name1
|
89
|
+
% export SKYPE_TO=your_skype_name2
|
90
|
+
% rake test
|
91
|
+
|
92
|
+
|
83
93
|
Contributing
|
84
94
|
------------
|
85
95
|
1. Fork it
|
data/Rakefile
CHANGED
data/lib/skype/platforms/mac.rb
CHANGED
@@ -1,7 +1,17 @@
|
|
1
|
-
require "appscript"
|
2
|
-
|
3
1
|
module Skype
|
4
2
|
def self.exec(command)
|
5
|
-
|
3
|
+
script = %Q{tell application "Skype"
|
4
|
+
send command "#{Utils.escape command}" script name "#{self.config[:app_name]}"
|
5
|
+
end tell}
|
6
|
+
res = `unset LD_LIBRARY_PATH; unset DYLD_LIBRARY_PATH; /usr/bin/osascript -e '#{script}'`.split(/[\n\r]+/)
|
7
|
+
res.shift if res.size > 1 and res[0] =~ /^dyld: /
|
8
|
+
res[0]
|
9
|
+
end
|
10
|
+
|
11
|
+
module Utils
|
12
|
+
def self.escape(str)
|
13
|
+
str.gsub(/(["\\])/){ "\\#{$1}" }.
|
14
|
+
gsub("'"){ "'\\''" }
|
15
|
+
end
|
6
16
|
end
|
7
17
|
end
|
data/lib/skype/version.rb
CHANGED
data/lib/skype/wrappers/chat.rb
CHANGED
@@ -36,8 +36,8 @@ module Skype
|
|
36
36
|
|
37
37
|
def initialize(id)
|
38
38
|
@id = id
|
39
|
-
@user = ::Skype.exec("GET CHATMESSAGE #{@id} from_handle").split(/\s/).last
|
40
|
-
@body = ::Skype.exec("GET CHATMESSAGE #{@id} body").scan(/^MESSAGE #{@id} BODY (.+)$/)[0][0]
|
39
|
+
@user = ::Skype.exec("GET CHATMESSAGE #{@id} from_handle").split(/\s/).last rescue @user = ""
|
40
|
+
@body = ::Skype.exec("GET CHATMESSAGE #{@id} body").scan(/^MESSAGE #{@id} BODY (.+)$/)[0][0] rescue @body = ""
|
41
41
|
@time = Time.at ::Skype.exec("GET CHATMESSAGE #{@id} timestamp").split(/\s/).last.to_i
|
42
42
|
end
|
43
43
|
|
data/skype.gemspec
CHANGED
data/test/test_helper.rb
ADDED
data/test/test_skype.rb
ADDED
@@ -0,0 +1,43 @@
|
|
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"]
|
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
|
30
|
+
end
|
31
|
+
|
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
|
+
end
|
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.1.
|
4
|
+
version: 0.1.1
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tmp_cache
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
55
69
|
description: Skype Desktop API wrapper for Ruby
|
56
70
|
email:
|
57
71
|
- hashimoto@shokai.org
|
@@ -61,11 +75,11 @@ extra_rdoc_files: []
|
|
61
75
|
files:
|
62
76
|
- .gitignore
|
63
77
|
- Gemfile
|
78
|
+
- Gemfile.lock
|
64
79
|
- History.txt
|
65
80
|
- LICENSE.txt
|
66
81
|
- README.md
|
67
82
|
- Rakefile
|
68
|
-
- chat.rb
|
69
83
|
- lib/skype.rb
|
70
84
|
- lib/skype/main.rb
|
71
85
|
- lib/skype/platforms/linux.rb
|
@@ -76,6 +90,8 @@ files:
|
|
76
90
|
- samples/chat.rb
|
77
91
|
- samples/send_message.rb
|
78
92
|
- skype.gemspec
|
93
|
+
- test/test_helper.rb
|
94
|
+
- test/test_skype.rb
|
79
95
|
homepage: https://github.com/shokai/skype-ruby
|
80
96
|
licenses:
|
81
97
|
- MIT
|
@@ -100,5 +116,6 @@ rubygems_version: 2.0.3
|
|
100
116
|
signing_key:
|
101
117
|
specification_version: 4
|
102
118
|
summary: Skype Desktop API wrapper for Ruby
|
103
|
-
test_files:
|
104
|
-
|
119
|
+
test_files:
|
120
|
+
- test/test_helper.rb
|
121
|
+
- test/test_skype.rb
|
data/chat.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
$:.unshift File.expand_path '../lib', File.dirname(__FILE__)
|
4
|
-
require 'skype'
|
5
|
-
|
6
|
-
chats = Skype.search "recentchats"
|
7
|
-
chats = chats.scan(/(#[^\s,]+)[\s,]/).map{|i| i[0] }
|
8
|
-
|
9
|
-
chats.each_with_index do |chat, index|
|
10
|
-
puts "[#{index}] #{chat}"
|
11
|
-
end
|
12
|
-
|
13
|
-
puts %Q{select chat number 0~#{chats.size-1} ?}
|
14
|
-
exit 1 unless (n = STDIN.gets.strip) =~ /^\d$/
|
15
|
-
|
16
|
-
chat = chats[n.to_i]
|
17
|
-
puts %Q{#{chat} was selected}
|
18
|
-
|
19
|
-
while line = STDIN.gets.strip
|
20
|
-
Skype.chatmessage chat, line
|
21
|
-
end
|