Class: FlashFlow::Data::Base
- Inherits:
-
Object
- Object
- FlashFlow::Data::Base
- Extended by:
- Forwardable
- Defined in:
- lib/flash_flow/data/base.rb
Instance Method Summary collapse
- #backwards_compatible_store ⇒ Object
-
#initialize(branch_config, filename, git, opts = {}) ⇒ Base
constructor
A new instance of Base.
- #initialize_collection(branch_config, remotes) ⇒ Object
- #merged_branches ⇒ Object
- #save! ⇒ Object
- #saved_branches ⇒ Object
- #to_hash ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(branch_config, filename, git, opts = {}) ⇒ Base
Returns a new instance of Base.
16 17 18 19 20 |
# File 'lib/flash_flow/data/base.rb', line 16 def initialize(branch_config, filename, git, opts={}) @git = git @store = Store.new(filename, git, opts) @collection = initialize_collection(branch_config, git.remotes_hash) end |
Instance Method Details
#backwards_compatible_store ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/flash_flow/data/base.rb', line 48 def backwards_compatible_store @backwards_compatible_store ||= begin hash = @store.get hash.has_key?('branches') ? hash : { 'branches' => hash } end end |
#initialize_collection(branch_config, remotes) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/flash_flow/data/base.rb', line 22 def initialize_collection(branch_config, remotes) collection = Collection.fetch(remotes, branch_config) || Collection.from_hash(remotes, backwards_compatible_store['branches']) collection.mark_all_as_current collection end |
#merged_branches ⇒ Object
44 45 46 |
# File 'lib/flash_flow/data/base.rb', line 44 def merged_branches @collection.reverse_merge(Collection.from_hash({}, backwards_compatible_store['branches'])) end |
#save! ⇒ Object
33 34 35 |
# File 'lib/flash_flow/data/base.rb', line 33 def save! @store.write(to_hash) end |
#saved_branches ⇒ Object
56 57 58 |
# File 'lib/flash_flow/data/base.rb', line 56 def saved_branches Collection.from_hash(@git.remotes, backwards_compatible_store['branches']).to_a end |
#to_hash ⇒ Object
37 38 39 40 41 42 |
# File 'lib/flash_flow/data/base.rb', line 37 def to_hash { 'version' => FlashFlow::VERSION, 'branches' => merged_branches.to_hash } end |
#version ⇒ Object
29 30 31 |
# File 'lib/flash_flow/data/base.rb', line 29 def version backwards_compatible_store['version'] end |