journea 0.1.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.
Files changed (135) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +8 -0
  3. data/README.md +131 -0
  4. data/Rakefile +26 -0
  5. data/app/controllers/journea/engine_controller.rb +19 -0
  6. data/app/controllers/journea/journeys_controller.rb +10 -0
  7. data/app/controllers/journea/steps_controller.rb +52 -0
  8. data/app/helpers/journea/form_helper.rb +25 -0
  9. data/app/models/journea/journey.rb +54 -0
  10. data/app/models/journea/journey_transition.rb +17 -0
  11. data/app/models/journea/keyvalue.rb +5 -0
  12. data/app/views/application/_back_link.html.haml +5 -0
  13. data/config/initializers/simple_form.rb +179 -0
  14. data/config/locales/simple_form.en.yml +31 -0
  15. data/config/routes.rb +5 -0
  16. data/db/migrate/20161201153630_create_journey_transitions.rb +22 -0
  17. data/db/migrate/20161201162349_create_journeys_table.rb +10 -0
  18. data/db/migrate/20161202162350_create_keyvalues_table.rb +11 -0
  19. data/lib/generators/journea/install_generator.rb +76 -0
  20. data/lib/generators/journea/templates/assets/application.js +23 -0
  21. data/lib/generators/journea/templates/assets/application.scss +49 -0
  22. data/lib/generators/journea/templates/config/initializers/journea.rb +23 -0
  23. data/lib/generators/journea/templates/config/initializers/journea2.rb +24 -0
  24. data/lib/generators/journea/templates/controllers/pages_controller.rb.example +2 -0
  25. data/lib/generators/journea/templates/views/application.html.haml +20 -0
  26. data/lib/generators/journea/templates/views/pages/start.html.haml.example +12 -0
  27. data/lib/generators/journea/templates/views/shared/error_messages.html.haml.example +7 -0
  28. data/lib/generators/journea/templates/views/steps/step.html.haml.example +8 -0
  29. data/lib/journea.rb +25 -0
  30. data/lib/journea/data.rb +20 -0
  31. data/lib/journea/engine.rb +27 -0
  32. data/lib/journea/state_machine.rb +40 -0
  33. data/lib/journea/step.rb +32 -0
  34. data/lib/journea/version.rb +3 -0
  35. data/lib/simple_form_object.rb +146 -0
  36. data/lib/tasks/journea_tasks.rake +4 -0
  37. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  38. data/spec/dummy/Rakefile +6 -0
  39. data/spec/dummy/app/assets/config/manifest.js +5 -0
  40. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  41. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  42. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  43. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  44. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  45. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  46. data/spec/dummy/app/controllers/pages_controller.rb +4 -0
  47. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  48. data/spec/dummy/app/jobs/application_job.rb +2 -0
  49. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  50. data/spec/dummy/app/models/application_record.rb +3 -0
  51. data/spec/dummy/app/steps/address_step.rb +4 -0
  52. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  53. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  54. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  55. data/spec/dummy/app/views/pages/start.html.erb +1 -0
  56. data/spec/dummy/app/views/steps/address.html.erb +5 -0
  57. data/spec/dummy/app/views/steps/name.html.erb +5 -0
  58. data/spec/dummy/app/views/steps/phone_number.html.erb +0 -0
  59. data/spec/dummy/bin/bundle +3 -0
  60. data/spec/dummy/bin/rails +4 -0
  61. data/spec/dummy/bin/rake +4 -0
  62. data/spec/dummy/bin/setup +34 -0
  63. data/spec/dummy/bin/update +29 -0
  64. data/spec/dummy/config.ru +5 -0
  65. data/spec/dummy/config/application.rb +14 -0
  66. data/spec/dummy/config/boot.rb +5 -0
  67. data/spec/dummy/config/cable.yml +9 -0
  68. data/spec/dummy/config/database.yml +25 -0
  69. data/spec/dummy/config/environment.rb +5 -0
  70. data/spec/dummy/config/environments/development.rb +54 -0
  71. data/spec/dummy/config/environments/production.rb +86 -0
  72. data/spec/dummy/config/environments/test.rb +42 -0
  73. data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
  74. data/spec/dummy/config/initializers/assets.rb +11 -0
  75. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  76. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  77. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  78. data/spec/dummy/config/initializers/inflections.rb +16 -0
  79. data/spec/dummy/config/initializers/journea.rb +8 -0
  80. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  81. data/spec/dummy/config/initializers/new_framework_defaults.rb +24 -0
  82. data/spec/dummy/config/initializers/session_store.rb +3 -0
  83. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  84. data/spec/dummy/config/locales/en.yml +23 -0
  85. data/spec/dummy/config/puma.rb +47 -0
  86. data/spec/dummy/config/routes.rb +4 -0
  87. data/spec/dummy/config/secrets.yml +22 -0
  88. data/spec/dummy/config/spring.rb +6 -0
  89. data/spec/dummy/db/development.sqlite3 +0 -0
  90. data/spec/dummy/db/schema.rb +42 -0
  91. data/spec/dummy/db/test.sqlite3 +0 -0
  92. data/spec/dummy/log/development.log +57 -0
  93. data/spec/dummy/log/test.log +448 -0
  94. data/spec/dummy/public/404.html +67 -0
  95. data/spec/dummy/public/422.html +67 -0
  96. data/spec/dummy/public/500.html +66 -0
  97. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  98. data/spec/dummy/public/apple-touch-icon.png +0 -0
  99. data/spec/dummy/public/favicon.ico +0 -0
  100. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/EA/EAR2KaBsPQau6HwaTGrxV7EGMwAWyS-4C8pGVDU1Z-Q.cache +1 -0
  101. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/JZ/JZuPFgM2mLQgAHB-r7Pt_TdGW3DRWPrplT7xPjnCJSE.cache +1 -0
  102. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/LT/LTt1oE1gi9m65YRwUp78DuufkCOfi3sa3Qa05_ykADk.cache +1 -0
  103. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Lj/LjRKOqtrClPtb97phuIWI7HHA8-p5J5nKHVE_zEycxo.cache +1 -0
  104. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/QM/QMxUWUtpFaqwG3RI9t3m38QtFAOvHpiY3LphKJiVRTc.cache +1 -0
  105. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/St/StFuOi5bd69ceiqz2D6EOCmRzHgwY0IxERsMfiCneGM.cache +1 -0
  106. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Vj/VjCUmI9pp5eD8BlYATbwJ4ZOk0438rwvtDrsttyWbfQ.cache +0 -0
  107. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Wl/WlLcUIADXcUxaOt8Gq59uQbO0mquikyz7jxiJjXjhaI.cache +1 -0
  108. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/YH/YHo__TrFq5y8rpx49T8d8ecyvMLbHFbnhz7IBV7pM98.cache +1 -0
  109. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Zu/ZuLXgeX6x_Dx8sCUbzuTtWu42HzQXWe7eooTgsonTnc.cache +0 -0
  110. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aG/aG1tp1pv4kBiSKx9ixZH5xiRXH-rGa0Hi6sdl4SHw6g.cache +3 -0
  111. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aw/awTDtuorxLsRLIGEYCefR-PTN7yptoaGRLEk13vHVLA.cache +1 -0
  112. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/b_/b_Itlk9QZZd7Rvf8kcA4yLP1R5Acu7jB-m1xQiSU0qE.cache +2 -0
  113. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/cW/cWHxYOqms7abJ-dzXyrn2G7nadJicU5kkC8SduS06yc.cache +0 -0
  114. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/cb/cbX7RFavWZoWojlrsXhsy4FN46UOfMwZYStkLHT5HJw.cache +1 -0
  115. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/eY/eYTHvo0Wl2TD2vipDcJ966HHXGrA4ZlJaiA2DnftKhM.cache +1 -0
  116. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/f4/f4CpFuYmsdh1EvlFVjsl1WmM2QA9_z9AuOebEOw4mts.cache +0 -0
  117. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gH/gHSjqTBRSW22rP9mSj8XW6huEXKpcIOehvF-2fvuShQ.cache +1 -0
  118. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m0/m0smDeM83DcmOVpX9zos6AIX40E9Tf2j26tyvKFgMwc.cache +1 -0
  119. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mW/mWrwQwWUQpAlMCLQ8dGv5VkAXd-TxvAtB5WPg9l09-A.cache +1 -0
  120. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mX/mX1nlsL_SWOB4y22W5FheRX0YEONKyOY7xUeIvRiHco.cache +2 -0
  121. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/n_/n_xYqQYhwEMQknb3jFQnjlxxBE9TzMNHCdJ-bEyZFIw.cache +2 -0
  122. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/nx/nxTv3sKVUQZADJyM3dPaVmUA78MIsMLD_K279yN_GsI.cache +2 -0
  123. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/oA/oAtzk5ZeF7lWCwNufspgWqtv_dQN_n5GumFNB4ScfBE.cache +2 -0
  124. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/rA/rACdJeX3jZNkhx4awGhdZeMdOfmARubkoVKVAZdwYog.cache +0 -0
  125. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sC/sCEBZXwTjRpEzThf7YHzHNfkAupMVOx_Ko7WNMAFHS0.cache +0 -0
  126. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/x7/x7PYh8DJvPykcEqpVab2vcY9-GFz-3cqtoMlRAu94Uc.cache +2 -0
  127. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yT/yTOf3QInGfDlRZlwZNDBLlbma19FQRHM035AKRxcRyw.cache +0 -0
  128. data/spec/features/journey_spec.rb +9 -0
  129. data/spec/lib/simple_form_object/attribute_spec.rb +74 -0
  130. data/spec/lib/simple_form_object/delegation_spec.rb +50 -0
  131. data/spec/lib/simple_form_object/model_spec.rb +90 -0
  132. data/spec/lib/steps_spec.rb +0 -0
  133. data/spec/requests/journeys_spec.rb +6 -0
  134. data/spec/spec_helper.rb +44 -0
  135. metadata +449 -0
@@ -0,0 +1,32 @@
1
+ require "simple_form_object"
2
+
3
+ module Journea
4
+ class Step
5
+ attr_accessor :journey
6
+
7
+ include SimpleFormObject
8
+
9
+ @custom_name = ""
10
+ class << self
11
+ attr_accessor :custom_name
12
+ end
13
+
14
+ def self.permitted_params
15
+ attributes.map(&:name)
16
+ end
17
+
18
+ def self.step_name
19
+ custom_name.presence || model_name.to_s.underscore
20
+ end
21
+
22
+ def step_name
23
+ self.class.step_name
24
+ end
25
+
26
+ def pre_save(form_params) end
27
+
28
+ def persisted?
29
+ true
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Journea
2
+ VERSION = "0.1.0".freeze
3
+ end
@@ -0,0 +1,146 @@
1
+ # Originally from: https://github.com/reinteractive-open/simple_form_object
2
+ # Copied here (along with specs) so we can add Rails 5 support and tweak as needed
3
+ module SimpleFormObject
4
+ extend ActiveSupport::Concern
5
+ include ActiveModel::Model
6
+ include ActiveModel::Callbacks
7
+
8
+ # TODO: There are a number of self. calls that rubocop claims are redundant
9
+ # in this file that need to be investigated.
10
+ # rubocop:disable Style/RedundantSelf
11
+ module ClassMethods
12
+ def attribute(name, type = :string, options = {})
13
+ self.send(:attr_accessor, name)
14
+
15
+ _attributes << Attribute.new(name, options, type)
16
+ end
17
+
18
+ def delegate_all(options = {})
19
+ @_delegation_target = options.fetch(:to)
20
+ end
21
+
22
+ def _delegation_target
23
+ @_delegation_target
24
+ end
25
+
26
+ def _attributes
27
+ @_attributes ||= []
28
+ end
29
+
30
+ def attributes
31
+ @_attributes
32
+ end
33
+
34
+ def _attribute(attribute_name)
35
+ _attributes.select { |a| a.name == attribute_name }.first
36
+ end
37
+
38
+ def model_name
39
+ ActiveModel::Name.new(self, nil, self.to_s.gsub(/Step$/, ""))
40
+ end
41
+ end
42
+
43
+ # TODO: Currently having to eat this rubocop error until such time as we
44
+ # understand what form the respond_to_missing? should take
45
+ # rubocop:disable Style/MethodMissing
46
+ def method_missing(method, *args, &block)
47
+ return super unless delegatable?(method)
48
+
49
+ # TODO: Figure out why self.class.delegate(method, to: self.class._delegation_target)
50
+ # doesn't work.
51
+
52
+ # TODO: At this time don't understand enough about the gem to understand how
53
+ # best to resolve this issue.
54
+ # rubocop:disable Lint/ShadowingOuterLocalVariable
55
+ self.class.send(:define_method, method) do |*args, &block|
56
+ _delegation_target.send(method, *args, &block)
57
+ end
58
+ # rubocop:enable Lint/ShadowingOuterLocalVariable
59
+
60
+ send(method, *args, &block)
61
+ end
62
+ # rubocop:enable Style/MethodMissing
63
+
64
+ def delegatable?(method)
65
+ if !_delegation_target.nil?
66
+ _delegation_target.respond_to?(method)
67
+ else
68
+ false
69
+ end
70
+ end
71
+
72
+ def _delegation_target
73
+ target = self.class._delegation_target
74
+
75
+ if target.is_a? Symbol
76
+ self.send(target)
77
+ else
78
+ target
79
+ end
80
+ end
81
+
82
+ def column_for_attribute(attribute)
83
+ self.class._attribute(attribute).fake_column
84
+ end
85
+
86
+ def attribute?(attribute_name)
87
+ self.class._attribute(attribute_name).present?
88
+ end
89
+
90
+ def initialize(attributes = {})
91
+ super
92
+ self.class._attributes.each do |attribute|
93
+ attribute.apply_default_to(self)
94
+ end
95
+ end
96
+
97
+ def attributes
98
+ attribs = {}
99
+ self.class._attributes.each do |a|
100
+ attribs[a.name] = self.send(a.name)
101
+ end
102
+ attribs
103
+ end
104
+
105
+ class Attribute
106
+ def initialize(name, options, type = nil)
107
+ @name = name
108
+ @type = type || :string
109
+ @options = options
110
+
111
+ extract_options
112
+ end
113
+
114
+ attr_accessor :name, :type, :options
115
+
116
+ def fake_column
117
+ self
118
+ end
119
+
120
+ def apply_default_to(form)
121
+ return unless form.send(@name).nil?
122
+
123
+ form.send("#{@name}=", default_value(form)) if @apply_default
124
+ end
125
+
126
+ private
127
+
128
+ def default_value(context)
129
+ if @default.respond_to?(:call)
130
+ context.instance_eval(&@default)
131
+ else
132
+ @default
133
+ end
134
+ end
135
+
136
+ def extract_options
137
+ @apply_default = true
138
+ @default = options.fetch(:default) do
139
+ @apply_default = false
140
+ nil
141
+ end
142
+ @skip_validations = options.fetch(:skip_validations, false)
143
+ end
144
+ end
145
+ # rubocop:enable Style/RedundantSelf
146
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :journey do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,13 @@
1
+ <%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
2
+ <%%= f.error_notification %>
3
+
4
+ <div class="form-inputs">
5
+ <%- attributes.each do |attribute| -%>
6
+ <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
7
+ <%- end -%>
8
+ </div>
9
+
10
+ <div class="form-actions">
11
+ <%%= f.button :submit %>
12
+ </div>
13
+ <%% 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,5 @@
1
+
2
+ //= link_tree ../images
3
+ //= link_directory ../javascripts .js
4
+ //= link_directory ../stylesheets .css
5
+ //= link journey_manifest.js
@@ -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,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the rails generate channel command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -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,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+ end
@@ -0,0 +1,4 @@
1
+ class PagesController < ApplicationController
2
+ def start
3
+ end
4
+ 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
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,4 @@
1
+ class AddressStep < Journea::Step
2
+ attribute :address_line_1, :string
3
+ attribute :address_line_2, :string
4
+ end
@@ -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 @@
1
+ <%= link_to 'Start now', journea.journeys_path, method: :post %>
@@ -0,0 +1,5 @@
1
+ <h1>Address</h1>
2
+ <p>Please enter your address:</p>
3
+ <%= simple_form_for @step do |f| %>
4
+ <%= f.button :submit, 'Continue' %>
5
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <h1>Name</h1>
2
+ <p>Please do not enter your name.</p>
3
+ <%= simple_form_for @step do |f| %>
4
+ <%= f.button :submit, 'Continue' %>
5
+ <% end %>
@@ -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