Sha256: 2f578b500b37a57d582f7d62a5d4085a557034215bf452e107c3363f12d5fb21

Contents?: true

Size: 725 Bytes

Versions: 14

Compression:

Stored size: 725 Bytes

Contents

# frozen_string_literal: true

module Mutant
  class Subject
    class Config
      include Adamantium, Anima.new(:inline_disable, :mutation)

      DEFAULT = new(inline_disable: false, mutation: Mutation::Config::DEFAULT)

      DISABLE_REGEXP = /(\s|^)mutant:disable(?:\s|$)/.freeze
      SYNTAX_REGEXP  = /\A(?:#|=begin\n)/.freeze

      def self.parse(comments:, mutation:)
        new(
          inline_disable: comments.any? { |comment| DISABLE_REGEXP.match?(comment_body(comment)) },
          mutation:       mutation
        )
      end

      def self.comment_body(comment)
        comment.text.sub(SYNTAX_REGEXP, '')
      end
      private_class_method :comment_body
    end # Config
  end # Subject
end # Mutant

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mutant-0.11.25 lib/mutant/subject/config.rb
mutant-0.11.24 lib/mutant/subject/config.rb
mutant-0.11.23 lib/mutant/subject/config.rb
mutant-0.11.22 lib/mutant/subject/config.rb
mutant-0.11.21 lib/mutant/subject/config.rb
mutant-0.11.20 lib/mutant/subject/config.rb
mutant-0.11.19 lib/mutant/subject/config.rb
mutant-0.11.18 lib/mutant/subject/config.rb
mutant-0.11.17 lib/mutant/subject/config.rb
mutant-0.11.16 lib/mutant/subject/config.rb
mutant-0.11.15 lib/mutant/subject/config.rb
mutant-0.11.14 lib/mutant/subject/config.rb
mutant-0.11.13 lib/mutant/subject/config.rb
mutant-0.11.12 lib/mutant/subject/config.rb