pswincom 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/lib/pswincom/request.rb +7 -0
- data/lib/pswincom/utility/options.rb +21 -6
- metadata +4 -4
data/README.md
CHANGED
@@ -41,6 +41,7 @@ Properties currently supported are:
|
|
41
41
|
* :TTL - time to live in minutes
|
42
42
|
* :deliverytime - a Time object specifying when to send the message
|
43
43
|
* :tariff - the amount (in local currency as cents/"ører") to charge the receiver
|
44
|
+
* :servicecode - ServiceCode for sending GAS messages. Requires that :tariff is set
|
44
45
|
|
45
46
|
Specifying Host
|
46
47
|
---------------
|
data/lib/pswincom/request.rb
CHANGED
@@ -9,6 +9,12 @@ module PSWinCom
|
|
9
9
|
@messages = []
|
10
10
|
end
|
11
11
|
def add args
|
12
|
+
# Only accept servicecode when there is a tariff associated
|
13
|
+
# with the message
|
14
|
+
if args[:servicecode] && args[:tariff].nil?
|
15
|
+
raise ArgumentError, "A message with a servicecode also needs a tariff"
|
16
|
+
end
|
17
|
+
|
12
18
|
@messages << args
|
13
19
|
self
|
14
20
|
end
|
@@ -30,6 +36,7 @@ module PSWinCom
|
|
30
36
|
m.SND args[:sender] if args[:sender]
|
31
37
|
m.TTL args[:TTL] if args[:TTL]
|
32
38
|
m.TARIFF args[:tariff] if args[:tariff]
|
39
|
+
m.SERVICECODE args[:servicecode] if args[:servicecode]
|
33
40
|
m.DELIVERYTIME args[:deliverytime].strftime(TIME_FORMAT) if args.include? :deliverytime
|
34
41
|
end
|
35
42
|
end
|
@@ -7,26 +7,39 @@ module PSWinCom
|
|
7
7
|
class Options
|
8
8
|
class << self
|
9
9
|
|
10
|
+
def current_setting setting
|
11
|
+
value = @options.send(setting)
|
12
|
+
value ||= "(not set)"
|
13
|
+
" #{setting.to_s}:".ljust(37) + value.to_s
|
14
|
+
end
|
15
|
+
|
10
16
|
def parse(args)
|
11
17
|
@options = self.default_options
|
12
18
|
parser = OptionParser.new do |opts|
|
13
19
|
opts.banner = "Usage: sms [options] recipient(s) message"
|
20
|
+
opts.separator ""
|
14
21
|
opts.separator " Recipients can be a comma-separated list, up to 100 max."
|
15
22
|
opts.separator ""
|
16
|
-
opts.separator "
|
23
|
+
opts.separator " Current settings:"
|
24
|
+
opts.separator current_setting(:username)
|
25
|
+
opts.separator current_setting(:password)
|
26
|
+
opts.separator current_setting(:from)
|
27
|
+
opts.separator current_setting(:host)
|
28
|
+
opts.separator ""
|
29
|
+
opts.separator " Specific options:"
|
17
30
|
|
18
31
|
opts.on('-u', '--username USERNAME',
|
19
|
-
"Specify
|
32
|
+
"Specify username (overrides ~/.pswincom setting)") do |username|
|
20
33
|
@options.username = username
|
21
34
|
end
|
22
35
|
|
23
36
|
opts.on('-p', '--password PASSWORD',
|
24
|
-
"Specify
|
37
|
+
"Specify password (overrides ~/.pswincom setting)") do |password|
|
25
38
|
@options.password = password
|
26
39
|
end
|
27
40
|
|
28
41
|
opts.on('-f', '--from NAME_OR_NUMBER',
|
29
|
-
"Specify
|
42
|
+
"Specify name or number of sender") do |from|
|
30
43
|
@options.from = from
|
31
44
|
end
|
32
45
|
|
@@ -35,11 +48,13 @@ module PSWinCom
|
|
35
48
|
@options.host = host
|
36
49
|
end
|
37
50
|
|
38
|
-
opts.on('-d', '--debug'
|
51
|
+
opts.on('-d', '--debug',
|
52
|
+
"Print debug information") do
|
39
53
|
PSWinCom::API.debug_mode = true
|
40
54
|
end
|
41
55
|
|
42
|
-
opts.on('-t', '--test'
|
56
|
+
opts.on('-t', '--test',
|
57
|
+
"Messages will not really be sent") do
|
43
58
|
PSWinCom::API.test_mode = true
|
44
59
|
end
|
45
60
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pswincom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- PSWinCom AS
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-30 00:00:00 +02:00
|
19
19
|
default_executable: sms
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|