Module: Smess

Defined in:
lib/smess.rb,
lib/smess/sms.rb,
lib/smess/utils.rb,
lib/smess/output.rb,
lib/smess/logging.rb,
lib/smess/version.rb,
lib/smess/outputs/auto.rb,
lib/smess/outputs/test.rb,
lib/smess/outputs/twilio.rb,
lib/smess/outputs/http_base.rb,
lib/smess/outputs/smsglobal.rb,
lib/smess/outputs/clickatell.rb,
lib/smess/outputs/global_mouth.rb,
lib/smess/outputs/link_mobility.rb,
lib/smess/outputs/card_board_fish.rb,
lib/smess/outputs/twilio_whatsapp.rb

Defined Under Namespace

Modules: Logging Classes: Auto, CardBoardFish, Clickatell, Config, GlobalMouth, HttpBase, LinkMobility, Output, Sms, Smsglobal, Test, Twilio, TwilioWhatsapp

Constant Summary collapse

VERSION =
'3.2.0'

Class Method Summary collapse

Class Method Details

.booleanize(value) ⇒ Object



6
7
8
# File 'lib/smess/utils.rb', line 6

def booleanize(value)
  value.to_s.downcase == "true"
end

.configObject



38
39
40
# File 'lib/smess.rb', line 38

def self.config
  @config ||= Config.new
end

.configure {|config| ... } ⇒ Object

Yields:



46
47
48
# File 'lib/smess.rb', line 46

def self.configure
  yield(config)
end

.named_output_instance(name) ⇒ Object



32
33
34
35
36
# File 'lib/smess.rb', line 32

def self.named_output_instance(name)
  output_class_name = config.configured_outputs.fetch(name)[:type].to_s.camelize
  conf = config.configured_outputs[name][:config]
  "Smess::#{output_class_name}".constantize.new(conf)
end

.new(*args) ⇒ Object



28
29
30
# File 'lib/smess.rb', line 28

def self.new(*args)
  Sms.new(*args)
end

.reset_configObject



42
43
44
# File 'lib/smess.rb', line 42

def self.reset_config
  @config = Config.new
end

.separate_sms(text) ⇒ Object

returns an array of strings of <160 char lengths, split on whitespace this should be used when sending via non-concatenating providers



34
35
36
37
38
39
40
41
42
# File 'lib/smess/utils.rb', line 34

def separate_sms(text)
  return [text] unless text.sms_length > SMS_MAX_LENGTH
  result = []
  while text.sms_length > SMS_MAX_LENGTH
    part, text = text.split_at( separation_point(text) )
    result << part.strip
  end
  result << text.strip
end

.split_sms(text) ⇒ Object

returns an array of strings of gsm-compatible lengths this should be used when sending via concatenating providers



12
13
14
15
16
17
18
19
20
21
# File 'lib/smess/utils.rb', line 12

def split_sms(text)
  return [text] unless text.sms_length > 160
  result = []

  while text.sms_length > 0
    part, text = text.split_at( split_point(text) )
    result << part
  end
  result
end