twilio_base 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +82 -0
  5. data/.ruby-version +1 -0
  6. data/.tool-versions +1 -0
  7. data/Gemfile +8 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +142 -0
  10. data/Rakefile +12 -0
  11. data/app/controllers/twilio_base/base_controller.rb +32 -0
  12. data/app/models/twilio_base/global_config.rb +5 -0
  13. data/app/services/twilio_base/api_key.rb +15 -0
  14. data/app/services/twilio_base/application.rb +29 -0
  15. data/app/services/twilio_base/clients.rb +37 -0
  16. data/app/services/twilio_base/phone_number.rb +40 -0
  17. data/app/services/twilio_base/protocols/voice/base.rb +65 -0
  18. data/app/services/twilio_base/protocols/voice/pstn.rb +13 -0
  19. data/app/services/twilio_base/protocols/voice/sip.rb +48 -0
  20. data/app/services/twilio_base/protocols/voice.rb +24 -0
  21. data/app/services/twilio_base/request_verification_service.rb +21 -0
  22. data/app/services/twilio_base/routers/voice/base.rb +44 -0
  23. data/app/services/twilio_base/routers/voice/default.rb +24 -0
  24. data/app/services/twilio_base/routers/voice/direct_dial.rb +10 -0
  25. data/app/services/twilio_base/routers/voice/task_router.rb +34 -0
  26. data/app/services/twilio_base/sync/service.rb +18 -0
  27. data/app/services/twilio_base/task_router/activity.rb +49 -0
  28. data/app/services/twilio_base/task_router/base.rb +17 -0
  29. data/app/services/twilio_base/task_router/task.rb +33 -0
  30. data/app/services/twilio_base/task_router/task_queue.rb +40 -0
  31. data/app/services/twilio_base/task_router/worker.rb +27 -0
  32. data/app/services/twilio_base/task_router/workflow.rb +22 -0
  33. data/app/services/twilio_base/task_router/workspace.rb +51 -0
  34. data/bin/console +8 -0
  35. data/bin/rails +14 -0
  36. data/bin/setup +6 -0
  37. data/circle.yml +36 -0
  38. data/config/locales/en.yml +2 -0
  39. data/config/routes.rb +4 -0
  40. data/db/migrate/20171214105252_create_twilio_base_global_configs.rb +18 -0
  41. data/lib/twilio_base/engine.rb +7 -0
  42. data/lib/twilio_base/helpers/protocols.rb +12 -0
  43. data/lib/twilio_base/version.rb +5 -0
  44. data/lib/twilio_base.rb +11 -0
  45. data/spec/factories/channel_sid.rb +7 -0
  46. data/spec/factories/chat_member_id.rb +7 -0
  47. data/spec/factories/global_config/activity_sid.rb +7 -0
  48. data/spec/factories/global_config/api_key_secret.rb +7 -0
  49. data/spec/factories/global_config/api_key_sid.rb +7 -0
  50. data/spec/factories/global_config/application_sid.rb +7 -0
  51. data/spec/factories/global_config/chat_service_sid.rb +7 -0
  52. data/spec/factories/global_config/conference_sid.rb +7 -0
  53. data/spec/factories/global_config/message_sid.rb +7 -0
  54. data/spec/factories/global_config/phone_number.rb +7 -0
  55. data/spec/factories/global_config/recording_sid.rb +7 -0
  56. data/spec/factories/global_config/sync_service_sid.rb +7 -0
  57. data/spec/factories/global_config/task_sid.rb +7 -0
  58. data/spec/factories/global_config/voice_call_sid.rb +7 -0
  59. data/spec/factories/global_config/worker_sid.rb +7 -0
  60. data/spec/factories/global_config/workflow_sid.rb +7 -0
  61. data/spec/factories/global_config/workspace_sid.rb +7 -0
  62. data/spec/factories/global_configs.rb +28 -0
  63. data/spec/lib/twilio_base/helpers/protocols_spec.rb +49 -0
  64. data/spec/services/twilio_base/api_key_spec.rb +17 -0
  65. data/spec/services/twilio_base/application_spec.rb +31 -0
  66. data/spec/services/twilio_base/phone_number_spec.rb +49 -0
  67. data/spec/services/twilio_base/protocols/voice/base_spec.rb +134 -0
  68. data/spec/services/twilio_base/protocols/voice/pstn_spec.rb +13 -0
  69. data/spec/services/twilio_base/protocols/voice/sip_spec.rb +104 -0
  70. data/spec/services/twilio_base/protocols/voice_spec.rb +48 -0
  71. data/spec/services/twilio_base/request_verification_service_spec.rb +105 -0
  72. data/spec/services/twilio_base/routers/voice/base_spec.rb +91 -0
  73. data/spec/services/twilio_base/routers/voice/default_spec.rb +59 -0
  74. data/spec/services/twilio_base/routers/voice/task_router_spec.rb +63 -0
  75. data/spec/services/twilio_base/sync/service.rb +25 -0
  76. data/spec/services/twilio_base/task_router/activity_spec.rb +68 -0
  77. data/spec/services/twilio_base/task_router/task_queue_spec.rb +114 -0
  78. data/spec/services/twilio_base/task_router/worker_spec.rb +49 -0
  79. data/spec/services/twilio_base/task_router/workflow_spec.rb +37 -0
  80. data/spec/spec_helper.rb +68 -0
  81. data/spec/support/factory_bot.rb +9 -0
  82. data/spec/support/shared_contexts/global_config.rb +6 -0
  83. data/spec/support/shared_contexts/twilio_controller.rb +7 -0
  84. data/spec/support/twilio_base/fake/api_key.rb +26 -0
  85. data/spec/support/twilio_base/fake/application.rb +59 -0
  86. data/spec/support/twilio_base/fake/available_phone_number.rb +29 -0
  87. data/spec/support/twilio_base/fake/chat/channel.rb +63 -0
  88. data/spec/support/twilio_base/fake/chat/client.rb +40 -0
  89. data/spec/support/twilio_base/fake/chat/member.rb +27 -0
  90. data/spec/support/twilio_base/fake/chat/message.rb +47 -0
  91. data/spec/support/twilio_base/fake/chat/service.rb +52 -0
  92. data/spec/support/twilio_base/fake/clients/rest.rb +84 -0
  93. data/spec/support/twilio_base/fake/clients/sms.rb +27 -0
  94. data/spec/support/twilio_base/fake/conference.rb +48 -0
  95. data/spec/support/twilio_base/fake/flex_flow.rb +36 -0
  96. data/spec/support/twilio_base/fake/helpers.rb +38 -0
  97. data/spec/support/twilio_base/fake/incoming_phone_number.rb +46 -0
  98. data/spec/support/twilio_base/fake/lookup/client.rb +29 -0
  99. data/spec/support/twilio_base/fake/lookup/phone_number.rb +34 -0
  100. data/spec/support/twilio_base/fake/notify/binding.rb +41 -0
  101. data/spec/support/twilio_base/fake/notify/notification.rb +40 -0
  102. data/spec/support/twilio_base/fake/notify/segment_membership.rb +17 -0
  103. data/spec/support/twilio_base/fake/notify/user.rb +30 -0
  104. data/spec/support/twilio_base/fake/notify/v1.rb +33 -0
  105. data/spec/support/twilio_base/fake/proxy.rb +30 -0
  106. data/spec/support/twilio_base/fake/recording.rb +44 -0
  107. data/spec/support/twilio_base/fake/sync/client.rb +17 -0
  108. data/spec/support/twilio_base/fake/sync/service.rb +78 -0
  109. data/spec/support/twilio_base/fake/sync/services/document.rb +50 -0
  110. data/spec/support/twilio_base/fake/sync/services/list.rb +50 -0
  111. data/spec/support/twilio_base/fake/sync/services/lists/item.rb +48 -0
  112. data/spec/support/twilio_base/fake/sync/services/map.rb +50 -0
  113. data/spec/support/twilio_base/fake/sync/services/maps/item.rb +54 -0
  114. data/spec/support/twilio_base/fake/task_router/activity.rb +34 -0
  115. data/spec/support/twilio_base/fake/task_router/channel.rb +40 -0
  116. data/spec/support/twilio_base/fake/task_router/client.rb +31 -0
  117. data/spec/support/twilio_base/fake/task_router/statistic.rb +38 -0
  118. data/spec/support/twilio_base/fake/task_router/task.rb +80 -0
  119. data/spec/support/twilio_base/fake/task_router/task_queue.rb +46 -0
  120. data/spec/support/twilio_base/fake/task_router/worker.rb +64 -0
  121. data/spec/support/twilio_base/fake/task_router/workflow.rb +54 -0
  122. data/spec/support/twilio_base/fake/task_router/workspace.rb +83 -0
  123. data/spec/support/twilio_base/fake/voice_call.rb +54 -0
  124. data/spec/support/twilio_base/responses/twiml.rb +29 -0
  125. data/spec/twilio_base_dummy/.gitignore +21 -0
  126. data/spec/twilio_base_dummy/Rakefile +5 -0
  127. data/spec/twilio_base_dummy/app/assets/config/manifest.js +0 -0
  128. data/spec/twilio_base_dummy/app/channels/application_cable/channel.rb +6 -0
  129. data/spec/twilio_base_dummy/app/channels/application_cable/connection.rb +6 -0
  130. data/spec/twilio_base_dummy/app/controllers/application_controller.rb +5 -0
  131. data/spec/twilio_base_dummy/app/controllers/concerns/.keep +0 -0
  132. data/spec/twilio_base_dummy/app/helpers/application_helper.rb +4 -0
  133. data/spec/twilio_base_dummy/bin/bundle +5 -0
  134. data/spec/twilio_base_dummy/bin/rails +11 -0
  135. data/spec/twilio_base_dummy/bin/rake +11 -0
  136. data/spec/twilio_base_dummy/bin/setup +36 -0
  137. data/spec/twilio_base_dummy/bin/spring +18 -0
  138. data/spec/twilio_base_dummy/bin/update +31 -0
  139. data/spec/twilio_base_dummy/config/application.rb +13 -0
  140. data/spec/twilio_base_dummy/config/boot.rb +7 -0
  141. data/spec/twilio_base_dummy/config/cable.yml +5 -0
  142. data/spec/twilio_base_dummy/config/database.example.yml +13 -0
  143. data/spec/twilio_base_dummy/config/environment.rb +5 -0
  144. data/spec/twilio_base_dummy/config/environments/development.rb +28 -0
  145. data/spec/twilio_base_dummy/config/environments/test.rb +17 -0
  146. data/spec/twilio_base_dummy/config/initializers/application_controller_renderer.rb +1 -0
  147. data/spec/twilio_base_dummy/config/initializers/assets.rb +3 -0
  148. data/spec/twilio_base_dummy/config/initializers/backtrace_silencers.rb +1 -0
  149. data/spec/twilio_base_dummy/config/initializers/cookies_serializer.rb +3 -0
  150. data/spec/twilio_base_dummy/config/initializers/filter_parameter_logging.rb +3 -0
  151. data/spec/twilio_base_dummy/config/initializers/inflections.rb +1 -0
  152. data/spec/twilio_base_dummy/config/initializers/mime_types.rb +1 -0
  153. data/spec/twilio_base_dummy/config/initializers/new_framework_defaults.rb +9 -0
  154. data/spec/twilio_base_dummy/config/initializers/session_store.rb +3 -0
  155. data/spec/twilio_base_dummy/config/initializers/wrap_parameters.rb +5 -0
  156. data/spec/twilio_base_dummy/config/locales/en.yml +23 -0
  157. data/spec/twilio_base_dummy/config/puma.rb +7 -0
  158. data/spec/twilio_base_dummy/config/routes.rb +5 -0
  159. data/spec/twilio_base_dummy/config/secrets.yml +10 -0
  160. data/spec/twilio_base_dummy/config/spring.rb +8 -0
  161. data/spec/twilio_base_dummy/config.ru +7 -0
  162. data/spec/twilio_base_dummy/db/schema.rb +31 -0
  163. data/spec/twilio_base_dummy/db/seeds.rb +1 -0
  164. data/spec/twilio_base_dummy/lib/assets/.keep +0 -0
  165. data/spec/twilio_base_dummy/lib/tasks/.keep +0 -0
  166. data/spec/twilio_base_dummy/log/.keep +0 -0
  167. data/spec/twilio_base_dummy/public/404.html +67 -0
  168. data/spec/twilio_base_dummy/public/422.html +67 -0
  169. data/spec/twilio_base_dummy/public/500.html +66 -0
  170. data/spec/twilio_base_dummy/public/apple-touch-icon-precomposed.png +0 -0
  171. data/spec/twilio_base_dummy/public/apple-touch-icon.png +0 -0
  172. data/spec/twilio_base_dummy/public/favicon.ico +0 -0
  173. data/spec/twilio_base_dummy/public/robots.txt +5 -0
  174. data/spec/twilio_base_dummy/tmp/.keep +0 -0
  175. data/spec/twilio_base_dummy/vendor/assets/javascripts/.keep +0 -0
  176. data/spec/twilio_base_dummy/vendor/assets/stylesheets/.keep +0 -0
  177. data/spec/twilio_base_spec.rb +7 -0
  178. data/twilio_base.gemspec +45 -0
  179. metadata +580 -0
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TwilioBase
4
+ module Fake
5
+ module TaskRouter
6
+ class Worker
7
+ Worker = Struct.new(
8
+ :sid,
9
+ :friendly_name,
10
+ :activity_sid,
11
+ :attributes,
12
+ :activity_name,
13
+ :available,
14
+ :date_status_changed
15
+ ) do
16
+ def delete
17
+ self
18
+ end
19
+
20
+ def update(_attributes = {})
21
+ self
22
+ end
23
+ end
24
+
25
+ cattr_accessor :sid, :workers
26
+ self.workers = []
27
+
28
+ def initialize(sid = nil)
29
+ self.sid = sid || FactoryBot.generate(:worker_sid)
30
+ end
31
+
32
+ def create(attributes)
33
+ worker = Worker.new(
34
+ sid,
35
+ attributes[:friendly_name],
36
+ attributes[:activity_sid],
37
+ attributes[:attributes],
38
+ attributes[:activity_name],
39
+ attributes[:available],
40
+ attributes[:date_status_changed]
41
+ )
42
+ self.class.workers << worker
43
+ worker
44
+ end
45
+
46
+ def fetch
47
+ workers.detect { |worker| worker.sid == sid }
48
+ end
49
+
50
+ def list(_attributes = {})
51
+ workers
52
+ end
53
+
54
+ def update(_attributes = {})
55
+ self
56
+ end
57
+
58
+ def worker_channels(name = nil)
59
+ Channel.new(name)
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TwilioBase
4
+ module Fake
5
+ module TaskRouter
6
+ class Workflow
7
+ Workflow = Struct.new(:attributes) do
8
+ def sid
9
+ @sid ||= GlobalConfig.first&.workflow_sid ||
10
+ FactoryBot.generate(:workflow_sid)
11
+ end
12
+
13
+ def assignment_callback_url
14
+ attributes[:assignment_callback_url]
15
+ end
16
+
17
+ def configuration
18
+ attributes[:configuration]
19
+ end
20
+
21
+ def friendly_name
22
+ attributes[:friendly_name]
23
+ end
24
+
25
+ def update(attributes)
26
+ self.attributes = attributes
27
+ end
28
+ end
29
+
30
+ cattr_accessor :sid, :workflows
31
+ self.workflows = []
32
+
33
+ def initialize(sid = nil)
34
+ self.sid = sid
35
+ end
36
+
37
+ def create(attributes)
38
+ workflow = Workflow.new(attributes)
39
+ self.class.workflows << workflow
40
+ workflow
41
+ end
42
+
43
+ def update(attributes)
44
+ found_workflow = workflows.detect { |workflow| workflow.sid == sid }
45
+ found_workflow&.update(attributes)
46
+ end
47
+
48
+ def list
49
+ workflows
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TwilioBase
4
+ module Fake
5
+ module TaskRouter
6
+ class Workspace
7
+ Workspace = Struct.new(:attributes) do
8
+ def sid
9
+ @sid ||= GlobalConfig.first&.workspace_sid ||
10
+ FactoryBot.generate(:workspace_sid)
11
+ end
12
+
13
+ def event_callback_url
14
+ attributes[:event_callback_url]
15
+ end
16
+
17
+ def friendly_name
18
+ attributes[:friendly_name]
19
+ end
20
+
21
+ def task_queues
22
+ Fake::TaskRouter::TaskQueue.new
23
+ end
24
+
25
+ def activities
26
+ Fake::TaskRouter::Activity.new
27
+ end
28
+
29
+ def workflows
30
+ Fake::TaskRouter::Workflow.new
31
+ end
32
+
33
+ def update(attributes)
34
+ self.attributes = attributes
35
+ end
36
+ end
37
+
38
+ cattr_accessor :sid, :workspaces
39
+ self.workspaces = []
40
+
41
+ def initialize(sid = nil)
42
+ self.sid = sid
43
+ end
44
+
45
+ def create(params)
46
+ workspace = Workspace.new(params)
47
+ self.class.workspaces << workspace
48
+ workspace
49
+ end
50
+
51
+ def update(attributes)
52
+ workspaces.detect do |workspace|
53
+ workspace.sid == sid
54
+ end&.update(attributes)
55
+ end
56
+
57
+ def list
58
+ workspaces
59
+ end
60
+
61
+ def activities
62
+ Fake::TaskRouter::Activity.new
63
+ end
64
+
65
+ def statistics(sid = nil)
66
+ Fake::TaskRouter::Statistic.new(sid, workspaces.first.attributes)
67
+ end
68
+
69
+ def tasks(sid = nil)
70
+ Fake::TaskRouter::Task.new(sid)
71
+ end
72
+
73
+ def workers(sid = nil)
74
+ Fake::TaskRouter::Worker.new(sid)
75
+ end
76
+
77
+ def workflows(sid = nil)
78
+ Fake::TaskRouter::Workflow.new(sid)
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TwilioBase
4
+ module Fake
5
+ class VoiceCall
6
+ Call = Struct.new(:sid, :attributes) do
7
+ def from
8
+ attributes[:from]
9
+ end
10
+
11
+ def status
12
+ attributes[:status]
13
+ end
14
+
15
+ def to
16
+ attributes[:to]
17
+ end
18
+
19
+ def update(attributes)
20
+ self.attributes = attributes
21
+ end
22
+ end
23
+
24
+ cattr_accessor :calls, :sid
25
+ self.calls = []
26
+
27
+ def initialize(sid = FactoryBot.generate(:voice_call_sid))
28
+ self.sid = sid
29
+ end
30
+
31
+ def create(args = {})
32
+ call = Call.new(sid, args)
33
+ calls << call
34
+ call
35
+ end
36
+
37
+ def list(attributes = {})
38
+ calls.select do |call|
39
+ call.attributes.slice(*attributes.keys) == attributes
40
+ end
41
+ end
42
+
43
+ def fetch
44
+ calls.detect { |call| call.sid == sid }
45
+ end
46
+
47
+ def update(*); end
48
+
49
+ def recordings(recording_sid = nil)
50
+ TwilioBase::Fake::Recording.new(recording_sid)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TwilioBase
4
+ module Responses
5
+ module Twiml
6
+ def dial_twiml(params: {})
7
+ hangup = params[:hangup].present? ? '<Hangup/>' : ''
8
+ protocol = params[:protocol].to_s.titleize
9
+ play_urls = Array(params[:play_urls]).map do |play|
10
+ "<Play>#{play}</Play>\n"
11
+ end.join('')
12
+
13
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" \
14
+ "\n<Response>\n" \
15
+ "#{play_urls}" \
16
+ "#{hangup}" \
17
+ "<Dial action=\"#{CGI.escapeHTML(params[:action_url])}\" "\
18
+ "callerId=\"#{params[:caller_id]}\">" \
19
+ "\n<#{protocol} " \
20
+ "statusCallback=\"#{params[:status_callback_url]}\" " \
21
+ "statusCallbackEvent=\"#{params[:status_callback_events]}\">" \
22
+ "#{params[:endpoint]}" \
23
+ "</#{protocol}>" \
24
+ "\n</Dial>\n" \
25
+ "</Response>\n"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,21 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*
16
+ /tmp/*
17
+ !/log/.keep
18
+ !/tmp/.keep
19
+
20
+ # Ignore Byebug command history file.
21
+ .byebug_history
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'config/application'
4
+
5
+ Rails.application.load_tasks
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationCable
4
+ class Channel < ActionCable::Channel::Base
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationCable
4
+ class Connection < ActionCable::Connection::Base
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationController < ActionController::Base
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationHelper
4
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
5
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ begin
5
+ load File.expand_path('spring', __dir__)
6
+ rescue LoadError => e
7
+ raise unless e.message.include?('spring')
8
+ end
9
+ APP_PATH = File.expand_path('../config/application', __dir__)
10
+ require_relative '../config/boot'
11
+ require 'rails/commands'
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ begin
5
+ load File.expand_path('spring', __dir__)
6
+ rescue LoadError => e
7
+ raise unless e.message.include?('spring')
8
+ end
9
+ require_relative '../config/boot'
10
+ require 'rake'
11
+ Rake.application.run
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'pathname'
5
+ require 'fileutils'
6
+ include FileUtils
7
+
8
+ # path to your application root.
9
+ APP_ROOT = Pathname.new File.expand_path('..', __dir__)
10
+
11
+ def system!(*args)
12
+ system(*args) || abort("\n== Command #{args} failed ==")
13
+ end
14
+
15
+ chdir APP_ROOT do
16
+ # This script is a starting point to setup your application.
17
+ # Add necessary setup steps to this file.
18
+
19
+ puts '== Installing dependencies =='
20
+ system! 'gem install bundler --conservative'
21
+ system('bundle check') || system!('bundle install')
22
+
23
+ # puts "\n== Copying sample files =="
24
+ # unless File.exist?('config/database.yml')
25
+ # cp 'config/database.yml.sample', 'config/database.yml'
26
+ # end
27
+
28
+ puts "\n== Preparing database =="
29
+ system! 'bin/rails db:setup'
30
+
31
+ puts "\n== Removing old logs and tempfiles =="
32
+ system! 'bin/rails log:clear tmp:clear'
33
+
34
+ puts "\n== Restarting application server =="
35
+ system! 'bin/rails restart'
36
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # This file loads spring without using Bundler, in order to be fast.
5
+ # It gets overwritten when you run the `spring binstub` command.
6
+
7
+ unless defined?(Spring)
8
+ require 'rubygems'
9
+ require 'bundler'
10
+
11
+ lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
12
+ spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
13
+ if spring
14
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
15
+ gem 'spring', spring.version
16
+ require 'spring/binstub'
17
+ end
18
+ end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'pathname'
5
+ require 'fileutils'
6
+ include FileUtils
7
+
8
+ # path to your application root.
9
+ APP_ROOT = Pathname.new File.expand_path('..', __dir__)
10
+
11
+ def system!(*args)
12
+ system(*args) || abort("\n== Command #{args} failed ==")
13
+ end
14
+
15
+ chdir APP_ROOT do
16
+ # This script is a way to update your development environment automatically.
17
+ # Add necessary update steps to this file.
18
+
19
+ puts '== Installing dependencies =='
20
+ system! 'gem install bundler --conservative'
21
+ system('bundle check') || system!('bundle install')
22
+
23
+ puts "\n== Updating database =="
24
+ system! 'bin/rails db:migrate'
25
+
26
+ puts "\n== Removing old logs and tempfiles =="
27
+ system! 'bin/rails log:clear tmp:clear'
28
+
29
+ puts "\n== Restarting application server =="
30
+ system! 'bin/rails restart'
31
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'boot'
4
+
5
+ require 'rails/all'
6
+
7
+ Bundler.require(*Rails.groups)
8
+ require 'twilio_base'
9
+
10
+ module TwilioBaseDummy
11
+ class Application < Rails::Application
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
4
+
5
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
6
+
7
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -0,0 +1,5 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
@@ -0,0 +1,13 @@
1
+ default: &default
2
+ adapter: postgresql
3
+ pool: 5
4
+ timeout: 5000
5
+ host: localhost
6
+
7
+ development:
8
+ database: twilio_base_development
9
+ <<: *default
10
+
11
+ test:
12
+ database: twilio_base_development
13
+ <<: *default
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'application'
4
+
5
+ Rails.application.initialize!
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ config.cache_classes = false
5
+ config.eager_load = false
6
+ config.consider_all_requests_local = true
7
+
8
+ if Rails.root.join('tmp/caching-dev.txt').exist?
9
+ config.action_controller.perform_caching = true
10
+
11
+ config.cache_store = :memory_store
12
+ config.public_file_server.headers = {
13
+ 'Cache-Control' => 'public, max-age=172800'
14
+ }
15
+ else
16
+ config.action_controller.perform_caching = false
17
+
18
+ config.cache_store = :null_store
19
+ end
20
+
21
+ config.action_mailer.raise_delivery_errors = false
22
+ config.action_mailer.perform_caching = false
23
+ config.active_support.deprecation = :log
24
+ config.active_record.migration_error = :page_load
25
+ config.assets.debug = true
26
+ config.assets.quiet = true
27
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
28
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.configure do
4
+ config.cache_classes = true
5
+ config.eager_load = false
6
+ config.public_file_server.enabled = true
7
+ config.public_file_server.headers = {
8
+ 'Cache-Control' => 'public, max-age=3600'
9
+ }
10
+ config.consider_all_requests_local = true
11
+ config.action_controller.perform_caching = false
12
+ config.action_dispatch.show_exceptions = false
13
+ config.action_controller.allow_forgery_protection = false
14
+ config.action_mailer.perform_caching = false
15
+ config.action_mailer.delivery_method = :test
16
+ config.active_support.deprecation = :stderr
17
+ end
@@ -0,0 +1 @@
1
+ # frozen_string_literal: true
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.config.assets.version = '1.0'
@@ -0,0 +1 @@
1
+ # frozen_string_literal: true
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1 @@
1
+ # frozen_string_literal: true
@@ -0,0 +1 @@
1
+ # frozen_string_literal: true
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.config.raise_on_unfiltered_parameters = true
4
+ Rails.application.config.action_controller.per_form_csrf_tokens = true
5
+ Rails.application.config.action_controller.forgery_protection_origin_check = true
6
+ ActiveSupport.to_time_preserves_timezone = true
7
+ Rails.application.config.active_record.belongs_to_required_by_default = true
8
+ ActiveSupport.halt_callback_chains_on_return_false = false
9
+ Rails.application.config.ssl_options = { hsts: { subdomains: true } }
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_twilio_base_dummy_session'
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ ActiveSupport.on_load(:action_controller) do
4
+ wrap_parameters format: [:json]
5
+ end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i
4
+ threads threads_count, threads_count
5
+ port ENV.fetch('PORT') { 3000 }
6
+ environment ENV.fetch('RAILS_ENV') { 'development' }
7
+ plugin :tmp_restart
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ mount TwilioBase::Engine => '/twilio_base'
5
+ end
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ development:
4
+ secret_key_base: 18f9e62228e14c9845ae7e0b99618264b071c535882c7275e3b570397c589077363059e4b31bb31dbfec96af67d4ea2b7cca55910e20f93eefbf6dfe61f07b19
5
+
6
+ test:
7
+ secret_key_base: fb04e24056df300bf3585d334d812fa78c0970347713cd0010fd3faa0a21f6eea3bee0a66c63524d02677e30cd149e4f51cc6bfbed82798582fe95cb3c17ea0d
8
+
9
+ production:
10
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>