Sha256: 8f0c57cc78aa6f09b10c89a3f1a4e09a4f337ead9a3e14c9432f0347f1594def

Contents?: true

Size: 1.41 KB

Versions: 17

Compression:

Stored size: 1.41 KB

Contents

class CommitPresenter
  include UrlHelper

  def initialize(commits)
    @commits = OneOrMany.new(commits)
  end

  def as_json(*args)
    @commits.map(&method(:commit_to_json))
  end

  def commit_to_json(commit)
    hash = {
      id: commit.id,
      sha: commit.sha,
      message: commit.summary,
      project: commit.project.slug,
      linkTo: github_commit_url(commit.project, commit.sha), # <-- !todo: more abstract
      committer: {
        name: commit.committer,
        email: commit.committer_email } }

    release = commit.releases.earliest
    if release
      # NB: we want to sort these with TesterNotes
      #     by the field 'createdAt', so while this
      #     _actually_ represents 'releasedAt', we'll
      #     call it 'createdAt' for now.
      hash[:createdAt] = release.created_at
      hash[:environment] = release.environment_name
    end
    hash
  end

  def verbose
    @commits.map do |commit|
      commit_to_json(commit).merge({
        tag: commit.tags.first,
        hours: commit.hours_worked,
        tickets: commit.ticket_numbers,
        unreachable: commit.unreachable,
        releases: commit.releases.map { |release| {
          environment: release.environment_name,
          createdAt: release.created_at } },
        committers: commit.committers.map { |committer| {
          id: committer.id,
          email: committer.email,
          name: committer.name } } })
    end
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
houston-core-0.8.0.pre app/presenters/commit_presenter.rb
houston-core-0.7.0 app/presenters/commit_presenter.rb
houston-core-0.7.0.beta4 app/presenters/commit_presenter.rb
houston-core-0.7.0.beta3 app/presenters/commit_presenter.rb
houston-core-0.7.0.beta2 app/presenters/commit_presenter.rb
houston-core-0.7.0.beta app/presenters/commit_presenter.rb
houston-core-0.6.3 app/presenters/commit_presenter.rb
houston-core-0.6.2 app/presenters/commit_presenter.rb
houston-core-0.6.1 app/presenters/commit_presenter.rb
houston-core-0.6.0 app/presenters/commit_presenter.rb
houston-core-0.5.6 app/presenters/commit_presenter.rb
houston-core-0.5.5 app/presenters/commit_presenter.rb
houston-core-0.5.4 app/presenters/commit_presenter.rb
houston-core-0.5.3 app/presenters/commit_presenter.rb
houston-core-0.5.2 app/presenters/commit_presenter.rb
houston-core-0.5.1 app/presenters/commit_presenter.rb
houston-core-0.5.0 app/presenters/commit_presenter.rb