any_sms 0.3.0 → 0.4.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 +4 -4
- data/.rubocop.yml +4 -0
- data/.travis.yml +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +5 -8
- data/any_sms.gemspec +3 -3
- data/lib/any_sms/backend/base.rb +1 -1
- data/lib/any_sms/backend/logger.rb +2 -2
- data/lib/any_sms/backend/null_sender.rb +1 -1
- data/lib/any_sms/matchers/send_sms.rb +8 -7
- data/lib/any_sms/sending.rb +3 -2
- data/lib/any_sms/version.rb +1 -1
- metadata +16 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd201b20e9e6f5f8c4cbd818a78cf76cb2e375d7
|
4
|
+
data.tar.gz: e3cb1236b0ef59051cd464795ff8686c68a41cd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6218c8ad05efaccbe8243a4892e03e696ca4aa0bb239a3415f6c1997fcd306a30c02980a2f1641cb5e9cfccbce4e481ca9e554b1faec75debe1d2a7a26a91c66
|
7
|
+
data.tar.gz: bcc041dc093a9a18983c6314f92e1a756f5d2897c72884b8351e5b6f2cbb6bac633f6463a9ef394b3b598fdd2920d328345421721eb31ec9cda6e0e3dea6c1c3
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -3,18 +3,15 @@
|
|
3
3
|
[](https://travis-ci.org/Fedcomp/any_sms)
|
4
4
|
[](https://badge.fury.io/rb/any_sms)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
without having to rewrite any code that actually sends SMS.
|
9
|
-
Supports multiple backends.
|
10
|
-
Sending SMS is not pain anymore!
|
6
|
+
Simple and flexible solution to send sms in ruby,
|
7
|
+
supporting variety of sms services.
|
11
8
|
|
12
9
|
## Installation and usage
|
13
10
|
|
14
11
|
Add this line to your application's Gemfile:
|
15
12
|
|
16
13
|
```ruby
|
17
|
-
gem "any_sms"
|
14
|
+
gem "any_sms", "~> 0.4.0"
|
18
15
|
```
|
19
16
|
|
20
17
|
Then somewhere in your initialization code:
|
@@ -258,8 +255,8 @@ For now you may just mock `AnySMS.send_sms` and check it was executed.
|
|
258
255
|
Bug reports and pull requests are welcome on GitHub at https://github.com/Fedcomp/any_sms
|
259
256
|
|
260
257
|
## Submitting a Pull Request
|
261
|
-
1. Fork the [official repository](https://github.com/Fedcomp/any_sms).
|
262
|
-
2. Create a
|
258
|
+
1. Fork the [official repository](https://github.com/Fedcomp/any_sms/fork).
|
259
|
+
2. Create a feature/bugfix branch.
|
263
260
|
3. Implement your feature or bug fix.
|
264
261
|
4. Add, commit, and push your changes.
|
265
262
|
5. Submit a pull request.
|
data/any_sms.gemspec
CHANGED
@@ -8,7 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Fedcomp"]
|
9
9
|
spec.email = ["aglergen@gmail.com"]
|
10
10
|
|
11
|
-
spec.summary = "
|
11
|
+
spec.summary = "Simple and flexible solution to send sms in ruby, " \
|
12
|
+
"supporting variety of sms services."
|
12
13
|
|
13
14
|
spec.homepage = "https://github.com/Fedcomp/any_sms"
|
14
15
|
spec.license = "MIT"
|
@@ -26,13 +27,12 @@ Gem::Specification.new do |spec|
|
|
26
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
28
|
spec.require_paths = ["lib"]
|
28
29
|
|
29
|
-
spec.add_development_dependency "bundler", "~> 1.12"
|
30
30
|
spec.add_development_dependency "rake", "~> 10.0"
|
31
31
|
spec.add_development_dependency "rspec", "~> 3.0"
|
32
32
|
|
33
33
|
spec.add_development_dependency "guard", "~> 2.14"
|
34
34
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
35
|
+
spec.add_development_dependency "guard-yard"
|
35
36
|
spec.add_development_dependency "pry-byebug", "~> 3.4"
|
36
37
|
spec.add_development_dependency "rubocop"
|
37
|
-
spec.add_development_dependency "guard-yard"
|
38
38
|
end
|
data/lib/any_sms/backend/base.rb
CHANGED
@@ -16,7 +16,7 @@ module AnySMS::Backend
|
|
16
16
|
#
|
17
17
|
# @param _phone [String] Phone number to send sms (not used in this implementation)
|
18
18
|
# @param _text [String] Sms text (not used in this implementation)
|
19
|
-
def send_sms(_phone, _text)
|
19
|
+
def send_sms(_phone, _text, _args = {})
|
20
20
|
raise NotImplementedError,
|
21
21
|
"You should create your own class for every sms service you use"
|
22
22
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
class AnySMS::Backend::Logger < AnySMS::Backend::Base
|
3
3
|
# Log level validation, all invalid values lead to ArgumentError.
|
4
4
|
# Has anyone heard how to receive log levels from ruby logger itself?
|
5
|
-
LOG_SEVERITY = [
|
5
|
+
LOG_SEVERITY = %i[debug info warn error fatal unknown].freeze
|
6
6
|
|
7
7
|
# @param logger [::Logger] Class implementing logger interface
|
8
8
|
# @param severity [Symbol] Severity to log with
|
@@ -20,7 +20,7 @@ class AnySMS::Backend::Logger < AnySMS::Backend::Base
|
|
20
20
|
#
|
21
21
|
# @param phone [String] Phone number to send sms
|
22
22
|
# @param text [String] Sms text
|
23
|
-
def send_sms(phone, text)
|
23
|
+
def send_sms(phone, text, _args = {})
|
24
24
|
@logger.send(@severity, "[SMS] #{phone}: #{text}")
|
25
25
|
respond_with_status :success
|
26
26
|
end
|
@@ -5,7 +5,7 @@ class AnySMS::Backend::NullSender < AnySMS::Backend::Base
|
|
5
5
|
#
|
6
6
|
# @param _phone [String] Phone number to send sms (not used in this implementation)
|
7
7
|
# @param _text [String] Sms text (not used in this implementation)
|
8
|
-
def send_sms(_phone, _text)
|
8
|
+
def send_sms(_phone, _text, _args = {})
|
9
9
|
respond_with_status :success
|
10
10
|
end
|
11
11
|
end
|
@@ -38,13 +38,13 @@ RSpec::Matchers.define :send_sms do |options|
|
|
38
38
|
failure_message do
|
39
39
|
message = "expected block to send "
|
40
40
|
|
41
|
-
if @phone && @text
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
message += if @phone && @text
|
42
|
+
"sms message" \
|
43
|
+
" to phone number \"#{@phone}\"" \
|
44
|
+
" with text \"#{@text}\""
|
45
|
+
else
|
46
|
+
"any sms message"
|
47
|
+
end
|
48
48
|
|
49
49
|
"#{message}, nothing was sent"
|
50
50
|
end
|
@@ -66,3 +66,4 @@ RSpec::Matchers.define :send_sms do |options|
|
|
66
66
|
@result ||= AnySMS::Response.new(status: :success)
|
67
67
|
end
|
68
68
|
end
|
69
|
+
# rubocop:enable Metrics/BlockLength
|
data/lib/any_sms/sending.rb
CHANGED
@@ -5,11 +5,12 @@ module AnySMS
|
|
5
5
|
#
|
6
6
|
# @param phone [String] Phone number for sms
|
7
7
|
# @param text [String] Text for sms
|
8
|
-
# @param
|
8
|
+
# @param backend [Symbol] Keyword argument to specify non-default backend
|
9
|
+
# @param args [Hash] Additional options for delivery bypassed to final backend
|
9
10
|
def send_sms(phone, text, args = {})
|
10
11
|
backend_name = args.delete(:backend)
|
11
12
|
backend_class(backend_name).new(backend_params(backend_name))
|
12
|
-
.send_sms(phone, text)
|
13
|
+
.send_sms(phone, text, args)
|
13
14
|
end
|
14
15
|
|
15
16
|
private
|
data/lib/any_sms/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: any_sms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fedcomp
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.12'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.12'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rake
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,35 +67,35 @@ dependencies:
|
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '4.7'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: guard-yard
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- - "
|
73
|
+
- - ">="
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
75
|
+
version: '0'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
|
-
- - "
|
80
|
+
- - ">="
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
82
|
+
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
84
|
+
name: pry-byebug
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
|
-
- - "
|
87
|
+
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
89
|
+
version: '3.4'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
|
-
- - "
|
94
|
+
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
96
|
+
version: '3.4'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
98
|
+
name: rubocop
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - ">="
|
@@ -169,8 +155,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
155
|
version: '0'
|
170
156
|
requirements: []
|
171
157
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.6.8
|
173
159
|
signing_key:
|
174
160
|
specification_version: 4
|
175
|
-
summary:
|
161
|
+
summary: Simple and flexible solution to send sms in ruby, supporting variety of sms
|
162
|
+
services.
|
176
163
|
test_files: []
|