Sha256: 1670aa3f31019e46a644e9671b89cbc5ca8032428f8f1021f171c7c6dc23fec6

Contents?: true

Size: 1.02 KB

Versions: 11

Compression:

Stored size: 1.02 KB

Contents

module Rake
  module Funnel
    class AmbiguousFileError < StandardError
      attr_reader :task_name, :search_pattern, :candidates, :description

      def initialize(message, task_name, search_pattern, candidates)
        description = "Could not run task '#{task_name}'. #{message}"
        super(description)

        @description = description
        @task_name = task_name
        @search_pattern = search_pattern
        @candidates = candidates
      end

      def to_s
        msg = [] << inspect_description << inspect_search_pattern << inspect_candidates
        msg = msg.flatten.compact
        msg = [super.to_s] if msg.empty?

        msg.join("\n")
      end

      private
      def inspect_description
        [description] if description
      end

      def inspect_search_pattern
        ["Search pattern used: #{search_pattern}"] if search_pattern
      end

      def inspect_candidates
        return if (candidates || []).empty?
        ['Candidates:', candidates.map { |c| "  - #{c}" }]
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rake-funnel-0.18.0 lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.17.0 lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.16.1 lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.16.0 lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.15.0.pre lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.14.0.pre lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.13.0.pre lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.12.0.pre lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.11.0.pre lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.10.0.pre lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.9.1.pre lib/rake/funnel/ambiguous_file_error.rb