-
Notifications
You must be signed in to change notification settings - Fork 24
/
umlaut_app_template.rb
37 lines (27 loc) · 1.3 KB
/
umlaut_app_template.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# An app template to set up a Rails app with umlaut, with required
# configuration and generated content.
# ENV['UMLAUT_GEM_PATH'] can be used to add the line to Gemfile
# with a path to local checkout of Umlaut. NOTE WELL the path
# passed in ENV must be absolute path OR relative to the generated
# app's gemfile (which is confusing). (We've already lost the actual
# CWD by the the time the generator runs, so we can't correct to relative
# to original command CWD)
#
# Add the lib path from the copy of Umlaut we're in to the load path.
# Since we're an app template, our gem isn't loaded yet.
umlaut_lib = File.expand_path(File.dirname(__FILE__) + '/../')
$LOAD_PATH.unshift(umlaut_lib) if File.directory?(umlaut_lib) && !$LOAD_PATH.include?(umlaut_lib)
require 'umlaut/version'
umlaut_version = Umlaut::VERSION.split(".")
gem_spec_str =
"\ngem 'umlaut', '>= #{Umlaut::VERSION}', '< #{umlaut_version.first.to_i + 1}'"
if ENV["UMLAUT_GEM_PATH"]
path = File.expand_path( ENV["UMLAUT_GEM_PATH"] )
gem_spec_str += ", :path => '#{path}'"
end
append_file "Gemfile", gem_spec_str
generate "umlaut:remove_turbolinks"
generate "umlaut:install"
# future rails will offer an after_bundle hook we could use for
# a post-install message. Instead, the post-install message for now
# is in the `umlaut` command wrapper.