skype 0.1.5 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7abc203b8c8e00b1338cb47e58297b1382e560fe
4
- data.tar.gz: 523913048ed2032061443f685ce0d8e340173f62
3
+ metadata.gz: e68ed01cb9d2602a623e54a3b5e8aa2c76f87221
4
+ data.tar.gz: 1e09a51e82d16821366472e523e52d99769121c7
5
5
  SHA512:
6
- metadata.gz: 6a0d3056586e3409170cd6b5cc2185db45090ff4a88708b856a74c4613ad1d6e0cf506aec97a37e1a75af1603b52deddce7e9190fe884bdf2061492daa5225ca
7
- data.tar.gz: 7b291a9d5cca6a21285f1db28a7414d0ebd97139df4408f554f5ebc83bf3f41857bb6db37ed8d3351c434e3392c842d35f24f5905de14033ff96545a0c0e25a4
6
+ metadata.gz: d928b372617006a58bd30a512ea1a72925c4f0cf865a9ca71961370d2da93d3ce513cc97823fdefe64e648963f2f30d5f9fbfe236ba913eb16823298c38b5e5b
7
+ data.tar.gz: 5208227f716a88cfee3487968a510e72fed98db77d28867b5293bb9f528d783fa74f49f66944363f51f556838243b87c81d55c2e6bf569e909aaa60aeb1bb17b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- skype (0.1.5)
4
+ skype (0.2.0)
5
5
  tmp_cache
6
6
 
7
7
  GEM
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.2.0 2013-06-30
2
+
3
+ * add Call API wrapper and tests
4
+
1
5
  === 0.1.5 2013-06-30
2
6
 
3
7
  * add skype-chat command
@@ -24,7 +28,7 @@
24
28
 
25
29
  === 0.1.0 2013-06-27
26
30
 
27
- * add Chat API
31
+ * add Chat API wrapper
28
32
 
29
33
  === 0.0.3 2013-06-20
30
34
 
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
@@ -3,6 +3,8 @@ require 'rubygems'
3
3
  $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
4
4
  require 'skype'
5
5
 
6
+ puts "skype rubygem v#{Skype::VERSION}"
7
+
6
8
  chats = Skype.chats
7
9
  puts "#{chats.length} chats found"
8
10
  chats.each_with_index do |c, index|
data/lib/skype.rb CHANGED
@@ -14,6 +14,7 @@ require case RUBY_PLATFORM
14
14
  end
15
15
  require "skype/main"
16
16
  require "skype/wrappers/chat"
17
+ require "skype/wrappers/call"
17
18
 
18
19
  module Skype
19
20
  end
@@ -17,7 +17,9 @@ module Skype
17
17
  end
18
18
  end
19
19
 
20
- def self.exec(command)
21
- filter_response (@@connection||=Connection.new).invoke command
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
@@ -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
- filter_response `unset LD_LIBRARY_PATH; unset DYLD_LIBRARY_PATH; /usr/bin/osascript -e '#{script}'`.strip
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
@@ -1,3 +1,3 @@
1
1
  module Skype
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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
- p Skype.call to
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
@@ -1,6 +1,6 @@
1
1
  require File.expand_path 'test_helper', File.dirname(__FILE__)
2
2
 
3
- class TestSkype < MiniTest::Test
3
+ class TestSkypeChat < MiniTest::Test
4
4
 
5
5
  SKYPE_FROM = ENV["SKYPE_FROM"]
6
6
  SKYPE_TO = ENV["SKYPE_TO"] || "echo123"
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.5
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-29 00:00:00.000000000 Z
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