Sha256: 8282443c7d4f69b5a876027eb896810a6910012ef1b6fa5610360fbea0ed90f1

Contents?: true

Size: 486 Bytes

Versions: 4

Compression:

Stored size: 486 Bytes

Contents

module DuperVisor
  class Detector
    attr_accessor :filename
    def initialize(filename)
      self.filename = filename
    end

    def detect
      format_from_extension(filename) if filename.is_a?(String)
    end

    private

    def format_from_extension(filename)
      extension = filename.gsub(/.*\.([\w]+)/, '\1')
      format = if extension =~ /(json|ya?ml|ini)/i
        f = extension.downcase.to_sym
        f == :yml ? :yaml : f
      end
      format
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dupervisor-1.0.5 lib/dupervisor/detector.rb
dupervisor-1.0.4 lib/dupervisor/detector.rb
dupervisor-1.0.3 lib/dupervisor/detector.rb
dupervisor-1.0.2 lib/dupervisor/detector.rb