Module: Nake::TaskHelpers
- Includes:
- FileUtils
- Defined in:
- lib/nake/helpers.rb,
lib/nake/template.rb
Instance Method Summary collapse
- #erb(source, target, context = Hash.new) ⇒ Object
- #run(*parts) ⇒ Object
-
#sh(*parts) ⇒ Object
return true if process suceeded, false otherwise sh “ls -a” sh “ls”, “-a”.
- #template(source, target, context = Hash.new) ⇒ Object
-
#zsh(*parts) ⇒ Object
zsh “ls .*(.)”.
Instance Method Details
#erb(source, target, context = Hash.new) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/nake/template.rb', line 12 def erb(source, target, context = Hash.new) template = ErbTemplate.new(source) File.open(target, "w") do |file| file.puts(template.render(context)) end end |
#run(*parts) ⇒ Object
9 10 11 12 |
# File 'lib/nake/helpers.rb', line 9 def run(*parts) puts parts.join(" ").cyan system(*parts) end |
#sh(*parts) ⇒ Object
return true if process suceeded, false otherwise sh “ls -a” sh “ls”, “-a”
17 18 19 20 |
# File 'lib/nake/helpers.rb', line 17 def sh(*parts) puts "#{"$".magenta} #{parts.join(" ").cyan}" system("sh", "-c", *parts) end |
#template(source, target, context = Hash.new) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/nake/template.rb', line 5 def template(source, target, context = Hash.new) template = Template.new(source) File.open(target, "w") do |file| file.puts(template.render(context)) end end |
#zsh(*parts) ⇒ Object
zsh “ls .*(.)”
23 24 25 26 |
# File 'lib/nake/helpers.rb', line 23 def zsh(*parts) puts "#{"%".magenta} #{parts.join(" ").cyan}" system("zsh", "-c", *parts) end |