Class: DebtCeiling::ArcheologicalDig

Inherits:
Object
  • Object
show all
Defined in:
lib/debt_ceiling/archeological_dig.rb

Constant Summary collapse

ARCHEOLOGY_RECORD_VERSION_NUMBER =

increment for backward incompatible changes in record format

"v0"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = '.', opts = {}) ⇒ ArcheologicalDig

Returns a new instance of ArcheologicalDig.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/debt_ceiling/archeological_dig.rb', line 14

def initialize(path='.', opts={})
  @redis = redis_if_available
  @path = path
  @opts = opts
  @source_control =  SourceControlSystem::Base.create
  DebtCeiling.load_configuration unless opts[:preconfigured]
  @records = source_control.revisions_refs(path).map do |commit|
    if note = config_note_present_on_commit(commit)
      extract_record_from_note(note)
    else
      build_record(commit)
    end
  end
  redis.set(self.class.dig_json_key(path), records.to_json) if redis
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



7
8
9
# File 'lib/debt_ceiling/archeological_dig.rb', line 7

def opts
  @opts
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/debt_ceiling/archeological_dig.rb', line 7

def path
  @path
end

#recordsObject (readonly)

Returns the value of attribute records.



7
8
9
# File 'lib/debt_ceiling/archeological_dig.rb', line 7

def records
  @records
end

#redisObject (readonly)

Returns the value of attribute redis.



7
8
9
# File 'lib/debt_ceiling/archeological_dig.rb', line 7

def redis
  @redis
end

#source_controlObject (readonly)

Returns the value of attribute source_control.



7
8
9
# File 'lib/debt_ceiling/archeological_dig.rb', line 7

def source_control
  @source_control
end

Class Method Details

.dig_json_key(path) ⇒ Object



9
10
11
12
# File 'lib/debt_ceiling/archeological_dig.rb', line 9

def self.dig_json_key(path)
  project_name = File.expand_path(path).split('/').last
  "DebtCeiling_#{project_name}_#{ARCHEOLOGY_RECORD_VERSION_NUMBER}"
end