Questions tagged [ruby-block]
37 questions
0
votes
1 answer
In the second run of chef-client, lazy attribute of docker_container on "link" is not getting resolved and passed unreadable value
my first time to ask stuff on stack-overflow, here in china i seldom able to meet any chef developer to talk about my problem so i am posting it here to seek for help. This issue has been bothering me for weeks and i am still trying to settle…
0
votes
2 answers
I have a conundrum involving blocks and passing them around, need help solving it
Ok, so I've build a DSL and part of it requires the user of the DSL to define what I called a 'writer block'
writer do |data_block|
CSV.open("data.csv", "wb") do |csv|
headers_written = false
data_block do |hash|
(csv <<…

Thermatix
- 2,757
- 21
- 51
0
votes
2 answers
ruby block not executing code, only printing output
I have two chef recipes I want to run in a defined order. First is the install recipe, then it's the config.
Here is the code invoking the recipes:
ruby_block "bowbridge_config" do
block do
run_context.include_recipe…

Vladimir
- 417
- 5
- 20
0
votes
3 answers
Ruby - Iterating over and calling an array of methods
Lets say I have two methods:
def hello
'hello'
end
def world
'world'
end
Now I want to call these methods in a fashion like this:
try_retry{
hello
}
try_retry{
world
}
assume try_retry is a method that will retry the block of code if an…

Im_Matt_Murdock
- 27
- 1
- 7
0
votes
1 answer
Variable assignment takes place in a block in a block
I first had this code, but it wasn't working:
VIM = Vimrunner::RSpec.configure do |config|
config.reuse_server = true
config.start_vim do
vim = Vimrunner.start
vim
end
end
The configure is just a method that does the settings for a…

hgiesel
- 5,430
- 2
- 29
- 56
0
votes
2 answers
How does the block form of Array#new work given "Array.new(10) { |e| e = e * 2 }"?
I am having trouble understanding the part inside the curly braces.
Array.new(10) { |e| e = e * 2 }
# => [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
I get that a new array with ten values is created, but what is the second half doing?

Kevin Kelbie
- 74
- 4
-1
votes
1 answer
chef resource ruby_block replacing aline in file
how to replace :
export JAVA_HOME=${JAVA_HOME}
with :
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::") in
hadoop-env.sh using
RUBY_BLOCK resource in CHEF

rajpalla
- 35
- 5