agilibox 1.0.10 → 1.0.11
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/CHANGELOG.md +5 -0
- data/app/sms/agilibox/sms/application_sms.rb +42 -0
- data/app/sms/agilibox/sms/strategies/amazon_sns.rb +50 -0
- data/app/sms/agilibox/sms/strategies/base.rb +22 -0
- data/app/sms/agilibox/sms/strategies/test.rb +12 -0
- data/app/sms/agilibox/sms.rb +25 -0
- data/features/support/agilibox.rb +2 -0
- data/features/support/timecop.rb +3 -0
- data/lib/agilibox/rspec.rb +29 -0
- data/lib/agilibox/test_helpers.rb +13 -0
- data/lib/agilibox/version.rb +1 -1
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 626ceeea45261567ea302c0994021df65612a71c
|
4
|
+
data.tar.gz: 7f7134b4e26583e5daffb9610022822080c4a163
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5654e800ab7c2027bd499b04c7559969b8d4c94671b1fd4e4d88922da8d39a6bc2368072b8bb07428fbe4006c862fba17c7b8848cbd133f7d2c0ba1eff071e5f
|
7
|
+
data.tar.gz: 5b1be7380d0d7b9d33e40128d0cc827a52f430a7491fd075dc2e25c4abf961ff02ca3c824cc00047733c5e1c8640e3dad4ec1c7384a33d9f64871701401971cc
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
class Agilibox::SMS::ApplicationSMS
|
2
|
+
attr_reader :options
|
3
|
+
|
4
|
+
def initialize(options)
|
5
|
+
@options = options
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def action_name
|
11
|
+
options[:action_name]
|
12
|
+
end
|
13
|
+
|
14
|
+
def t(key, *args)
|
15
|
+
if key.start_with?(".")
|
16
|
+
path = self.class.to_s.underscore.tr("/", ".")
|
17
|
+
key = "#{path}.#{action_name}#{key}"
|
18
|
+
end
|
19
|
+
|
20
|
+
I18n.t(key, *args)
|
21
|
+
end
|
22
|
+
|
23
|
+
def sms(data)
|
24
|
+
Agilibox::SMS.strategy.new(data)
|
25
|
+
end
|
26
|
+
|
27
|
+
class << self
|
28
|
+
private :new
|
29
|
+
|
30
|
+
def method_missing(m, *args)
|
31
|
+
if respond_to_missing?(m)
|
32
|
+
new(action_name: m).public_send(m, *args)
|
33
|
+
else
|
34
|
+
super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def respond_to_missing?(m, *)
|
39
|
+
public_instance_methods.include?(m)
|
40
|
+
end
|
41
|
+
end # class << self
|
42
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class Agilibox::SMS::Strategies::AmazonSNS < Agilibox::SMS::Strategies::Base
|
2
|
+
class << self
|
3
|
+
attr_writer :region
|
4
|
+
|
5
|
+
def sns_region
|
6
|
+
@sns_region ||= (ENV["SNS_REGION"] || ENV["AWS_REGION"])
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_writer :access_key_id
|
10
|
+
|
11
|
+
def sns_access_key_id
|
12
|
+
@sns_access_key_id ||= (ENV["SNS_ACCESS_KEY_ID"] || ENV["AWS_ACCESS_KEY_ID"])
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_writer :secret_access_key
|
16
|
+
|
17
|
+
def sns_secret_access_key
|
18
|
+
@sns_secret_access_key ||= (ENV["SNS_SECRET_ACCESS_KEY"] || ENV["AWS_SECRET_ACCESS_KEY"])
|
19
|
+
end
|
20
|
+
end # class << self
|
21
|
+
|
22
|
+
def client
|
23
|
+
@client ||= Aws::SNS::Client.new(
|
24
|
+
:region => self.class.sns_region,
|
25
|
+
:access_key_id => self.class.sns_access_key_id,
|
26
|
+
:secret_access_key => self.class.sns_secret_access_key,
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def call
|
33
|
+
from = data[:from] || Agilibox::SMS.default_from
|
34
|
+
|
35
|
+
client.publish(
|
36
|
+
:phone_number => data[:to],
|
37
|
+
:message => data[:body],
|
38
|
+
:message_attributes => {
|
39
|
+
"AWS.SNS.SMS.SenderID" => {
|
40
|
+
:data_type => "String",
|
41
|
+
:string_value => from,
|
42
|
+
},
|
43
|
+
"AWS.SNS.SMS.SMSType" => {
|
44
|
+
:data_type => "String",
|
45
|
+
:string_value => "Transactional",
|
46
|
+
},
|
47
|
+
},
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Agilibox::SMS::Strategies::Base
|
2
|
+
attr_reader :data
|
3
|
+
|
4
|
+
def initialize(data)
|
5
|
+
@data = data
|
6
|
+
end
|
7
|
+
|
8
|
+
def deliver_now
|
9
|
+
call
|
10
|
+
end
|
11
|
+
|
12
|
+
# TODO : Delay
|
13
|
+
def deliver_later
|
14
|
+
deliver_now
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def call
|
20
|
+
raise NotImplementedError
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Agilibox::SMS
|
2
|
+
class << self
|
3
|
+
attr_writer :strategy
|
4
|
+
|
5
|
+
def strategy
|
6
|
+
@strategy ||= default_strategy
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_writer :default_from
|
10
|
+
|
11
|
+
def default_from
|
12
|
+
@default_from ||= Rails.application.class.to_s.chomp("::Application")
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def default_strategy
|
18
|
+
if Rails.env.development? || Rails.env.test?
|
19
|
+
Agilibox::SMS::Strategies::Test
|
20
|
+
else
|
21
|
+
Agilibox::SMS::Strategies::AmazonSNS
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end # class << self
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative "test_helpers"
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.include Agilibox::TestHelpers
|
5
|
+
|
6
|
+
if defined?(FactoryBot)
|
7
|
+
config.include FactoryBot::Syntax::Methods
|
8
|
+
end
|
9
|
+
|
10
|
+
if defined?(FactoryGirl)
|
11
|
+
warn "Please replace FactoryGirl by FactoryBot"
|
12
|
+
config.include FactoryGirl::Syntax::Methods
|
13
|
+
end
|
14
|
+
|
15
|
+
if defined?(Devise)
|
16
|
+
config.include Devise::Test::ControllerHelpers, type: :controller
|
17
|
+
end
|
18
|
+
|
19
|
+
config.after(:each) { Timecop.return }
|
20
|
+
end
|
21
|
+
|
22
|
+
Shoulda::Matchers.configure do |config|
|
23
|
+
config.integrate do |with|
|
24
|
+
with.test_framework :rspec
|
25
|
+
with.library :rails
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Zonebie.set_random_timezone
|
data/lib/agilibox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agilibox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- agilidée
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails-i18n
|
@@ -117,6 +117,11 @@ files:
|
|
117
117
|
- app/serializers/agilibox/serializers.rb
|
118
118
|
- app/serializers/agilibox/serializers/base.rb
|
119
119
|
- app/serializers/agilibox/serializers/xlsx.rb
|
120
|
+
- app/sms/agilibox/sms.rb
|
121
|
+
- app/sms/agilibox/sms/application_sms.rb
|
122
|
+
- app/sms/agilibox/sms/strategies/amazon_sns.rb
|
123
|
+
- app/sms/agilibox/sms/strategies/base.rb
|
124
|
+
- app/sms/agilibox/sms/strategies/test.rb
|
120
125
|
- app/sorters/agilibox/sorter.rb
|
121
126
|
- app/views/agilibox/forms/_checkboxes_dropdown.html.slim
|
122
127
|
- app/views/agilibox/search/_form.html.slim
|
@@ -132,6 +137,7 @@ files:
|
|
132
137
|
- config/locales/errors.fr.yml
|
133
138
|
- config/routes.rb
|
134
139
|
- db/migrate/20170502143330_enable_unaccent.rb
|
140
|
+
- features/support/agilibox.rb
|
135
141
|
- features/support/ajax.rb
|
136
142
|
- features/support/database_cleaner.rb
|
137
143
|
- features/support/env.rb
|
@@ -144,6 +150,7 @@ files:
|
|
144
150
|
- features/support/select2.rb
|
145
151
|
- features/support/sign_in.rb
|
146
152
|
- features/support/simplecov.rb
|
153
|
+
- features/support/timecop.rb
|
147
154
|
- features/support/turbolinks.rb
|
148
155
|
- features/support/zonebie.rb
|
149
156
|
- lib/agilibox.rb
|
@@ -153,6 +160,8 @@ files:
|
|
153
160
|
- lib/agilibox/engine.rb
|
154
161
|
- lib/agilibox/engine_file.rb
|
155
162
|
- lib/agilibox/form_back_url.rb
|
163
|
+
- lib/agilibox/rspec.rb
|
164
|
+
- lib/agilibox/test_helpers.rb
|
156
165
|
- lib/agilibox/version.rb
|
157
166
|
- lib/tasks/agilibox_tasks.rake
|
158
167
|
- lib/tasks/cucumber.rake
|