Class: Stronglyboards::LockFile

Inherits:
Object
  • Object
show all
Defined in:
lib/stronglyboards/lock_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(project_file) ⇒ LockFile

Returns a new instance of LockFile.



4
5
6
# File 'lib/stronglyboards/lock_file.rb', line 4

def initialize(project_file)
  @path = File.dirname(project_file) + '/' + LOCK_FILE_NAME
end

Instance Method Details

#contentsObject



8
9
10
11
12
# File 'lib/stronglyboards/lock_file.rb', line 8

def contents
  # Load the lock file containing configuration
  file = File.open(@path, 'r')
  YAML::load(file)
end

#deleteObject



21
22
23
# File 'lib/stronglyboards/lock_file.rb', line 21

def delete
  File.delete(@path)
end

#exists?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/stronglyboards/lock_file.rb', line 25

def exists?
  File.exists?(@path)
end

#update(options) ⇒ Object



14
15
16
17
18
19
# File 'lib/stronglyboards/lock_file.rb', line 14

def update(options)
  puts "Writing lock file at #{@path}"
  File.open(@path, 'w+') do |file|
    file.write(YAML::dump(options))
  end
end