workarea-reviews 3.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.eslintignore +2 -0
  4. data/.eslintrc +24 -0
  5. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  6. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  7. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  8. data/.gitignore +16 -0
  9. data/.scss-lint.yml +188 -0
  10. data/.yardopts +1 -0
  11. data/CHANGELOG.md +763 -0
  12. data/CODE_OF_CONDUCT.md +3 -0
  13. data/CONTRIBUTING.md +3 -0
  14. data/Gemfile +6 -0
  15. data/LICENSE +52 -0
  16. data/README.md +107 -0
  17. data/Rakefile +54 -0
  18. data/app/assets/images/workarea/admin/icons/star.svg +1 -0
  19. data/app/assets/images/workarea/storefront/icons/empty_star.svg +1 -0
  20. data/app/assets/images/workarea/storefront/icons/half_star.svg +1 -0
  21. data/app/assets/images/workarea/storefront/icons/star.svg +1 -0
  22. data/app/assets/javascripts/workarea/storefront/reviews/modules/product_review_ajax_submit.js +39 -0
  23. data/app/assets/javascripts/workarea/storefront/reviews/modules/product_reviews_sort_menus.js +82 -0
  24. data/app/assets/javascripts/workarea/storefront/reviews/modules/rating_buttons.js +103 -0
  25. data/app/assets/javascripts/workarea/storefront/reviews/templates/sort_by_property.jst.ejs +11 -0
  26. data/app/assets/stylesheets/workarea/storefront/reviews/components/_rating.scss +28 -0
  27. data/app/assets/stylesheets/workarea/storefront/reviews/components/_reviews.scss +59 -0
  28. data/app/assets/stylesheets/workarea/storefront/reviews/components/_reviews_aggregate.scss +38 -0
  29. data/app/assets/stylesheets/workarea/storefront/reviews/components/_write_review.scss +63 -0
  30. data/app/controllers/workarea/admin/catalog_products_controller.decorator +9 -0
  31. data/app/controllers/workarea/admin/import_reviews_controller.rb +35 -0
  32. data/app/controllers/workarea/admin/reviews_controller.rb +51 -0
  33. data/app/controllers/workarea/storefront/review_requests_controller.rb +50 -0
  34. data/app/controllers/workarea/storefront/reviews_controller.rb +53 -0
  35. data/app/helpers/workarea/admin/reviews_helper.rb +12 -0
  36. data/app/helpers/workarea/storefront/reviews_helper.rb +24 -0
  37. data/app/mailers/workarea/admin/status_report_mailer.decorator +8 -0
  38. data/app/mailers/workarea/storefront/review_mailer.rb +23 -0
  39. data/app/models/workarea/catalog/product.decorator +15 -0
  40. data/app/models/workarea/fulfillment.decorator +11 -0
  41. data/app/models/workarea/review.rb +135 -0
  42. data/app/models/workarea/review/request.rb +62 -0
  43. data/app/models/workarea/search/admin/review.rb +72 -0
  44. data/app/models/workarea/search/storefront/product.decorator +9 -0
  45. data/app/models/workarea/sort.decorator +17 -0
  46. data/app/queries/workarea/review_request_params.rb +47 -0
  47. data/app/queries/workarea/review_summary.rb +11 -0
  48. data/app/queries/workarea/search/admin_reviews.rb +40 -0
  49. data/app/queries/workarea/search/category_browse.decorator +9 -0
  50. data/app/queries/workarea/search/product_search.decorator +9 -0
  51. data/app/seeds/review_seeds.rb +49 -0
  52. data/app/services/workarea/create_review.rb +99 -0
  53. data/app/view_models/workarea/admin/product_view_model.decorator +7 -0
  54. data/app/view_models/workarea/admin/review_view_model.rb +23 -0
  55. data/app/view_models/workarea/admin/reviews_search_view_model.rb +46 -0
  56. data/app/view_models/workarea/storefront/product_view_model.decorator +13 -0
  57. data/app/view_models/workarea/storefront/review_view_model.rb +14 -0
  58. data/app/views/workarea/admin/activities/_review_create.html.haml +12 -0
  59. data/app/views/workarea/admin/activities/_review_destroy.html.haml +10 -0
  60. data/app/views/workarea/admin/activities/_review_update.html.haml +10 -0
  61. data/app/views/workarea/admin/reviews/_aux_navigation.html.haml +5 -0
  62. data/app/views/workarea/admin/reviews/_catalog_products_aux_link.html.haml +5 -0
  63. data/app/views/workarea/admin/reviews/_dashboard_navigation.html.haml +1 -0
  64. data/app/views/workarea/admin/reviews/_menu.html.haml +3 -0
  65. data/app/views/workarea/admin/reviews/_summary.html.haml +12 -0
  66. data/app/views/workarea/admin/reviews/edit.html.haml +77 -0
  67. data/app/views/workarea/admin/reviews/index.html.haml +74 -0
  68. data/app/views/workarea/admin/status_report_mailer/_reviews.html.haml +5 -0
  69. data/app/views/workarea/storefront/products/_rating.html.haml +10 -0
  70. data/app/views/workarea/storefront/products/_reviews.html.haml +23 -0
  71. data/app/views/workarea/storefront/products/_reviews_aggregate.html.haml +22 -0
  72. data/app/views/workarea/storefront/products/_reviews_summary.html.haml +2 -0
  73. data/app/views/workarea/storefront/review_mailer/review_request.html.haml +22 -0
  74. data/app/views/workarea/storefront/review_requests/show.html.haml +44 -0
  75. data/app/views/workarea/storefront/reviews/new.html.haml +68 -0
  76. data/app/views/workarea/storefront/style_guides/_reviews_product_summary_docs.html.haml +13 -0
  77. data/app/views/workarea/storefront/style_guides/components/_reviews.html.haml +17 -0
  78. data/app/workers/workarea/create_review_requests.rb +33 -0
  79. data/app/workers/workarea/schedule_review_requests.rb +44 -0
  80. data/app/workers/workarea/send_review_requests.rb +12 -0
  81. data/app/workers/workarea/update_product_review_data.rb +26 -0
  82. data/bin/rails +18 -0
  83. data/config/initializers/append_points.rb +70 -0
  84. data/config/initializers/assets.rb +1 -0
  85. data/config/initializers/configuration.rb +29 -0
  86. data/config/initializers/rack_attack.rb +11 -0
  87. data/config/initializers/recaptcha.rb +19 -0
  88. data/config/initializers/scheduled_jobs.rb +8 -0
  89. data/config/locales/en.yml +104 -0
  90. data/config/routes.rb +21 -0
  91. data/lib/tasks/verify.rake +16 -0
  92. data/lib/workarea/mailer_previews/storefront/review_mailer_preview.rb +10 -0
  93. data/lib/workarea/reviews.rb +13 -0
  94. data/lib/workarea/reviews/engine.rb +12 -0
  95. data/lib/workarea/reviews/version.rb +5 -0
  96. data/test/dummy/Rakefile +6 -0
  97. data/test/dummy/app/assets/config/manifest.js +4 -0
  98. data/test/dummy/app/assets/images/.keep +0 -0
  99. data/test/dummy/app/assets/javascripts/application.js +13 -0
  100. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  101. data/test/dummy/app/controllers/application_controller.rb +3 -0
  102. data/test/dummy/app/controllers/concerns/.keep +0 -0
  103. data/test/dummy/app/helpers/application_helper.rb +2 -0
  104. data/test/dummy/app/jobs/application_job.rb +2 -0
  105. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  106. data/test/dummy/app/models/concerns/.keep +0 -0
  107. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  108. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  109. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  110. data/test/dummy/bin/bundle +3 -0
  111. data/test/dummy/bin/rails +4 -0
  112. data/test/dummy/bin/rake +4 -0
  113. data/test/dummy/bin/setup +34 -0
  114. data/test/dummy/bin/update +29 -0
  115. data/test/dummy/config.ru +5 -0
  116. data/test/dummy/config/application.rb +25 -0
  117. data/test/dummy/config/boot.rb +5 -0
  118. data/test/dummy/config/cable.yml +9 -0
  119. data/test/dummy/config/environment.rb +5 -0
  120. data/test/dummy/config/environments/development.rb +55 -0
  121. data/test/dummy/config/environments/production.rb +86 -0
  122. data/test/dummy/config/environments/test.rb +43 -0
  123. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  124. data/test/dummy/config/initializers/assets.rb +11 -0
  125. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  126. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  127. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  128. data/test/dummy/config/initializers/inflections.rb +16 -0
  129. data/test/dummy/config/initializers/mime_types.rb +4 -0
  130. data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
  131. data/test/dummy/config/initializers/session_store.rb +3 -0
  132. data/test/dummy/config/initializers/workarea.rb +5 -0
  133. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  134. data/test/dummy/config/locales/en.yml +23 -0
  135. data/test/dummy/config/puma.rb +47 -0
  136. data/test/dummy/config/routes.rb +5 -0
  137. data/test/dummy/config/secrets.yml +22 -0
  138. data/test/dummy/config/spring.rb +6 -0
  139. data/test/dummy/db/seeds.rb +2 -0
  140. data/test/dummy/lib/assets/.keep +0 -0
  141. data/test/dummy/log/.keep +0 -0
  142. data/test/factories/reviews.rb +32 -0
  143. data/test/fixtures/reviews.csv +5 -0
  144. data/test/helpers/workarea/admin/reviews_helper_test.rb +17 -0
  145. data/test/helpers/workarea/storefront/reviews_helper_test.rb +19 -0
  146. data/test/integration/workarea/admin/reviews_integration_test.rb +33 -0
  147. data/test/integration/workarea/storefront/review_requests_integration_test.rb +63 -0
  148. data/test/integration/workarea/storefront/reviews_integration_test.rb +82 -0
  149. data/test/javascripts/fixtures/product_review_ajax_submit.html.haml +4 -0
  150. data/test/javascripts/product_review_ajax_submit_spec.js +28 -0
  151. data/test/javascripts/spec_helper.js +23 -0
  152. data/test/models/workarea/review/request_test.rb +18 -0
  153. data/test/models/workarea/review_test.rb +94 -0
  154. data/test/models/workarea/search/storefront/product_test.decorator +14 -0
  155. data/test/queries/workarea/review_request_params_test.rb +64 -0
  156. data/test/services/workarea/create_review_test.rb +131 -0
  157. data/test/system/workarea/admin/review_system_test.rb +96 -0
  158. data/test/system/workarea/storefront/review_request_system_test.rb +34 -0
  159. data/test/system/workarea/storefront/review_system_test.rb +113 -0
  160. data/test/teaspoon_env.rb +10 -0
  161. data/test/test_helper.rb +11 -0
  162. data/test/workers/workarea/create_review_requests_test.rb +38 -0
  163. data/test/workers/workarea/schedule_review_requests_test.rb +115 -0
  164. data/test/workers/workarea/send_review_requests_test.rb +30 -0
  165. data/workarea-reviews.gemspec +22 -0
  166. metadata +241 -0
@@ -0,0 +1 @@
1
+ Rails.application.config.assets.precompile += %w( workarea/**/icons/*.svg )
@@ -0,0 +1,29 @@
1
+ Workarea.configure do |config|
2
+ config.seeds << 'Workarea::ReviewSeeds'
3
+
4
+ config.jump_to_navigation.merge!('Product Reviews' => :reviews_path)
5
+
6
+ config.product_copy_default_attributes ||= {}
7
+ config.product_copy_default_attributes.merge!(
8
+ total_reviews: 0,
9
+ average_rating: nil
10
+ )
11
+
12
+ config.data_file_ignored_fields << %w(total_reviews average_rating)
13
+
14
+ # The amount of time before a Review::Request will auto expire
15
+ # and be removed from the collection
16
+ config.review_request_ttl = 6.months
17
+
18
+ # The maximum number of review requests to send for each order
19
+ # Each request will be for a different order item, selected by
20
+ # most expensive.
21
+ config.review_requests_per_order = 3
22
+
23
+ # The amount of time after an order is shipped before the first review
24
+ # requests will be sent.
25
+ config.review_request_initial_delivery_delay = 14.days
26
+
27
+ # The amount of time after the last request was sent to send another.
28
+ config.review_request_secondary_delivery_delay = 5.days
29
+ end
@@ -0,0 +1,11 @@
1
+ class Rack::Attack
2
+ # Throttle POST requests to /reviews by email address
3
+ #
4
+ # Key: "rack::attack:#{Time.now.to_i/:period}:reviews/email:#{req.email}"
5
+ throttle('reviews/email', limit: 2, period: 2.minutes) do |req|
6
+ if req.path == '/reviews' && req.post?
7
+ # return the email if present, nil otherwise
8
+ req.params['email'].presence
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ recaptcha =
2
+ if Rails.application.secrets.recaptcha.present?
3
+ Rails.application.secrets.recaptcha.symbolize_keys
4
+ elsif Rails.env.development? || Rails.env.test?
5
+ # These are keys provided by google for the purpose of testing.
6
+ # See https://developers.google.com/recaptcha/docs/faq
7
+ {
8
+ site_key: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI',
9
+ secret_key: '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'
10
+ }
11
+ end
12
+
13
+ if recaptcha.present?
14
+ Recaptcha.configure do |config|
15
+ config.site_key = recaptcha[:site_key]
16
+ config.secret_key = recaptcha[:secret_key]
17
+ config.proxy = ENV.fetch('HTTP_PROXY', (recaptcha[:proxy] if recaptcha[:proxy].present?))
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ unless Workarea.config.skip_service_connections
2
+ Sidekiq::Cron::Job.create(
3
+ name: 'Workarea::SendReviewRequests',
4
+ klass: 'Workarea::SendReviewRequests',
5
+ cron: "0 0 * * * #{Time.zone.tzinfo.identifier}",
6
+ queue: 'low'
7
+ )
8
+ end
@@ -0,0 +1,104 @@
1
+ en:
2
+ workarea:
3
+ admin:
4
+ activities:
5
+ review: Review
6
+ review_create_html: Created a %{name}
7
+ review_destroy_html: Removed a %{name}
8
+ review_update_html: updated %{fields} on the %{name} review
9
+ catalog:
10
+ dashboard_link: Dashboard link
11
+ catalog_products:
12
+ reviews_link: All Reviews
13
+ pending: (%{pending} Pending)
14
+ dashboards:
15
+ marketing:
16
+ reviews: Product reviews
17
+ fields:
18
+ body: Body
19
+ title: Title
20
+ rating: Rating
21
+ approved: Approved
22
+ auto_approve: Approve All Reviews
23
+ verified: Verified Purchaser
24
+ reviews:
25
+ approved: Approved
26
+ catalog_products_cards:
27
+ title: Reviews
28
+ edit:
29
+ review: Review
30
+ review_for_html: Review for %{product_link}
31
+ save_review: Save Review
32
+ title: Title
33
+ view_product: View Product
34
+ view_user: View User
35
+ flash_messages:
36
+ destroyed: Review has been removed.
37
+ updated: Review has been saved
38
+ index:
39
+ dashboard_link: Marketing dashboard
40
+ heading: Reviews
41
+ page_title: Reviews
42
+ review: Review
43
+ review_for: Review for %{product}
44
+ menu:
45
+ product_reviews:
46
+ one: Product Reviews (%{count})
47
+ other: Product Reviews (%{count})
48
+ zero: Product Reviews
49
+ pending: Pending
50
+ summary:
51
+ type: Review
52
+ unverified: Unverified
53
+ verified: Verified
54
+ status_report_mailer:
55
+ reviews:
56
+ pending_html: "%{count} awaiting approval."
57
+ review: review
58
+ recent_html: "%{count} submitted within the last day."
59
+ title: Reviews
60
+ sorts:
61
+ top_rated: Top Rated
62
+ highest_rating: Highest Rating
63
+ lowest_rating: Lowest Rating
64
+ storefront:
65
+ email:
66
+ review_request:
67
+ subject: Review your recent purchase of %{product}
68
+ link: Write a review
69
+ fields:
70
+ username: Username
71
+ review_requests:
72
+ flash_messages:
73
+ already_submitted: This review has already been submitted.
74
+ reviews:
75
+ flash_messages:
76
+ created: Your review has been submitted. Thanks!
77
+ failure: There was a problem saving your review.
78
+ heading: Reviews
79
+ out_of: out of
80
+ purchase_requirement: A purchase is required before you can post a review
81
+ rating: Rating
82
+ read_reviews: Read Reviews
83
+ review_for: Review for %{product}
84
+ review_title: Review Title
85
+ reviews:
86
+ one: "%{count} review"
87
+ other: "%{count} reviews"
88
+ zero: "%{count} reviews"
89
+ stars:
90
+ one: 1 star
91
+ other: "%{count} stars"
92
+ submit: Submit Review
93
+ submit_disabled: Submitting Review...
94
+ total_spent_validation: must make a purchase before creating a review
95
+ verified_purchaser: Verified Purchaser
96
+ write_a_review: Write a Review
97
+ write_a_review_title: Write a Review for "%{name}"
98
+ your_review: Your Review
99
+ notes:
100
+ display_name: Only the first letter of your name will be displayed.
101
+ email: Will only be used if we need to get in touch with you.
102
+ users:
103
+ first_name: First name
104
+ last_name: Last name
@@ -0,0 +1,21 @@
1
+ Workarea::Admin::Engine.routes.draw do
2
+ scope '(:locale)', constraints: Workarea::I18n.routes_constraint do
3
+ resources :reviews, except: [:new, :create]
4
+ resources :catalog_products, only: [] do
5
+ member do
6
+ get :reviews
7
+ end
8
+ end
9
+ end
10
+ end
11
+
12
+ Workarea::Storefront::Engine.routes.draw do
13
+ scope '(:locale)', constraints: Workarea::I18n.routes_constraint do
14
+ get 'reviews/:product_id/new' => 'reviews#new', as: :new_product_review
15
+ post 'reviews/:product_id' => 'reviews#create', as: :create_product_review
16
+
17
+ resources :review_requests, only: :show do
18
+ member { post :complete }
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ namespace :workarea do
2
+ namespace :reviews do
3
+ desc 'Assign verified to each review based on whether the user has any orders with the product being reviewed'
4
+ task verify: :environment do
5
+ Workarea::Review.all.each_by(100) do |review|
6
+ user = Workarea::User.find(review.user_id) rescue nil
7
+
8
+ next unless user.present?
9
+
10
+ creator = Workarea::CreateReview.new(review, user: user)
11
+
12
+ review.update!(verified: creator.verified?)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ module Workarea
2
+ module Storefront
3
+ class ReviewMailerPreview < ActionMailer::Preview
4
+ def review_request
5
+ request = Review::Request.ready_to_send.first || Review::Request.first
6
+ ReviewMailer.review_request(request.id.to_s)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ require 'workarea'
2
+ require 'workarea/storefront'
3
+ require 'workarea/admin'
4
+
5
+ require 'recaptcha/rails'
6
+
7
+ module Workarea
8
+ module Reviews
9
+ end
10
+ end
11
+
12
+ require 'workarea/reviews/version'
13
+ require 'workarea/reviews/engine'
@@ -0,0 +1,12 @@
1
+ module Workarea
2
+ module Reviews
3
+ class Engine < ::Rails::Engine
4
+ include Workarea::Plugin
5
+ isolate_namespace Workarea::Reviews
6
+
7
+ config.to_prepare do
8
+ Storefront::ApplicationController.helper(Storefront::ReviewsHelper)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Workarea
2
+ module Reviews
3
+ VERSION = '3.0.10'.freeze
4
+ end
5
+ 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
@@ -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', 'data-turbolinks-track': 'reload' %>
8
+ <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
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,34 @@
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
+ # puts "\n== Copying sample files =="
22
+ # unless File.exist?('config/database.yml')
23
+ # cp 'config/database.yml.sample', 'config/database.yml'
24
+ # end
25
+
26
+ puts "\n== Preparing database =="
27
+ system! 'bin/rails db:setup'
28
+
29
+ puts "\n== Removing old logs and tempfiles =="
30
+ system! 'bin/rails log:clear tmp:clear'
31
+
32
+ puts "\n== Restarting application server =="
33
+ system! 'bin/rails restart'
34
+ 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