Class: Simp::Metadata::Engine
- Inherits:
-
Object
- Object
- Simp::Metadata::Engine
- Defined in:
- lib/simp/metadata/engine.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#sources ⇒ Object
Returns the value of attribute sources.
-
#ssh_key ⇒ Object
Returns the value of attribute ssh_key.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #components ⇒ Object
- #dirty? ⇒ Boolean
-
#initialize(cachepath = nil, metadatarepos = nil, edition = 'community', options = {}) ⇒ Engine
constructor
A new instance of Engine.
- #releases ⇒ Object
- #save(message = 'Auto-saving using simp-metadata') ⇒ Object
- #writable_source ⇒ Object
- #writable_source_name ⇒ Object
- #writable_source_name=(source) ⇒ Object
- #writable_url(metadata_name, url) ⇒ Object
Constructor Details
#initialize(cachepath = nil, metadatarepos = nil, edition = 'community', options = {}) ⇒ Engine
Returns a new instance of Engine.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/simp/metadata/engine.rb', line 11 def initialize(cachepath = nil, = nil, edition = 'community', = {}) ENV['GIT_SSH'] = "#{File.dirname(__FILE__)}/git_ssh_wrapper.sh" unless ['ssh_key'].nil? ENV['SIMP_METADATA_SSHKEY'] = (['ssh_key']).to_s end @options = @sources = {} @writable_source = 'simp-metadata' priority = 0 bootstrap_source = Simp::Metadata::Bootstrap_source.new(edition) if .class.to_s == 'Hash' .each do |reponame, url| if url.match?(/https?:\/\/|git@/) method = 'git' extract = false else method = 'file' extract = true end # XXX: ToDo replace with better logic once Simp::Metadata.download_component gets refactored. # MUCH LAYERING VIOLATIONS next unless bootstrap_source.components.key?(reponame) bootstrap_source.components[reponame]['locations'][0]['url'] = url bootstrap_source.components[reponame]['locations'][0]['method'] = method bootstrap_source.components[reponame]['locations'][0]['extract'] = extract end end @sources[bootstrap_source.name] = bootstrap_source components.keys.each do |key| component = components[key] @sources[key] = Simp::Metadata::Source.new({ name: key, component: component }.merge(cachepath: cachepath, edition: edition, engine: self)) end end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/simp/metadata/engine.rb', line 8 def @options end |
#sources ⇒ Object
Returns the value of attribute sources.
9 10 11 |
# File 'lib/simp/metadata/engine.rb', line 9 def sources @sources end |
#ssh_key ⇒ Object
Returns the value of attribute ssh_key.
89 90 91 |
# File 'lib/simp/metadata/engine.rb', line 89 def ssh_key @ssh_key end |
Instance Method Details
#cleanup ⇒ Object
93 94 95 96 97 |
# File 'lib/simp/metadata/engine.rb', line 93 def cleanup @sources.each do |_name, source| source.cleanup end end |
#components ⇒ Object
45 46 47 |
# File 'lib/simp/metadata/engine.rb', line 45 def components Simp::Metadata::Components.new(self) end |
#dirty? ⇒ Boolean
53 54 55 56 57 58 59 |
# File 'lib/simp/metadata/engine.rb', line 53 def dirty? dirty = false @sources.each do |_name, source| dirty = true if source.dirty? end dirty end |
#releases ⇒ Object
49 50 51 |
# File 'lib/simp/metadata/engine.rb', line 49 def releases Simp::Metadata::Releases.new(self) end |
#save(message = 'Auto-saving using simp-metadata') ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/simp/metadata/engine.rb', line 77 def save( = 'Auto-saving using simp-metadata') Simp::Metadata.debug2('Saving metadata') @sources.each do |_name, source| if source.dirty? Simp::Metadata.debug1("#{source} - dirty, saving") source.save() else Simp::Metadata.debug1("#{source} - clean, not saving") end end end |
#writable_source ⇒ Object
69 70 71 |
# File 'lib/simp/metadata/engine.rb', line 69 def writable_source @sources[@writable_source] end |
#writable_source_name ⇒ Object
65 66 67 |
# File 'lib/simp/metadata/engine.rb', line 65 def writable_source_name @writable_source end |
#writable_source_name=(source) ⇒ Object
61 62 63 |
# File 'lib/simp/metadata/engine.rb', line 61 def writable_source_name=(source) @writable_source = source end |
#writable_url(metadata_name, url) ⇒ Object
73 74 75 |
# File 'lib/simp/metadata/engine.rb', line 73 def writable_url(, url) @sources[].write_url = url end |