Class: SiteFuel::Processor::AbstractStringBasedProcessor
- Inherits:
-
AbstractProcessor
- Object
- AbstractProcessor
- SiteFuel::Processor::AbstractStringBasedProcessor
- Defined in:
- lib/sitefuel/processors/AbstractStringBasedProcessor.rb
Direct Known Subclasses
CSSProcessor, HAMLProcessor, HTMLProcessor, JavaScriptProcessor, SASSProcessor
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Attributes inherited from AbstractProcessor
#execution_list, #original_size, #processed_size, #resource_name
Class Method Summary collapse
-
.filter_string(filter, string) ⇒ Object
mostly intended for debugging; applies a single filter directly to a string.
-
.process_file(filename, config = {}) ⇒ Object
lightweight wrapper for opening a resource and generating the file.
-
.process_string(string, config = {}) ⇒ Object
opens a resource in-memory and returns the generated string.
- .processor_type ⇒ Object
Instance Method Summary collapse
-
#generate ⇒ Object
generates the string and shoves it into the deployment abstraction.
-
#generate_string ⇒ Object
generates the actual string.
-
#open_file(filename, resource_name = nil) ⇒ Object
opens a resource from a file.
-
#open_string(string) ⇒ Object
opens a resource directly from a string.
- #processor_symbol ⇒ Object
- #save(file_tree) ⇒ Object
Methods inherited from AbstractProcessor
#add_filter, #add_filterset, #clear_filters, #create_file, default_filterset, #drop_filter, #execute, file_pattern_match?, file_patterns, #filter?, filter?, filters, filters_in_filterset, filterset?, filterset_ignore, filtersets, find_processors, #finish_filters, #initialize, processes_file?, processor_name, #run_filter, #run_filterset, #setup_filters
Methods included from ClassLogging
#debug, #error, #fatal, #info, #warn
Methods included from Configurable
#configuration_options, #configure, #ensure_configurable_option, #post_configuration, #pre_configuration, #set_configuration
Methods included from Logging
#debug, #error, #fatal, #info, #logger=, #warn
Constructor Details
This class inherits a constructor from SiteFuel::Processor::AbstractProcessor
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
110 111 112 |
# File 'lib/sitefuel/processors/AbstractStringBasedProcessor.rb', line 110 def document @document end |
Class Method Details
.filter_string(filter, string) ⇒ Object
mostly intended for debugging; applies a single filter directly to a string
filter can either be a single filter or an array of filters
48 49 50 51 52 53 |
# File 'lib/sitefuel/processors/AbstractStringBasedProcessor.rb', line 48 def self.filter_string(filter, string) proc = self.new() proc.configure(:filters => filter) proc.open_string(string) proc.generate_string end |
.process_file(filename, config = {}) ⇒ Object
lightweight wrapper for opening a resource and generating the file
29 30 31 32 33 34 |
# File 'lib/sitefuel/processors/AbstractStringBasedProcessor.rb', line 29 def self.process_file(filename, config = {}) proc = self.new() proc.configure(config) proc.open_file(filename) proc.generate end |
.process_string(string, config = {}) ⇒ Object
opens a resource in-memory and returns the generated string
37 38 39 40 41 42 |
# File 'lib/sitefuel/processors/AbstractStringBasedProcessor.rb', line 37 def self.process_string(string, config = {}) proc = self.new() proc.configure(config) proc.open_string(string) proc.generate_string end |
.processor_type ⇒ Object
20 21 22 |
# File 'lib/sitefuel/processors/AbstractStringBasedProcessor.rb', line 20 def self.processor_type 'String' end |
Instance Method Details
#generate ⇒ Object
generates the string and shoves it into the deployment abstraction
96 97 98 99 |
# File 'lib/sitefuel/processors/AbstractStringBasedProcessor.rb', line 96 def generate generate_string return self end |
#generate_string ⇒ Object
generates the actual string
88 89 90 91 92 93 |
# File 'lib/sitefuel/processors/AbstractStringBasedProcessor.rb', line 88 def generate_string self.execute self.processed_size = @document.length document end |
#open_file(filename, resource_name = nil) ⇒ Object
opens a resource from a file
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/sitefuel/processors/AbstractStringBasedProcessor.rb', line 56 def open_file(filename, resource_name = nil) info "#{self.class} opening #{filename}" self.document = File.read(filename) self.original_size = File.size(filename) case when (resource_name == nil and @resource_name == nil) @resource_name = filename when @resource_name != nil # just leave @resource_name be else @resource_name = resource_name end debug "\t\tOpened with resource name: '#{@resource_name}'" return self end |
#open_string(string) ⇒ Object
opens a resource directly from a string
79 80 81 82 83 84 85 |
# File 'lib/sitefuel/processors/AbstractStringBasedProcessor.rb', line 79 def open_string(string) info "#{self.class} opening in embedded mode" self.document = string self.original_size = string.length self.resource_name = '<<embedded string>>' end |
#processor_symbol ⇒ Object
24 25 26 |
# File 'lib/sitefuel/processors/AbstractStringBasedProcessor.rb', line 24 def processor_symbol 'S' end |