Class: Plugin
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #git_url? ⇒ Boolean
- #info ⇒ Object
-
#initialize(uri, name = nil) ⇒ Plugin
constructor
A new instance of Plugin.
- #install(method = nil, options = {}) ⇒ Object
- #installed? ⇒ Boolean
- #svn_url? ⇒ Boolean
- #to_s ⇒ Object
- #uninstall ⇒ Object
Constructor Details
#initialize(uri, name = nil) ⇒ Plugin
Returns a new instance of Plugin.
148 149 150 151 |
# File 'lib/commands/plugin.rb', line 148 def initialize(uri, name=nil) @uri = uri guess_name(uri) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
146 147 148 |
# File 'lib/commands/plugin.rb', line 146 def name @name end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
146 147 148 |
# File 'lib/commands/plugin.rb', line 146 def uri @uri end |
Class Method Details
.find(name) ⇒ Object
153 154 155 |
# File 'lib/commands/plugin.rb', line 153 def self.find(name) name =~ /\// ? new(name) : Repositories.instance.find_plugin(name) end |
Instance Method Details
#git_url? ⇒ Boolean
165 166 167 |
# File 'lib/commands/plugin.rb', line 165 def git_url? @uri =~ /^git:\/\// || @uri =~ /\.git$/ end |
#info ⇒ Object
206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/commands/plugin.rb', line 206 def info tmp = "#{rails_env.root}/_tmp_about.yml" if svn_url? cmd = "svn export #{@uri} \"#{rails_env.root}/#{tmp}\"" puts cmd if $verbose system(cmd) end open(svn_url? ? tmp : File.join(@uri, 'about.yml')) do |stream| stream.read end rescue "No about.yml found in #{uri}" ensure FileUtils.rm_rf tmp if svn_url? end |
#install(method = nil, options = {}) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/commands/plugin.rb', line 174 def install(method=nil, = {}) method ||= rails_env.best_install_method? if :http == method method = :export if svn_url? method = :clone if git_url? end uninstall if installed? and [:force] unless installed? send("install_using_#{method}", ) run_install_hook else puts "already installed: #{name} (#{uri}). pass --force to reinstall" end end |
#installed? ⇒ Boolean
169 170 171 172 |
# File 'lib/commands/plugin.rb', line 169 def installed? File.directory?("#{rails_env.root}/vendor/plugins/#{name}") \ or rails_env.externals.detect{ |name, repo| self.uri == repo } end |
#svn_url? ⇒ Boolean
161 162 163 |
# File 'lib/commands/plugin.rb', line 161 def svn_url? @uri =~ /svn(?:\+ssh)?:\/\/*/ end |
#to_s ⇒ Object
157 158 159 |
# File 'lib/commands/plugin.rb', line 157 def to_s "#{@name.ljust(30)}#{@uri}" end |
#uninstall ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/commands/plugin.rb', line 191 def uninstall path = "#{rails_env.root}/vendor/plugins/#{name}" if File.directory?(path) puts "Removing 'vendor/plugins/#{name}'" if $verbose run_uninstall_hook rm_r path else puts "Plugin doesn't exist: #{path}" end # clean up svn:externals externals = rails_env.externals externals.reject!{|n,u| name == n or name == u} rails_env.externals = externals end |