workarea-product_badges 1.3.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 (83) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +16 -0
  3. data/.eslintrc +25 -0
  4. data/.gitignore +19 -0
  5. data/.markdownlint.json +10 -0
  6. data/.rails-rubocop.yml +119 -0
  7. data/.rubocop.yml +8 -0
  8. data/.scss-lint.yml +192 -0
  9. data/CHANGELOG.md +101 -0
  10. data/Gemfile +16 -0
  11. data/README.md +167 -0
  12. data/Rakefile +63 -0
  13. data/app/assets/stylesheets/workarea/product_badges/components/_badges.scss +47 -0
  14. data/app/models/workarea/catalog/product.decorator +11 -0
  15. data/app/view_models/workarea/storefront/product_view_model.decorator +52 -0
  16. data/app/views/workarea/admin/catalog_products/_badge_fields.html.haml +40 -0
  17. data/app/views/workarea/storefront/products/_badges.haml +5 -0
  18. data/bin/rails +20 -0
  19. data/config/initializers/appends.rb +21 -0
  20. data/config/initializers/workarea.rb +9 -0
  21. data/config/locales/en.yml +19 -0
  22. data/lib/workarea/product_badges/engine.rb +8 -0
  23. data/lib/workarea/product_badges/version.rb +5 -0
  24. data/lib/workarea/product_badges.rb +30 -0
  25. data/script/admin_ci +9 -0
  26. data/script/ci +11 -0
  27. data/script/core_ci +9 -0
  28. data/script/plugins_ci +9 -0
  29. data/script/storefront_ci +9 -0
  30. data/test/dummy/Rakefile +6 -0
  31. data/test/dummy/app/assets/config/manifest.js +4 -0
  32. data/test/dummy/app/assets/images/.keep +0 -0
  33. data/test/dummy/app/assets/javascripts/application.js +13 -0
  34. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  35. data/test/dummy/app/controllers/application_controller.rb +3 -0
  36. data/test/dummy/app/controllers/concerns/.keep +0 -0
  37. data/test/dummy/app/helpers/application_helper.rb +2 -0
  38. data/test/dummy/app/jobs/application_job.rb +2 -0
  39. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  40. data/test/dummy/app/models/concerns/.keep +0 -0
  41. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  42. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  43. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  44. data/test/dummy/bin/bundle +3 -0
  45. data/test/dummy/bin/rails +4 -0
  46. data/test/dummy/bin/rake +4 -0
  47. data/test/dummy/bin/setup +38 -0
  48. data/test/dummy/bin/update +29 -0
  49. data/test/dummy/bin/yarn +11 -0
  50. data/test/dummy/config/application.rb +26 -0
  51. data/test/dummy/config/boot.rb +5 -0
  52. data/test/dummy/config/cable.yml +10 -0
  53. data/test/dummy/config/environment.rb +5 -0
  54. data/test/dummy/config/environments/development.rb +54 -0
  55. data/test/dummy/config/environments/production.rb +91 -0
  56. data/test/dummy/config/environments/test.rb +44 -0
  57. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  58. data/test/dummy/config/initializers/assets.rb +14 -0
  59. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  60. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  61. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  62. data/test/dummy/config/initializers/inflections.rb +16 -0
  63. data/test/dummy/config/initializers/mime_types.rb +4 -0
  64. data/test/dummy/config/initializers/workarea.rb +5 -0
  65. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  66. data/test/dummy/config/locales/en.yml +33 -0
  67. data/test/dummy/config/puma.rb +56 -0
  68. data/test/dummy/config/routes.rb +5 -0
  69. data/test/dummy/config/secrets.yml +32 -0
  70. data/test/dummy/config/spring.rb +6 -0
  71. data/test/dummy/config.ru +5 -0
  72. data/test/dummy/db/seeds.rb +2 -0
  73. data/test/dummy/lib/assets/.keep +0 -0
  74. data/test/dummy/log/.keep +0 -0
  75. data/test/dummy/package.json +5 -0
  76. data/test/integration/workarea/admin/products_badging_integration_test.rb +15 -0
  77. data/test/system/workarea/admin/product_badges_system_test.rb +29 -0
  78. data/test/system/workarea/storefront/product_badges_system_test.rb +62 -0
  79. data/test/teaspoon_env.rb +6 -0
  80. data/test/test_helper.rb +10 -0
  81. data/test/view_models/workarea/storefront/product_view_model_badging_test.rb +81 -0
  82. data/workarea-product_badges.gemspec +17 -0
  83. metadata +143 -0
data/Rakefile ADDED
@@ -0,0 +1,63 @@
1
+ begin
2
+ require "bundler/setup"
3
+ rescue LoadError
4
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
+ end
6
+
7
+ require "rdoc/task"
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = "rdoc"
11
+ rdoc.title = "Product Badges"
12
+ rdoc.options << "--line-numbers"
13
+ rdoc.rdoc_files.include("README.md")
14
+ rdoc.rdoc_files.include("lib/**/*.rb")
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load "rails/tasks/engine.rake"
19
+ load "rails/tasks/statistics.rake"
20
+ load 'workarea/changelog.rake'
21
+
22
+ require "rake/testtask"
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << "lib"
26
+ t.libs << "test"
27
+ t.pattern = "test/**/*_test.rb"
28
+ t.verbose = false
29
+ end
30
+
31
+ task default: :test
32
+
33
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
34
+ require "workarea/product_badges/version"
35
+
36
+ desc "Release version #{Workarea::ProductBadges::VERSION} of the gem"
37
+ task :release do
38
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
39
+
40
+ #Rake::Task['workarea:changelog'].execute
41
+ #system 'git add CHANGELOG.md'
42
+ #system 'git commit -m "Update CHANGELOG"'
43
+ #system 'git push origin HEAD'
44
+
45
+ system "git tag -a v#{Workarea::ProductBadges::VERSION} -m 'Tagging #{Workarea::ProductBadges::VERSION}'"
46
+ system "git push --tags"
47
+
48
+ system "gem build workarea-product_badges.gemspec"
49
+ system "gem push workarea-product_badges-#{Workarea::ProductBadges::VERSION}.gem"
50
+ system "gem push workarea-product_badges-#{Workarea::ProductBadges::VERSION}.gem --host #{host}"
51
+ system "rm workarea-product_badges-#{Workarea::ProductBadges::VERSION}.gem"
52
+ end
53
+
54
+ desc "Run the JavaScript tests"
55
+ ENV["TEASPOON_RAILS_ENV"] = File.expand_path("../test/dummy/config/environment", __FILE__)
56
+ task teaspoon: "app:teaspoon"
57
+
58
+ desc "Start a server at http://localhost:3000/teaspoon for JavaScript tests"
59
+ task :teaspoon_server do
60
+ Dir.chdir("test/dummy")
61
+ teaspoon_env = File.expand_path("../test/teaspoon_env.rb", __FILE__)
62
+ system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
63
+ end
@@ -0,0 +1,47 @@
1
+ /*------------------------------------*\
2
+ #BADGES
3
+ \*------------------------------------*/
4
+
5
+ $badges-top-offset: 0 !default;
6
+ $badges-left-offset: 0 !default;
7
+ $badges-product-detail-max-width: 150px !default;
8
+
9
+ $badge-color: $black !default;
10
+ $badge-background-color: $blue !default;
11
+ $badge-new-background-color: $green !default;
12
+ $badge-sale-background-color: $red !default;
13
+ $badge-best-seller-background-color: $red !default;
14
+
15
+
16
+ .badges {
17
+ position: absolute;
18
+ top: $badges-top-offset;
19
+ left: $badges-left-offset;
20
+ pointer-events: none;
21
+
22
+ .product-detail-container & {
23
+ position: static;
24
+ max-width: $badges-product-detail-max-width;
25
+ }
26
+ }
27
+
28
+ .badges__badge {
29
+ margin-top: $spacing-unit;
30
+ padding: ($spacing-unit / 2) ($spacing-unit * 2);
31
+ color: $badge-color;
32
+ background-color: $badge-background-color;
33
+ }
34
+
35
+ .badges__badge--new {
36
+ background-color: $badge-new-background-color;
37
+ }
38
+
39
+ .badges__badge--sale {
40
+ background-color: $badge-sale-background-color;
41
+ }
42
+
43
+ .badges__badge--best-seller {
44
+ background-color: $badge-best-seller-background-color;
45
+ }
46
+
47
+ .badges__badge-text {}
@@ -0,0 +1,11 @@
1
+ module Workarea
2
+ decorate Catalog::Product, with: :product_badges do
3
+ decorated do
4
+ field :new_badge, type: Boolean, default: true
5
+ field :sale_badge, type: Boolean, default: true
6
+ field :best_seller_badge, type: Boolean, default: true
7
+ field :badges, type: Array, default: []
8
+ list_field :badges
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,52 @@
1
+ module Workarea
2
+ decorate Storefront::ProductViewModel, with: :product_badges do
3
+ def badges
4
+ @badges ||= begin
5
+ badges = Badges.sort.call(model.badges + automatic_badges)
6
+
7
+ if Badges.max_badges.present?
8
+ badges.first(Badges.max_badges)
9
+ else
10
+ badges
11
+ end
12
+ end
13
+ end
14
+
15
+ def automatic_badges
16
+ [new_product_badge, sale_badge, best_seller_badge].compact
17
+ end
18
+
19
+ private
20
+ def new_product_badge
21
+ if new? && model.new_badge?
22
+ t("workarea.storefront.products.badges.new")
23
+ end
24
+ end
25
+
26
+ def sale_badge
27
+ if on_sale? && model.sale_badge?
28
+ t("workarea.storefront.products.badges.sale")
29
+ end
30
+ end
31
+
32
+ def best_seller_badge
33
+ if best_seller? && model.best_seller_badge?
34
+ t("workarea.storefront.products.badges.best_seller")
35
+ end
36
+ end
37
+
38
+ def best_sellers
39
+ top_seller_limit = Badges.number_of_top_sellers
40
+ @best_sellers ||= Workarea::Insights::TopProducts.current.results.first(top_seller_limit).map { |p| p["product_id"] }
41
+ end
42
+
43
+ def best_seller?
44
+ return false unless best_sellers.present?
45
+ model.id.in?(best_sellers)
46
+ end
47
+
48
+ def new?
49
+ model.public_send(Workarea.config.product_badges[:new_date_field]) > Badges.new_threshold.days.ago
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,40 @@
1
+ .property
2
+ = label_tag 'product_badges_list', t('workarea.admin.catalog_products.edit.custom_badges_label'), class: 'property__name'
3
+ = text_field_tag 'product[badges_list]', @product.badges_list, class: 'text-box'
4
+ %span.property__note
5
+ = t('workarea.admin.catalog_products.edit.tags_note')
6
+ = link_to '#csv-help', data: { tooltip: '' } do
7
+ = inline_svg('workarea/admin/icons/help.svg', class: 'svg-icon svg-icon--small svg-icon--blue', title: t('workarea.admin.catalog_products.edit.learn_more'))
8
+
9
+ %h2= t('workarea.admin.catalog_products.edit.auto_badging_enabled')
10
+
11
+ .grid
12
+ .grid__cell.grid__cell--25
13
+ .property
14
+ %span.property__name
15
+ = t('workarea.admin.catalog_products.edit.new_product_badge')
16
+ = link_to '#new-badge-info', data: { tooltip: '' } do
17
+ = inline_svg('workarea/admin/icons/help.svg', class: 'svg-icon svg-icon--small svg-icon--blue', title: t('workarea.admin.catalog_products.edit.new_product_badge'))
18
+ #new-badge-info.tooltip-content
19
+ %p= t('workarea.admin.catalog_products.edit.new_badge_tool_tip', new_threshold: Workarea::Badges.new_threshold)
20
+ = toggle_button_for 'product[new_badge]', @product.new_badge
21
+
22
+ .grid__cell.grid__cell--25
23
+ .property
24
+ %span.property__name
25
+ = t('workarea.admin.catalog_products.edit.sale_badge')
26
+ = link_to '#sale-badge-info', data: { tooltip: '' } do
27
+ = inline_svg('workarea/admin/icons/help.svg', class: 'svg-icon svg-icon--small svg-icon--blue', title: t('workarea.admin.catalog_products.edit.sale_badge'))
28
+ #sale-badge-info.tooltip-content
29
+ %p= t('workarea.admin.catalog_products.edit.sale_badge_tool_tip')
30
+ = toggle_button_for 'product[sale_badge]', @product.sale_badge
31
+
32
+ .grid__cell.grid__cell--25
33
+ .property
34
+ %span.property__name
35
+ = t('workarea.admin.catalog_products.edit.best_seller_badge')
36
+ = link_to '#best-seller-badge-info', data: { tooltip: '' } do
37
+ = inline_svg('workarea/admin/icons/help.svg', class: 'svg-icon svg-icon--small svg-icon--blue', title: t('workarea.admin.catalog_products.edit.best_seller_badge'))
38
+ #best-seller-badge-info.tooltip-content
39
+ %p= t('workarea.admin.catalog_products.edit.best_seller_badge_tool_tip', top_sellers: Workarea::Badges.number_of_top_sellers)
40
+ = toggle_button_for 'product[best_seller_badge]', @product.best_seller_badge
@@ -0,0 +1,5 @@
1
+ - if product.badges.present?
2
+ .badges
3
+ - product.badges.each do |badge|
4
+ .badges__badge{ class: "badges__badge--#{badge.parameterize}" }
5
+ .badges__badge-text= badge
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/product_badges/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,21 @@
1
+ module Workarea
2
+ Plugin.append_partials(
3
+ "admin.product_fields",
4
+ "workarea/admin/catalog_products/badge_fields"
5
+ )
6
+
7
+ Plugin.append_partials(
8
+ "storefront.product_summary",
9
+ "workarea/storefront/products/badges"
10
+ )
11
+
12
+ Plugin.append_partials(
13
+ "storefront.product_description",
14
+ "workarea/storefront/products/badges"
15
+ )
16
+
17
+ Plugin.append_stylesheets(
18
+ "storefront.components",
19
+ "workarea/product_badges/components/badges"
20
+ )
21
+ end
@@ -0,0 +1,9 @@
1
+ Workarea.configure do |config|
2
+ config.product_badges = {
3
+ new_threshold: 30,
4
+ new_date_field: :created_at,
5
+ number_of_top_sellers: 10,
6
+ max_badges: nil,
7
+ sort: ->(badges) { badges.sort_by { |b| ["New", "Sale", "Best Seller"].find_index(b) || 999 } }
8
+ }
9
+ end
@@ -0,0 +1,19 @@
1
+ en:
2
+ workarea:
3
+ admin:
4
+ catalog_products:
5
+ edit:
6
+ auto_badging_enabled: Auto badging enabled for...
7
+ best_seller_badge: Best Seller badge
8
+ best_seller_badge_tool_tip: This badge will show if it is in the top %{top_sellers} best selling products.
9
+ custom_badges_label: Custom badges
10
+ new_product_badge: New product badge
11
+ new_badge_tool_tip: This badge will show if the product was created within the last %{new_threshold} days.
12
+ sale_badge: Sale badge
13
+ sale_badge_tool_tip: This badge will show if any of the pricing records are set to on sale.
14
+ storefront:
15
+ products:
16
+ badges:
17
+ best_seller: Best Seller
18
+ new: New
19
+ sale: Sale
@@ -0,0 +1,8 @@
1
+ module Workarea
2
+ module ProductBadges
3
+ class Engine < ::Rails::Engine
4
+ include Workarea::Plugin
5
+ isolate_namespace Workarea::ProductBadges
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ module Workarea
2
+ module ProductBadges
3
+ VERSION = "1.3.2"
4
+ end
5
+ end
@@ -0,0 +1,30 @@
1
+ require "workarea"
2
+ require "workarea/storefront"
3
+ require "workarea/admin"
4
+
5
+ require "workarea/product_badges/engine"
6
+ require "workarea/product_badges/version"
7
+
8
+ module Workarea
9
+ module Badges
10
+ def self.new_threshold
11
+ config[:new_threshold].try(&:to_i) || 30
12
+ end
13
+
14
+ def self.number_of_top_sellers
15
+ config[:number_of_top_sellers].try(:to_i) || 10
16
+ end
17
+
18
+ def self.max_badges
19
+ config[:max_badges].try(:to_i)
20
+ end
21
+
22
+ def self.sort
23
+ config[:sort]
24
+ end
25
+
26
+ def self.config
27
+ Workarea.config.product_badges
28
+ end
29
+ end
30
+ end
data/script/admin_ci ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem install bundler
4
+ bundle update
5
+
6
+ CI_GEM_PATH="$(bundle show workarea-ci)"
7
+ . ${CI_GEM_PATH}/exe/workarea-set-ci-env
8
+
9
+ bin/rails app:workarea:test:admin
data/script/ci ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem install bundler
4
+ bundle update
5
+
6
+ CI_GEM_PATH="$(bundle show workarea-ci)"
7
+ . ${CI_GEM_PATH}/exe/workarea-set-ci-env
8
+
9
+ bundle exec workarea-lint
10
+ bundle exec workarea-audit
11
+ bin/rails test test/**/*_test.rb
data/script/core_ci ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem install bundler
4
+ bundle update
5
+
6
+ CI_GEM_PATH="$(bundle show workarea-ci)"
7
+ . ${CI_GEM_PATH}/exe/workarea-set-ci-env
8
+
9
+ bin/rails app:workarea:test:core
data/script/plugins_ci ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem install bundler
4
+ bundle update
5
+
6
+ CI_GEM_PATH="$(bundle show workarea-ci)"
7
+ . ${CI_GEM_PATH}/exe/workarea-set-ci-env
8
+
9
+ bin/rails app:workarea:test:plugins
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem install bundler
4
+ bundle update
5
+
6
+ CI_GEM_PATH="$(bundle show workarea-ci)"
7
+ . ${CI_GEM_PATH}/exe/workarea-set-ci-env
8
+
9
+ bin/rails app:workarea:test:storefront
@@ -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,38 @@
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== Copying sample files =="
26
+ # unless File.exist?('config/database.yml')
27
+ # cp 'config/database.yml.sample', 'config/database.yml'
28
+ # end
29
+
30
+ puts "\n== Preparing database =="
31
+ system! 'bin/rails db:setup'
32
+
33
+ puts "\n== Removing old logs and tempfiles =="
34
+ system! 'bin/rails log:clear tmp:clear'
35
+
36
+ puts "\n== Restarting application server =="
37
+ system! 'bin/rails restart'
38
+ end
@@ -0,0 +1,29 @@
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== Updating database =="
22
+ system! 'bin/rails db:migrate'
23
+
24
+ puts "\n== Removing old logs and tempfiles =="
25
+ system! 'bin/rails log:clear tmp:clear'
26
+
27
+ puts "\n== Restarting application server =="
28
+ system! 'bin/rails restart'
29
+ 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,26 @@
1
+ require_relative "boot"
2
+
3
+ require "action_controller/railtie"
4
+ require "action_view/railtie"
5
+ require "action_mailer/railtie"
6
+ require "rails/test_unit/railtie"
7
+ require "sprockets/railtie"
8
+ require "teaspoon-mocha"
9
+
10
+ # Workarea must be required before other gems to ensure control over Rails.env
11
+ # for running tests
12
+ require "workarea/core"
13
+ require "workarea/admin"
14
+ require "workarea/storefront"
15
+ Bundler.require(*Rails.groups)
16
+ require "workarea/product_badges"
17
+
18
+ module Dummy
19
+ class Application < Rails::Application
20
+ # Initialize configuration defaults for originally generated Rails version.
21
+
22
+ # Settings in config/environments/* take precedence over those specified here.
23
+ # Application configuration should go into files in config/initializers
24
+ # -- all .rb files in that directory are automatically loaded.
25
+ end
26
+ 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!