Class: FlashFlow::Data::Base
- Inherits:
-
Object
- Object
- FlashFlow::Data::Base
- Extended by:
- Forwardable
- Defined in:
- lib/flash_flow/data/base.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
Instance Method Summary collapse
-
#initialize(branch_config, filename, git, opts = {}) ⇒ Base
constructor
A new instance of Base.
- #initialize_collection(branch_config) ⇒ Object
- #merged_branches ⇒ Object
- #pending_release ⇒ Object
- #ready_to_merge_release ⇒ Object
- #releases ⇒ Object
- #save! ⇒ Object
- #saved_branches ⇒ Object
- #stored_branches ⇒ Object
- #stored_data ⇒ Object
- #to_hash ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(branch_config, filename, git, opts = {}) ⇒ Base
Returns a new instance of Base.
19 20 21 22 23 |
# File 'lib/flash_flow/data/base.rb', line 19 def initialize(branch_config, filename, git, opts={}) @git = git @store = Store.new(filename, git, opts) @collection = initialize_collection(branch_config) end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
17 18 19 |
# File 'lib/flash_flow/data/base.rb', line 17 def collection @collection end |
Instance Method Details
#initialize_collection(branch_config) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/flash_flow/data/base.rb', line 25 def initialize_collection(branch_config) stored_collection = Collection.from_hash(stored_branches) if ! branch_config.empty? collection = Collection.fetch(branch_config) # Order matters. We are marking the PRs as current, not the branches stored in the json collection.mark_all_as_current collection = collection.reverse_merge(stored_collection) else collection = stored_collection collection.mark_all_as_current end collection.branches.delete_if { |k, v| TimeHelper.massage_time(v.updated_at) < Time.now - TimeHelper.two_weeks } collection end |
#merged_branches ⇒ Object
68 69 70 |
# File 'lib/flash_flow/data/base.rb', line 68 def merged_branches @collection.reverse_merge(Collection.from_hash({}, stored_branches)) end |
#pending_release ⇒ Object
80 81 82 |
# File 'lib/flash_flow/data/base.rb', line 80 def pending_release releases.detect { |r| r['status'] == 'Pending' } end |
#ready_to_merge_release ⇒ Object
84 85 86 |
# File 'lib/flash_flow/data/base.rb', line 84 def ready_to_merge_release releases.detect { |r| r['status'] == 'Ready to merge' } end |
#releases ⇒ Object
64 65 66 |
# File 'lib/flash_flow/data/base.rb', line 64 def releases @releases ||= stored_data['releases'] || [] end |
#save! ⇒ Object
48 49 50 |
# File 'lib/flash_flow/data/base.rb', line 48 def save! @store.write(to_hash) end |
#saved_branches ⇒ Object
76 77 78 |
# File 'lib/flash_flow/data/base.rb', line 76 def saved_branches Collection.from_hash(stored_branches).to_a end |
#stored_branches ⇒ Object
60 61 62 |
# File 'lib/flash_flow/data/base.rb', line 60 def stored_branches @stored_branches ||= stored_data['branches'] || {} end |
#stored_data ⇒ Object
72 73 74 |
# File 'lib/flash_flow/data/base.rb', line 72 def stored_data @stored_data ||= @store.get end |
#to_hash ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/flash_flow/data/base.rb', line 52 def to_hash { 'version' => FlashFlow::VERSION, 'branches' => @collection.to_hash, 'releases' => releases } end |
#version ⇒ Object
44 45 46 |
# File 'lib/flash_flow/data/base.rb', line 44 def version stored_data['version'] end |