twilio_base 1.8.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 +7 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +82 -0
- data/.ruby-version +1 -0
- data/.tool-versions +1 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +142 -0
- data/Rakefile +12 -0
- data/app/controllers/twilio_base/base_controller.rb +32 -0
- data/app/models/twilio_base/global_config.rb +5 -0
- data/app/services/twilio_base/api_key.rb +15 -0
- data/app/services/twilio_base/application.rb +29 -0
- data/app/services/twilio_base/clients.rb +37 -0
- data/app/services/twilio_base/phone_number.rb +40 -0
- data/app/services/twilio_base/protocols/voice/base.rb +65 -0
- data/app/services/twilio_base/protocols/voice/pstn.rb +13 -0
- data/app/services/twilio_base/protocols/voice/sip.rb +48 -0
- data/app/services/twilio_base/protocols/voice.rb +24 -0
- data/app/services/twilio_base/request_verification_service.rb +21 -0
- data/app/services/twilio_base/routers/voice/base.rb +44 -0
- data/app/services/twilio_base/routers/voice/default.rb +24 -0
- data/app/services/twilio_base/routers/voice/direct_dial.rb +10 -0
- data/app/services/twilio_base/routers/voice/task_router.rb +34 -0
- data/app/services/twilio_base/sync/service.rb +18 -0
- data/app/services/twilio_base/task_router/activity.rb +49 -0
- data/app/services/twilio_base/task_router/base.rb +17 -0
- data/app/services/twilio_base/task_router/task.rb +33 -0
- data/app/services/twilio_base/task_router/task_queue.rb +40 -0
- data/app/services/twilio_base/task_router/worker.rb +27 -0
- data/app/services/twilio_base/task_router/workflow.rb +22 -0
- data/app/services/twilio_base/task_router/workspace.rb +51 -0
- data/bin/console +8 -0
- data/bin/rails +14 -0
- data/bin/setup +6 -0
- data/circle.yml +36 -0
- data/config/locales/en.yml +2 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20171214105252_create_twilio_base_global_configs.rb +18 -0
- data/lib/twilio_base/engine.rb +7 -0
- data/lib/twilio_base/helpers/protocols.rb +12 -0
- data/lib/twilio_base/version.rb +5 -0
- data/lib/twilio_base.rb +11 -0
- data/spec/factories/channel_sid.rb +7 -0
- data/spec/factories/chat_member_id.rb +7 -0
- data/spec/factories/global_config/activity_sid.rb +7 -0
- data/spec/factories/global_config/api_key_secret.rb +7 -0
- data/spec/factories/global_config/api_key_sid.rb +7 -0
- data/spec/factories/global_config/application_sid.rb +7 -0
- data/spec/factories/global_config/chat_service_sid.rb +7 -0
- data/spec/factories/global_config/conference_sid.rb +7 -0
- data/spec/factories/global_config/message_sid.rb +7 -0
- data/spec/factories/global_config/phone_number.rb +7 -0
- data/spec/factories/global_config/recording_sid.rb +7 -0
- data/spec/factories/global_config/sync_service_sid.rb +7 -0
- data/spec/factories/global_config/task_sid.rb +7 -0
- data/spec/factories/global_config/voice_call_sid.rb +7 -0
- data/spec/factories/global_config/worker_sid.rb +7 -0
- data/spec/factories/global_config/workflow_sid.rb +7 -0
- data/spec/factories/global_config/workspace_sid.rb +7 -0
- data/spec/factories/global_configs.rb +28 -0
- data/spec/lib/twilio_base/helpers/protocols_spec.rb +49 -0
- data/spec/services/twilio_base/api_key_spec.rb +17 -0
- data/spec/services/twilio_base/application_spec.rb +31 -0
- data/spec/services/twilio_base/phone_number_spec.rb +49 -0
- data/spec/services/twilio_base/protocols/voice/base_spec.rb +134 -0
- data/spec/services/twilio_base/protocols/voice/pstn_spec.rb +13 -0
- data/spec/services/twilio_base/protocols/voice/sip_spec.rb +104 -0
- data/spec/services/twilio_base/protocols/voice_spec.rb +48 -0
- data/spec/services/twilio_base/request_verification_service_spec.rb +105 -0
- data/spec/services/twilio_base/routers/voice/base_spec.rb +91 -0
- data/spec/services/twilio_base/routers/voice/default_spec.rb +59 -0
- data/spec/services/twilio_base/routers/voice/task_router_spec.rb +63 -0
- data/spec/services/twilio_base/sync/service.rb +25 -0
- data/spec/services/twilio_base/task_router/activity_spec.rb +68 -0
- data/spec/services/twilio_base/task_router/task_queue_spec.rb +114 -0
- data/spec/services/twilio_base/task_router/worker_spec.rb +49 -0
- data/spec/services/twilio_base/task_router/workflow_spec.rb +37 -0
- data/spec/spec_helper.rb +68 -0
- data/spec/support/factory_bot.rb +9 -0
- data/spec/support/shared_contexts/global_config.rb +6 -0
- data/spec/support/shared_contexts/twilio_controller.rb +7 -0
- data/spec/support/twilio_base/fake/api_key.rb +26 -0
- data/spec/support/twilio_base/fake/application.rb +59 -0
- data/spec/support/twilio_base/fake/available_phone_number.rb +29 -0
- data/spec/support/twilio_base/fake/chat/channel.rb +63 -0
- data/spec/support/twilio_base/fake/chat/client.rb +40 -0
- data/spec/support/twilio_base/fake/chat/member.rb +27 -0
- data/spec/support/twilio_base/fake/chat/message.rb +47 -0
- data/spec/support/twilio_base/fake/chat/service.rb +52 -0
- data/spec/support/twilio_base/fake/clients/rest.rb +84 -0
- data/spec/support/twilio_base/fake/clients/sms.rb +27 -0
- data/spec/support/twilio_base/fake/conference.rb +48 -0
- data/spec/support/twilio_base/fake/flex_flow.rb +36 -0
- data/spec/support/twilio_base/fake/helpers.rb +38 -0
- data/spec/support/twilio_base/fake/incoming_phone_number.rb +46 -0
- data/spec/support/twilio_base/fake/lookup/client.rb +29 -0
- data/spec/support/twilio_base/fake/lookup/phone_number.rb +34 -0
- data/spec/support/twilio_base/fake/notify/binding.rb +41 -0
- data/spec/support/twilio_base/fake/notify/notification.rb +40 -0
- data/spec/support/twilio_base/fake/notify/segment_membership.rb +17 -0
- data/spec/support/twilio_base/fake/notify/user.rb +30 -0
- data/spec/support/twilio_base/fake/notify/v1.rb +33 -0
- data/spec/support/twilio_base/fake/proxy.rb +30 -0
- data/spec/support/twilio_base/fake/recording.rb +44 -0
- data/spec/support/twilio_base/fake/sync/client.rb +17 -0
- data/spec/support/twilio_base/fake/sync/service.rb +78 -0
- data/spec/support/twilio_base/fake/sync/services/document.rb +50 -0
- data/spec/support/twilio_base/fake/sync/services/list.rb +50 -0
- data/spec/support/twilio_base/fake/sync/services/lists/item.rb +48 -0
- data/spec/support/twilio_base/fake/sync/services/map.rb +50 -0
- data/spec/support/twilio_base/fake/sync/services/maps/item.rb +54 -0
- data/spec/support/twilio_base/fake/task_router/activity.rb +34 -0
- data/spec/support/twilio_base/fake/task_router/channel.rb +40 -0
- data/spec/support/twilio_base/fake/task_router/client.rb +31 -0
- data/spec/support/twilio_base/fake/task_router/statistic.rb +38 -0
- data/spec/support/twilio_base/fake/task_router/task.rb +80 -0
- data/spec/support/twilio_base/fake/task_router/task_queue.rb +46 -0
- data/spec/support/twilio_base/fake/task_router/worker.rb +64 -0
- data/spec/support/twilio_base/fake/task_router/workflow.rb +54 -0
- data/spec/support/twilio_base/fake/task_router/workspace.rb +83 -0
- data/spec/support/twilio_base/fake/voice_call.rb +54 -0
- data/spec/support/twilio_base/responses/twiml.rb +29 -0
- data/spec/twilio_base_dummy/.gitignore +21 -0
- data/spec/twilio_base_dummy/Rakefile +5 -0
- data/spec/twilio_base_dummy/app/assets/config/manifest.js +0 -0
- data/spec/twilio_base_dummy/app/channels/application_cable/channel.rb +6 -0
- data/spec/twilio_base_dummy/app/channels/application_cable/connection.rb +6 -0
- data/spec/twilio_base_dummy/app/controllers/application_controller.rb +5 -0
- data/spec/twilio_base_dummy/app/controllers/concerns/.keep +0 -0
- data/spec/twilio_base_dummy/app/helpers/application_helper.rb +4 -0
- data/spec/twilio_base_dummy/bin/bundle +5 -0
- data/spec/twilio_base_dummy/bin/rails +11 -0
- data/spec/twilio_base_dummy/bin/rake +11 -0
- data/spec/twilio_base_dummy/bin/setup +36 -0
- data/spec/twilio_base_dummy/bin/spring +18 -0
- data/spec/twilio_base_dummy/bin/update +31 -0
- data/spec/twilio_base_dummy/config/application.rb +13 -0
- data/spec/twilio_base_dummy/config/boot.rb +7 -0
- data/spec/twilio_base_dummy/config/cable.yml +5 -0
- data/spec/twilio_base_dummy/config/database.example.yml +13 -0
- data/spec/twilio_base_dummy/config/environment.rb +5 -0
- data/spec/twilio_base_dummy/config/environments/development.rb +28 -0
- data/spec/twilio_base_dummy/config/environments/test.rb +17 -0
- data/spec/twilio_base_dummy/config/initializers/application_controller_renderer.rb +1 -0
- data/spec/twilio_base_dummy/config/initializers/assets.rb +3 -0
- data/spec/twilio_base_dummy/config/initializers/backtrace_silencers.rb +1 -0
- data/spec/twilio_base_dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/twilio_base_dummy/config/initializers/filter_parameter_logging.rb +3 -0
- data/spec/twilio_base_dummy/config/initializers/inflections.rb +1 -0
- data/spec/twilio_base_dummy/config/initializers/mime_types.rb +1 -0
- data/spec/twilio_base_dummy/config/initializers/new_framework_defaults.rb +9 -0
- data/spec/twilio_base_dummy/config/initializers/session_store.rb +3 -0
- data/spec/twilio_base_dummy/config/initializers/wrap_parameters.rb +5 -0
- data/spec/twilio_base_dummy/config/locales/en.yml +23 -0
- data/spec/twilio_base_dummy/config/puma.rb +7 -0
- data/spec/twilio_base_dummy/config/routes.rb +5 -0
- data/spec/twilio_base_dummy/config/secrets.yml +10 -0
- data/spec/twilio_base_dummy/config/spring.rb +8 -0
- data/spec/twilio_base_dummy/config.ru +7 -0
- data/spec/twilio_base_dummy/db/schema.rb +31 -0
- data/spec/twilio_base_dummy/db/seeds.rb +1 -0
- data/spec/twilio_base_dummy/lib/assets/.keep +0 -0
- data/spec/twilio_base_dummy/lib/tasks/.keep +0 -0
- data/spec/twilio_base_dummy/log/.keep +0 -0
- data/spec/twilio_base_dummy/public/404.html +67 -0
- data/spec/twilio_base_dummy/public/422.html +67 -0
- data/spec/twilio_base_dummy/public/500.html +66 -0
- data/spec/twilio_base_dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/twilio_base_dummy/public/apple-touch-icon.png +0 -0
- data/spec/twilio_base_dummy/public/favicon.ico +0 -0
- data/spec/twilio_base_dummy/public/robots.txt +5 -0
- data/spec/twilio_base_dummy/tmp/.keep +0 -0
- data/spec/twilio_base_dummy/vendor/assets/javascripts/.keep +0 -0
- data/spec/twilio_base_dummy/vendor/assets/stylesheets/.keep +0 -0
- data/spec/twilio_base_spec.rb +7 -0
- data/twilio_base.gemspec +45 -0
- 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
|
|
File without changes
|
|
File without changes
|
|
@@ -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,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,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 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
@@ -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,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,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"] %>
|