Sha256: 2f7a322542e4bc064c14a14044d983cbc9c0a3fc6e972699ab01f1cd95e4646b

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

module Hoboken
  module AddOns
    # Add metrics (flog, flay, simplecov).
    #
    class Metrics < ::Hoboken::Group
      def add_gems
        gem 'flog', version: '4.6', group: :test
        gem 'flay', version: '2.12', group: :test
        gem 'simplecov', version: '0.21', require: false, group: :test
      end

      def copy_task_templates
        empty_directory('tasks')
        template('hoboken/templates/metrics.rake.tt', 'tasks/metrics.rake')
      end

      def simplecov_test_unit
        return if rspec?

        insert_into_file 'test/test_helper.rb', before: snippet_location do
          snippet('test')
        end
      end

      def simplecov_rspec
        return unless rspec?

        insert_into_file 'spec/spec_helper.rb', before: snippet_location do
          snippet('rspec')
        end
      end

      def reminders
        say "\nGemfile updated... don't forget to 'bundle install'"
      end

      private

      def snippet(framework_folder)
        <<~CODE
          require 'simplecov'
          SimpleCov.start do
            add_filter '/bin/'
            add_filter '/config/'
            add_filter '/#{framework_folder}/'
            coverage_dir 'tmp/coverage'
          end

        CODE
      end

      def snippet_location
        %r{require 'bundler/setup'}
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hoboken-0.9.0 lib/hoboken/add_ons/metrics.rb