aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/commands/plugin.rb30
2 files changed, 29 insertions, 3 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 32bd48cbf7..76998f3eec 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Improve script/plugin on Windows. #2646 [Chad Fowler]
+
* The *_plugindoc Rake tasks look deeper into the plugins' lib directories. #2652 [bellis@deepthought.org]
* The PostgreSQL :db_structure_dump Rake task limits its dump to the schema search path in database.yml. [Anatol Pomozov <anatol.pomozov@gmail.com>]
diff --git a/railties/lib/commands/plugin.rb b/railties/lib/commands/plugin.rb
index 0e69f4b595..8dc569387b 100644
--- a/railties/lib/commands/plugin.rb
+++ b/railties/lib/commands/plugin.rb
@@ -46,6 +46,12 @@
# Send patches to rtomayko@gmail.com
$verbose = false
+`svn --version`
+unless $?.success?
+ $stderr.puts "ERROR: Must have subversion (svn) available in the PATH to use plugin manager"
+ exit 1
+end
+
require 'fileutils'
require 'tempfile'
@@ -193,7 +199,7 @@ end
class Repositories
include Enumerable
- def initialize(cache_file="~/.rails-plugin-sources")
+ def initialize(cache_file = File.join(find_home, ".rails-plugin-sources"))
@cache_file = File.expand_path(cache_file)
load!
end
@@ -252,7 +258,25 @@ class Repositories
http://svn.aviditybytes.com/rails/plugins/
REPOSITORIES
end
-
+
+ def find_home
+ ['HOME', 'USERPROFILE'].each do |homekey|
+ return ENV[homekey] if ENV[homekey]
+ end
+ if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
+ return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
+ end
+ begin
+ File.expand_path("~")
+ rescue StandardError => ex
+ if File::ALT_SEPARATOR
+ "C:/"
+ else
+ "/"
+ end
+ end
+ end
+
def self.instance
@instance ||= Repositories.new
end
@@ -740,4 +764,4 @@ module Commands
end
-Commands::Plugin.parse! \ No newline at end of file
+Commands::Plugin.parse!