Class: Hastie::ServerGenerator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/hastie/server_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



11
12
13
# File 'lib/hastie/server_generator.rb', line 11

def self.banner
  "hastie create_server [NAME]"
end

.source_rootObject



18
19
20
# File 'lib/hastie/server_generator.rb', line 18

def self.source_root
  File.dirname(__FILE__)
end

Instance Method Details

#create_git_repoObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/hastie/server_generator.rb', line 36

def create_git_repo
  in_root do
    say_status "note", "creating git repository in #{self.destination_root}"
    repo = Grit::Repo.init(".")
    all_files = Dir.glob("./**")
    #all_files.each {|f| say_status "note", "adding #{f}"}
    repo.add(all_files)
    repo.commit_all("initial commit of server scaffold. created from hastie")
  end
end

#create_serverObject



32
33
34
# File 'lib/hastie/server_generator.rb', line 32

def create_server
  directory("templates/server", self.destination_root)
end

#set_destinationObject



22
23
24
25
26
27
28
29
30
# File 'lib/hastie/server_generator.rb', line 22

def set_destination
  # hack to unfreeze the options hash
  self.options = Thor::CoreExt::HashWithIndifferentAccess.new(options)

  # want to allow for relative paths
  options[:server_id] = File.basename(name)
  self.destination_root = File.join(File.dirname(name), options[:server_id])
  say_status "note", "root: #{self.destination_root}"
end