Module: HtmlSlicer
- Defined in:
- lib/html_slicer/engine.rb,
lib/html_slicer.rb,
lib/html_slicer/config.rb,
lib/html_slicer/options.rb,
lib/html_slicer/railtie.rb,
lib/html_slicer/version.rb,
lib/html_slicer/installer.rb,
lib/html_slicer/interface.rb,
lib/html_slicer/processor.rb,
lib/html_slicer/utilities.rb,
lib/html_slicer/cached_stuff.rb,
lib/html_slicer/helpers/tags.rb,
lib/html_slicer/helpers/slicer.rb,
lib/html_slicer/mappers/slicing.rb,
lib/html_slicer/mappers/resizing.rb,
lib/html_slicer/helpers/action_view_extension.rb,
lib/html_slicer/models/active_record_extension.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ActionViewExtension, ActiveRecordExtension, Helpers, Installer, Mappers, Process, Utilities Classes: CachedStuff, Configuration, Engine, Interface, Options, Processor, Railtie, ResizingOptions, SlicingOptions
Constant Summary collapse
- VERSION =
"0.1.8"
Class Method Summary collapse
-
.config(style = nil) ⇒ Object
Config accessor for HtmlSlicer.
-
.configure(style = nil) {|eval("@config#{"_#{style}" if style} ||= #{style ? "@config.duplicate" : "Configuration.new"}")| ... } ⇒ Object
Configures global settings for HtmlSlicer.
- .load! ⇒ Object
- .load_processor!(name) ⇒ Object
Class Method Details
.config(style = nil) ⇒ Object
Config accessor for HtmlSlicer. Accepts argument as a style
.
41 42 43 |
# File 'lib/html_slicer/config.rb', line 41 def self.config(style = nil) eval("@config#{"_#{style}" if style}") || raise("Config style '#{style}' is invalid.") end |
.configure(style = nil) {|eval("@config#{"_#{style}" if style} ||= #{style ? "@config.duplicate" : "Configuration.new"}")| ... } ⇒ Object
Configures global settings for HtmlSlicer
Default global configuration options
window = 4
outer_window = 0
left = 0
right = 0
param_name = :slice
Override/complete global configuration
HtmlSlicer.configure do |config|
config.slice = {:complete => /\s+|\z/, :maximum => 2000}
config.resize = {:width => 300, :only => {:tag => 'iframe'}}
config.window = 5
config.param_name = :any_other_param_name
end
Passing an argument (:symbol) creates stylized configuration, which can be used like that:
HtmlSlicer.configure(:paged) do |config|
config.as = :page
config.param_name = :page
end
class Post < ActiveRecord::Base
slice :content, :config => :paged
end
-
Missing options are inherited from global one.
36 37 38 |
# File 'lib/html_slicer/config.rb', line 36 def self.configure(style = nil, &block) yield eval("@config#{"_#{style}" if style} ||= #{style ? "@config.duplicate" : "Configuration.new"}") end |
.load! ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/html_slicer.rb', line 7 def self.load! require 'html_slicer/utilities' require 'html_slicer/config' require 'html_slicer/interface' require 'html_slicer/engine' require 'html_slicer/helpers/action_view_extension' require 'html_slicer/helpers/slicer' require 'html_slicer/railtie' end |
.load_processor!(name) ⇒ Object
27 28 29 30 31 |
# File 'lib/html_slicer/processor.rb', line 27 def self.load_processor!(name) if defined?(Rails.root) && Rails.root require File.(Rails.root.join("lib", "html_slicer_processors", "#{name.to_s.underscore}.rb")) end end |