Class: Librarian::Puppet::Cli

Inherits:
Cli
  • Object
show all
Extended by:
Particularity
Includes:
Particularity, Util
Defined in:
lib/librarian/puppet/cli.rb

Defined Under Namespace

Modules: Particularity

Instance Method Summary collapse

Methods included from Particularity

root_module

Methods included from Util

#clean_uri, #cp_r, #debug, #info, #module_name, #normalize_name, #rsync?, #warn

Instance Method Details

#initObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/librarian/puppet/cli.rb', line 23

def init
  copy_file environment.specfile_name

  if File.exists? ".gitignore"
    gitignore = File.read('.gitignore').split("\n")
  else
    gitignore = []
  end

  gitignore << ".tmp/" unless gitignore.include? ".tmp/"
  gitignore << "modules/" unless gitignore.include? "modules/"

  File.open(".gitignore", 'w') do |f|
    f.puts gitignore.join("\n")
  end
end

#installObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/librarian/puppet/cli.rb', line 52

def install

  ensure!
  clean! if options["clean"]
  unless options["destructive"].nil?
    environment.config_db.local['destructive'] = options['destructive'].to_s
  end
  if options.include?("strip-dot-git")
    strip_dot_git_val = options["strip-dot-git"] ? "1" : nil
    environment.config_db.local["install.strip-dot-git"] = strip_dot_git_val
  end
  if options.include?("path")
    environment.config_db.local["path"] = options["path"]
  end

  environment.config_db.local['use-v1-api'] = options['use-v1-api'] ? '1' : nil
  unless options["use-forge"].nil?
    environment.config_db.local['use-forge'] = options['use-forge'].to_s
  end
  unless options["git-destructive"].nil?
    environment.config_db.local['git-destructive'] = options['git-destructive'].to_s
  end
  environment.config_db.local['mode'] = options['local'] ? 'local' : nil

  resolve!
  debug { "Install: dependencies resolved"}
  install!
end

#packageObject



97
98
99
100
# File 'lib/librarian/puppet/cli.rb', line 97

def package
  environment.vendor!
  install
end

#update(*names) ⇒ Object

only used to replace / to - in the module names



82
83
84
85
# File 'lib/librarian/puppet/cli.rb', line 82

def update(*names)
  warn("Usage of module/name is deprecated, use module-name") if names.any? {|n| n.include?("/")}
  super(*names.map{|n| normalize_name(n)})
end

#versionObject



102
103
104
# File 'lib/librarian/puppet/cli.rb', line 102

def version
  say "librarian-puppet v#{Librarian::Puppet::VERSION}"
end