Class: Vagrant::Bundler::SolutionFile
- Inherits:
-
Object
- Object
- Vagrant::Bundler::SolutionFile
- Defined in:
- lib/vagrant/bundler.rb
Instance Attribute Summary collapse
-
#dependency_list ⇒ Array<Gem::Dependency>
List of required dependencies.
-
#plugin_file ⇒ Pathname
readonly
Path to plugin file.
-
#solution_file ⇒ Pathname
readonly
Path to solution file.
Instance Method Summary collapse
-
#delete! ⇒ Boolean
Delete the solution file.
-
#initialize(plugin_file:, solution_file: nil) ⇒ SolutionFile
constructor
A new instance of SolutionFile.
-
#invalidate! ⇒ FalseClass
Invalidate this solution file.
-
#store! ⇒ Object
Store the solution file.
-
#to_s ⇒ Object
:nodoc:.
-
#valid? ⇒ Boolean
Contained solution is valid.
Constructor Details
#initialize(plugin_file:, solution_file: nil) ⇒ SolutionFile
Returns a new instance of SolutionFile.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vagrant/bundler.rb', line 31 def initialize(plugin_file:, solution_file: nil) @logger = Log4r::Logger.new("vagrant::bundler::signature_file") @plugin_file = Pathname.new(plugin_file.to_s) if solution_file @solution_file = Pathname.new(solution_file.to_s) else @solution_file = Pathname.new(@plugin_file.to_s + ".sol") end @valid = false @dependency_list = [].freeze @logger.debug("new solution file instance plugin_file=#{plugin_file} " \ "solution_file=#{solution_file}") load end |
Instance Attribute Details
#dependency_list ⇒ Array<Gem::Dependency>
Returns list of required dependencies.
27 28 29 |
# File 'lib/vagrant/bundler.rb', line 27 def dependency_list @dependency_list end |
#plugin_file ⇒ Pathname (readonly)
Returns path to plugin file.
23 24 25 |
# File 'lib/vagrant/bundler.rb', line 23 def plugin_file @plugin_file end |
#solution_file ⇒ Pathname (readonly)
Returns path to solution file.
25 26 27 |
# File 'lib/vagrant/bundler.rb', line 25 def solution_file @solution_file end |
Instance Method Details
#delete! ⇒ Boolean
Delete the solution file
72 73 74 75 76 77 78 79 80 |
# File 'lib/vagrant/bundler.rb', line 72 def delete! if !solution_file.exist? @logger.debug("solution file does not exist. nothing to delete.") return false end @logger.debug("deleting solution file - #{solution_file}") solution_file.delete true end |
#invalidate! ⇒ FalseClass
Returns invalidate this solution file.
64 65 66 67 |
# File 'lib/vagrant/bundler.rb', line 64 def invalidate! @logger.debug("manually invalidating solution file") @valid = false end |
#store! ⇒ Object
Store the solution file
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/vagrant/bundler.rb', line 83 def store! if !plugin_file.exist? @logger.debug("plugin file does not exist, not storing solution") return end if !solution_file.dirname.exist? @logger.debug("creating directory for solution file: #{solution_file.dirname}") solution_file.dirname.mkpath end @logger.debug("writing solution file contents to disk") solution_file.write({ dependencies: dependency_list.map { |d| [d.name, d.requirements_list] }, checksum: plugin_file_checksum, vagrant_version: Vagrant::VERSION }.to_json) @valid = true end |
#to_s ⇒ Object
:nodoc:
103 104 105 106 |
# File 'lib/vagrant/bundler.rb', line 103 def to_s # :nodoc: "<Vagrant::Bundler::SolutionFile:#{plugin_file}:" \ "#{solution_file}:#{valid? ? "valid" : "invalid"}>" end |
#valid? ⇒ Boolean
Returns contained solution is valid.
59 60 61 |
# File 'lib/vagrant/bundler.rb', line 59 def valid? @valid end |