Module: Samlr::Command

Defined in:
lib/samlr/command.rb

Overview

Helper module for command line options

Constant Summary collapse

COMMANDS =
[ :verify, :schema_validate, :print ]

Class Method Summary collapse

Class Method Details

.execute(options, path = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/samlr/command.rb', line 9

def self.execute(options, path = nil)
  Samlr.logger.level    = Logger::DEBUG if options[:verbose]
  Samlr.validation_mode = :log if options[:skip_validation]

  if options[:verify]
    if File.directory?(path)
      result = []
      Dir.glob("#{path}/*.*").each do |file|
        result << execute_verify(file, options)
      end
      result.join("\n")
    else
      execute_verify(path, options)
    end
  elsif options[:schema_validate]
    Samlr::Tools.validate(:path => path)
  elsif options[:print]
    Samlr::Response.parse(File.read(path)).to_xml
  end
end