class Skele::Skeleton
Attributes
destination[R]
skeleton[R]
skeleton_dir[R]
Public Class Methods
new(skeleton, destination, root=SKELETON_ROOT)
click to toggle source
# File lib/skele.rb, line 11 def initialize(skeleton, destination, root=SKELETON_ROOT) @skeleton = skeleton @skeleton_dir = root + @skeleton @destination = destination + File::SEPARATOR @ignore = [".git", ".hg"] end
Public Instance Methods
bundle_install()
click to toggle source
# File lib/skele.rb, line 83 def bundle_install if File.exists? @destination + "Gemfile" bundler_result = "" unless bundler_installed? bundler_result += "Bundler wasn't found, so we're installing it\n\n" bundler_result += `gem install bundler` bundler_result += "\n\n" end bundler_result += `bundle install` return bundler_result end return nil end
bundler_installed?()
click to toggle source
# File lib/skele.rb, line 70 def bundler_installed? # make sure bundler is installed bundler_list = `gem list bundler` bundler_list.split("\n").each do |line| if (/^bundler/i).match(line) return true end end return false end
copy_files()
click to toggle source
# File lib/skele.rb, line 35 def copy_files if File.directory? @skeleton_dir result = Array.new Find.find(@skeleton_dir) do |file| relative_path = relative_path file, @skeleton_dir # skip the containing directory next if relative_path.empty? # skip .git directory next if @ignore.include? relative_path.split(File::SEPARATOR)[0] # copy files if(File.directory? file) if File.exists?(@destination + relative_path) result.push({:action => "exists", :file => relative_path}) else Dir::mkdir(@destination + relative_path) result.push({:action => "mkdir", :file => relative_path}) end else if File.exists?(@destination + relative_path) result.push({:action => "exists", :file => relative_path}) else FileUtils::copy(file, @destination + relative_path) result.push({:action => "create", :file => relative_path}) end end end end return result end
relative_path(abspath,relativeto)
click to toggle source
# File lib/skele.rb, line 18 def relative_path(abspath,relativeto) path = abspath.split(File::SEPARATOR) rel = relativeto.split(File::SEPARATOR) while (path.length > 0) && (path.first == rel.first) path.shift rel.shift end path.join(File::SEPARATOR) end
summon()
click to toggle source
# File lib/skele.rb, line 30 def summon copy_files bundle_install end