Class: Smith::ACLCompiler

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Includes:
Logger
Defined in:
lib/smith/acl_compiler.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logger

included

Constructor Details

#initialize ⇒ ACLCompiler

Returns a new instance of ACLCompiler.



20
21
22
23
# File 'lib/smith/acl_compiler.rb', line 20

def initialize
  @acl_type_cache = AclTypeCache.instance
  @acl_parser = ACLParser.new
end

Class Method Details

.find_so ⇒ Object



13
14
15
# File 'lib/smith/acl_compiler.rb', line 13

def self.find_so
  $:.map{|p| Pathname.new(p).join("ruby_generator.so")}.detect{|so| so.exist? }
end

Instance Method Details

#compile ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/smith/acl_compiler.rb', line 25

def compile
  $LOAD_PATH << Smith.acl_cache_path

  Smith.acl_path.each do |path|
    $LOAD_PATH << path

    acls_files = path_glob(path)
    out_of_date_acls = path_glob(path).select { |p| should_compile?(p) }
    if out_of_date_acls.size > 0
      compile_on_path(path, acls_files, out_of_date_acls)
    end

    acls_files.each do |acl_file|
      acl_class_path = acl_compiled_path(acl_file)
      load_acl(acl_class_path)
      add_to_type_cache(acl_class_path)
    end
  end
end