Module: Facter::Util::Parser

### Home Classes Methods

### In Files

- lib/facter/util/parser.rb

### Namespace

- MODULE Facter::Util::Parser::KeyValuePairOutputFormat
- CLASS Facter::Util::Parser::Base
- CLASS Facter::Util::Parser::JsonParser
- CLASS Facter::Util::Parser::NothingParser
- CLASS Facter::Util::Parser::PowershellParser
- CLASS Facter::Util::Parser::ScriptParser
- CLASS Facter::Util::Parser::TextParser
- CLASS Facter::Util::Parser::YamlParser

### Methods

- ::extension_matches?
- ::file_extension
- ::parser_for
- ::register

### Files

- LICENSE
- Rakefile
- THANKS

### Class/Module Index

Quicksearch

- Facter
- Facter::Application
- Facter::Manufacturer
- Facter::Memory
- Facter::NetMask
- Facter::Util
- Facter::Util::CFPropertyList
- Facter::Util::CFPropertyList::CFArray
- Facter::Util::CFPropertyList::CFBoolean
- Facter::Util::CFPropertyList::CFData
- Facter::Util::CFPropertyList::CFDate
- Facter::Util::CFPropertyList::CFDictionary
- Facter::Util::CFPropertyList::CFInteger
- Facter::Util::CFPropertyList::CFReal
- Facter::Util::CFPropertyList::CFString
- Facter::Util::CFPropertyList::CFType
- Facter::Util::CFPropertyList::XML
- Facter::Util::Collection
- Facter::Util::CompositeLoader
- Facter::Util::Config
- Facter::Util::Confine
- Facter::Util::DirectoryLoader
- Facter::Util::DirectoryLoader::NoSuchDirectoryError
- Facter::Util::EC2
- Facter::Util::Fact
- Facter::Util::FileRead
- Facter::Util::IP
- Facter::Util::IP::Windows
- Facter::Util::IP::Windows::Bindings4
- Facter::Util::IP::Windows::Bindings6
- Facter::Util::Loader
- Facter::Util::Macaddress
- Facter::Util::Macaddress::Darwin
- Facter::Util::Macaddress::Windows
- Facter::Util::Macosx
- Facter::Util::MonkeyPatches
- Facter::Util::MonkeyPatches::Lines
- Facter::Util::NothingLoader
- Facter::Util::Parser
- Facter::Util::Parser::Base
- Facter::Util::Parser::JsonParser
- Facter::Util::Parser::KeyValuePairOutputFormat
- Facter::Util::Parser::NothingParser
- Facter::Util::Parser::PowershellParser
- Facter::Util::Parser::ScriptParser
- Facter::Util::Parser::TextParser
- Facter::Util::Parser::YamlParser
- Facter::Util::Processor
- Facter::Util::Registry
- Facter::Util::Resolution
- Facter::Util::SolarisZones
- Facter::Util::Uptime
- Facter::Util::Values
- Facter::Util::Virtual
- Facter::Util::Vlans
- Facter::Util::WMI
- Facter::Util::Xendomains
- Plist
- Plist::Emit
- Plist::Listener
- Plist::PArray
- Plist::PData
- Plist::PDate
- Plist::PDict
- Plist::PFalse
- Plist::PInteger
- Plist::PKey
- Plist::PList
- Plist::PReal
- Plist::PString
- Plist::PTag
- Plist::PTrue
- Plist::StreamParser
- CFFormatError
- CFPlistError
- CFTypeError
- IO
- Object
- String

No matching classes.

# Facter::Util::Parser

### Public Class Methods

extension_matches?(filename, ext) click to toggle source

For support mutliple extensions you can pass an array of extensions as `ext`.

    # File lib/facter/util/parser.rb, line 13
    def self.extension_matches?(filename, ext)
      extension = case ext
      when String
        ext.downcase
      when Enumerable
        ext.collect {|x| x.downcase }
      end
      [extension].flatten.to_a.include?(file_extension(filename).downcase)
    end

file_extension(filename) click to toggle source

    # File lib/facter/util/parser.rb, line 23
    def self.file_extension(filename)
      File.extname(filename).sub(".", '')
    end

parser_for(filename) click to toggle source

    # File lib/facter/util/parser.rb, line 31
    def self.parser_for(filename)
      registration = @parsers.detect { |k| k[1].call(filename) }

      if registration.nil?
        NothingParser.new
      else
        registration[0].new(filename)
      end
    end

register(klass, &suitable) click to toggle source

    # File lib/facter/util/parser.rb, line 27
    def self.register(klass, &suitable)
      @parsers << [klass, suitable]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.