Class: CodeBuildNotifier::BuildHistory

Inherits:
Object
  • Object
show all
Defined in:
lib/codebuild-notifier/build_history.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, current_build) ⇒ BuildHistory

Returns a new instance of BuildHistory.



30
31
32
33
# File 'lib/codebuild-notifier/build_history.rb', line 30

def initialize(config, current_build)
  @config = config
  @current_build = current_build
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



25
26
27
# File 'lib/codebuild-notifier/build_history.rb', line 25

def config
  @config
end

#current_buildObject (readonly)

Returns the value of attribute current_build.



25
26
27
# File 'lib/codebuild-notifier/build_history.rb', line 25

def current_build
  @current_build
end

Instance Method Details

#last_entryObject



35
36
37
38
39
40
41
42
43
# File 'lib/codebuild-notifier/build_history.rb', line 35

def last_entry
  # If this build was launched using the Retry command from the console
  # or api we don't have a Pull Request or branch name to use in the
  # primary key, so we query by commit hash and project instead.
  item = launched_by_retry? ? find_by_commit_and_project : find_by_id

  # Provide .dot access to hash values from Dynamo item.
  item && Hashie::Mash.new(item)
end

#write_entry(source_id) {|updates| ... } ⇒ Object

Yields:

  • (updates)


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/codebuild-notifier/build_history.rb', line 45

def write_entry(source_id)
  updates = hash_to_dynamo_update(new_entry).merge(
    key: { source_id: source_id }
  )

  yield updates if block_given?

  dynamo_client.update_item(
    updates.merge(table_name: dynamo_table)
  )
end