twilio_send_sms 0.0.0 → 0.0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aaf631a5afccc635ab7e7ce71b41a933727e03e0
4
- data.tar.gz: d87c8d198ed4c8035a74480181ec0f2a00a0a501
3
+ metadata.gz: 744d18690f5302718e7f4f61ba4c58eae91c84ec
4
+ data.tar.gz: 91cd29c511dbe81a4bd75102f20234184e184b18
5
5
  SHA512:
6
- metadata.gz: 0392725f8880754652e388d17b95e7f63ce479db69c1ea80a45321a45301c2452ac466c1844c353b6dc9e1ccf628503042edd41feece7056efd93d43a5b83786
7
- data.tar.gz: 979a7e1fca1eb6f3a90a6ce2171689ba2e51158186b3756e008672c5a5ad8ea0d22db99362e07dd0a3f838300c476a0471ad6530f4b729abc220a0a3923f0f40
6
+ metadata.gz: 2a16ff0fe3f73077696b7175986fccea4ae16ac547f1138a6ff6db9b6099477dd0b49cd56b910ab3b63c4a9a4e62cd6f9b960dfbe9d61452b7d916079cf5d1c8
7
+ data.tar.gz: 1dab7b53acc9dcce42c356bfe0724a53e84dda920792a4e2a21d51ce1481353b68e48b694b6e136a881ae0efba3aa595d0872485d38dfff609bce1c56eaa3127
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'twilio_send_sms'
4
+ require 'optparse'
5
+ require 'yaml'
6
+ require 'active_support/core_ext/hash'
7
+
8
+ command_line_options = {}
9
+
10
+ ARGV << '-h' if ARGV.empty?
11
+
12
+ OptionParser.new do |o|
13
+ o.banner = 'Usage: twilio_send_sms [options]' << "\n"
14
+
15
+ o.banner << 'Keys listed below should go to ~/.twilio_send_sms.yml'
16
+
17
+ o.on(
18
+ '-i value',
19
+ '--account-sid=value',
20
+ 'Twilio Account SID. key: :account_sid '
21
+ ) do |x|
22
+ command_line_options[ :account_sid ] = x
23
+ end
24
+
25
+ o.on(
26
+ '-p value',
27
+ '--auth-token=value',
28
+ 'Twilio Auth Token. key: :auth_token'
29
+ ) do |x|
30
+ command_line_options[ :auth_token ] = x
31
+ end
32
+
33
+ o.on(
34
+ '-m value',
35
+ '--message=value',
36
+ 'Message'
37
+ ) do |x|
38
+ command_line_options[ :message_body ] = x
39
+ end
40
+
41
+ o.on(
42
+ '-f value',
43
+ '--from=value',
44
+ 'From Phone Number. key: :message_from'
45
+ ) do |x|
46
+ command_line_options[ :message_from ] = x
47
+ end
48
+
49
+ o.on(
50
+ '-t value',
51
+ '--to=value',
52
+ 'To Phone Number. key: :message_to'
53
+ ) do |x|
54
+ command_line_options[ :message_to ] = x
55
+ end
56
+
57
+ o.on( '-h', '--help', 'Show this message' ) do
58
+ puts o
59
+
60
+ exit
61
+ end
62
+
63
+ end.parse!
64
+
65
+ begin
66
+ config_file_options =
67
+ YAML.load_file( File.expand_path('$HOME/.twilio_send_sms.yml') )
68
+
69
+ rescue Errno::ENOENT
70
+ config_file_options = {}
71
+ end
72
+
73
+ options = config_file_options.
74
+ merge( command_line_options ).
75
+ with_indifferent_access
76
+
77
+ TwilioSendSms.send_sms( options )
@@ -1,5 +1,28 @@
1
+ require 'twilio-ruby'
2
+
1
3
  class TwilioSendSms
2
- def self.hi
3
- puts "hello from twilio_send_sms"
4
+ def self.send_sms(options)
5
+ @options = options
6
+
7
+ create_client
8
+
9
+ create_message
10
+ end
11
+
12
+ private
13
+
14
+ def self.create_client
15
+ @client = Twilio::REST::Client.new(
16
+ @options[ :account_sid ],
17
+ @options[ :auth_token ]
18
+ )
19
+ end
20
+
21
+ def self.create_message
22
+ @client.messages.create(
23
+ from: @options[ :message_from ],
24
+ to: @options[ :message_to ],
25
+ body: @options[ :message_body ]
26
+ )
4
27
  end
5
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio_send_sms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Griffiths
@@ -12,10 +12,12 @@ date: 2017-03-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Adds a command to send an sms from the command line
14
14
  email: lgcboulder@gmail.com
15
- executables: []
15
+ executables:
16
+ - twilio_send_sms
16
17
  extensions: []
17
18
  extra_rdoc_files: []
18
19
  files:
20
+ - bin/twilio_send_sms
19
21
  - lib/twilio_send_sms.rb
20
22
  homepage: https://rubygems.org/gems/twilio_send_sms
21
23
  licenses: