Sha256: c37d52997c24a55cd153f5b64d51e9d41c57693b7459fb3efe59bca7736b2315

Contents?: true

Size: 1.27 KB

Versions: 108

Compression:

Stored size: 1.27 KB

Contents

module PuppetSpec::Modules
  class << self
    def create(name, dir, options = {})
      module_dir = File.join(dir, name)
      FileUtils.mkdir_p(module_dir)

      environment = options[:environment]

      if metadata = options[:metadata]
        metadata[:source]  ||= 'github'
        metadata[:author]  ||= 'puppetlabs'
        metadata[:version] ||= '9.9.9'
        metadata[:license] ||= 'to kill'
        metadata[:dependencies] ||= []

        metadata[:name] = "#{metadata[:author]}/#{name}"

        File.open(File.join(module_dir, 'metadata.json'), 'w') do |f|
          f.write(metadata.to_json)
        end
      end

      if tasks = options[:tasks]
        tasks_dir = File.join(module_dir, 'tasks')
        FileUtils.mkdir_p(tasks_dir)
        tasks.each do |task_files|
          task_files.each do |task_file|
            FileUtils.touch(File.join(tasks_dir, task_file))
          end
        end
      end

      Puppet::Module.new(name, module_dir, environment)
    end

    def generate_files(name, dir, options = {})
      module_dir = File.join(dir, name)
      FileUtils.mkdir_p(module_dir)

      if metadata = options[:metadata]
        File.open(File.join(module_dir, 'metadata.json'), 'w') do |f|
          f.write(metadata.to_json)
        end
      end
    end
  end
end

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
puppet-5.5.22 spec/lib/puppet_spec/modules.rb
puppet-5.5.22-x86-mingw32 spec/lib/puppet_spec/modules.rb
puppet-5.5.22-x64-mingw32 spec/lib/puppet_spec/modules.rb
puppet-5.5.22-universal-darwin spec/lib/puppet_spec/modules.rb
puppet-5.5.21 spec/lib/puppet_spec/modules.rb
puppet-5.5.21-x86-mingw32 spec/lib/puppet_spec/modules.rb
puppet-5.5.21-x64-mingw32 spec/lib/puppet_spec/modules.rb
puppet-5.5.21-universal-darwin spec/lib/puppet_spec/modules.rb
puppet-5.5.20 spec/lib/puppet_spec/modules.rb
puppet-5.5.20-x86-mingw32 spec/lib/puppet_spec/modules.rb
puppet-5.5.20-x64-mingw32 spec/lib/puppet_spec/modules.rb
puppet-5.5.20-universal-darwin spec/lib/puppet_spec/modules.rb
puppet-5.5.19 spec/lib/puppet_spec/modules.rb
puppet-5.5.19-x86-mingw32 spec/lib/puppet_spec/modules.rb
puppet-5.5.19-x64-mingw32 spec/lib/puppet_spec/modules.rb
puppet-5.5.19-universal-darwin spec/lib/puppet_spec/modules.rb
puppet-5.5.18 spec/lib/puppet_spec/modules.rb
puppet-5.5.18-x86-mingw32 spec/lib/puppet_spec/modules.rb
puppet-5.5.18-x64-mingw32 spec/lib/puppet_spec/modules.rb
puppet-5.5.18-universal-darwin spec/lib/puppet_spec/modules.rb