skype 0.1.0 → 0.1.1

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: e1715eeb6270ab42387b2f16b396ff8d3216d690
4
- data.tar.gz: 56e7b9d58ba245b15729de2cd2b22af2c929c0a4
3
+ metadata.gz: 9a374dd4707ba6ebcd367220c2acb71eeb1fbe56
4
+ data.tar.gz: c2a6cd4dc9e31794a60ce5b1cc0fa33dedfba53f
5
5
  SHA512:
6
- metadata.gz: db905f810d96b25eb01234c732ebcfe1e93e8bef311e0528690fedd7c372da17038d44ee7e1d2904b194d1bedc98926a36bdc2a00c9b500a1606b95f86b6b5c1
7
- data.tar.gz: ba1ac32a63d698a197586f71d96768c1245ee0d7b053e43a77f6f4f6ad876bd6f98f4f1191dd96fa0d62f4cee48b80caa0d58c12f7e486e92ffd9a184db9fb1c
6
+ metadata.gz: 70bcedf70842e5f9cb7fa127febfa815bf563e7914bcda542d7615ac4d3b96db793f7d9358d912f517ec95f752ae71115e7764a1ca9b9773b5250748ab02a58d
7
+ data.tar.gz: c0a1fb7f01c9bb8dda17151749601ca6a378a0cb2a66133e61c4e11f09437f4396b8828409b09073b9e2190cc084ef79e11dc35aa491856f861ae1c0f59072c9
data/.gitignore CHANGED
@@ -7,7 +7,6 @@
7
7
  .config
8
8
  .yardoc
9
9
  .ruby-version
10
- Gemfile.lock
11
10
  InstalledFiles
12
11
  _yardoc
13
12
  coverage
@@ -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!
@@ -1,3 +1,8 @@
1
+ === 0.1.1 2013-06-29
2
+
3
+ * add tests
4
+ * use /usr/bin/osascript instead of rb-appscript
5
+
1
6
  === 0.1.0 2013-06-27
2
7
 
3
8
  * add Chat API
data/README.md CHANGED
@@ -17,7 +17,7 @@ Installation
17
17
 
18
18
  for Mac
19
19
 
20
- % gem install skype rb-appscript
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
@@ -1 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "test/test_*.rb"
6
+ end
7
+
8
+ task :default => :test
@@ -1,7 +1,17 @@
1
- require "appscript"
2
-
3
1
  module Skype
4
2
  def self.exec(command)
5
- Appscript.app("skype").send_ :script_name => self.config[:app_name], :command => command
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
@@ -1,3 +1,3 @@
1
1
  module Skype
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
 
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "minitest", "~> 5.0"
25
26
  end
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+ require 'minitest/autorun'
3
+
4
+ $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
5
+ require 'skype'
@@ -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.0
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-27 00:00:00.000000000 Z
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
- has_rdoc:
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