Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
View
@@ -14,5 +14,6 @@ module Moonshine #:nodoc:
$LOAD_PATH.unshift(here)
end
+require 'moonshine/core_ext'
require 'moonshine/manifest'
require 'moonshine/manifest/rails'
12 lib/moonshine/core_ext.rb
View
@@ -0,0 +1,12 @@
+# These extensions to Pathname let us use Pathname with puppet more easily
+# ie exec "blah", :cwd => Pathname.new('/etc')
+Pathname.class_eval do
+ def =~(pattern)
+ to_s =~ pattern
+ end
+
+ def gsub(*args)
+ to_s.gsub(*args)
+ end
+
+end
8 lib/moonshine/manifest/rails/rails.rb
View
@@ -71,7 +71,7 @@ def rails_rake_environment
exec 'rake tasks',
:command => 'rake environment 2>&1 | tee -a /var/log/moonshine_rake.log',
:user => configuration[:user],
- :cwd => rails_root.to_s,
+ :cwd => rails_root,
:environment => "RAILS_ENV=#{ENV['RAILS_ENV']}",
:logoutput => true,
:require => [
@@ -129,7 +129,7 @@ def rails_gems
:user => configuration[:user]
exec 'bundle install',
:command => 'bundle install',
- :cwd => rails_root.to_s,
+ :cwd => rails_root,
:before => [exec('rails_gems'), exec('bundle lock')],
:require => file('/etc/gemrc'),
:user => configuration[:user]
@@ -137,7 +137,7 @@ def rails_gems
# http://groups.google.com/group/phusion-passenger/browse_thread/thread/6642823360242cab/b75495c82b565fb1?#b75495c82b565fb1
exec 'bundle lock',
:command => 'bundle lock',
- :cwd => rails_root.to_s,
+ :cwd => rails_root,
:creates => gemfile_lock_path.to_s,
:user => configuration[:user]
else
@@ -269,7 +269,7 @@ def rake(name, options = {})
exec("rake #{name}", {
:command => "rake #{name} 2>&1 | tee -a /var/log/moonshine_rake.log",
:user => configuration[:user],
- :cwd => rails_root.to_s,
+ :cwd => rails_root,
:environment => "RAILS_ENV=#{ENV['RAILS_ENV']}",
:require => exec('rake tasks'),
:logoutput => true,
11 test/test_pathname.rb
View
@@ -0,0 +1,11 @@
+require 'test_helper'
+
+class TestPathname < Test::Unit::TestCase
+ def test_match
+ assert Pathname.new('/etc') =~ /#{File::SEPARATOR}/
+ end
+
+ def test_gsub
+ assert_equal '/tmp', Pathname.new('/etc').gsub('etc', 'tmp')
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.