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, readonly = false) ⇒ 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, readonly = false) ⇒ Directory
Returns a new instance of Directory.
28 29 30 31 32 |
# File 'lib/puppet_forge_server/backends/directory.rb', line 28 def initialize(url, readonly = false) @module_dir = url @log = PuppetForgeServer::Logger.get @readonly = readonly 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
43 44 45 46 |
# File 'lib/puppet_forge_server/backends/directory.rb', line 43 def get_file_buffer(relative_path) path = Dir["#{@module_dir}/**/#{relative_path}"].first File.open(path, 'r') if path end |
#get_metadata(author, name, options = {}) ⇒ Object
38 39 40 41 |
# File 'lib/puppet_forge_server/backends/directory.rb', line 38 def (, name, = {}) version = [:version] ? [:version] : '*' get_modules("#{}-#{name}-#{version}.tar.gz", ) end |
#query_metadata(query, options = {}) ⇒ Object
34 35 36 |
# File 'lib/puppet_forge_server/backends/directory.rb', line 34 def (query, = {}) get_modules("*#{query}*.tar.gz", ) end |
#upload(file_data) ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/puppet_forge_server/backends/directory.rb', line 48 def upload(file_data) return false if @readonly 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 |