I am newbie in Ruby, Rake and shell script. Here I created one simple task in Rake which parse YAML file and returns its response. Following is the task in my Rakefile. It works fine and puts prints the yaml value on console.
task :test, [:env] do |t, args|
db_settings = YAML::load(File.open("test.yml"))["#{args[:env]}"]
puts db_settings
end
Following is the result of the task.
{"url"=>"http://test.com", "end"=>"test"}
["test[local]"]
But when I want to call this task from shell script then it didn't return response to script. not sure ruby not able to send response or script itself doing something wrong.
Following is shell script that I am using to call this rake task.
res= rake test[local]
echo $res
How can I get this parsed yaml from rake task to shell script?
Second question is, will this script be able to use this Parsed yaml. Rake task returns env specific json structure to script and the script supposed to get the element using key.
Can someone help on this to? is the current approach to use Yaml on script.