module Glaemscribe::API::ResourceManager

Constants

ALL
CHARSET_EXT
CHARSET_PATH
MODE_EXT
MODE_FILES
MODE_PATH

The same structure is kept within the gem

Public Class Methods

available_mode_names() click to toggle source
# File lib/api/resource_manager.rb, line 44
def self.available_mode_names
  Dir.glob(MODE_FILES).map { |mode_file|     
    self.mode_name_from_file_path(mode_file)
  }
end
charset(name) click to toggle source
# File lib/api/resource_manager.rb, line 129
def self.charset(name)
  @loaded_charsets[name]
end
charset_name_from_file_path(file_path) click to toggle source
# File lib/api/resource_manager.rb, line 84
def self.charset_name_from_file_path(file_path)
  File.basename(file_path,".*")
end
class_for_post_processor_operator_name(operator_name) click to toggle source
# File lib/api/resource_manager.rb, line 70
def self.class_for_post_processor_operator_name(operator_name)
  @post_processor_operator_classes[operator_name]
end
class_for_pre_processor_operator_name(operator_name) click to toggle source
# File lib/api/resource_manager.rb, line 66
def self.class_for_pre_processor_operator_name(operator_name)
  @pre_processor_operator_classes[operator_name]
end
load_charsets(which_ones = ALL) click to toggle source
# File lib/api/resource_manager.rb, line 108
def self.load_charsets(which_ones = ALL)

  which_ones = [which_ones] if(which_ones.is_a?(String))  
    
  Dir.glob(CHARSET_PATH + "*.#{CHARSET_EXT}") { |charset_file|

    charset_name = self.charset_name_from_file_path(charset_file)
    
    next if(which_ones != ALL && !which_ones.include?(charset_name))
    next if(@loaded_charsets.include? charset_name) # Don't load a charset twice
  
    API::Debug::log("*" * 20)
    API::Debug::log("Parsing Charset : #{charset_name}")
    API::Debug::log("*" * 20)
  
    charset = API::CharsetParser.new().parse(charset_file)
    
    @loaded_charsets[charset.name] = charset if charset 
  } 
end
load_modes(which_ones = ALL) click to toggle source
# File lib/api/resource_manager.rb, line 88
def self.load_modes(which_ones = ALL)
  
  which_ones = [which_ones] if(which_ones.is_a?(String))  
    
  Dir.glob(MODE_FILES) { |mode_file|

    mode_name = self.mode_name_from_file_path(mode_file)

    next if(which_ones != ALL && !which_ones.include?(mode_name))
    next if(@loaded_modes.include? mode_name) # Don't load a charset twice
    
    API::Debug::log("*" * 20)
    API::Debug::log("Parsing Mode : #{mode_name}")
    API::Debug::log("*" * 20)
  
    mode = API::ModeParser.new().parse(mode_file)
    @loaded_modes[mode.name] = mode if mode 
  }  
end
loaded_charsets() click to toggle source
# File lib/api/resource_manager.rb, line 54
def self.loaded_charsets
  @loaded_charsets
end
loaded_modes() click to toggle source
# File lib/api/resource_manager.rb, line 50
def self.loaded_modes
  @loaded_modes
end
mode_name_from_file_path(file_path) click to toggle source
# File lib/api/resource_manager.rb, line 79
def self.mode_name_from_file_path(file_path)
  ext = (file_path =~ /\.glaem\.dev$/)?(".glaem.dev"):(".glaem")
  File.basename(file_path,ext)
end
p() click to toggle source
# File lib/api/resource_manager.rb, line 74
def self.p
  puts @pre_processor_operator_classes.inspect
  puts @post_processor_operator_classes.inspect        
end
register_post_processor_class(operator_name, operator_class) click to toggle source
# File lib/api/resource_manager.rb, line 62
def self.register_post_processor_class(operator_name, operator_class)
  @post_processor_operator_classes[operator_name] = operator_class
end
register_pre_processor_class(operator_name, operator_class) click to toggle source
# File lib/api/resource_manager.rb, line 58
def self.register_pre_processor_class(operator_name, operator_class)
  @pre_processor_operator_classes[operator_name] = operator_class
end