rumour-ruby 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6dce269781a3e3baca936962fd4bc3a5361e5e24
4
+ data.tar.gz: 49b07e0be76d9e1d86d1fe1761fbb1d6aa2d0a57
5
+ SHA512:
6
+ metadata.gz: e9a5ef57ce68307f6ebedd489313994a084ebaeb7250a809ae4ad68f26b83dc0caf4ed89782b3cbaa430de78c3b30612356423cf7efcf1224f6bfb674abec7cc
7
+ data.tar.gz: dbf604cbb49de4dcee5101ad05636f119ef007e39fb146c410593a537f32b655b74210a57e24ae0e34fac883cb9d7e547c8b7a331506176de44c144b9938230a
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ *.gem
15
+ mkmf.log
16
+ *.sublime-project
17
+ *.sublime-workspace
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ require: rubocop-rspec
2
+
3
+ Documentation:
4
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rumour-ruby.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Rumour
2
+
3
+ Rumour is a Ruby wrapper to communicate with Rumour REST API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rumour-ruby'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rumour-ruby
20
+
21
+ ## Requirements
22
+
23
+ To communicate with Rumour REST API you will need a Rumour account.
24
+
25
+ ## Usage
26
+
27
+ First, initialize a client:
28
+ ```ruby
29
+ access_token = 'your_rumour_access_token'
30
+
31
+ rumour = Rumour::Client.new(access_token)
32
+ ```
33
+
34
+ Then, send a text message:
35
+ ```ruby
36
+ from = '+15005550006'
37
+ recipient = '+15005550005'
38
+
39
+ rumour.send_text_message()
40
+ #=> {'id' => '1', 'from' => '+15005550006', 'recipient' => '+15005550005', ... }
41
+ ```
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it ( https://github.com/joaodiogocosta/rumour-ruby/fork )
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,40 @@
1
+ require 'httparty'
2
+ require 'json'
3
+ require 'base64'
4
+ require 'forwardable'
5
+
6
+ module Rumour
7
+ class Client
8
+ include HTTParty
9
+ base_uri 'rumour.herokuapp.com/api/v1'
10
+
11
+ attr_accessor :access_token
12
+
13
+ def initialize(access_token = nil)
14
+ @access_token = access_token || Rumour.configuration.access_token
15
+ end
16
+
17
+ def send_text_message(sender, recipient, body)
18
+ post('/text_messages', text_message: { from: sender, recipient: recipient, body: body })
19
+ end
20
+
21
+ def deliver_push_notification(platform, recipient, data)
22
+ post('/push_notifications', platform: platform, recipient: recipient, data: data)
23
+ end
24
+
25
+ private
26
+
27
+ def post(url, params = {}, headers = {})
28
+ response = self.class.post(url, query: params, headers: headers.merge(auth_header))
29
+ JSON.parse(response.body)
30
+ end
31
+
32
+ def auth_header
33
+ { 'Authorization' => "Bearer #{credentials}" }
34
+ end
35
+
36
+ def credentials
37
+ Base64.urlsafe_encode64(@access_token)
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,22 @@
1
+ module Rumour
2
+ class Configuration
3
+ CONFIGURABLE_ATTRIBUTES = [
4
+ :api_key,
5
+ :access_token
6
+ ]
7
+
8
+ attr_accessor *CONFIGURABLE_ATTRIBUTES
9
+
10
+ def initialize
11
+ # Nothing to do
12
+ end
13
+ end
14
+
15
+ def self.configuration
16
+ @configuration ||= Configuration.new
17
+ end
18
+
19
+ def self.configure
20
+ yield configuration
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Rumour
2
+ VERSION = '0.0.1'
3
+ end
data/lib/rumour.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'rumour-ruby/version'
2
+ require 'rumour-ruby/configuration'
3
+ require 'rumour-ruby/client'
4
+
5
+ module Rumour
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rumour-ruby/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rumour-ruby"
8
+ spec.version = Rumour::VERSION
9
+ spec.authors = ["Joao Diogo Costa"]
10
+ spec.email = ["joaodiogocosta@redlightsoft.com"]
11
+ spec.summary = %q{Ruby wrapper for the Rumour REST API}
12
+ spec.description = %q{Use rumour-ruby to communicate with Rumour REST API}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'httparty', '~> 0.13.3'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ RUMOUR_TEST_ACCESS_TOKEN = '13b91294f69c5e6046274d249911c275e21e013e'
4
+ TWILIO_TEST_SENDER_NUMBER = '+15005550006'
5
+ TWILIO_TEST_RECIPIENT_NUMBER = '+14108675309'
6
+
7
+ Rumour.configure do |config|
8
+ config.access_token = 'CONFIGURED_ACCESS_TOKEN'
9
+ end
10
+
11
+ RSpec.describe Rumour::Client do
12
+
13
+ describe '.new' do
14
+ it 'sets the authentication credentials' do
15
+ rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
16
+
17
+ expect(rumour_client.access_token).to eq(RUMOUR_TEST_ACCESS_TOKEN)
18
+ end
19
+
20
+ it 'falls back to the configuration credentials' do
21
+ rumour_client = Rumour::Client.new
22
+
23
+ expect(rumour_client.access_token).to eq('CONFIGURED_ACCESS_TOKEN')
24
+ end
25
+ end
26
+
27
+ describe '.send_text_message with valid data' do
28
+ it 'creates and retrieves a new message as a hash' do
29
+ rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
30
+ text_message = rumour_client.send_text_message(TWILIO_TEST_SENDER_NUMBER, TWILIO_TEST_RECIPIENT_NUMBER, 'Hello from rumour-ruby!')
31
+
32
+ expect(text_message['id']).to_not be_nil
33
+ end
34
+ end
35
+
36
+ describe '.send_text_message with invalid data' do
37
+ it 'creates and retrieves a new message as a hash' do
38
+ rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
39
+ text_message = rumour_client.send_text_message('+351123456789', '+351123456789', 'Hello from rumour-ruby!')
40
+
41
+ expect(text_message['message']).to_not be_nil
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Rumour do
4
+ describe '.configure' do
5
+ before do
6
+ described_class.configure do |config|
7
+ config.api_key = 'some_api_key'
8
+ config.access_token = 'some_access_token'
9
+ end
10
+ end
11
+
12
+ it 'assigns the authentication credentials' do
13
+ expect(described_class.configuration.api_key).to eq('some_api_key')
14
+ expect(described_class.configuration.access_token).to eq('some_access_token')
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ require 'rumour'
2
+ # require "codeclimate-test-reporter"
3
+ # CodeClimate::TestReporter.start
4
+
5
+ RSpec.configure do |config|
6
+ config.expect_with :rspec do |expectations|
7
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
8
+ end
9
+
10
+ config.mock_with :rspec do |mocks|
11
+ mocks.verify_partial_doubles = true
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rumour-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joao Diogo Costa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.13.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.13.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Use rumour-ruby to communicate with Rumour REST API
56
+ email:
57
+ - joaodiogocosta@redlightsoft.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".rubocop.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - lib/rumour-ruby/client.rb
70
+ - lib/rumour-ruby/configuration.rb
71
+ - lib/rumour-ruby/version.rb
72
+ - lib/rumour.rb
73
+ - rumour-ruby.gemspec
74
+ - spec/client_spec.rb
75
+ - spec/configuration_spec.rb
76
+ - spec/spec_helper.rb
77
+ homepage: ''
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.4.3
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Ruby wrapper for the Rumour REST API
101
+ test_files:
102
+ - spec/client_spec.rb
103
+ - spec/configuration_spec.rb
104
+ - spec/spec_helper.rb