Class: Gusteau::Bureau

Inherits:
Object
  • Object
show all
Includes:
ERB
Defined in:
lib/gusteau/bureau.rb

Instance Method Summary collapse

Methods included from ERB

#read_erb, #read_erb_yaml

Constructor Details

#initialize(name) ⇒ Bureau

Returns a new instance of Bureau.



10
11
12
13
14
15
16
17
18
# File 'lib/gusteau/bureau.rb', line 10

def initialize(name)
  @name = name
  @template_path = File.expand_path('../../../template', __FILE__)

  @login   = Etc.getlogin
  @ssh_key = File.read(File.expand_path '~/.ssh/id_rsa.pub').chomp rescue 'Your SSH key'

  abort "Directory #{name} already exists" if File.exists?(name)
end

Instance Method Details

#generate!(init = true) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/gusteau/bureau.rb', line 20

def generate!(init = true)
  FileUtils.cp_r(@template_path, @name)
  template '.gusteau.yml'
  template 'README.md'
  template 'spec/example-box/platform_spec.rb'
  template "data_bags/users/#{@login}.json", "data_bags/users/user.json.erb"
  Dir.chdir(@name) { exec "bash ./init.sh #{@name} ; rm ./init.sh" } if(init)
end