workarea-emarsys 1.0.2

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.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.gitignore +22 -0
  7. data/CHANGELOG.md +28 -0
  8. data/CODE_OF_CONDUCT.md +3 -0
  9. data/CONTRIBUTING.md +3 -0
  10. data/Gemfile +12 -0
  11. data/LICENSE +52 -0
  12. data/LICENSE.md +3 -0
  13. data/README.md +93 -0
  14. data/Rakefile +60 -0
  15. data/app/assets/images/emarsys/.keep +0 -0
  16. data/app/assets/javascripts/emarsys/.keep +0 -0
  17. data/app/assets/javascripts/workarea/storefront/emarsys/modules/web_extend_adapter.js +128 -0
  18. data/app/assets/stylesheets/emarsys/.keep +0 -0
  19. data/app/controllers/.keep +0 -0
  20. data/app/controllers/workarea/admin/configurations_controller.rb +33 -0
  21. data/app/controllers/workarea/storefront/email_signups_controller.decorator +16 -0
  22. data/app/controllers/workarea/storefront/users/addresses_controller.decorator +13 -0
  23. data/app/helpers/.keep +0 -0
  24. data/app/helpers/workarea/storefront/emarsys_analytics_helper.rb +13 -0
  25. data/app/lib/workarea/emarsys/bogus_gateway.rb +36 -0
  26. data/app/lib/workarea/emarsys/gateway.rb +94 -0
  27. data/app/lib/workarea/emarsys/response.rb +18 -0
  28. data/app/lib/workarea/emarsys/sales_data_bogus_gateway.rb +29 -0
  29. data/app/lib/workarea/emarsys/sales_data_gateway.rb +51 -0
  30. data/app/models/emarsys/configuration.rb +16 -0
  31. data/app/models/emarsys/country.rb +220 -0
  32. data/app/models/workarea/email/signup.decorator +8 -0
  33. data/app/models/workarea/order.decorator +8 -0
  34. data/app/models/workarea/user.decorator +8 -0
  35. data/app/services/emarsys/contact/order.rb +31 -0
  36. data/app/services/emarsys/contact/user.rb +25 -0
  37. data/app/services/emarsys/contact.rb +55 -0
  38. data/app/view_models/workarea/admin/emarsys_configuration_view_model.rb +20 -0
  39. data/app/views/workarea/admin/emarsys/configurations/edit.html.haml +68 -0
  40. data/app/views/workarea/admin/shared/_emarsys_configuration_link.html.haml +1 -0
  41. data/app/views/workarea/storefront/_emarsys_tracking.html.haml +11 -0
  42. data/app/views/workarea/storefront/emarsys/_current_user_emarsys_cart.json.jbuilder +6 -0
  43. data/app/workers/workarea/emarsys/save_email_signup.rb +40 -0
  44. data/app/workers/workarea/emarsys/save_order.rb +32 -0
  45. data/app/workers/workarea/emarsys/save_user.rb +44 -0
  46. data/app/workers/workarea/emarsys/sync_orders.rb +50 -0
  47. data/bin/rails +20 -0
  48. data/config/initializers/appends.rb +19 -0
  49. data/config/initializers/scheduled_jobs.rb +6 -0
  50. data/config/initializers/workarea.rb +16 -0
  51. data/config/locales/en.yml +28 -0
  52. data/config/routes.rb +7 -0
  53. data/lib/workarea/emarsys/engine.rb +12 -0
  54. data/lib/workarea/emarsys/version.rb +5 -0
  55. data/lib/workarea/emarsys.rb +59 -0
  56. data/test/dummy/Rakefile +6 -0
  57. data/test/dummy/app/assets/config/manifest.js +4 -0
  58. data/test/dummy/app/assets/images/.keep +0 -0
  59. data/test/dummy/app/assets/javascripts/application.js +13 -0
  60. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  61. data/test/dummy/app/controllers/application_controller.rb +3 -0
  62. data/test/dummy/app/controllers/concerns/.keep +0 -0
  63. data/test/dummy/app/helpers/application_helper.rb +2 -0
  64. data/test/dummy/app/jobs/application_job.rb +2 -0
  65. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  66. data/test/dummy/app/models/concerns/.keep +0 -0
  67. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  68. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  69. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  70. data/test/dummy/bin/bundle +3 -0
  71. data/test/dummy/bin/rails +4 -0
  72. data/test/dummy/bin/rake +4 -0
  73. data/test/dummy/bin/setup +30 -0
  74. data/test/dummy/bin/update +26 -0
  75. data/test/dummy/bin/yarn +11 -0
  76. data/test/dummy/config/application.rb +30 -0
  77. data/test/dummy/config/boot.rb +5 -0
  78. data/test/dummy/config/cable.yml +10 -0
  79. data/test/dummy/config/environment.rb +5 -0
  80. data/test/dummy/config/environments/development.rb +51 -0
  81. data/test/dummy/config/environments/production.rb +88 -0
  82. data/test/dummy/config/environments/test.rb +44 -0
  83. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  84. data/test/dummy/config/initializers/assets.rb +14 -0
  85. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  86. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  87. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  88. data/test/dummy/config/initializers/inflections.rb +16 -0
  89. data/test/dummy/config/initializers/mime_types.rb +4 -0
  90. data/test/dummy/config/initializers/workarea.rb +5 -0
  91. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  92. data/test/dummy/config/locales/en.yml +33 -0
  93. data/test/dummy/config/puma.rb +56 -0
  94. data/test/dummy/config/routes.rb +5 -0
  95. data/test/dummy/config/secrets.yml +32 -0
  96. data/test/dummy/config/spring.rb +6 -0
  97. data/test/dummy/config.ru +5 -0
  98. data/test/dummy/db/seeds.rb +2 -0
  99. data/test/dummy/lib/assets/.keep +0 -0
  100. data/test/dummy/log/.keep +0 -0
  101. data/test/integration/workarea/admin/emarsys_configuration_integration_test.rb +25 -0
  102. data/test/lib/workarea/emarsys/gateway_test.rb +26 -0
  103. data/test/services/emarsys/contact_test.rb +44 -0
  104. data/test/support/workarea/emarsys_api_config.rb +19 -0
  105. data/test/system/workarea/storefront/emarsys_tracking_system_test.rb +25 -0
  106. data/test/teaspoon_env.rb +6 -0
  107. data/test/test_helper.rb +10 -0
  108. data/test/vcr_cassettes/emarsys/add_contact.yml +67 -0
  109. data/test/vcr_cassettes/emarsys/get_contact.yml +129 -0
  110. data/test/vcr_cassettes/emarsys/sales/send_data.yml +42 -0
  111. data/test/workers/workarea/emarsys/save_user_test.rb +30 -0
  112. data/test/workers/workarea/emarsys/sync_orders_test.rb +38 -0
  113. data/workarea-emarsys.gemspec +24 -0
  114. metadata +211 -0
@@ -0,0 +1,40 @@
1
+ module Workarea
2
+ module Emarsys
3
+ class SaveEmailSignup
4
+ include Sidekiq::Worker
5
+ include Sidekiq::CallbacksWorker
6
+
7
+ sidekiq_options(
8
+ enqueue_on: { Workarea::Email::Signup => :create },
9
+ queue: 'low'
10
+ )
11
+
12
+ def perform(id)
13
+ email_signup = Workarea::Email::Signup.find(id)
14
+ email = email_signup.email
15
+
16
+ # Emarasys Key values are
17
+ # integer, value
18
+ # where integer corresponds to a field in their
19
+ # internal database
20
+ attrs = { contacts: [
21
+ "3" => email,
22
+ "31" => 1
23
+ ]
24
+ }
25
+ response = gateway.create_contact(attrs)
26
+
27
+ email_signup.update_attributes!(
28
+ emarsys_exported_at: Time.current,
29
+ emarsys_external_id: response.body["data"]["ids"].first
30
+ )
31
+ end
32
+
33
+ private
34
+
35
+ def gateway
36
+ Emarsys.gateway
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,32 @@
1
+ module Workarea
2
+ module Emarsys
3
+ class SaveOrderContact
4
+ include Sidekiq::Worker
5
+ include Sidekiq::CallbacksWorker
6
+
7
+ sidekiq_options(
8
+ enqueue_on: { Workarea::Order => [:place] },
9
+ unique: :until_executing
10
+ )
11
+
12
+ def perform(id)
13
+ return unless settings.customer_id.present?
14
+
15
+ order = Workarea::Order.find(id)
16
+ address = Workarea::Payment.find(order.id).address
17
+
18
+ attrs = Emarsys::Contact.new(order, address: address, contact_from: 'order').to_h
19
+ gateway.create_contact(attrs)
20
+ end
21
+
22
+ private
23
+ def settings
24
+ Workarea::Emarsys::Configuration.current
25
+ end
26
+
27
+ def gateway
28
+ Emarsys.gateway
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,44 @@
1
+ module Workarea
2
+ module Emarsys
3
+ class SaveUser
4
+ include Sidekiq::Worker
5
+ include Sidekiq::CallbacksWorker
6
+
7
+ sidekiq_options(
8
+ enqueue_on: { Workarea::User => :save },
9
+ queue: 'low'
10
+ )
11
+
12
+ def perform(id)
13
+ return unless settings.customer_id.present?
14
+
15
+ user = Workarea::User.find(id)
16
+
17
+ attrs = Emarsys::Contact.new(user, { address: address(user), contact_from: 'user' }).to_h
18
+
19
+ response = gateway.create_contact(attrs)
20
+
21
+ user.set(emarsys_exported_at: Time.current)
22
+ external_id = response.body["data"]["id"] || response.body["data"]["ids"].first
23
+ user.set(emarsys_external_id: external_id)
24
+ end
25
+
26
+ private
27
+
28
+ def gateway
29
+ Emarsys.gateway
30
+ end
31
+
32
+ def settings
33
+ Workarea::Emarsys::Configuration.current
34
+ end
35
+
36
+ def address(user)
37
+ return unless user.addresses.present?
38
+
39
+ return user.default_billing_address if user.default_billing_address.present?
40
+ user.addresses.sort_by { |a| a.created_at.to_i }.last
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,50 @@
1
+ module Workarea
2
+ module Emarsys
3
+ class SyncOrders
4
+ include Sidekiq::Worker
5
+
6
+ def perform
7
+ # get the orders based on the time span set in config
8
+ orders = Workarea::Order.emarsys_exportable
9
+
10
+ return if orders.empty?
11
+
12
+ Dir.mktmpdir do |dir|
13
+ file = "order_export.csv"
14
+ path = "#{dir}/#{file}"
15
+ File.new(path, 'w+')
16
+
17
+ CSV.open(path, "wb") do |csv|
18
+ csv << headers
19
+ orders.each do |order|
20
+ order.items.each do |item|
21
+ csv << order_line(item)
22
+ end
23
+ end
24
+ end
25
+ gateway.send_file(path)
26
+ end
27
+ end
28
+
29
+ private
30
+ def order_line(item)
31
+ [
32
+ item.order.id,
33
+ item.order.email,
34
+ item.product_id,
35
+ item.total_price.to_s,
36
+ item.quantity,
37
+ item.order.placed_at.utc.iso8601
38
+ ]
39
+ end
40
+
41
+ def headers
42
+ ["order", "email", "item", "price", "quantity", "timestamp"]
43
+ end
44
+
45
+ def gateway
46
+ Emarsys.sales_data_gateway
47
+ end
48
+ end
49
+ end
50
+ end
data/bin/rails ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
6
+ ENGINE_PATH = File.expand_path('../../lib/workarea/emarsys/engine', __FILE__)
7
+ APP_PATH = File.expand_path('../../test/dummy/config/application', __FILE__)
8
+
9
+ # Set up gems listed in the Gemfile.
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
11
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
12
+
13
+ require "action_controller/railtie"
14
+ require "action_view/railtie"
15
+ require "action_mailer/railtie"
16
+ require "rails/test_unit/railtie"
17
+ require "sprockets/railtie"
18
+ require 'teaspoon-mocha'
19
+
20
+ require 'rails/engine/commands'
@@ -0,0 +1,19 @@
1
+ Workarea.append_partials(
2
+ 'storefront.document_head',
3
+ 'workarea/storefront/emarsys_tracking'
4
+ )
5
+
6
+ Workarea.append_partials(
7
+ 'storefront.current_user',
8
+ 'workarea/storefront/emarsys/current_user_emarsys_cart'
9
+ )
10
+
11
+ Workarea.append_partials(
12
+ "admin.settings_menu",
13
+ "workarea/admin/shared/emarsys_configuration_link"
14
+ )
15
+
16
+ Workarea.append_javascripts(
17
+ 'storefront.modules',
18
+ 'workarea/storefront/emarsys/modules/web_extend_adapter'
19
+ )
@@ -0,0 +1,6 @@
1
+ Sidekiq::Cron::Job.create(
2
+ name: 'Workarea::Emarsys::SyncOrders',
3
+ klass: 'Workarea::Emarsys::SyncOrders',
4
+ cron: '0 */6 * * *',
5
+ queue: 'low'
6
+ )
@@ -0,0 +1,16 @@
1
+ Workarea.configure do |config|
2
+ config.emarsys ||= ActiveSupport::Configurable::Configuration.new
3
+
4
+ config.emarsys.escher_key = 'suite_workarea_v1'
5
+ config.emarsys.scope = 'eu/workarea/ems_request'
6
+ config.emarsys.partner_scope = 'eu/suite/ems_request'
7
+
8
+ config.emarsys.export_interval = 1.day
9
+
10
+ # Merchant ID used for web extend JS
11
+ # this is required for the web extend javascript
12
+ config.emarsys.merchant_id = nil
13
+
14
+ config.emarsys.api_timeout = 3
15
+ config.emarsys.open_timeout = 3
16
+ end
@@ -0,0 +1,28 @@
1
+ ---
2
+ en:
3
+ workarea:
4
+ admin:
5
+ shared:
6
+ primary_nav:
7
+ emarsys_configuration_title: Emarsys Configuration
8
+ emarsys_configuration:
9
+ edit:
10
+ flash_messages:
11
+ updated: Emarsys configuration has been updated
12
+ save_error: There was a problem updating the configuration
13
+ title: Emarsys Configuration
14
+ button: Save Emarsys Configuration
15
+ production: Use Production API?
16
+ customer_id: Customer ID
17
+ merchant_id: Merchant ID
18
+ api_key: API Key
19
+ sales_api_key: Sales Data API Key
20
+ no_key: No API key configured. Contact your developer to add this secure value. Customers will not be sent until this value is set.
21
+ no_sales_key: No Sales API key configured. Contact your developer to add this secure value. Order files will not be sent until this value is set.
22
+ help:
23
+ api_key: API Key for customer synchronization. Can be found in the Emarsys adminstration system.
24
+ sales_api_key: API Key for order file synchronization. Can be found in the Emarsys adminstration system.
25
+ production: Use the Live/Production API endpoints. Turn this on when ready to go live with your integration.
26
+ customer_id: Emarsys customer ID. Required for using API endpoints. Contact your Emarays Support team to get this value.
27
+ merchant_id: Emarsys merchant ID. This value is required for the Web Extend data integration.
28
+
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ Workarea::Admin::Engine.routes.draw do
2
+ scope '(:locale)', constraints: Workarea::I18n.routes_constraint do
3
+ namespace :emarsys do
4
+ resource :configuration, only: [:edit, :update]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ module Workarea
2
+ module Emarsys
3
+ class Engine < ::Rails::Engine
4
+ include Workarea::Plugin
5
+ isolate_namespace Workarea::Emarsys
6
+
7
+ config.to_prepare do
8
+ Storefront::ApplicationController.helper(Storefront::EmarsysAnalyticsHelper)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Workarea
2
+ module Emarsys
3
+ VERSION = "1.0.2"
4
+ end
5
+ end
@@ -0,0 +1,59 @@
1
+ require 'workarea'
2
+ require 'workarea/storefront'
3
+ require 'workarea/admin'
4
+ require 'workarea/google_product_feed'
5
+
6
+ require 'workarea/emarsys/engine'
7
+ require 'workarea/emarsys/version'
8
+
9
+ require 'escher'
10
+
11
+ module Workarea
12
+ module Emarsys
13
+ def self.credentials
14
+ (Rails.application.secrets.emarsys || {}).deep_symbolize_keys
15
+ end
16
+
17
+ def self.sales_data_credentials
18
+ (Rails.application.secrets.emarsys_sales || {}).deep_symbolize_keys
19
+ end
20
+
21
+ def self.secret_key
22
+ credentials[:secret_key]
23
+ end
24
+
25
+ def self.api_token
26
+ sales_data_credentials[:api_token]
27
+ end
28
+
29
+ def self.customer_id
30
+ credentials[:customer_id]
31
+ end
32
+
33
+ def self.config
34
+ Workarea.config.emarsys
35
+ end
36
+
37
+ # Conditionally use the real gateway when secrets are present.
38
+ # Otherwise, use the bogus gateway.
39
+ #
40
+ # @return [Emarsys::Gateway]
41
+ def self.gateway
42
+ if credentials.present?
43
+ settings = Workarea::Emarsys::Configuration.current
44
+ Emarsys::Gateway.new(secret_key, settings.customer_id, { test: !settings.production? })
45
+ else
46
+ Emarsys::BogusGateway.new
47
+ end
48
+ end
49
+
50
+ def self.sales_data_gateway
51
+ if credentials.present?
52
+ settings = Workarea::Emarsys::Configuration.current
53
+ Emarsys::SalesDataGateway.new(api_token, { merchant_id: settings.merchant_id })
54
+ else
55
+ Emarsys::SalesDataBogusGateway.new
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,4 @@
1
+
2
+ //= link_tree ../images
3
+ //= link_directory ../javascripts .js
4
+ //= link_directory ../stylesheets .css
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
File without changes
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= csrf_meta_tags %>
6
+
7
+ <%= stylesheet_link_tag 'application', media: 'all' %>
8
+ <%= javascript_include_tag 'application' %>
9
+ </head>
10
+
11
+ <body>
12
+ <%= yield %>
13
+ </body>
14
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a starting point to setup your application.
15
+ # Add necessary setup steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ # Install JavaScript dependencies if using Yarn
22
+ # system('bin/yarn')
23
+
24
+
25
+ puts "\n== Removing old logs and tempfiles =="
26
+ system! 'bin/rails log:clear tmp:clear'
27
+
28
+ puts "\n== Restarting application server =="
29
+ system! 'bin/rails restart'
30
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a way to update your development environment automatically.
15
+ # Add necessary update steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ puts "\n== Removing old logs and tempfiles =="
22
+ system! 'bin/rails log:clear tmp:clear'
23
+
24
+ puts "\n== Restarting application server =="
25
+ system! 'bin/rails restart'
26
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ VENDOR_PATH = File.expand_path('..', __dir__)
3
+ Dir.chdir(VENDOR_PATH) do
4
+ begin
5
+ exec "yarnpkg #{ARGV.join(" ")}"
6
+ rescue Errno::ENOENT
7
+ $stderr.puts "Yarn executable was not detected in the system."
8
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
9
+ exit 1
10
+ end
11
+ end
@@ -0,0 +1,30 @@
1
+ require_relative 'boot'
2
+
3
+ # Pick the frameworks you want:
4
+ # require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_view/railtie"
7
+ require "action_mailer/railtie"
8
+ require "active_job/railtie"
9
+ # require "action_cable/engine"
10
+ require "rails/test_unit/railtie"
11
+ require "sprockets/railtie"
12
+
13
+ # Workarea must be required before other gems to ensure control over Rails.env
14
+ # for running tests
15
+ require 'workarea/core'
16
+ require 'workarea/admin'
17
+ require 'workarea/storefront'
18
+ Bundler.require(*Rails.groups)
19
+ require "workarea/emarsys"
20
+
21
+ module Dummy
22
+ class Application < Rails::Application
23
+ # Initialize configuration defaults for originally generated Rails version.
24
+ config.load_defaults 5.1
25
+
26
+ # Settings in config/environments/* take precedence over those specified here.
27
+ # Application configuration should go into files in config/initializers
28
+ # -- all .rb files in that directory are automatically loaded.
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
6
+
7
+ production:
8
+ adapter: redis
9
+ url: redis://localhost:6379/1
10
+ channel_prefix: dummy_production
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative 'application'
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,51 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports.
13
+ config.consider_all_requests_local = true
14
+
15
+ # Enable/disable caching. By default caching is disabled.
16
+ if Rails.root.join('tmp/caching-dev.txt').exist?
17
+ config.action_controller.perform_caching = true
18
+
19
+ config.cache_store = :memory_store
20
+ config.public_file_server.headers = {
21
+ 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
22
+ }
23
+ else
24
+ config.action_controller.perform_caching = false
25
+
26
+ config.cache_store = :null_store
27
+ end
28
+
29
+ # Don't care if the mailer can't send.
30
+ config.action_mailer.raise_delivery_errors = false
31
+
32
+ config.action_mailer.perform_caching = false
33
+
34
+ # Print deprecation notices to the Rails logger.
35
+ config.active_support.deprecation = :log
36
+
37
+ # Debug mode disables concatenation and preprocessing of assets.
38
+ # This option may cause significant delays in view rendering with a large
39
+ # number of complex assets.
40
+ config.assets.debug = true
41
+
42
+ # Suppress logger output for asset requests.
43
+ config.assets.quiet = true
44
+
45
+ # Raises error for missing translations
46
+ # config.action_view.raise_on_missing_translations = true
47
+
48
+ # Use an evented file watcher to asynchronously detect changes in source code,
49
+ # routes, locales, etc. This feature depends on the listen gem.
50
+ # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
51
+ end