Class: Extension
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #git_url? ⇒ Boolean
-
#initialize(uri, name = nil) ⇒ Extension
constructor
A new instance of Extension.
- #install(options = {}) ⇒ Object
- #installed? ⇒ Boolean
- #svn_url? ⇒ Boolean
- #to_s ⇒ Object
- #uninstall ⇒ Object
Constructor Details
#initialize(uri, name = nil) ⇒ Extension
Returns a new instance of Extension.
42 43 44 45 |
# File 'lib/commands/extension.rb', line 42 def initialize(uri, name=nil) @uri = uri guess_name(uri) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
40 41 42 |
# File 'lib/commands/extension.rb', line 40 def name @name end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
40 41 42 |
# File 'lib/commands/extension.rb', line 40 def uri @uri end |
Instance Method Details
#git_url? ⇒ Boolean
55 56 57 |
# File 'lib/commands/extension.rb', line 55 def git_url? @uri =~ /^git:\/\// || @uri =~ /\.git$/ end |
#install(options = {}) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/commands/extension.rb', line 63 def install( = {}) method = :clone uninstall if installed? and [:force] unless installed? send("install_using_#{method}", ) else puts "already installed: #{name} (#{uri}). pass --force to reinstall" end end |
#installed? ⇒ Boolean
59 60 61 |
# File 'lib/commands/extension.rb', line 59 def installed? File.directory?("#{spree_env.root}/vendor/extensions/#{name}") end |
#svn_url? ⇒ Boolean
51 52 53 |
# File 'lib/commands/extension.rb', line 51 def svn_url? @uri =~ /svn(?:\+ssh)?:\/\/*/ end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/commands/extension.rb', line 47 def to_s "#{@name.ljust(30)}#{@uri}" end |
#uninstall ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/commands/extension.rb', line 74 def uninstall path = "#{spree_env.root}/vendor/extensions/#{name}" if File.directory?(path) puts "Removing 'vendor/extensions/#{name}'" if $verbose rm_r path else puts "Extension doesn't exist: #{path}" end end |