Class: ActiveLdap::GetText::Parser — activeldap - ActiveLdap

Class: ActiveLdap::GetText::Parser

Inherits:
Object
  • Object
show all
Includes:
ActiveLdap::GetText
Defined in:
lib/active_ldap/get_text/parser.rb

Instance Method Summary (collapse)

Constructor Details

- (Parser) initialize(configuration = nil)

Returns a new instance of Parser



9
10
11
12
13
14
15
# File 'lib/active_ldap/get_text/parser.rb', line 9

def initialize(configuration=nil)
  configuration = ensure_configuration(configuration)
  configuration = default_configuration.merge(configuration)

  configuration = extract_options(configuration)
  ActiveLdap::Base.setup_connection(configuration)
end

Instance Method Details

- (Object) extract_all_in_schema(targets = [])



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/active_ldap/get_text/parser.rb', line 37

def extract_all_in_schema(targets=[])
  extract(targets) do
    schema = ActiveLdap::Base.schema
    schema.object_classes.each do |object_class|
      register_object_class(object_class, "-")
    end
    schema.attributes.each do |attribute|
      register_attribute(attribute, "-")
    end
    schema.ldap_syntaxes.each do |syntax|
      register_syntax(syntax, "-")
    end
  end
end

- (Object) parse(file, targets = [])



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/active_ldap/get_text/parser.rb', line 17

def parse(file, targets=[])
  targets = RubyParser.parse(file, targets) if RubyParser.target?(file)
  extract(targets) do
    load_constants(file).each do |name|
      klass = name.constantize
      next unless klass.is_a?(Class)
      next unless klass < ActiveLdap::Base
      register(klass.name.singularize.underscore.gsub(/_/, " "), file)
      next unless @extract_schema
      klass.classes.each do |object_class|
        register_object_class(object_class, file)
      end
    end
  end
end

- (Boolean) target?(file)

Returns:

  • (Boolean)


33
34
35
# File 'lib/active_ldap/get_text/parser.rb', line 33

def target?(file)
  @classes_re.match(File.read(file))
end