rfetion 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rfetion/command.rb +45 -14
- data/lib/rfetion/fetion.rb +6 -3
- data/rfetion.gemspec +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
data/lib/rfetion/command.rb
CHANGED
@@ -4,10 +4,12 @@ options = {}
|
|
4
4
|
|
5
5
|
OptionParser.new do |opts|
|
6
6
|
# Set a banner, displayed at the top of the help screen.
|
7
|
-
opts.banner =
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
opts.banner = "Usage: rfetion [options]"
|
8
|
+
|
9
|
+
opts.separator ""
|
10
|
+
opts.separator <<EOF
|
11
|
+
Example: rfetion -m mobile -p password -f friend_mobile -c sms_content
|
12
|
+
rfetion -m mobile -p password -a friend_mobile
|
11
13
|
EOF
|
12
14
|
|
13
15
|
opts.on('-m', '--mobile MOBILE', 'Fetion mobile number') do |mobile|
|
@@ -31,19 +33,48 @@ EOF
|
|
31
33
|
options[:add_mobile] = f
|
32
34
|
end
|
33
35
|
|
36
|
+
opts.separator ""
|
37
|
+
opts.separator "different mode:"
|
38
|
+
|
39
|
+
opts.on('--debug', 'debug mode') do
|
40
|
+
options[:debug] = true
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on('--silence', 'silence mode') do
|
44
|
+
options[:silence] = true
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.separator ""
|
48
|
+
opts.separator "Common options:"
|
49
|
+
|
50
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
51
|
+
puts opts
|
52
|
+
exit
|
53
|
+
end
|
54
|
+
|
34
55
|
opts.parse!
|
35
56
|
end
|
36
57
|
|
37
|
-
|
38
|
-
|
39
|
-
|
58
|
+
def level(options)
|
59
|
+
return Logger::DEBUG if options[:debug]
|
60
|
+
return Logger::ERROR if options[:silence]
|
61
|
+
return Logger::INFO
|
62
|
+
end
|
63
|
+
|
64
|
+
begin
|
65
|
+
if options[:add_mobile]
|
66
|
+
raise FetionException.new('You must input your mobile number and password') unless options[:mobile_no] and options[:password]
|
67
|
+
Fetion.add_buddy(options[:mobile_no], options[:password], options[:add_mobile], level(options))
|
68
|
+
exit
|
40
69
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
70
|
+
|
71
|
+
raise FetionException.new('You must input your mobile number, password and content') unless options[:mobile_no] and options[:password] and options[:content]
|
72
|
+
if options[:friends_mobile].empty?
|
73
|
+
Fetion.send_sms_to_self(options[:mobile_no], options[:password], options[:content], level(options))
|
74
|
+
else
|
75
|
+
Fetion.send_sms_to_friends(options[:mobile_no], options[:password], options[:friends_mobile], options[:content], level(options))
|
48
76
|
end
|
77
|
+
rescue FetionException => e
|
78
|
+
puts e.message
|
79
|
+
puts "Please use 'rfetion -h' to get more details"
|
49
80
|
end
|
data/lib/rfetion/fetion.rb
CHANGED
@@ -25,8 +25,9 @@ class Fetion
|
|
25
25
|
@logger.level = level
|
26
26
|
end
|
27
27
|
|
28
|
-
def Fetion.send_sms_to_self(mobile_no, password, content)
|
28
|
+
def Fetion.send_sms_to_self(mobile_no, password, content, level = Logger::INFO)
|
29
29
|
fetion = Fetion.new
|
30
|
+
fetion.logger_level = level
|
30
31
|
fetion.mobile_no = mobile_no
|
31
32
|
fetion.password = password
|
32
33
|
fetion.login
|
@@ -35,10 +36,11 @@ class Fetion
|
|
35
36
|
fetion.logout
|
36
37
|
end
|
37
38
|
|
38
|
-
def Fetion.send_sms_to_friends(mobile_no, password, friend_mobiles, content)
|
39
|
+
def Fetion.send_sms_to_friends(mobile_no, password, friend_mobiles, content, level = Logger::INFO)
|
39
40
|
friend_mobiles = Array(friend_mobiles)
|
40
41
|
friend_mobiles.collect! {|mobile| mobile.to_i}
|
41
42
|
fetion = Fetion.new
|
43
|
+
fetion.logger_level = level
|
42
44
|
fetion.mobile_no = mobile_no
|
43
45
|
fetion.password = password
|
44
46
|
fetion.login
|
@@ -53,8 +55,9 @@ class Fetion
|
|
53
55
|
fetion.logout
|
54
56
|
end
|
55
57
|
|
56
|
-
def Fetion.add_buddy(mobile_no, password, friend_mobile)
|
58
|
+
def Fetion.add_buddy(mobile_no, password, friend_mobile, level = Logger::INFO)
|
57
59
|
fetion = Fetion.new
|
60
|
+
fetion.logger_level = level
|
58
61
|
fetion.mobile_no = mobile_no
|
59
62
|
fetion.password = password
|
60
63
|
fetion.login
|
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.2"
|
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-17}
|
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"]
|
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.2
|
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-17 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|