Class: PuppetForgeServer::Backends::Directory

Inherits:
Object
  • Object
show all
Includes:
Utils::Archiver
Defined in:
lib/puppet_forge_server/backends/directory.rb

Constant Summary collapse

@@PRIORITY =

Give highest priority to locally hosted modules

0

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Archiver

#read_entry

Constructor Details

#initialize(url) ⇒ Directory

Returns a new instance of Directory.



28
29
30
# File 'lib/puppet_forge_server/backends/directory.rb', line 28

def initialize(url)
  @module_dir = url
end

Instance Attribute Details

#PRIORITYObject (readonly)

Returns the value of attribute PRIORITY.



26
27
28
# File 'lib/puppet_forge_server/backends/directory.rb', line 26

def PRIORITY
  @PRIORITY
end

Instance Method Details

#get_file_buffer(relative_path) ⇒ Object



41
42
43
44
# File 'lib/puppet_forge_server/backends/directory.rb', line 41

def get_file_buffer(relative_path)
  path = File.join(File.expand_path(@module_dir), relative_path)
  File.open(path, 'r') if File.exist?(path)
end

#get_metadata(author, name, options = {}) ⇒ Object



36
37
38
39
# File 'lib/puppet_forge_server/backends/directory.rb', line 36

def (author, name, options = {})
  version = options[:version] ? options[:version] : '*'
  ("#{author}-#{name}-#{version}.tar.gz", options)
end

#query_metadata(query, options = {}) ⇒ Object



32
33
34
# File 'lib/puppet_forge_server/backends/directory.rb', line 32

def (query, options = {})
  ("*#{query}*.tar.gz", options)
end

#upload(file_data) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/puppet_forge_server/backends/directory.rb', line 46

def upload(file_data)
  filename = File.join(@module_dir, file_data[:filename])
  return false if File.exist?(filename)
  File.open(filename, 'w') do |f|
    f.write(file_data[:tempfile].read)
  end
  true
end