ai_noto 0.1.0 → 0.2.0

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: 96d4d11673a28b7006179b8a3c4a6657d28426b1
4
- data.tar.gz: cfa8d9c8076c6bb8c5696bb0ebee4660925f0cf2
3
+ metadata.gz: 2b46743ac21b9a239e8ec48c88d327754de46399
4
+ data.tar.gz: 1fc9f5fc1657147993278a909afc84a9001ed39e
5
5
  SHA512:
6
- metadata.gz: bf7ad78de4ff80b640ca3c1be3ce4460be6354cb06504c06fb9f121464afd6993cafc03f72d05a0604b81a7d336c5ff97673cdce0db51beb27acfc7c270bcabe
7
- data.tar.gz: d29517425e1892c905068de9a66db0f541cb8a2b607aea71f5e2d55022f0ea488b1fa5b9bc0b7f48a394d53c722d852a136b2bbaf96f3ac7e9d1ab92f4165d68
6
+ metadata.gz: 4114f3a7e595f6d6a0c9b5d22e8a4b0e59ffadc6b8ac709a3d6dba5c1987297b91deec7b70e92b83a31987711fba8752e10b0915a095bde3be6038ae31be8944
7
+ data.tar.gz: 02dc8fd0081a2e3bcad8bd058664933ca5b390bea216cdb4317cf7be5d3aa9724be202fc61d0e42996ce9806b7d7811e21f5ff861dc8ac39626eff57e4a25a63
data/.gitignore CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.travis.yml CHANGED
File without changes
data/CODE_OF_CONDUCT.md CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
@@ -3,8 +3,6 @@
3
3
 
4
4
  Ai Noto (Love Notes) lets you quickly send SMS messages from your CLI.
5
5
 
6
- TODO: Support multiple recipients
7
-
8
6
  ## Installation
9
7
 
10
8
  Add this line to your application's Gemfile:
@@ -34,7 +32,21 @@ Edit the `config.yml.dist` file with your Twilio credentials. Also
34
32
  make sure to provide a proper Twilio from_number then rename
35
33
  the sample dist file to `config.yml`
36
34
 
35
+
36
+ ### Set up recipients
37
+ In `config.yml` please ensure a default_recipient is filled in
38
+ You may also add specific recipients e.g.:
39
+ ```
40
+ "Foo": "+18001234567"
41
+ ```
42
+
37
43
  ### Send a new message
44
+ Send a message to Foo:
45
+ > ainoto new Foo "Hello World"
46
+
47
+ If no recipient is specified then it will send a message to
48
+ `default_recipient` in config.yml
49
+
38
50
  > ainoto new "hello world!"
39
51
 
40
52
  ## Development
data/Rakefile CHANGED
File without changes
data/ai_noto.gemspec CHANGED
File without changes
data/bin/setup CHANGED
File without changes
data/lib/ai_noto.rb CHANGED
@@ -2,8 +2,8 @@ require "twilio-ruby"
2
2
  require "yaml"
3
3
 
4
4
  module AiNoto
5
- def self.send(contents)
6
- Message.new(contents, twilio_client).send_sms!
5
+ def self.send(recipient, contents)
6
+ Message.new(contents, twilio_client, recipient).send_sms!
7
7
  end
8
8
 
9
9
  def self.twilio_client
@@ -18,12 +18,16 @@ module AiNoto
18
18
  config["twilio_auth_token"]]
19
19
  end
20
20
 
21
+ def self.default_recipient
22
+ YAML.load_file(config_file)["default_recipient"]
23
+ end
24
+
21
25
  def self.from_number
22
26
  YAML.load_file(config_file)["from_number"]
23
27
  end
24
28
 
25
- def self.to_number
26
- YAML.load_file(config_file)["to_number"]
29
+ def self.to_number(recipient = nil)
30
+ recipient = recipient.nil? ? default_recipient : YAML.load_file(config_file)[recipient]
27
31
  end
28
32
 
29
33
  def self.config
@@ -35,16 +39,17 @@ module AiNoto
35
39
  end
36
40
 
37
41
  class Message
38
- attr_accessor :contents, :twilio_client
42
+ attr_accessor :contents, :twilio_client, :recipient
39
43
 
40
- def initialize(contents, twilio_client)
44
+ def initialize(contents, twilio_client, recipient)
41
45
  @contents = contents
42
46
  @twilio_client = twilio_client
47
+ @recipient = recipient
43
48
  end
44
49
 
45
50
  def send_sms!
46
51
  twilio_client.api.account.messages.create(from: AiNoto.from_number,
47
- to: AiNoto.to_number,
52
+ to: AiNoto.to_number(recipient),
48
53
  body: contents)
49
54
  end
50
55
  end
@@ -1,3 +1,3 @@
1
1
  module AiNoto
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/ai_noto_cli.rb CHANGED
@@ -8,10 +8,10 @@ require 'byebug'
8
8
  class AiNotoCLI < Thor
9
9
  include AiNoto
10
10
 
11
- desc 'new "MESSAGE"', 'send a new "MESSAGE" to default person'
12
- def new(message)
13
- puts "Sending a message to #{AiNoto.to_number}"
14
- AiNoto.send(message)
11
+ desc 'new [recipient] "MESSAGE"', 'send a new "MESSAGE" to recipient'
12
+ def new(recipient=nil, message)
13
+ puts "Sending a message to #{AiNoto.to_number(recipient)}"
14
+ AiNoto.send(recipient, message)
15
15
  end
16
16
  end
17
17
 
data/lib/config.test.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  twilio_account_sid: '1234'
2
2
  twilio_auth_token: '1234'
3
3
  from_number: "+19045745217"
4
- to_number: "+18001234567"
4
+ default_recipient: "+18001234567"
5
+ "Ashley": "+18001112222"
data/lib/config.yml.dist CHANGED
@@ -2,3 +2,5 @@ from_number: "+18001234567"
2
2
  to_number: "+18001234567"
3
3
  twilio_account_sid: "enter your account sid"
4
4
  twilio_auth_token: "enter your auth token"
5
+ default_recipient: "+18001234567"
6
+ "John": "+18001112222"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ai_noto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sid Ngeth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-12 00:00:00.000000000 Z
11
+ date: 2017-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler