skype 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3aa1c4c74b77b558bdafa765fb9b103d8cb748f
4
- data.tar.gz: d85482711127b14a939ace7d8e593f867bca0d88
3
+ metadata.gz: 9fb5dc7ad40243c4ed83700b041c4503829721d4
4
+ data.tar.gz: ce838b0e3a2ba45c67de7ee2fbd6b1f6b44c9434
5
5
  SHA512:
6
- metadata.gz: 0301d08af03c2ec6a172ec367ee373326f14b21c9be663487b33e0384622c11a0ec93bf7ee7704d3e98229fe4c39cfdd8857d950ed028efd3bfe17c6d656c78d
7
- data.tar.gz: f685779d51d96b3425175d6123b35a531ea0b69e20dd8d32f9b743b79625990fc78fa8e7ca60ef0f64a1c2a08ec24595132dc7f55507037e014064cc5d8136ed
6
+ metadata.gz: 841f2f1210196ea337119df90c678e5449d84511d06b3959503384711bdfe80da14c1b25a143e8a68159b1ab4973647d56ce0d4c172b359d523cfc188f78f153
7
+ data.tar.gz: 58c970aaf597ceae2d390c929c6b8f59a42446a8434b7312b75a9c09804d748d51b2b2a635344c5bbd5ae635a305c07cb7bad31f993627f1fc44206b5c531446
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- skype (0.2.1)
4
+ skype (0.2.2)
5
5
  tmp_cache
6
6
 
7
7
  GEM
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.2.2 2013-07-03
2
+
3
+ * get properties of Skype::Chat::Message on access
4
+
1
5
  === 0.2.1 2013-06-30
2
6
 
3
7
  * add function Skype::Call#talking?
data/lib/skype/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Skype
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -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| i.to_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
- @user = ::Skype.exec("GET CHATMESSAGE #{@id} from_handle").split(/\s/).last rescue @user = ""
44
- @body = ::Skype.exec("GET CHATMESSAGE #{@id} body").scan(/^(CHAT)?MESSAGE #{@id} BODY (.+)$/)[0][1] rescue @body = ""
45
- @time = Time.at ::Skype.exec("GET CHATMESSAGE #{@id} timestamp").split(/\s/).last.to_i
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
- "[#{@time}] <#{@user}> #{@body} "
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
- loop do
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 = ENV["SKYPE_TO"] || "echo123"
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
- sleep 1
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.1
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-06-30 00:00:00.000000000 Z
11
+ date: 2013-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tmp_cache