From a0f610602bb6f509ac11f68f85de81790ef6959c Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sat, 6 Oct 2012 16:42:51 -0400 Subject: [PATCH] support the ruby version option --- features/ruby_gemfile.feature | 11 +++++++++++ lib/penchant/gemfile.rb | 10 +++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/features/ruby_gemfile.feature b/features/ruby_gemfile.feature index 291ff4d..96173d1 100644 --- a/features/ruby_gemfile.feature +++ b/features/ruby_gemfile.feature @@ -411,3 +411,14 @@ Feature: Gemfiles gem "one" """ + Scenario: Pass through the Ruby version + Given I have the file "Gemfile.penchant" with the content: + """ + ruby '1.9.3' + """ + When I rebuild the Gemfile for "local" mode + Then the file "Gemfile" should have the following content: + """ + # generated by penchant, environment: local + ruby "1.9.3" + """ diff --git a/lib/penchant/gemfile.rb b/lib/penchant/gemfile.rb index ead4c1c..b2a79ab 100644 --- a/lib/penchant/gemfile.rb +++ b/lib/penchant/gemfile.rb @@ -203,6 +203,10 @@ module Penchant end end + def ruby(version) + @output << %{ruby "#{version}"} + end + protected def args_to_string(args) args.inspect[1..-2] @@ -218,9 +222,9 @@ module Penchant [ args, template ] end - def call_and_indent_output(block) + def call_and_indent_output(block = nil, &given_block) index = @output.length - block.call + (block || given_block).call index.upto(@output.length - 1) do |i| @output[i] = " " + @output[i] end @@ -270,7 +274,7 @@ module Penchant properties[key] = value end end - + properties end