Module: Kdep::State
- Defined in:
- lib/kdep/state.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- FILENAME =
"state.yml".freeze
- INITIAL_TAG =
"0.0".freeze
- HEADER =
<<~HEADER # Last tag deployed by kdep bump -- do not edit by hand. # This file is safe to commit. See: https://github.com/repleadfy/kdep HEADER
Class Method Summary collapse
- .exists?(deploy_dir) ⇒ Boolean
- .load(deploy_dir) ⇒ Object
- .parseable_tag?(tag) ⇒ Boolean
- .tag(deploy_dir) ⇒ Object
- .write(deploy_dir, tag:) ⇒ Object
Class Method Details
.exists?(deploy_dir) ⇒ Boolean
39 40 41 |
# File 'lib/kdep/state.rb', line 39 def self.exists?(deploy_dir) File.exist?(File.join(deploy_dir, FILENAME)) end |
.load(deploy_dir) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/kdep/state.rb', line 15 def self.load(deploy_dir) path = File.join(deploy_dir, FILENAME) return nil unless File.exist?(path) data = YAML.safe_load(File.read(path)) || {} unless data.is_a?(Hash) && data["tag"] raise Error, "#{path}: missing required key 'tag'" end data end |
.parseable_tag?(tag) ⇒ Boolean
43 44 45 46 |
# File 'lib/kdep/state.rb', line 43 def self.parseable_tag?(tag) require "kdep/version_tagger" !!Kdep::VersionTagger.parse(tag) end |
.tag(deploy_dir) ⇒ Object
25 26 27 28 |
# File 'lib/kdep/state.rb', line 25 def self.tag(deploy_dir) loaded = load(deploy_dir) loaded && loaded["tag"] end |