Class: Arrow::Config::YamlLoader
- Includes:
- Arrow::Constants
- Defined in:
- lib/arrow/config-loaders/yaml.rb
Overview
The Arrow::Config::YamlLoader class, a derivative of Arrow::Config::Loader. It is used to load configuration files written in YAML for the Arrow web application framework.
Authors
-
Michael Granger <[email protected]>
Please see the file LICENSE in the top-level directory for licensing details.
Constant Summary
Constants included from Arrow::Constants
Arrow::Constants::HTML_MIMETYPE, Arrow::Constants::RUBY_MARSHALLED_MIMETYPE, Arrow::Constants::RUBY_OBJECT_MIMETYPE, Arrow::Constants::XHTML_MIMETYPE, Arrow::Constants::YAML_DOMAIN
Instance Method Summary collapse
-
#is_newer?(file, time) ⇒ Boolean
Return
true
if the specifiedfile
is newer than the giventime
. -
#load(filename) ⇒ Object
Load and return configuration values from the YAML
file
specified. -
#save(confighash, filename) ⇒ Object
Save configuration values to the YAML
file
specified.
Methods inherited from Loader
Methods inherited from Object
deprecate_class_method, deprecate_method, inherited
Instance Method Details
#is_newer?(file, time) ⇒ Boolean
Return true
if the specified file
is newer than the given time
.
64 65 66 67 68 69 70 |
# File 'lib/arrow/config-loaders/yaml.rb', line 64 def is_newer?( file, time ) return false unless File.exists?( file ) st = File.stat( file ) self.log.debug "File mtime is: %s, comparison time is: %s" % [ st.mtime, time ] return st.mtime > time end |
#load(filename) ⇒ Object
Load and return configuration values from the YAML file
specified.
47 48 49 50 |
# File 'lib/arrow/config-loaders/yaml.rb', line 47 def load( filename ) self.log.info "Loading YAML-format configuration from '%s'" % filename return YAML.load_file( filename ) end |
#save(confighash, filename) ⇒ Object
Save configuration values to the YAML file
specified.
54 55 56 57 58 59 |
# File 'lib/arrow/config-loaders/yaml.rb', line 54 def save( confighash, filename ) self.log.info "Saving YAML-format configuration to '%s'" % filename File.open( filename, File::WRONLY|File::CREAT|File::TRUNC ) {|ofh| ofh.print( confighash.to_yaml ) } end |