Class: Bindle::Commands::Init

Inherits:
Base
  • Object
show all
Defined in:
lib/bindle/commands/init.rb

Instance Method Summary collapse

Methods inherited from Base

banner, default_command_root, default_source_root, display_name, source_root

Instance Method Details

#bundle_installObject

From railties: github.com/rails/rails/blob/f96478369e/railties/lib/rails/generators/app_base.rb#L253



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/bindle/commands/init.rb', line 62

def bundle_install
  say_status :running, "bundle install"

  _bundle_command = Gem.bin_path('bundler', 'bundle')

  require 'bundler'

  if !options[:pretend]
    Bundler.with_clean_env do
      print `"#{Gem.ruby}" "#{_bundle_command}" install --binstubs`
    end
  end
end

#chefObject



40
41
42
43
44
45
46
47
48
# File 'lib/bindle/commands/init.rb', line 40

def chef
  empty_directory "chef"

  inside "chef" do
    directory "roles"

    template "README.md"
  end
end

#cheffileObject



28
29
30
# File 'lib/bindle/commands/init.rb', line 28

def cheffile
  template "Cheffile"
end

#gemfileObject



32
33
34
# File 'lib/bindle/commands/init.rb', line 32

def gemfile
  template "Gemfile"
end

#gitignoreObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/bindle/commands/init.rb', line 50

def gitignore
  if File.exists?(File.join(self.destination_root, ".git"))
    append_to_file ".gitignore", <<-IGNORE.strip_heredoc
      /chef/cookbooks
      /chef/tmp
      /chef/packages
      /.vagrant
    IGNORE
  end
end

#install_cookbooksObject



76
77
78
79
80
81
82
83
84
# File 'lib/bindle/commands/init.rb', line 76

def install_cookbooks
  say_status :running, "librarian-chef install"

  if !options[:pretend]
    environment = Librarian::Chef::Environment.new({pwd: self.destination_root})
    Librarian::Action::Resolve.new(environment).run
    Librarian::Action::Install.new(environment).run
  end
end

#kniferbObject



19
20
21
22
# File 'lib/bindle/commands/init.rb', line 19

def kniferb
  empty_directory ".chef"
  template "knife.rb", ".chef/knife.rb"
end

#librarianObject



36
37
38
# File 'lib/bindle/commands/init.rb', line 36

def librarian
  directory "librarian", ".librarian"
end

#mainObject



13
14
15
16
17
# File 'lib/bindle/commands/init.rb', line 13

def main
  unless name.nil?
    self.destination_root = project_name
  end
end

#vagrantfileObject



24
25
26
# File 'lib/bindle/commands/init.rb', line 24

def vagrantfile
  template "Vagrantfile"
end