Module: Compass::Magick::Configuration
- Extended by:
- Configuration::Inheritance::ClassMethods, Configuration
- Included in:
- Configuration
- Defined in:
- lib/magick/configuration.rb,
lib/plugins/phantom.rb
Overview
Configuration methods to allow plugins to register new configurable properties.
Instance Method Summary collapse
-
#add_property(name) ⇒ Object
Registers a new property in ‘config.rb`.
-
#comment_for_phantom_executable ⇒ String
Emits the comment for the ‘phantom_executable` property into the configuration file when serialized – makes it easier to understand for new Users.
-
#comment_for_phantom_script ⇒ String
Emits the comment for the ‘phantom_script` property into the configuration file when serialized – makes it easier to understand for new Users.
-
#cygwin_path(path) ⇒ String
Converts a Cygwin Unix path to a Windows path, e.g.:.
-
#default_phantom_executable ⇒ String
Provides the default value for ‘phantom_executable` when one isn’t specified in the configuration file.
-
#default_phantom_script ⇒ String
Provides the default value for ‘phantom_script` when one isn’t specified in the configuration file.
Instance Method Details
#add_property(name) ⇒ Object
Registers a new property in ‘config.rb`.
If you use this method, you should also define two additional methods:
-
comment_for_$name - emits a comment against the properly into the configuration file when serialized
-
default_$name - provides a default value for the property when one isn’t specified in the configuration file
20 21 22 23 |
# File 'lib/magick/configuration.rb', line 20 def add_property(name) Compass::Configuration::ATTRIBUTES.push(name) inherited_accessor(name) end |
#comment_for_phantom_executable ⇒ String
Emits the comment for the ‘phantom_executable` property into the configuration file when serialized – makes it easier to understand for new Users.
23 24 25 |
# File 'lib/plugins/phantom.rb', line 23 def comment_for_phantom_executable "# Path to the PhantomJS binary\n" end |
#comment_for_phantom_script ⇒ String
Emits the comment for the ‘phantom_script` property into the configuration file when serialized – makes it easier to understand for new Users.
32 33 34 |
# File 'lib/plugins/phantom.rb', line 32 def comment_for_phantom_script "# Path to magick.js used to render a web page (using PhantomJS, a headless WebKit)\n" end |
#cygwin_path(path) ⇒ String
Converts a Cygwin Unix path to a Windows path, e.g.:
/cygdrive/d/path/to/file
==>
D:/path/to/file
33 34 35 36 37 38 39 |
# File 'lib/magick/configuration.rb', line 33 def cygwin_path(path) if RUBY_PLATFORM.include?('cygwin') && path.index('/') == 0 IO.popen("cygpath -m #{path.include?(':') ? '-p' : ''} #{path.shellescape}").readline.chomp.gsub(/;/, '\\;') else path end end |
#default_phantom_executable ⇒ String
Provides the default value for ‘phantom_executable` when one isn’t specified in the configuration file.
40 41 42 |
# File 'lib/plugins/phantom.rb', line 40 def default_phantom_executable ENV['PHANTOM_PATH'] || 'phantomjs' end |
#default_phantom_script ⇒ String
Provides the default value for ‘phantom_script` when one isn’t specified in the configuration file.
49 50 51 |
# File 'lib/plugins/phantom.rb', line 49 def default_phantom_script cygwin_path(ENV['PHANTOM_SCRIPT'] || File.join(EXTRAS_PATH, 'magick.js')) end |