Module: RocketSMS
- Extended by:
- RocketSMS
- Included in:
- RocketSMS
- Defined in:
- lib/rocket_sms.rb,
lib/rocket_sms/did.rb,
lib/rocket_sms/gateway.rb,
lib/rocket_sms/message.rb,
lib/rocket_sms/version.rb,
lib/rocket_sms/scheduler.rb,
lib/rocket_sms/transceiver.rb
Defined Under Namespace
Classes: Did, Gateway, Message, Scheduler, Transceiver
Constant Summary
collapse
- LIB_PATH =
File.dirname(__FILE__) + '/rocket_sms/'
- VERSION =
"0.1.1"
Instance Method Summary
collapse
Instance Method Details
62
63
64
|
# File 'lib/rocket_sms.rb', line 62
def configure
yield self
end
|
#gateway ⇒ Object
53
54
55
|
# File 'lib/rocket_sms.rb', line 53
def gateway
@gateway ||= RocketSMS::Gateway.instance
end
|
#log_location ⇒ Object
88
89
90
|
# File 'lib/rocket_sms.rb', line 88
def log_location
@log_location ||= STDOUT
end
|
#log_location=(location) ⇒ Object
92
93
94
|
# File 'lib/rocket_sms.rb', line 92
def log_location=(location)
@log_location = location unless location.nil?
end
|
#logger ⇒ Object
84
85
86
|
# File 'lib/rocket_sms.rb', line 84
def logger
@logger ||= Logger.new(log_location)
end
|
#queues ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/rocket_sms.rb', line 41
def queues
@queues ||= {
mt: {
pending: 'gateway:queues:mt:pending',
success: 'gateway:queues:mt:success',
failure: 'gateway:queues:mt:failure'
},
mo: 'gateway:queues:mo:received',
dr: 'gateway:queues:dr'
}
end
|
#redis ⇒ Object
57
58
59
|
# File 'lib/rocket_sms.rb', line 57
def redis
@redis ||= EM::Hiredis.connect(redis_url)
end
|
#redis_url ⇒ Object
76
77
78
|
# File 'lib/rocket_sms.rb', line 76
def redis_url
@redis_url ||= "redis://localhost:6379"
end
|
#redis_url=(url) ⇒ Object
80
81
82
|
# File 'lib/rocket_sms.rb', line 80
def redis_url=(url)
@redis_url = url unless url.nil?
end
|
#settings ⇒ Object
72
73
74
|
# File 'lib/rocket_sms.rb', line 72
def settings
@settings
end
|
#settings=(yaml_file_location) ⇒ Object
66
67
68
69
70
|
# File 'lib/rocket_sms.rb', line 66
def settings=(yaml_file_location)
@settings = symbolize_keys(YAML.load(IO.read(yaml_file_location)))
redis_url = @settings[:redis] && @settings[:redis][:url]
log_location = @settings[:log] && @settings[:log][:location]
end
|
#start ⇒ Object
35
36
37
38
39
|
# File 'lib/rocket_sms.rb', line 35
def start
@pid = Process.pid
gateway.start
end
|
#symbolize_keys(hash) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/rocket_sms.rb', line 96
def symbolize_keys(hash)
hash.inject({}){|result, (key, value)|
new_key = case key
when String then key.to_sym
else key
end
new_value = case value
when Hash then symbolize_keys(value)
else value
end
result[new_key] = new_value
result
}
end
|