Skip to content
This repository
Browse code

Monkey patched pathname to work with puppet better, so we don't have …

…to call rails_root.to_s everywhere.
  • Loading branch information...
commit fc2b9430cedf6b49374855591b42c74a9353ed40 1 parent 978af64
Josh Nichols technicalpickles authored
1  lib/moonshine.rb
@@ -14,5 +14,6 @@ module Moonshine #:nodoc:
14 14 $LOAD_PATH.unshift(here)
15 15 end
16 16
  17 +require 'moonshine/core_ext'
17 18 require 'moonshine/manifest'
18 19 require 'moonshine/manifest/rails'
12 lib/moonshine/core_ext.rb
... ... @@ -0,0 +1,12 @@
  1 +# These extensions to Pathname let us use Pathname with puppet more easily
  2 +# ie exec "blah", :cwd => Pathname.new('/etc')
  3 +Pathname.class_eval do
  4 + def =~(pattern)
  5 + to_s =~ pattern
  6 + end
  7 +
  8 + def gsub(*args)
  9 + to_s.gsub(*args)
  10 + end
  11 +
  12 +end
8 lib/moonshine/manifest/rails/rails.rb
@@ -71,7 +71,7 @@ def rails_rake_environment
71 71 exec 'rake tasks',
72 72 :command => 'rake environment 2>&1 | tee -a /var/log/moonshine_rake.log',
73 73 :user => configuration[:user],
74   - :cwd => rails_root.to_s,
  74 + :cwd => rails_root,
75 75 :environment => "RAILS_ENV=#{ENV['RAILS_ENV']}",
76 76 :logoutput => true,
77 77 :require => [
@@ -129,7 +129,7 @@ def rails_gems
129 129 :user => configuration[:user]
130 130 exec 'bundle install',
131 131 :command => 'bundle install',
132   - :cwd => rails_root.to_s,
  132 + :cwd => rails_root,
133 133 :before => [exec('rails_gems'), exec('bundle lock')],
134 134 :require => file('/etc/gemrc'),
135 135 :user => configuration[:user]
@@ -137,7 +137,7 @@ def rails_gems
137 137 # http://groups.google.com/group/phusion-passenger/browse_thread/thread/6642823360242cab/b75495c82b565fb1?#b75495c82b565fb1
138 138 exec 'bundle lock',
139 139 :command => 'bundle lock',
140   - :cwd => rails_root.to_s,
  140 + :cwd => rails_root,
141 141 :creates => gemfile_lock_path.to_s,
142 142 :user => configuration[:user]
143 143 else
@@ -269,7 +269,7 @@ def rake(name, options = {})
269 269 exec("rake #{name}", {
270 270 :command => "rake #{name} 2>&1 | tee -a /var/log/moonshine_rake.log",
271 271 :user => configuration[:user],
272   - :cwd => rails_root.to_s,
  272 + :cwd => rails_root,
273 273 :environment => "RAILS_ENV=#{ENV['RAILS_ENV']}",
274 274 :require => exec('rake tasks'),
275 275 :logoutput => true,
11 test/test_pathname.rb
... ... @@ -0,0 +1,11 @@
  1 +require 'test_helper'
  2 +
  3 +class TestPathname < Test::Unit::TestCase
  4 + def test_match
  5 + assert Pathname.new('/etc') =~ /#{File::SEPARATOR}/
  6 + end
  7 +
  8 + def test_gsub
  9 + assert_equal '/tmp', Pathname.new('/etc').gsub('etc', 'tmp')
  10 + end
  11 +end

0 comments on commit fc2b943

Please sign in to comment.
Something went wrong with that request. Please try again.