Class: RubyCms::Lockfile
- Inherits:
-
Object
- Object
- RubyCms::Lockfile
- Defined in:
- lib/ruby_cms/lockfile.rb
Overview
Reads/writes .ruby_cms.yml at the host app root: which modules are installed.
Constant Summary collapse
- FILENAME =
".ruby_cms.yml"
Instance Method Summary collapse
- #add!(modules, version:) ⇒ Object
-
#excludes ⇒ Object
App-relative globs the host never wants overwritten by update/sync.
-
#initialize(app_root) ⇒ Lockfile
constructor
A new instance of Lockfile.
- #modules ⇒ Object
- #version ⇒ Object
- #write!(modules:, version:) ⇒ Object
Constructor Details
Instance Method Details
#add!(modules, version:) ⇒ Object
39 40 41 |
# File 'lib/ruby_cms/lockfile.rb', line 39 def add!(modules, version:) write!(modules: (self.modules + Array(modules)).uniq, version: version) end |
#excludes ⇒ Object
App-relative globs the host never wants overwritten by update/sync.
22 23 24 25 26 |
# File 'lib/ruby_cms/lockfile.rb', line 22 def excludes return [] unless @path.exist? Array(data["exclude"]).map(&:to_s) end |
#modules ⇒ Object
15 16 17 18 19 |
# File 'lib/ruby_cms/lockfile.rb', line 15 def modules return [] unless @path.exist? Array(data["modules"]).map(&:to_sym) end |
#version ⇒ Object
28 29 30 |
# File 'lib/ruby_cms/lockfile.rb', line 28 def version data["version"] if @path.exist? end |
#write!(modules:, version:) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/ruby_cms/lockfile.rb', line 32 def write!(modules:, version:) existing_exclude = @path.exist? ? Array(data["exclude"]) : [] @data = { "version" => version, "modules" => modules.map(&:to_s).uniq.sort } @data["exclude"] = existing_exclude unless existing_exclude.empty? @path.write(YAML.dump(@data)) end |