skype 0.2.1 → 0.2.2
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/Gemfile.lock +1 -1
- data/History.txt +4 -0
- data/lib/skype/version.rb +1 -1
- data/lib/skype/wrappers/chat.rb +36 -9
- data/samples/call.rb +3 -3
- data/test/test_call.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fb5dc7ad40243c4ed83700b041c4503829721d4
|
4
|
+
data.tar.gz: ce838b0e3a2ba45c67de7ee2fbd6b1f6b44c9434
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 841f2f1210196ea337119df90c678e5449d84511d06b3959503384711bdfe80da14c1b25a143e8a68159b1ab4973647d56ce0d4c172b359d523cfc188f78f153
|
7
|
+
data.tar.gz: 58c970aaf597ceae2d390c929c6b8f59a42446a8434b7312b75a9c09804d748d51b2b2a635344c5bbd5ae635a305c07cb7bad31f993627f1fc44206b5c531446
|
data/Gemfile.lock
CHANGED
data/History.txt
CHANGED
data/lib/skype/version.rb
CHANGED
data/lib/skype/wrappers/chat.rb
CHANGED
@@ -11,8 +11,6 @@ module Skype
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class Chat
|
14
|
-
@@message_cache = TmpCache::Cache.new
|
15
|
-
|
16
14
|
attr_reader :id, :topic, :members
|
17
15
|
|
18
16
|
def initialize(id)
|
@@ -25,9 +23,7 @@ module Skype
|
|
25
23
|
::Skype.exec("GET CHAT #{@id} RECENTCHATMESSAGES").
|
26
24
|
split(/,? /).
|
27
25
|
select{|i| i =~ /^\d+$/ }.
|
28
|
-
map{|i|
|
29
|
-
map{|i| @@message_cache.get(i) || @@message_cache.set(i, Skype::Chat::Message.new(i), 3600*72) }.
|
30
|
-
sort{|a,b| b.time <=> a.time }
|
26
|
+
map{|i| Skype::Chat::Message.new i }
|
31
27
|
end
|
32
28
|
|
33
29
|
def post(message)
|
@@ -35,18 +31,49 @@ module Skype
|
|
35
31
|
end
|
36
32
|
|
37
33
|
class Message
|
34
|
+
@@cache = TmpCache::Cache.new
|
38
35
|
|
39
36
|
attr_reader :id, :user, :body, :time
|
40
37
|
|
41
38
|
def initialize(id)
|
42
39
|
@id = id.to_i
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
if cache = @@cache.get(@id)
|
41
|
+
@user = cache[:user]
|
42
|
+
@body = cache[:body]
|
43
|
+
@time = cache[:time]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def user
|
48
|
+
get_properties
|
49
|
+
@user
|
50
|
+
end
|
51
|
+
|
52
|
+
def body
|
53
|
+
get_properties
|
54
|
+
@body
|
55
|
+
end
|
56
|
+
|
57
|
+
def time
|
58
|
+
get_properties
|
59
|
+
@time
|
46
60
|
end
|
47
61
|
|
48
62
|
def to_s
|
49
|
-
"[#{
|
63
|
+
"[#{time}] <#{user}> #{body} "
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
def get_properties
|
68
|
+
return if @user and @body and @time
|
69
|
+
@user = ::Skype.exec("GET CHATMESSAGE #{@id} from_handle").split(/\s/).last rescue @user = ""
|
70
|
+
@body = ::Skype.exec("GET CHATMESSAGE #{@id} body").scan(/^(CHAT)?MESSAGE #{@id} BODY (.+)$/)[0][1] rescue @body = ""
|
71
|
+
@time = Time.at ::Skype.exec("GET CHATMESSAGE #{@id} timestamp").split(/\s/).last.to_i
|
72
|
+
@@cache.set(@id, {
|
73
|
+
:user => @user,
|
74
|
+
:body => @body,
|
75
|
+
:time => @time
|
76
|
+
}, 3600*72)
|
50
77
|
end
|
51
78
|
|
52
79
|
end
|
data/samples/call.rb
CHANGED
@@ -8,9 +8,9 @@ print "> "
|
|
8
8
|
to = STDIN.gets.strip
|
9
9
|
call = Skype.call to
|
10
10
|
|
11
|
-
|
11
|
+
|
12
|
+
while !call.talking?
|
12
13
|
puts call.status
|
13
|
-
break if call.talking?
|
14
14
|
sleep 1
|
15
15
|
end
|
16
16
|
|
@@ -19,6 +19,6 @@ end
|
|
19
19
|
sleep 1
|
20
20
|
end
|
21
21
|
|
22
|
-
call.hangup
|
22
|
+
call.hangup if call.talking?
|
23
23
|
|
24
24
|
puts call.status
|
data/test/test_call.rb
CHANGED
@@ -3,14 +3,16 @@ require File.expand_path 'test_helper', File.dirname(__FILE__)
|
|
3
3
|
class TestSkypeCall < MiniTest::Test
|
4
4
|
|
5
5
|
SKYPE_FROM = ENV["SKYPE_FROM"]
|
6
|
-
SKYPE_TO =
|
6
|
+
SKYPE_TO = "echo123"
|
7
7
|
|
8
8
|
def test_call
|
9
9
|
call = Skype.call SKYPE_TO
|
10
10
|
STDERR.puts call if call.kind_of? String
|
11
11
|
assert_equal call.class, Skype::Call
|
12
12
|
assert_equal call.to, SKYPE_TO
|
13
|
-
|
13
|
+
while !call.talking?
|
14
|
+
sleep 2
|
15
|
+
end
|
14
16
|
call.hangup
|
15
17
|
assert [:finished, :missed, :cancelled].include? call.status
|
16
18
|
assert_equal call.talking?, false
|
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.2.
|
4
|
+
version: 0.2.2
|
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-
|
11
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tmp_cache
|