Module: Glaemscribe::API::ResourceManager
- Defined in:
- lib/api/resource_manager.rb
Constant Summary collapse
- MODE_PATH =
File.dirname(__FILE__) + "/../../glaemresources/modes/"
- MODE_EXT =
"glaem"
- CHARSET_PATH =
File.dirname(__FILE__) + "/../../glaemresources/charsets/"
- CHARSET_EXT =
"cst"
- ALL =
["*"]
- MODE_FILES =
[MODE_PATH + "*.#{MODE_EXT}"]
Class Method Summary collapse
- .available_mode_names ⇒ Object
- .charset(name) ⇒ Object
- .charset_name_from_file_path(file_path) ⇒ Object
- .class_for_post_processor_operator_name(operator_name) ⇒ Object
- .class_for_pre_processor_operator_name(operator_name) ⇒ Object
- .load_charsets(which_ones = ALL) ⇒ Object
- .load_modes(which_ones = ALL) ⇒ Object
- .loaded_charsets ⇒ Object
- .loaded_modes ⇒ Object
- .mode_name_from_file_path(file_path) ⇒ Object
- .p ⇒ Object
- .register_post_processor_class(operator_name, operator_class) ⇒ Object
- .register_pre_processor_class(operator_name, operator_class) ⇒ Object
Class Method Details
.available_mode_names ⇒ Object
43 44 45 46 47 |
# File 'lib/api/resource_manager.rb', line 43 def self.available_mode_names Dir.glob(MODE_FILES).map { |mode_file| self.mode_name_from_file_path(mode_file) } end |
.charset(name) ⇒ Object
128 129 130 |
# File 'lib/api/resource_manager.rb', line 128 def self.charset(name) @loaded_charsets[name] end |
.charset_name_from_file_path(file_path) ⇒ Object
83 84 85 |
# File 'lib/api/resource_manager.rb', line 83 def self.charset_name_from_file_path(file_path) File.basename(file_path,".*") end |
.class_for_post_processor_operator_name(operator_name) ⇒ Object
69 70 71 |
# File 'lib/api/resource_manager.rb', line 69 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) ⇒ Object
65 66 67 |
# File 'lib/api/resource_manager.rb', line 65 def self.class_for_pre_processor_operator_name(operator_name) @pre_processor_operator_classes[operator_name] end |
.load_charsets(which_ones = ALL) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/api/resource_manager.rb', line 107 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) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/api/resource_manager.rb', line 87 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 ⇒ Object
53 54 55 |
# File 'lib/api/resource_manager.rb', line 53 def self.loaded_charsets @loaded_charsets end |
.loaded_modes ⇒ Object
49 50 51 |
# File 'lib/api/resource_manager.rb', line 49 def self.loaded_modes @loaded_modes end |
.mode_name_from_file_path(file_path) ⇒ Object
78 79 80 81 |
# File 'lib/api/resource_manager.rb', line 78 def self.mode_name_from_file_path(file_path) ext = (file_path =~ /\.glaem\.dev$/)?(".glaem.dev"):(".glaem") File.basename(file_path,ext) end |
.p ⇒ Object
73 74 75 76 |
# File 'lib/api/resource_manager.rb', line 73 def self.p puts @pre_processor_operator_classes.inspect puts @post_processor_operator_classes.inspect end |
.register_post_processor_class(operator_name, operator_class) ⇒ Object
61 62 63 |
# File 'lib/api/resource_manager.rb', line 61 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) ⇒ Object
57 58 59 |
# File 'lib/api/resource_manager.rb', line 57 def self.register_pre_processor_class(operator_name, operator_class) @pre_processor_operator_classes[operator_name] = operator_class end |