journea 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +8 -0
- data/README.md +131 -0
- data/Rakefile +26 -0
- data/app/controllers/journea/engine_controller.rb +19 -0
- data/app/controllers/journea/journeys_controller.rb +10 -0
- data/app/controllers/journea/steps_controller.rb +52 -0
- data/app/helpers/journea/form_helper.rb +25 -0
- data/app/models/journea/journey.rb +54 -0
- data/app/models/journea/journey_transition.rb +17 -0
- data/app/models/journea/keyvalue.rb +5 -0
- data/app/views/application/_back_link.html.haml +5 -0
- data/config/initializers/simple_form.rb +179 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20161201153630_create_journey_transitions.rb +22 -0
- data/db/migrate/20161201162349_create_journeys_table.rb +10 -0
- data/db/migrate/20161202162350_create_keyvalues_table.rb +11 -0
- data/lib/generators/journea/install_generator.rb +76 -0
- data/lib/generators/journea/templates/assets/application.js +23 -0
- data/lib/generators/journea/templates/assets/application.scss +49 -0
- data/lib/generators/journea/templates/config/initializers/journea.rb +23 -0
- data/lib/generators/journea/templates/config/initializers/journea2.rb +24 -0
- data/lib/generators/journea/templates/controllers/pages_controller.rb.example +2 -0
- data/lib/generators/journea/templates/views/application.html.haml +20 -0
- data/lib/generators/journea/templates/views/pages/start.html.haml.example +12 -0
- data/lib/generators/journea/templates/views/shared/error_messages.html.haml.example +7 -0
- data/lib/generators/journea/templates/views/steps/step.html.haml.example +8 -0
- data/lib/journea.rb +25 -0
- data/lib/journea/data.rb +20 -0
- data/lib/journea/engine.rb +27 -0
- data/lib/journea/state_machine.rb +40 -0
- data/lib/journea/step.rb +32 -0
- data/lib/journea/version.rb +3 -0
- data/lib/simple_form_object.rb +146 -0
- data/lib/tasks/journea_tasks.rake +4 -0
- data/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +5 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/pages_controller.rb +4 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/steps/address_step.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/app/views/pages/start.html.erb +1 -0
- data/spec/dummy/app/views/steps/address.html.erb +5 -0
- data/spec/dummy/app/views/steps/name.html.erb +5 -0
- data/spec/dummy/app/views/steps/phone_number.html.erb +0 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +34 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +14 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +9 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +54 -0
- data/spec/dummy/config/environments/production.rb +86 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/journea.rb +8 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +24 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +42 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +57 -0
- data/spec/dummy/log/test.log +448 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/EA/EAR2KaBsPQau6HwaTGrxV7EGMwAWyS-4C8pGVDU1Z-Q.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/JZ/JZuPFgM2mLQgAHB-r7Pt_TdGW3DRWPrplT7xPjnCJSE.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/LT/LTt1oE1gi9m65YRwUp78DuufkCOfi3sa3Qa05_ykADk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Lj/LjRKOqtrClPtb97phuIWI7HHA8-p5J5nKHVE_zEycxo.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/QM/QMxUWUtpFaqwG3RI9t3m38QtFAOvHpiY3LphKJiVRTc.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/St/StFuOi5bd69ceiqz2D6EOCmRzHgwY0IxERsMfiCneGM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Vj/VjCUmI9pp5eD8BlYATbwJ4ZOk0438rwvtDrsttyWbfQ.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Wl/WlLcUIADXcUxaOt8Gq59uQbO0mquikyz7jxiJjXjhaI.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/YH/YHo__TrFq5y8rpx49T8d8ecyvMLbHFbnhz7IBV7pM98.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Zu/ZuLXgeX6x_Dx8sCUbzuTtWu42HzQXWe7eooTgsonTnc.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aG/aG1tp1pv4kBiSKx9ixZH5xiRXH-rGa0Hi6sdl4SHw6g.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aw/awTDtuorxLsRLIGEYCefR-PTN7yptoaGRLEk13vHVLA.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/b_/b_Itlk9QZZd7Rvf8kcA4yLP1R5Acu7jB-m1xQiSU0qE.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/cW/cWHxYOqms7abJ-dzXyrn2G7nadJicU5kkC8SduS06yc.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/cb/cbX7RFavWZoWojlrsXhsy4FN46UOfMwZYStkLHT5HJw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/eY/eYTHvo0Wl2TD2vipDcJ966HHXGrA4ZlJaiA2DnftKhM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/f4/f4CpFuYmsdh1EvlFVjsl1WmM2QA9_z9AuOebEOw4mts.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gH/gHSjqTBRSW22rP9mSj8XW6huEXKpcIOehvF-2fvuShQ.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m0/m0smDeM83DcmOVpX9zos6AIX40E9Tf2j26tyvKFgMwc.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mW/mWrwQwWUQpAlMCLQ8dGv5VkAXd-TxvAtB5WPg9l09-A.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mX/mX1nlsL_SWOB4y22W5FheRX0YEONKyOY7xUeIvRiHco.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/n_/n_xYqQYhwEMQknb3jFQnjlxxBE9TzMNHCdJ-bEyZFIw.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/nx/nxTv3sKVUQZADJyM3dPaVmUA78MIsMLD_K279yN_GsI.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/oA/oAtzk5ZeF7lWCwNufspgWqtv_dQN_n5GumFNB4ScfBE.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/rA/rACdJeX3jZNkhx4awGhdZeMdOfmARubkoVKVAZdwYog.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sC/sCEBZXwTjRpEzThf7YHzHNfkAupMVOx_Ko7WNMAFHS0.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/x7/x7PYh8DJvPykcEqpVab2vcY9-GFz-3cqtoMlRAu94Uc.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yT/yTOf3QInGfDlRZlwZNDBLlbma19FQRHM035AKRxcRyw.cache +0 -0
- data/spec/features/journey_spec.rb +9 -0
- data/spec/lib/simple_form_object/attribute_spec.rb +74 -0
- data/spec/lib/simple_form_object/delegation_spec.rb +50 -0
- data/spec/lib/simple_form_object/model_spec.rb +90 -0
- data/spec/lib/steps_spec.rb +0 -0
- data/spec/requests/journeys_spec.rb +6 -0
- data/spec/spec_helper.rb +44 -0
- metadata +449 -0
data/lib/journea/step.rb
ADDED
@@ -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,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,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 %>
|
data/spec/dummy/Rakefile
ADDED
@@ -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,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 @@
|
|
1
|
+
<%= yield %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= link_to 'Start now', journea.journeys_path, method: :post %>
|
File without changes
|
data/spec/dummy/bin/rake
ADDED
@@ -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
|