Class: UpmSupport::UpfileLock
- Inherits:
-
Object
- Object
- UpmSupport::UpfileLock
- Defined in:
- lib/upm_support/uplift.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #dependencies ⇒ Object
-
#initialize(path) ⇒ UpfileLock
constructor
A new instance of UpfileLock.
- #remove_dependency(name, version) ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(path) ⇒ UpfileLock
Returns a new instance of UpfileLock.
10 11 12 13 |
# File 'lib/upm_support/uplift.rb', line 10 def initialize(path) @path = path @content = File.read(path).split("\n") end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/upm_support/uplift.rb', line 8 def path @path end |
Instance Method Details
#dependencies ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/upm_support/uplift.rb', line 15 def dependencies idx = @content.index('# SOLVED DEPENDENCIES') @content[(idx + 1)..].grep(/^[A-z]/).to_h do |l| m = l.match(/(.*) \((.*)\)/) [m[1], m[2]] end end |
#remove_dependency(name, version) ⇒ Object
23 24 25 26 |
# File 'lib/upm_support/uplift.rb', line 23 def remove_dependency(name, version) idx = @content.index('# SOLVED DEPENDENCIES') @content = @content.reject.each_with_index { |l, ix| ix > idx and l =~ /^#{name} \(#{version}\)/ } end |
#save ⇒ Object
28 29 30 |
# File 'lib/upm_support/uplift.rb', line 28 def save File.write(@path, @content.join("\n")) end |