rfetion 0.3.5 → 0.3.6
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.
- data/VERSION +1 -1
- data/lib/contact.rb +0 -0
- data/lib/rfetion/contact.rb +11 -0
- data/lib/rfetion/fetion.rb +10 -6
- data/lib/rfetion.rb +1 -0
- data/rfetion.gemspec +4 -2
- metadata +4 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/lib/contact.rb
ADDED
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Contact
|
2
|
+
attr_reader :uri, :mobile_no, :nickname, :impresa, :nickname
|
3
|
+
|
4
|
+
def initialize(uri, attrs)
|
5
|
+
@uri = uri
|
6
|
+
@mobile_no = attrs["mobile-no"]
|
7
|
+
@nickname = attrs["nickname"]
|
8
|
+
@impresa = attrs["impresa"]
|
9
|
+
@nickname = attrs["nickname"]
|
10
|
+
end
|
11
|
+
end
|
data/lib/rfetion/fetion.rb
CHANGED
@@ -38,7 +38,7 @@ class Fetion
|
|
38
38
|
|
39
39
|
def Fetion.send_sms_to_friends(mobile_no, password, friends, content, level = Logger::INFO)
|
40
40
|
friends = Array(friends)
|
41
|
-
friends.collect! {|friend| friend.
|
41
|
+
friends.collect! {|friend| friend.to_s}
|
42
42
|
fetion = Fetion.new
|
43
43
|
fetion.logger_level = level
|
44
44
|
fetion.mobile_no = mobile_no
|
@@ -48,9 +48,9 @@ class Fetion
|
|
48
48
|
fetion.get_buddy_list
|
49
49
|
fetion.get_contacts_info
|
50
50
|
fetion.contacts.each do |contact|
|
51
|
-
if friends.include? contact
|
52
|
-
fetion.send_sms(contact
|
53
|
-
elsif friends.any? { |friend| contact
|
51
|
+
if friends.include? contact.mobile_no.to_s
|
52
|
+
fetion.send_sms(contact.uri, content)
|
53
|
+
elsif friends.any? { |friend| contact.uri.index(friend) }
|
54
54
|
fetion.send_sms
|
55
55
|
end
|
56
56
|
end
|
@@ -81,6 +81,7 @@ class Fetion
|
|
81
81
|
raise FetionException.new('Fetion Error: No ssic found in cookie.') unless response['set-cookie'] =~ /ssic=(.*);/
|
82
82
|
|
83
83
|
@ssic = $1
|
84
|
+
@logger.debug response.body
|
84
85
|
doc = REXML::Document.new(response.body)
|
85
86
|
results = doc.root
|
86
87
|
@status_code = results.attributes["status-code"]
|
@@ -163,8 +164,11 @@ class Fetion
|
|
163
164
|
response = curl_exec(next_url, @ssic, FETION_SIPP)
|
164
165
|
raise FetionException.new("Fetion Error: Get contacts info error") unless response.is_a? Net::HTTPSuccess
|
165
166
|
|
166
|
-
response.body.scan(
|
167
|
-
|
167
|
+
response.body.scan(%r{<events>.*?</events>}).each do |events|
|
168
|
+
doc = REXML::Document.new(events)
|
169
|
+
doc.elements.each("events/event/results/contacts/contact") do |contact|
|
170
|
+
@contacts << Contact.new(contact.attributes["uri"], contact.elements.first.attributes)
|
171
|
+
end
|
168
172
|
end
|
169
173
|
@logger.debug @contacts.inspect
|
170
174
|
@logger.info "fetion get contacts info success"
|
data/lib/rfetion.rb
CHANGED
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.3.
|
8
|
+
s.version = "0.3.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{2009-10-
|
12
|
+
s.date = %q{2009-10-29}
|
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"]
|
@@ -21,8 +21,10 @@ Gem::Specification.new do |s|
|
|
21
21
|
"Rakefile",
|
22
22
|
"VERSION",
|
23
23
|
"bin/rfetion",
|
24
|
+
"lib/contact.rb",
|
24
25
|
"lib/rfetion.rb",
|
25
26
|
"lib/rfetion/command.rb",
|
27
|
+
"lib/rfetion/contact.rb",
|
26
28
|
"lib/rfetion/fetion.rb",
|
27
29
|
"rfetion.gemspec"
|
28
30
|
]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rfetion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-29 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -36,8 +36,10 @@ files:
|
|
36
36
|
- Rakefile
|
37
37
|
- VERSION
|
38
38
|
- bin/rfetion
|
39
|
+
- lib/contact.rb
|
39
40
|
- lib/rfetion.rb
|
40
41
|
- lib/rfetion/command.rb
|
42
|
+
- lib/rfetion/contact.rb
|
41
43
|
- lib/rfetion/fetion.rb
|
42
44
|
- rfetion.gemspec
|
43
45
|
has_rdoc: true
|