Class Index [+]

Quicksearch

ActiveSambaLdap::Command

Public Instance Methods

default_configuration_files() click to toggle source

(Not documented)

# File lib/active_samba_ldap/command.rb, line 63
    def default_configuration_files
      configuration_files = File.join(File.dirname(__FILE__),
                                      "configuration_files")
      if File.exists?(configuration_files)
        files = File.readlines(configuration_files).collect do |line|
          line.strip
        end.reject do |line|
          line.empty? or /^#/ =~ line
        end
      else
        files = [
          "/etc/activesambaldap/config.yaml",
          "/etc/activesambaldap/bind.yaml",
        ]
      end
      begin
        configuration_files_for_user = [
          File.expand_path(File.join("~", ".activesambaldap.conf")),
          File.expand_path(File.join("~", ".activesambaldap.bind")),
        ]
        files.concat(configuration_files_for_user)
      rescue ArgumentError
      end
      files
    end
parse_options(argv=nil) click to toggle source

(Not documented)

# File lib/active_samba_ldap/command.rb, line 11
    def parse_options(argv=nil)
      argv ||= ARGV.dup
      options = OpenStruct.new
      configuration_files = default_configuration_files
      opts = OptionParser.new do |opts|
        yield(opts, options)

        opts.separator("")
        opts.separator(_("Common options:"))

        opts.on_tail("--config=CONFIG",
                     _("Specify configuration file"),
                     _("Default configuration files:"),
                     *configuration_files.collect {|x| "  #{x}"}) do |file|
          configuration_files << file
        end

        opts.on_tail("-h", "--help", _("Show this message")) do
          puts opts
          exit
        end

        opts.on_tail("--version", _("Show version")) do
          puts VERSION
          exit
        end
      end

      begin
        opts.parse!(argv)
      rescue OptionParser::ParseError
        $stderr.puts($!)
        $stderr.puts(opts)
        exit 1
      end

      read_configuration_files(configuration_files)

      [argv, opts, options]
    end
read_configuration_files(files) click to toggle source

(Not documented)

# File lib/active_samba_ldap/command.rb, line 89
    def read_configuration_files(files)
      return if files.empty?
      Base.configurations = files.inject({}) do |result, file|
        if File.readable?(file)
          result.merge(Configuration.read(file))
        else
          result
        end
      end
    end
read_password(prompt, input=$stdin, output=$stdout) click to toggle source

(Not documented)

# File lib/active_samba_ldap/command.rb, line 52
    def read_password(prompt, input=$stdin, output=$stdout)
      output.print prompt
      system "/bin/stty -echo" if input.tty?
      password = input.gets
      password = password.chomp if password
      password
    ensure
      system "/bin/stty echo" if input.tty?
      output.puts
    end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.