Class: PuppetForgeServer::Backends::Directory
- Inherits:
-
Object
- Object
- PuppetForgeServer::Backends::Directory
- 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
-
#PRIORITY ⇒ Object
readonly
Returns the value of attribute PRIORITY.
Instance Method Summary collapse
- #get_file_buffer(relative_path) ⇒ Object
- #get_metadata(author, name, options = {}) ⇒ Object
-
#initialize(url) ⇒ Directory
constructor
A new instance of Directory.
- #query_metadata(query, options = {}) ⇒ Object
- #upload(file_data) ⇒ Object
Methods included from Utils::Archiver
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
#PRIORITY ⇒ Object (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.(@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 (, name, = {}) version = [:version] ? [:version] : '*' ("#{author}-#{name}-#{version}.tar.gz", ) end |
#query_metadata(query, options = {}) ⇒ Object
32 33 34 |
# File 'lib/puppet_forge_server/backends/directory.rb', line 32 def (query, = {}) ("*#{query}*.tar.gz", ) 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 |