metric_tools 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,68 +0,0 @@
1
- require 'rb-skypemac'
2
-
3
- module MetricTools
4
-
5
- #
6
- # Skypeのチャットにメッセージをpostするクラスです。
7
- # 使用するMac上でSkype for Mac OSXが起動していて、
8
- # 対象のチャットルームに発言できるアカウントでログインされている必要があります。
9
- #
10
- class Skype
11
-
12
- class << self
13
-
14
- #
15
- # nameで指定したチャットルームに発言出来る状態にします。
16
- # login_chat("[GREE] パンカク連絡チャット")
17
- #
18
- def login_chat(name)
19
- chats = SkypeMac::Skype.send_(:command => 'SEARCH RECENTCHATS')
20
- chats = chats.sub("CHATS ","").split(/,/)
21
-
22
- for id in chats
23
- chat_info = SkypeMac::Skype.send_(:command => 'GET CHAT %s FRIENDLYNAME' % id).split(' ')
24
- friendly_name = chat_info[3]
25
-
26
- if friendly_name.include?(name)
27
- @chat_id = chat_info[1]
28
- @chat_name = friendly_name
29
- end
30
- end
31
-
32
- raise "not existing chat room : #{name}" if @chat_id.nil?
33
- @chat_id
34
- end
35
-
36
- def logout
37
- @chat_id = nil
38
- @chat_name = nil
39
- end
40
-
41
- #
42
- # 現在のチャットルームのidを返します
43
- #
44
- def current_chat_id
45
- @chat_id
46
- end
47
-
48
- #
49
- # 現在のチャットルームの表示名を返します
50
- #
51
- def current_chat_name
52
- @chat_name
53
- end
54
-
55
- #
56
- # 現在のチャットルームに発言します
57
- #
58
- def post(message)
59
- return puts 'please login before.' if current_chat_id.nil?
60
-
61
- SkypeMac::Skype.send_(:command => "CHATMESSAGE #{current_chat_id} #{message}");
62
- end
63
-
64
- end
65
-
66
- end
67
-
68
- end
data/spec/skype_spec.rb DELETED
@@ -1,39 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require 'metric_tools'
4
-
5
- include MetricTools
6
-
7
- describe MetricTools::Skype do
8
- before do
9
- Skype.logout
10
- end
11
-
12
- describe '#login_chat' do
13
- context 'when specified existing room name' do
14
- it 'login chat room has specified friendly name' do
15
- Skype.login_chat(Pref::Skype::TEST_CHAT_ROOM)
16
-
17
- Skype.current_chat_id.should_not be_nil
18
- end
19
- end
20
-
21
- context 'when specified not existing room name' do
22
- it 'login chat room has specified friendly name' do
23
- proc { Skype.login_chat("そんな部屋はない") }.should raise_error(RuntimeError, 'not existing chat room : そんな部屋はない')
24
- Skype.current_chat_id.should be_nil
25
- end
26
- end
27
- end
28
-
29
- describe '#post' do
30
- before do
31
- Skype.login_chat(Pref::Skype::TEST_CHAT_ROOM)
32
- end
33
-
34
- it "post a message to specified id's chat" do
35
- Skype.post("テストです。" + DateTime.now.to_s)
36
- end
37
- end
38
-
39
- end