class Geminio::Shell
Attributes
options[RW]
Public Instance Methods
add_github_remote()
click to toggle source
# File lib/geminio/shell.rb, line 38 def add_github_remote Dir.chdir(destination_root) do `git remote add origin git@github.com:#{@github_repo}.git` end say "Github remote added (#{@github_repo}).", :green end
initialize_git_repo()
click to toggle source
# File lib/geminio/shell.rb, line 32 def initialize_git_repo Dir.chdir(destination_root) { `git init`; `git add .` } say "\nGit repo initialized successfully.", :green end
make_folder_structure()
click to toggle source
# File lib/geminio/shell.rb, line 12 def make_folder_structure self.class.source_root(template_path) say "Generating #{self.destination_root}", :green Dir.chdir(template_path) do Dir["**/*"].each do |node| next unless File.file? node file = node case File.extname(file) when '.erb' template file, destination(file.chomp('.erb')), @options else copy_file file, destination(file) end end end end
set_variables()
click to toggle source
# File lib/geminio/shell.rb, line 46 def set_variables @options.each {|k, v| instance_variable_set("@#{k}", v)} @github_repo = "#{@author_github}/#{@name}" end
Private Instance Methods
destination(path)
click to toggle source
# File lib/geminio/shell.rb, line 62 def destination(path) File.join(destination_root, interpolate(path)) end
interpolate(path)
click to toggle source
# File lib/geminio/shell.rb, line 54 def interpolate(path) path.gsub(/%[a-z]+%/) do |capture| keyword = capture[1..-2] keyword.extend StringExtensions @options[keyword.to_sym].underscore end end
template_path()
click to toggle source
# File lib/geminio/shell.rb, line 66 def template_path File.expand_path(@options[:template]) end