Class: Gratan::Exporter

Inherits:
Object
  • Object
show all
Defined in:
lib/gratan/exporter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(driver, options = {}) ⇒ Exporter

Returns a new instance of Exporter.



6
7
8
9
# File 'lib/gratan/exporter.rb', line 6

def initialize(driver, options = {})
  @driver = driver
  @options = options
end

Class Method Details

.export(driver, options = {}, &block) ⇒ Object



2
3
4
# File 'lib/gratan/exporter.rb', line 2

def self.export(driver, options = {}, &block)
  self.new(driver, options).export(&block)
end

Instance Method Details

#exportObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gratan/exporter.rb', line 11

def export
  grants = []

  @driver.each_user do |user, host|
    next if user =~ @options[:ignore_user]

    @driver.show_grants(user, host) do |stmt|
      grants << Gratan::GrantParser.parse(stmt)
    end
  end

  pack(grants)
end