rfetion 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rfetion/buddy_list.rb +4 -0
- data/lib/rfetion/contact.rb +4 -0
- data/lib/rfetion/fetion.rb +8 -3
- data/rfetion.gemspec +2 -2
- data/spec/rfetion/fetion_spec.rb +42 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.6
|
data/lib/rfetion/buddy_list.rb
CHANGED
data/lib/rfetion/contact.rb
CHANGED
@@ -9,6 +9,10 @@ class Fetion
|
|
9
9
|
"600" => "繁忙",
|
10
10
|
"0" => "脱机"
|
11
11
|
}
|
12
|
+
|
13
|
+
def to_json
|
14
|
+
{:uid => @uid, :sid => @sid, :bid => @bid, :uri => @uri, :mobile_no => @mobile_no, :nickname => @nickname, :impresa => @impresa, :status => @status}.to_json
|
15
|
+
end
|
12
16
|
|
13
17
|
def self.parse_buddy(b)
|
14
18
|
self.new(:uid => b['i'], :uri => b['u'], :nickname => b['n'], :bid => b['l'].empty? ? "0" : b['l'])
|
data/lib/rfetion/fetion.rb
CHANGED
@@ -6,6 +6,7 @@ require 'nokogiri'
|
|
6
6
|
require 'digest/sha1'
|
7
7
|
require 'openssl'
|
8
8
|
require 'logger'
|
9
|
+
require 'json'
|
9
10
|
|
10
11
|
class Fetion
|
11
12
|
attr_accessor :mobile_no, :sid, :password, :call, :seq, :alive, :ssic, :guid, :uri
|
@@ -31,6 +32,10 @@ class Fetion
|
|
31
32
|
@guid = Guid.new.to_s
|
32
33
|
end
|
33
34
|
|
35
|
+
def to_json
|
36
|
+
{:mobile_no => @mobile_no, :sid => @sid, :uid => @uid, :uri => @uri, :status_code => @status_code, :buddy_lists => @buddy_lists, :receives => @receives, :add_requests => @add_requests, :nickname => @nickname, :impresa => @impresa, :ssic => @ssic, :guid => @guid, :call => @call, :seq => @seq, :alive => @alive}.to_json
|
37
|
+
end
|
38
|
+
|
34
39
|
def logger_level=(level)
|
35
40
|
@logger.level = level
|
36
41
|
end
|
@@ -74,7 +79,7 @@ class Fetion
|
|
74
79
|
receivers = Array(receivers)
|
75
80
|
receivers.collect! {|receiver| receiver.to_s}
|
76
81
|
get_contacts
|
77
|
-
contacts.each do |contact|
|
82
|
+
contacts.flatten.each do |contact|
|
78
83
|
if receivers.include? contact.mobile_no.to_s or receivers.any? { |receiver| contact.uri.index(receiver) }
|
79
84
|
send_sms(contact.uri, content)
|
80
85
|
end
|
@@ -101,7 +106,7 @@ class Fetion
|
|
101
106
|
receivers = Array(receivers)
|
102
107
|
receivers.collect! {|receiver| receiver.to_s}
|
103
108
|
get_contacts
|
104
|
-
contacts.each do |contact|
|
109
|
+
contacts.flatten.each do |contact|
|
105
110
|
if receivers.include? contact.mobile_no.to_s or receivers.any? { |receiver| contact.uri.index(receiver) }
|
106
111
|
send_msg(contact.uri, content)
|
107
112
|
end
|
@@ -130,7 +135,7 @@ class Fetion
|
|
130
135
|
if receivers
|
131
136
|
receivers = Array(receivers)
|
132
137
|
receivers.collect! {|receiver| receiver.to_s}
|
133
|
-
new_receivers = contacts.collect do |contact|
|
138
|
+
new_receivers = contacts.flatten.collect do |contact|
|
134
139
|
if receivers.include? contact.mobile_no.to_s or receivers.any? { |receiver| contact.uri.index(receiver) }
|
135
140
|
contact.uri
|
136
141
|
end
|
data/rfetion.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rfetion}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Richard Huang"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-24}
|
13
13
|
s.description = %q{rfetion is a ruby gem for China Mobile fetion service that you can send SMS free.}
|
14
14
|
s.email = %q{flyerhzm@gmail.com}
|
15
15
|
s.executables = ["rfetion", "rfetion"]
|
data/spec/rfetion/fetion_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe Fetion do
|
4
4
|
class Fetion
|
5
|
-
attr_accessor :mobile_no, :sid, :password, :status_code, :user_status, :uid, :ssic, :nonce, :key, :signature, :response
|
5
|
+
attr_accessor :mobile_no, :sid, :password, :status_code, :user_status, :uid, :nickname, :impresa, :ssic, :nonce, :key, :signature, :response
|
6
6
|
end
|
7
7
|
|
8
8
|
before :each do
|
@@ -12,6 +12,47 @@ describe Fetion do
|
|
12
12
|
after :each do
|
13
13
|
FakeWeb.clean_registry
|
14
14
|
end
|
15
|
+
|
16
|
+
describe "to_json" do
|
17
|
+
before :each do
|
18
|
+
@fetion.mobile_no = '15800681509'
|
19
|
+
@fetion.sid = "730020377"
|
20
|
+
@fetion.password = "password"
|
21
|
+
@fetion.uid = "390937727"
|
22
|
+
@fetion.status_code = "200"
|
23
|
+
@fetion.user_status = "101"
|
24
|
+
@fetion.nickname = "flyerhzm"
|
25
|
+
@fetion.impresa = "http://www.fetionrobot.com"
|
26
|
+
@buddy_list0 = Fetion::BuddyList.new("0", "未分组")
|
27
|
+
@buddy_list1 = Fetion::BuddyList.new("1", "我的好友")
|
28
|
+
@buddy_list1.add_contact(Fetion::Contact.new(:uid => "226911221", :uri => "sip:572512981@fetion.com.cn;p=3544", :bid => "1"))
|
29
|
+
@buddy_list1.add_contact(Fetion::Contact.new(:uid => "295098062", :uri => "sip:638993408@fetion.com.cn;p=2242", :bid => "1"))
|
30
|
+
@buddy_list1.add_contact(Fetion::Contact.new(:uid => "579113578", :uri => "sip:838271744@fetion.com.cn;p=4805", :bid => "1"))
|
31
|
+
@buddy_list1.add_contact(Fetion::Contact.new(:uid => "665046562", :uri => "sip:926157269@fetion.com.cn;p=12906", :bid => "1"))
|
32
|
+
@buddy_list1.add_contact(Fetion::Contact.new(:uid => "687455743", :uri => "sip:881033150@fetion.com.cn;p=5493", :bid => "1"))
|
33
|
+
@buddy_list1.add_contact(Fetion::Contact.new(:uid => "714355089", :uri => "sip:973921799@fetion.com.cn;p=12193", :bid => "1"))
|
34
|
+
@buddy_list1.add_contact(Fetion::Contact.new(:uid => "732743291", :uri => "sip:480867781@fetion.com.cn;p=16105", :bid => "1"))
|
35
|
+
@buddy_list2 = Fetion::BuddyList.new("2", "好友")
|
36
|
+
@buddy_list3 = Fetion::BuddyList.new("3", "同学")
|
37
|
+
@buddy_list3.add_contact(Fetion::Contact.new(:uid => "222516658", :uri => "sip:793401629@fetion.com.cn;p=1919", :bid => "3"))
|
38
|
+
@buddy_list3.add_contact(Fetion::Contact.new(:uid => "227091544", :uri => "sip:669700695@fetion.com.cn;p=3546", :nickname => "郭庆", :bid => "3"))
|
39
|
+
@buddy_list3.add_contact(Fetion::Contact.new(:uid => "228358286", :uri => "sip:660250260@fetion.com.cn;p=3854", :nickname => "蔡智武", :bid => "3"))
|
40
|
+
@buddy_list3.add_contact(Fetion::Contact.new(:uid => "229415466", :uri => "sip:737769829@fetion.com.cn;p=4078", :nickname => "ice", :bid => "3"))
|
41
|
+
@buddy_list3.add_contact(Fetion::Contact.new(:uid => "296436724", :uri => "sip:760087520@fetion.com.cn;p=2467", :bid => "3"))
|
42
|
+
@buddy_lists = [@buddy_list0, @buddy_list1, @buddy_list2, @buddy_list3]
|
43
|
+
@fetion.instance_variable_set(:@buddy_lists, @buddy_lists)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should get all user attributes" do
|
47
|
+
fetion_json = @fetion.to_json
|
48
|
+
fetion_json.should be_include %Q|"mobile_no":"15800681509"|
|
49
|
+
fetion_json.should be_include %Q|"sid":"730020377"|
|
50
|
+
fetion_json.should be_include %Q|"uid":"390937727"|
|
51
|
+
fetion_json.should be_include %Q|"status_code":"200"|
|
52
|
+
fetion_json.should be_include %Q|"nickname":"flyerhzm"|
|
53
|
+
fetion_json.should be_include %Q|"impresa":"http://www.fetionrobot.com"|
|
54
|
+
end
|
55
|
+
end
|
15
56
|
|
16
57
|
describe "login" do
|
17
58
|
it "should login by mobile no" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
8
|
+
- 6
|
9
|
+
version: 0.5.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Richard Huang
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-24 00:00:00 +08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|