Sha256: 9c16fbf81d7e479b408625b2b219230e9123f563fe55a00f64da2f729bb56fc0

Contents?: true

Size: 1.67 KB

Versions: 4

Compression:

Stored size: 1.67 KB

Contents

require "commitment/version"
require 'json'

module Commitment
  module_function
  def config
    @config ||= Config.new
  end

  class Config
    attr_reader :rubocop_config
    attr_reader :brakeman_output_pathname
    attr_reader :jshint_pattern
    attr_reader :jshint_exclude_pattern
    attr_reader :jshint_options
    attr_reader :scss_lint_config
    attr_reader :percentage_coverage_goal
    attr_reader :code_coverage_last_run_pathname

    def initialize
      @project_pathname = default_project_pathname
      @rubocop_config = project_pathname.join('.hound.yml').to_s
      @brakeman_output_pathname = project_pathname.join('.tmp.brakeman.json')
      @jshint_pattern = 'app/assets/**/*.js'
      @jshint_exclude_pattern = 'app/assets/javascripts/vendor/*.js'
      @jshint_options = JSON.parse(project_pathname.join('.jshintrc').read)
      @scss_lint_config = project_pathname.join('.scss_lint.yml').to_s
      @percentage_coverage_goal = 100
      @code_coverage_last_run_pathname = project_pathname.join('coverage/.last_run.json')
    end

    def code_coverage_last_run_results
      if code_coverage_last_run_pathname.exist?
        JSON.parse(code_coverage_last_run_pathname.read)
      else
        abort("Commitment Failure: Unable to find code coverage information in `#{code_coverage_last_run_pathname.to_s}'")
      end
    end

    private

    attr_reader :project_pathname

    def default_project_pathname
      if defined?(Rails)
        Rails.root
      else
        require 'pathname'
        Pathname.new(File.expand_path('../commitment/generators/templates', __FILE__))
      end
    end
  end
  private_constant :Config
end

require 'commitment/railtie' if defined?(Rails)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
commitment-0.1.3 lib/commitment.rb
commitment-0.1.2 lib/commitment.rb
commitment-0.1.1 lib/commitment.rb
commitment-0.1.0 lib/commitment.rb