Class: Vagrant::Bundler::SolutionFile
- Inherits:
-
Object
- Object
- Vagrant::Bundler::SolutionFile
- Defined in:
- lib/vagrant/bundler.rb
Instance Attribute Summary collapse
-
#dependency_list ⇒ Array<Gem::Resolver::DependencyRequest>
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::solution_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::Resolver::DependencyRequest>
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
76 77 78 79 80 81 82 83 84 |
# File 'lib/vagrant/bundler.rb', line 76 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.
67 68 69 70 71 |
# File 'lib/vagrant/bundler.rb', line 67 def invalidate! @valid = false @logger.debug("manually invalidating solution file #{self}") @valid end |
#store! ⇒ Object
Store the solution file
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/vagrant/bundler.rb', line 87 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.dependency.name, d.dependency.requirements_list] }, checksum: plugin_file_checksum, vagrant_version: Vagrant::VERSION }.to_json) @valid = true end |
#to_s ⇒ Object
:nodoc:
107 108 109 110 |
# File 'lib/vagrant/bundler.rb', line 107 def to_s # :nodoc: "<Vagrant::Bundler::SolutionFile:#{plugin_file}:" \ "#{solution_file}:#{valid? ? "valid" : "invalid"}>" end |
#valid? ⇒ Boolean
Returns contained solution is valid.
62 63 64 |
# File 'lib/vagrant/bundler.rb', line 62 def valid? @valid end |