Methods
- best_install_method
- default
- default=
- externals
- externals=
- find
- install
- new
- use_checkout?
- use_externals?
- use_svn?
Attributes
[R] | root |
Public Class methods
[ show source ]
# File railties/lib/commands/plugin.rb, line 83 83: def self.default 84: @default ||= find 85: end
[ show source ]
# File railties/lib/commands/plugin.rb, line 87 87: def self.default=(rails_env) 88: @default = rails_env 89: end
[ show source ]
# File railties/lib/commands/plugin.rb, line 75 75: def self.find(dir=nil) 76: dir ||= pwd 77: while dir.length > 1 78: return new(dir) if File.exist?(File.join(dir, 'config', 'environment.rb')) 79: dir = File.dirname(dir) 80: end 81: end
[ show source ]
# File railties/lib/commands/plugin.rb, line 71 71: def initialize(dir) 72: @root = dir 73: end
Public Instance methods
[ show source ]
# File railties/lib/commands/plugin.rb, line 125 125: def best_install_method 126: return :http unless use_svn? 127: case 128: when use_externals? then :externals 129: when use_checkout? then :checkout 130: else :export 131: end 132: end
[ show source ]
# File railties/lib/commands/plugin.rb, line 134 134: def externals 135: return [] unless use_externals? 136: ext = `svn propget svn:externals "#{root}/vendor/plugins"` 137: lines = ext.respond_to?(:lines) ? ext.lines : ext 138: lines.reject{ |line| line.strip == '' }.map do |line| 139: line.strip.split(/\s+/, 2) 140: end 141: end
[ show source ]
# File railties/lib/commands/plugin.rb, line 143 143: def externals=(items) 144: unless items.is_a? String 145: items = items.map{|name,uri| "#{name.ljust(29)} #{uri.chomp('/')}"}.join("\n") 146: end 147: Tempfile.open("svn-set-prop") do |file| 148: file.write(items) 149: file.flush 150: system("svn propset -q svn:externals -F \"#{file.path}\" \"#{root}/vendor/plugins\"") 151: end 152: end
[ show source ]
# File railties/lib/commands/plugin.rb, line 91 91: def install(name_uri_or_plugin) 92: if name_uri_or_plugin.is_a? String 93: if name_uri_or_plugin =~ /:\/\// 94: plugin = Plugin.new(name_uri_or_plugin) 95: else 96: plugin = Plugins[name_uri_or_plugin] 97: end 98: else 99: plugin = name_uri_or_plugin 100: end 101: unless plugin.nil? 102: plugin.install 103: else 104: puts "Plugin not found: #{name_uri_or_plugin}" 105: end 106: end
[ show source ]
# File railties/lib/commands/plugin.rb, line 118 118: def use_checkout? 119: # this is a bit of a guess. we assume that if the rails environment 120: # is under subversion then they probably want the plugin checked out 121: # instead of exported. This can be overridden on the command line 122: File.directory?("#{root}/.svn") 123: end
[ show source ]
# File railties/lib/commands/plugin.rb, line 114 114: def use_externals? 115: use_svn? && File.directory?("#{root}/vendor/plugins/.svn") 116: end
[ show source ]
# File railties/lib/commands/plugin.rb, line 108 108: def use_svn? 109: require 'active_support/core_ext/kernel' 110: silence_stderr {`svn --version` rescue nil} 111: !$?.nil? && $?.success? 112: end