Sha256: 7798619c8325ead75ac8e7d0f7bb3b47064fb0b196f657fcfd5be5420631b6bd

Contents?: true

Size: 1.32 KB

Versions: 18

Compression:

Stored size: 1.32 KB

Contents

class EventFixtures
  attr_reader :options

  REMEDIATIONS = {
    "A" => 0,
    "B" => 10,
    "C" => 15,
    "D" => 20,
    "F" => 25,
  }.freeze

  def initialize(options)
    @options = {
      repo_name: "Example",
      details_url: "https://codeclimate.com/repos/1/feed",
      compare_url: "https://codeclimate.com/repos/1/compare",
    }.merge(options)
  end

  # Options: to, from
  def coverage
    to = options.delete(:to)
    from = options.delete(:from)
    delta = (to - from).round(1)

    options.merge(
      name: "coverage",
      covered_percent: to,
      previous_covered_percent: from,
      covered_percent_delta: delta,
    )
  end

  # Options: to, from
  def quality
    to = options.delete(:to)
    from = options.delete(:from)

    options.merge(
      name: "quality",
      constant_name: "User",
      rating: to,
      previous_rating: from,
      remediation_cost: REMEDIATIONS[to],
      previous_remediation_cost: REMEDIATIONS[from],
    )
  end

  # Options: warning_type, vulnerabilities
  def vulnerability
    options.merge(name: "vulnerability")
  end

  def issue
    options.merge(name: "issue")
  end
end

def event(name, options = {})
  fixtures = EventFixtures.new(options)

  if fixtures.respond_to?(name)
    fixtures.send(name)
  else
    raise ArgumentError, "No such fixture: #{name}"
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
codeclimate-services-1.11.4 spec/fixtures.rb
codeclimate-services-1.11.3 spec/fixtures.rb
codeclimate-services-1.11.2 spec/fixtures.rb
codeclimate-services-1.11.1 spec/fixtures.rb
codeclimate-services-1.11.0 spec/fixtures.rb
codeclimate-services-1.10.1 spec/fixtures.rb
codeclimate-services-1.10.0 spec/fixtures.rb
codeclimate-services-1.9.8 spec/fixtures.rb
codeclimate-services-1.9.7 spec/fixtures.rb
codeclimate-services-1.9.6 spec/fixtures.rb
codeclimate-services-1.9.5 spec/fixtures.rb
codeclimate-services-1.9.4 spec/fixtures.rb
codeclimate-services-1.9.3 spec/fixtures.rb
codeclimate-services-1.9.2 spec/fixtures.rb
codeclimate-services-1.9.1 spec/fixtures.rb
codeclimate-services-1.9.0 spec/fixtures.rb
codeclimate-services-1.8.0 spec/fixtures.rb
codeclimate-services-1.7.0 spec/fixtures.rb