Module: Librarian::Puppet::Util

Instance Method Summary collapse

Instance Method Details

#clean_uri(uri) ⇒ Object

Remove user and password from a URI object



30
31
32
33
34
35
# File 'lib/librarian/puppet/util.rb', line 30

def clean_uri(uri)
  new_uri = uri.clone
  new_uri.user = nil
  new_uri.password = nil
  new_uri
end

#cp_r(src, dest) ⇒ Object

workaround Issue #173 FileUtils.cp_r will fail if there is a symlink that points to a missing file or when the symlink is copied before the target file when preserve is true see also tickets.opscode.com/browse/CHEF-833



19
20
21
22
23
24
25
26
27
# File 'lib/librarian/puppet/util.rb', line 19

def cp_r(src, dest)
  begin
    FileUtils.cp_r(src, dest, :preserve => true)
  rescue Errno::ENOENT
    debug { "Failed to copy from #{src} to #{dest} preserving file types, trying again without preserving them" }
    FileUtils.rm_rf(dest)
    FileUtils.cp_r(src, dest)
  end
end

#debug(*args, &block) ⇒ Object



6
7
8
# File 'lib/librarian/puppet/util.rb', line 6

def debug(*args, &block)
  environment.logger.debug(*args, &block)
end

#info(*args, &block) ⇒ Object



9
10
11
# File 'lib/librarian/puppet/util.rb', line 9

def info(*args, &block)
  environment.logger.info(*args, &block)
end

#normalize_name(name) ⇒ Object

normalize module name to use organization-module instead of organization/module



38
39
40
# File 'lib/librarian/puppet/util.rb', line 38

def normalize_name(name)
  name.sub('/','-')
end

#warn(*args, &block) ⇒ Object



12
13
14
# File 'lib/librarian/puppet/util.rb', line 12

def warn(*args, &block)
  environment.logger.warn(*args, &block)
end