dreamcat4-moonshadow 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +165 -0
- data/app_generators/moonshine/moonshine_generator.rb +154 -0
- data/app_generators/moonshine/templates/Capfile +3 -0
- data/app_generators/moonshine/templates/rails/deploy.rb +3 -0
- data/app_generators/moonshine/templates/rails/gems.yml +1 -0
- data/app_generators/moonshine/templates/rails/manifest.rb +55 -0
- data/app_generators/moonshine/templates/rails/moonshine.rake +83 -0
- data/app_generators/moonshine/templates/rails/moonshine.yml +43 -0
- data/app_generators/moonshine/templates/readme.templates +5 -0
- data/app_generators/moonshine_plugin/USAGE +8 -0
- data/app_generators/moonshine_plugin/moonshine_plugin_generator.rb +39 -0
- data/app_generators/moonshine_plugin/templates/README.rdoc +14 -0
- data/app_generators/moonshine_plugin/templates/init.rb +3 -0
- data/app_generators/moonshine_plugin/templates/plugin.rb +19 -0
- data/app_generators/moonshine_plugin/templates/spec.rb +24 -0
- data/app_generators/moonshine_plugin/templates/spec_helper.rb +8 -0
- data/bin/moonshine +17 -0
- data/bin/moonshine_plugin +17 -0
- data/lib/moonshine.rb +7 -0
- data/lib/moonshine/bootstrap/bootstrap.mri.sh +21 -0
- data/lib/moonshine/bootstrap/bootstrap.ree.sh +34 -0
- data/lib/moonshine/capistrano.rb +242 -0
- data/lib/moonshine/manifest.rb +151 -0
- data/lib/moonshine/manifest/rails.rb +54 -0
- data/lib/moonshine/manifest/rails/apache.rb +99 -0
- data/lib/moonshine/manifest/rails/apt_gems.yml +32 -0
- data/lib/moonshine/manifest/rails/mysql.rb +79 -0
- data/lib/moonshine/manifest/rails/os.rb +115 -0
- data/lib/moonshine/manifest/rails/passenger.rb +93 -0
- data/lib/moonshine/manifest/rails/postgresql.rb +83 -0
- data/lib/moonshine/manifest/rails/rails.rb +237 -0
- data/lib/moonshine/manifest/rails/sqlite3.rb +8 -0
- data/lib/moonshine/manifest/rails/templates/innodb.cnf.erb +6 -0
- data/lib/moonshine/manifest/rails/templates/logrotate.conf.erb +15 -0
- data/lib/moonshine/manifest/rails/templates/moonshine.cnf.erb +63 -0
- data/lib/moonshine/manifest/rails/templates/passenger.conf.erb +106 -0
- data/lib/moonshine/manifest/rails/templates/passenger.vhost.erb +273 -0
- data/lib/moonshine/manifest/rails/templates/pg_hba.conf.erb +83 -0
- data/lib/moonshine/manifest/rails/templates/postgresql.conf.erb +493 -0
- data/lib/moonshine/manifest/rails/templates/unattended_upgrades.erb +18 -0
- data/lib/moonshine_setup_manifest.rb +39 -0
- metadata +135 -0
data/LICENSE
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
class MoonshineGenerator < RubiGen::Base
|
3
|
+
attr_reader :file_name, :klass_name, :is_rails_app, :moonshine_version
|
4
|
+
|
5
|
+
def initialize(runtime_args, runtime_options = {})
|
6
|
+
super
|
7
|
+
@destination_root = args.shift
|
8
|
+
@file_name = "application_manifest"
|
9
|
+
@klass_name = @file_name.classify
|
10
|
+
@is_rails_app = detect_rails
|
11
|
+
gem 'moonshine'
|
12
|
+
@moonshine_version = Gem.loaded_specs["moonshine"].version.to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
# Override with your own usage banner.
|
16
|
+
def banner
|
17
|
+
"Usage: #{$0} <path> [options]"
|
18
|
+
end
|
19
|
+
|
20
|
+
def manifest
|
21
|
+
recorded_session = record do |m|
|
22
|
+
directories(m)
|
23
|
+
m.template 'readme.templates', 'app/manifests/templates/README'
|
24
|
+
m.template 'Capfile', 'Capfile'
|
25
|
+
m.template "#{application_type}/moonshine.yml", "config/moonshine.yml"
|
26
|
+
m.template "#{application_type}/moonshine.rake", 'lib/tasks/moonshine.rake'
|
27
|
+
m.template 'rails/gems.yml', 'config/gems.yml', :assigns => { :gems => gems } if is_rails_app
|
28
|
+
generate_or_upgrade_manifest(m)
|
29
|
+
generate_or_upgrade_deploy(m)
|
30
|
+
end
|
31
|
+
intro
|
32
|
+
recorded_session
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
def intro
|
38
|
+
intro = <<-INTRO
|
39
|
+
|
40
|
+
After the Moonshine generator finishes don't forget to:
|
41
|
+
|
42
|
+
- Edit config/moonshine.yml
|
43
|
+
Use this file to manage configuration related to deploying and running the app:
|
44
|
+
domain name, git repos, package dependencies for gems, and more.
|
45
|
+
|
46
|
+
- Edit app/manifests/#{file_name}.rb
|
47
|
+
Use this to manage the configuration of everything else on the server:
|
48
|
+
define the server 'stack', cron jobs, mail aliases, configuration files
|
49
|
+
|
50
|
+
INTRO
|
51
|
+
puts intro if File.basename($0) == 'generate'
|
52
|
+
end
|
53
|
+
|
54
|
+
def detect_rails
|
55
|
+
begin
|
56
|
+
require File.expand_path(File.join(destination_root, 'config/environment.rb'))
|
57
|
+
rescue LoadError
|
58
|
+
false
|
59
|
+
else
|
60
|
+
true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def application_type
|
65
|
+
is_rails_app ? 'rails' : 'standalone'
|
66
|
+
end
|
67
|
+
|
68
|
+
def gems
|
69
|
+
gem_array = returning Array.new do |hash|
|
70
|
+
Rails.configuration.gems.map do |gem|
|
71
|
+
hash = { :name => gem.name }
|
72
|
+
hash.merge!(:source => gem.source) if gem.source
|
73
|
+
hash.merge!(:version => gem.requirement.to_s) if gem.requirement
|
74
|
+
hash
|
75
|
+
end if Rails.respond_to?( 'configuration' )
|
76
|
+
end
|
77
|
+
if (RAILS_GEM_VERSION rescue false)
|
78
|
+
gem_array << {:name => 'rails', :version => RAILS_GEM_VERSION }
|
79
|
+
else
|
80
|
+
gem_array << {:name => 'rails'}
|
81
|
+
end
|
82
|
+
gem_array
|
83
|
+
end
|
84
|
+
|
85
|
+
def directories(m)
|
86
|
+
m.directory 'app'
|
87
|
+
m.directory 'app/manifests'
|
88
|
+
m.directory 'app/manifests/templates'
|
89
|
+
m.directory 'config'
|
90
|
+
m.directory 'lib'
|
91
|
+
m.directory 'lib/tasks'
|
92
|
+
end
|
93
|
+
|
94
|
+
#generate or upgrade app/manifests/#{file_name}.rb
|
95
|
+
def generate_or_upgrade_manifest(m)
|
96
|
+
if File.exists?(destination_path("app/manifests/#{file_name}.rb"))
|
97
|
+
if File.read(destination_path("app/manifests/#{file_name}.rb")) =~ /vendor\/plugins\/moonshine/
|
98
|
+
gsub_file "app/manifests/#{file_name}.rb", /^.*vendor\/plugins\/moonshine.*$/mi do |match|
|
99
|
+
"#{moonshine_gem_string}\nrequire 'moonshine'\n"
|
100
|
+
end
|
101
|
+
else
|
102
|
+
gsub_file "app/manifests/#{file_name}.rb", /^gem 'moonshine'.*$/mi do |match|
|
103
|
+
moonshine_gem_string
|
104
|
+
end
|
105
|
+
end
|
106
|
+
else
|
107
|
+
m.template "#{application_type}/manifest.rb", "app/manifests/#{file_name}.rb", :assigns => { :moonshine_gem_string => moonshine_gem_string }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
#generate or upgrade config/deploy.rb
|
112
|
+
def generate_or_upgrade_deploy(m)
|
113
|
+
if File.exists?(destination_path('config/deploy.rb'))
|
114
|
+
if File.read(destination_path('config/deploy.rb')) =~ /moonshine\/capistrano/
|
115
|
+
gsub_file 'config/deploy.rb', /^gem 'moonshine'.*$/mi do |match|
|
116
|
+
moonshine_gem_string
|
117
|
+
end
|
118
|
+
else
|
119
|
+
File.prepend(destination_path('config/deploy.rb'), "#{moonshine_gem_string}\nrequire 'moonshine/capistrano'\n")
|
120
|
+
end
|
121
|
+
else
|
122
|
+
m.template "#{application_type}/deploy.rb", 'config/deploy.rb', :assigns => { :moonshine_gem_string => moonshine_gem_string }
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def moonshine_gem_string
|
127
|
+
"gem 'moonshine', '= #{moonshine_version}'"
|
128
|
+
end
|
129
|
+
|
130
|
+
def gsub_file(relative_destination, regexp, *args, &block)
|
131
|
+
path = destination_path(relative_destination)
|
132
|
+
content = File.read(path).gsub(regexp, *args, &block)
|
133
|
+
File.open(path, 'wb') { |file| file.write(content) }
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
class File
|
139
|
+
def self.prepend(path, string)
|
140
|
+
Tempfile.open File.basename(path) do |tempfile|
|
141
|
+
# prepend data to tempfile
|
142
|
+
tempfile << string
|
143
|
+
|
144
|
+
File.open(path, 'r+') do |file|
|
145
|
+
# append original data to tempfile
|
146
|
+
tempfile << file.read
|
147
|
+
# reset file positions
|
148
|
+
file.pos = tempfile.pos = 0
|
149
|
+
# copy all data back to original file
|
150
|
+
file << tempfile.read
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= gems.to_yaml %>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
<%= moonshine_gem_string %>
|
2
|
+
require 'moonshine'
|
3
|
+
class <%= klass_name %> < Moonshine::Manifest::Rails
|
4
|
+
# The majority of your configuration should be in <tt>config/moonshine.yml</tt>
|
5
|
+
# If necessary, you may provide extra configuration directly in this class
|
6
|
+
# using the configure method. The hash passed to the configure method is deep
|
7
|
+
# merged with what is in <tt>config/moonshine.yml</tt>. This could be used,
|
8
|
+
# for example, to store passwords and/or private keys outside of your SCM, or
|
9
|
+
# to query a web service for configuration data.
|
10
|
+
#
|
11
|
+
# In the example below, the value configuration[:custom][:random] can be used in
|
12
|
+
# your moonshine settings or templates.
|
13
|
+
#
|
14
|
+
# require 'net/http'
|
15
|
+
# require 'json'
|
16
|
+
# random = JSON::load(Net::HTTP.get(URI.parse('http://twitter.com/statuses/public_timeline.json'))).last['id']
|
17
|
+
# configure({
|
18
|
+
# :custom => { :random => random }
|
19
|
+
# })
|
20
|
+
|
21
|
+
# The default_stack recipe install Rails, Apache, Passenger, the database from
|
22
|
+
# database.yml, Postfix, Cron, logrotate and NTP. See lib/moonshine/manifest/rails.rb
|
23
|
+
# for details. To customize, remove this recipe and specify the components you want.
|
24
|
+
recipe :default_stack
|
25
|
+
|
26
|
+
# Add your application's custom requirements here
|
27
|
+
def application_packages
|
28
|
+
# If you've already told Moonshine about a package required by a gem with
|
29
|
+
# :apt_gems in <tt>moonshine.yml</tt> you do not need to include it here.
|
30
|
+
# package 'some_native_package', :ensure => :installed
|
31
|
+
|
32
|
+
# some_rake_task = "/usr/bin/rake -f #{configuration[:deploy_to]}/current/Rakefile custom:task RAILS_ENV=#{ENV['RAILS_ENV']}"
|
33
|
+
# cron 'custom:task', :command => some_rake_task, :user => configuration[:user], :minute => 0, :hour => 0
|
34
|
+
|
35
|
+
# %w( root rails ).each do |user|
|
36
|
+
# mailalias user, :recipient => 'you@domain.com'
|
37
|
+
# end
|
38
|
+
|
39
|
+
# farm_config = <<-CONFIG
|
40
|
+
# MOOCOWS = 3
|
41
|
+
# HORSIES = 10
|
42
|
+
# CONFIG
|
43
|
+
# file '/etc/farm.conf', :ensure => :present, :content => farm_config
|
44
|
+
|
45
|
+
# Logs for Rails, MySQL, and Apache are rotated by default
|
46
|
+
# logrotate '/var/log/some_service.log', :options => %w(weekly missingok compress), :postrotate => '/etc/init.d/some_service restart'
|
47
|
+
|
48
|
+
# Only run the following on the 'testing' stage using capistrano-ext's multistage functionality.
|
49
|
+
# on_stage 'testing' do
|
50
|
+
# file '/etc/motd', :ensure => :file, :content => "Welcome to the TEST server!"
|
51
|
+
# end
|
52
|
+
end
|
53
|
+
# The following line includes the 'application_packages' recipe defined above
|
54
|
+
recipe :application_packages
|
55
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
namespace :moonshine do
|
2
|
+
|
3
|
+
namespace :db do
|
4
|
+
desc "Bootstrap the database with fixtures from db/boostrap."
|
5
|
+
task :bootstrap => :environment do
|
6
|
+
require 'active_record/fixtures'
|
7
|
+
ActiveRecord::Base.establish_connection(Rails.env)
|
8
|
+
fixtures_dir = File.join(Rails.root, 'db/bootstrap/')
|
9
|
+
Dir.glob(File.join(fixtures_dir, '*.{yml,csv}')).each do |fixture_file|
|
10
|
+
Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Create fixtures in db/bootstrap. Specify tables with FIXTURES=x,y otherwise all will be created."
|
15
|
+
task :dump => :environment do
|
16
|
+
sql = "SELECT * FROM %s"
|
17
|
+
skip_tables = [ "schema_info", "sessions", "schema_migrations" ]
|
18
|
+
ActiveRecord::Base.establish_connection
|
19
|
+
tables = ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : ActiveRecord::Base.connection.tables - skip_tables
|
20
|
+
|
21
|
+
tables.each do |table_name|
|
22
|
+
i = "0000"
|
23
|
+
File.open("#{RAILS_ROOT}/db/bootstrap/#{table_name}.yml", 'w') do |file|
|
24
|
+
data = ActiveRecord::Base.connection.select_all(sql % table_name)
|
25
|
+
file.write data.inject({}) { |hsh, record|
|
26
|
+
hsh["#{table_name}_#{i.succ!}"] = record
|
27
|
+
hsh
|
28
|
+
}.to_yaml
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
namespace :app do
|
35
|
+
desc "Overwrite this task in your app if you have any bootstrap tasks that need to be run"
|
36
|
+
task :bootstrap do
|
37
|
+
#
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc <<-DOC
|
42
|
+
Attempt to bootstrap this application. In order, we run:
|
43
|
+
|
44
|
+
rake db:schema:load (if db/schema.rb exists)
|
45
|
+
rake db:migrate (if db/migrate exists)
|
46
|
+
rake moonshine:db:bootstrap (if db/bootstrap/ exists)
|
47
|
+
rake moonshine:app:bootstrap
|
48
|
+
|
49
|
+
All of this assumes one things. That your application can run 'rake
|
50
|
+
environment' with an empty database. Please ensure your application can do
|
51
|
+
so!
|
52
|
+
DOC
|
53
|
+
task :bootstrap do
|
54
|
+
Rake::Task["db:schema:load"].invoke if File.exist?("db/schema.rb")
|
55
|
+
Rake::Task["environment"].invoke
|
56
|
+
Rake::Task["db:migrate"].invoke if File.exist?("db/migrate")
|
57
|
+
Rake::Task["moonshine:db:bootstrap"].invoke if File.exist?("db/bootstrap")
|
58
|
+
Rake::Task["moonshine:app:bootstrap"].invoke
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Update config/moonshine.yml with a list of the required gems"
|
62
|
+
task :gems => 'gems:base' do
|
63
|
+
gem_array = Rails.configuration.gems.reject(&:frozen?).map do |gem|
|
64
|
+
hash = { :name => gem.name }
|
65
|
+
hash.merge!(:source => gem.source) if gem.source
|
66
|
+
hash.merge!(:version => gem.requirement.to_s) if gem.requirement
|
67
|
+
hash
|
68
|
+
end
|
69
|
+
if (RAILS_GEM_VERSION rescue false)
|
70
|
+
gem_array << {:name => 'rails', :version => RAILS_GEM_VERSION }
|
71
|
+
else
|
72
|
+
gem_array << {:name => 'rails'}
|
73
|
+
end
|
74
|
+
config_path = File.join(Dir.pwd, 'config', 'gems.yml')
|
75
|
+
File.open( config_path, 'w' ) do |out|
|
76
|
+
YAML.dump(gem_array, out )
|
77
|
+
end
|
78
|
+
puts "config/gems.yml has been updated with your application's gem"
|
79
|
+
puts "dependencies. Please commit these changes to your SCM or upload"
|
80
|
+
puts "them to your server with the cap local_config:upload command."
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|