|
@@ -1,5 +1,25 @@
|
|
|
-def source_paths
|
|
|
- [File.expand_path(File.dirname(__FILE__))]
|
|
|
+# Copied from: https://github.com/mattbrictson/rails-template
|
|
|
+# Add this template directory to source_paths so that Thor actions like
|
|
|
+# copy_file and template resolve against our source files. If this file was
|
|
|
+# invoked remotely via HTTP, that means the files are not present locally.
|
|
|
+# In that case, use `git clone` to download them to a local temporary dir.
|
|
|
+def add_template_repository_to_source_path
|
|
|
+ if __FILE__ =~ %r{\Ahttps?://}
|
|
|
+ require "tmpdir"
|
|
|
+ source_paths.unshift(tempdir = Dir.mktmpdir("jumpstart-"))
|
|
|
+ at_exit { FileUtils.remove_entry(tempdir) }
|
|
|
+ git clone: [
|
|
|
+ "--quiet",
|
|
|
+ "https://github.com/excid3/jumpstart.git",
|
|
|
+ tempdir
|
|
|
+ ].map(&:shellescape).join(" ")
|
|
|
+
|
|
|
+ if (branch = __FILE__[%r{jumpstart/(.+)/template.rb}, 1])
|
|
|
+ Dir.chdir(tempdir) { git checkout: branch }
|
|
|
+ end
|
|
|
+ else
|
|
|
+ source_paths.unshift(File.dirname(__FILE__))
|
|
|
+ end
|
|
|
end
|
|
|
|
|
|
def add_gems
|
|
@@ -160,6 +180,8 @@ def add_whenever
|
|
|
end
|
|
|
|
|
|
# Main setup
|
|
|
+add_template_repository_to_source_path
|
|
|
+
|
|
|
add_gems
|
|
|
|
|
|
after_bundle do
|