I am looking at a ruby script and testing it…
I don’t fully understand the following line of code :
database = YAML::load_file(“config/#{fetch(:db_file,
‘database.yml’)}”)
=> fetch(:db_file, ‘database.yml’) … what’s is this function
fetch() ?
I know the fetch(key, *extras) in ActiveSupport, but this is not the
case… any suggestion ?
thanks
Is this part of a capistrano script?
https://github.com/capistrano/capistrano/wiki/2.x-DSL-Configuration-Variables-Fetch If
so then it uses the value in deploy.rb where
set :db_file
is defined.
(Perhaps look here:
Capistrano Handbook
===================
## Index
* [Simple. The Way it Should Be](simple_the_way_it_should_be)
* [Building Blocks Variables & Tasks](building_blocks_varaibles_and_tasks)
* [Tasks](building_blocks_varaibles_and_tasks/tasks)
* [Variables](building_blocks_varaibles_and_tasks/variables)
* [Local Vs. Remote Tasks](/local_vs_remote_tasks)
* [Rights, Users and Privileges](/rights_users_privileges)
* [Command Line Options](/command_line_options)
### Anatomy of a Capistrano installation
Typically inside your application you will have a structure not dissimilar to the following:
/
|- public/
|- config/
This file has been truncated. show original
)
Otherwise I would imply you should give some more information about the
type of script you are looking at.
On 02/02/11 15:22, Erwin wrote:
case… any suggestion ?
thanks
–
best regards
Bente P.
Thanks , you’re right, :db_file is defined, and the line runs well…
my concern was about the ‘fetch’ function which returns a string…
it seems to return the second string argument if the first is not
defined …
but is it a Ruby function or a Rails function …
I know a anArray.fetch( aString) but not this one …
I told you: it is a method of capistrano.
set sets the value, fetch gets it
Follow my first link and read the chapter “Variables” …
Or look here
A deployment automation tool built on Ruby, Rake, and SSH. - GitHub - capistrano/capistrano: A deployment automation tool built on Ruby, Rake, and SSH.
Or look here
require "capistrano/proc_helpers"
module Capistrano
class Configuration
# Holds the variables assigned at Capistrano runtime via `set` and retrieved
# with `fetch`. Does internal bookkeeping to help identify user mistakes
# like spelling errors or unused variables that may lead to unexpected
# behavior.
class Variables
CAPISTRANO_LOCATION = File.expand_path("../..", __FILE__).freeze
IGNORED_LOCATIONS = [
"#{CAPISTRANO_LOCATION}/configuration/variables.rb:",
"#{CAPISTRANO_LOCATION}/configuration.rb:",
"#{CAPISTRANO_LOCATION}/dsl/env.rb:",
"/dsl.rb:",
"/forwardable.rb:"
].freeze
private_constant :CAPISTRANO_LOCATION, :IGNORED_LOCATIONS
include Capistrano::ProcHelpers
This file has been truncated. show original
On 02/02/11 17:57, Erwin wrote:
best regards
Bente P.
–
best regards
Bente P.