class Ufo::Sequence
Public Class Methods
source_paths()
click to toggle source
github.com/erikhuda/thor/blob/master/lib/thor/actions.rb#L49
# File lib/ufo/sequence.rb, line 11 def self.source_paths [File.expand_path("../../template", __FILE__)] end
Private Instance Methods
copy_project()
click to toggle source
# File lib/ufo/sequence.rb, line 63 def copy_project puts "Creating new project called #{project_name}." directory ".", project_name end
git_installed?()
click to toggle source
# File lib/ufo/sequence.rb, line 54 def git_installed? system("type git > /dev/null") end
inferred_app()
click to toggle source
# File lib/ufo/sequence.rb, line 16 def inferred_app File.basename(Dir.pwd) end
override_source_paths(*paths)
click to toggle source
# File lib/ufo/sequence.rb, line 20 def override_source_paths(*paths) # Using string with instance_eval because block doesnt have access to # path at runtime. self.class.instance_eval %{ def self.source_paths #{paths.flatten.inspect} end } end
repo_url()
click to toggle source
normalize repo_url
# File lib/ufo/sequence.rb, line 45 def repo_url template = options[:template] if template.include?('github.com') template # leave as is, user has provided full github url else "https://github.com/#{template}" end end
sh(command)
click to toggle source
# File lib/ufo/sequence.rb, line 58 def sh(command) puts "=> #{command}" system(command) end
sync_template_repo()
click to toggle source
# File lib/ufo/sequence.rb, line 30 def sync_template_repo unless git_installed? abort "Unable to detect git installation on your system. Git needs to be installed in order to use the --template option." end template_path = "#{ENV['HOME']}/.ufo/templates/#{options[:template]}" if File.exist?(template_path) sh("cd #{template_path} && git pull") else FileUtils.mkdir_p(File.dirname(template_path)) sh("git clone #{repo_url} #{template_path}") end end