class BB8::Commands::InitialiseProject

Attributes

path[R]

Public Class Methods

call(path) click to toggle source
# File lib/bb8/commands/initialise_project.rb, line 2
def self.call(path)
  new(path).call
end
new(path) click to toggle source
# File lib/bb8/commands/initialise_project.rb, line 6
def initialize(path)
  @path = File.expand_path path
end

Public Instance Methods

call() click to toggle source
# File lib/bb8/commands/initialise_project.rb, line 10
def call
  FileUtils.mkdir_p path

  `git init #{path}` unless git_present?
  add_gitignore      unless gitignore_present?
end

Private Instance Methods

add_gitignore() click to toggle source
# File lib/bb8/commands/initialise_project.rb, line 21
  def add_gitignore
    File.write gitignore_path, <<-INPUT
.env
*/.env
*.tfvars
*/*.tfvars
*.tfstate
*.tfstate.backup
*/*.tfstate
*/*.tfstate.backup
    INPUT
  end
git_present?() click to toggle source
# File lib/bb8/commands/initialise_project.rb, line 38
def git_present?
  File.exist? File.join(path, '.git')
end
gitignore_path() click to toggle source
# File lib/bb8/commands/initialise_project.rb, line 34
def gitignore_path
  File.join(path, '.gitignore')
end
gitignore_present?() click to toggle source
# File lib/bb8/commands/initialise_project.rb, line 42
def gitignore_present?
  File.exist? gitignore_path
end