nexmo_rails 0.3.1 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42b972b8b6b429ac78f330b225042443a6ae3ae3cec31cebb32620fc5bbc0392
4
- data.tar.gz: 0ff3462241fe40883f7f8bc9f82596176746be7025365bc096b833a305158d00
3
+ metadata.gz: d34cdf077d1ddbc165e0c8e1885195f7a696af8122f45051c485b21ead088cc5
4
+ data.tar.gz: 530deeff982fc3c73d9aeb6224ccfafdbb7b2b9e29ca3e5065cc53bdf1f57e45
5
5
  SHA512:
6
- metadata.gz: eb39f0e1b88c4624c4665c96ee28dc70d1b241cf8336ea563da775f5cceacf1788264413494a5f62f35d9880d9fe376999a04d5f55cc7e1f76731361050b8d09
7
- data.tar.gz: b7cb08bd45c7e5fe5e3b1caccfd236c4efe3e6cf8d96dc08d0ee2bd143aac81abb98d68035046664edb0030836ad804a376bb5efdfee31ebd7e694a3feb3bee8
6
+ metadata.gz: ee22b9998fe67c8a4cc3ea49a4387b5c197840d3a9b8f746cfb753d2606233eb2257d65ecb18930ffe31a93156d2050dcf8fb47f5535717a1110083109ed2040
7
+ data.tar.gz: 0f8c71c2fb376727a08af72ec579ea5f691326f5154c1cd331d2c30a41084aa0b2ee930aa3772773deb9f373d8be6314577168c86f08ba29c107a9a25c3ddd68
data/README.md CHANGED
@@ -16,27 +16,27 @@ Nexmo Rails requires:
16
16
 
17
17
  * Rails 5.2+
18
18
  * Ruby 2.5.3+
19
- * [dotenv](https://github.com/bkeepers/dotenv)
20
19
  * To use the Nexmo APIs, you [need an account](https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=nexmo-rails)
21
20
 
22
21
  ## Installation
23
22
 
24
- To install the Nexmo Rails gem, add it, along with `dotenv-rails`, to your project's Gemfile:
23
+ To install the Nexmo Rails gem add it to your project's Gemfile:
25
24
 
26
25
  ```ruby
27
26
 
28
27
  gem 'nexmo_rails'
29
- gem 'dotenv-rails'
30
28
 
31
29
  ```
32
30
 
33
- The `dotenv-rails` gem assists with environment variable management and utilization.
34
-
35
31
  Then, run `bundle install` from the command line.
36
32
 
37
33
  ## Usage
38
34
 
39
- The Nexmo Rails gem will initialize a new instance of the Nexmo client inside your Rails application and make it globally accessible. To make this happen, first add the desired Nexmo credentials to your `.env` file. For example, if you are using only the `API_KEY` and `API_SECRET`, then add the following:
35
+ The Nexmo Rails gem will initialize a new instance of the Nexmo client inside your Rails application and make it globally accessible. To make this happen, you must supply it with your Nexmo API credentials. You can do so either as environemnt variables or as part of your Rails credentials.
36
+
37
+ ### With Environment Variables
38
+
39
+ To add your Nexmo API credentials as environment variables, first add the desired Nexmo credentials to your `.env` file. For example, if you are using only the `API_KEY` and `API_SECRET`, then add the following:
40
40
 
41
41
  ```
42
42
 
@@ -55,11 +55,37 @@ NEXMO_APPLICATION_ID = your_application_id
55
55
 
56
56
  ```
57
57
 
58
+ Make sure you have the `dotenv-rails` Gem installed in your application and that your `.env` file is included in `.gitignore` so as not to commit your credentials to version control.
59
+
60
+ ### With Rails Credentials
61
+
62
+ To add your Nexmo API credentials to your Rails Credentials, go ahead and open your encrypted credentials file with the following command:
63
+
64
+ ```console
65
+
66
+ $ EDITOR="code --wait" rails credentials:edit
67
+
68
+ ```
69
+
70
+ You can replace the `EDITOR` variable with your preferred editor. Once the credentials file is open, you are able to add the Nexmo credentials with the following namespacing:
71
+
72
+ ```yaml
73
+
74
+ nexmo:
75
+ api_key:
76
+ api_secret:
77
+
78
+ ```
79
+
80
+ You may add any of the Nexmo API credentials your application needs nested within the `nexmo:` namespace.
81
+
82
+ ### Running the Initializer
83
+
58
84
  To initialize your global Nexmo client in your application, run the following from your terminal:
59
85
 
60
86
  ```console
61
87
 
62
- rails generate nexmo_initializer
88
+ $ rails generate nexmo_initializer
63
89
 
64
90
  ```
65
91
 
data/Rakefile CHANGED
@@ -6,6 +6,8 @@ end
6
6
 
7
7
  require 'rdoc/task'
8
8
 
9
+ require 'rails/dummy/tasks'
10
+
9
11
  RDoc::Task.new(:rdoc) do |rdoc|
10
12
  rdoc.rdoc_dir = 'rdoc'
11
13
  rdoc.title = 'NexmoRails'
@@ -1,4 +1,4 @@
1
- require 'rails/generators'
1
+ require 'rails/all'
2
2
 
3
3
  class NexmoInitializerGenerator < Rails::Generators::Base
4
4
  source_root File.expand_path('../templates', __FILE__)
@@ -6,6 +6,29 @@ class NexmoInitializerGenerator < Rails::Generators::Base
6
6
  desc "This generator creates a Nexmo initializer file at config/initializers and makes a configured Nexmo client globally available"
7
7
 
8
8
  def create_nexmo_initializer
9
+ if Rails.application.credentials.nexmo
10
+ return credentials_initializer
11
+ end
12
+
13
+ env_initializer
14
+ end
15
+
16
+ private
17
+
18
+ def credentials_initializer
19
+ initializer "nexmo.rb" do <<~HEREDOC
20
+ Nexmo.setup do |config|
21
+ config.api_key = Rails.application.credentials.nexmo[:api_key],
22
+ config.api_secret = Rails.application.credentials.nexmo[:api_secret],
23
+ config.signature_secret = Rails.application.credentials.nexmo[:api_signature],
24
+ config.application_id = Rails.application.credentials.nexmo[:application_id],
25
+ config.private_key = Rails.application.credentials.nexmo[:private_key]
26
+ end
27
+ HEREDOC
28
+ end
29
+ end
30
+
31
+ def env_initializer
9
32
  initializer "nexmo.rb" do <<~HEREDOC
10
33
  Nexmo.setup do |config|
11
34
  config.api_key = ENV['NEXMO_API_KEY']
@@ -1,3 +1,3 @@
1
1
  module NexmoRails
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.1'
3
3
  end
data/lib/nexmo_rails.rb CHANGED
@@ -7,10 +7,11 @@ module Nexmo
7
7
 
8
8
  attr_accessor :client
9
9
 
10
- def_delegators :@client, :account, :alerts, :applications, :calls,
11
- :conversations, :conversions, :files, :messages,
12
- :numbers, :number_insight, :pricing, :redact,
13
- :secrets, :sms, :signature, :tfa, :verify
10
+ def_delegators :@client, :account, :alerts, :applications,
11
+ :applications_v2, :calls, :conversations,
12
+ :conversions, :files, :messages, :numbers,
13
+ :number_insight, :pricing, :redact, :secrets,
14
+ :sms, :signature, :tfa, :verify
14
15
 
15
16
  def setup(&block)
16
17
  config = OpenStruct.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexmo_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nexmo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-13 00:00:00.000000000 Z
11
+ date: 2019-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rails-dummy
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Rails Initializer for Nexmo's Ruby Client
84
98
  email:
85
99
  - devrel@nexmo.com