Module: Pez::Command
- Defined in:
- lib/pez/base.rb
Class Method Summary collapse
- .add(url, options = {}, skip_config = false) ⇒ Object
- .remove(name = nil, options = {}) ⇒ Object
- .setup ⇒ Object
- .show(name = nil, options = {}) ⇒ Object
- .symlink ⇒ Object
- .update(name = nil, options = {}) ⇒ Object
Class Method Details
.add(url, options = {}, skip_config = false) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/pez/base.rb', line 94 def self.add(url, ={}, skip_config=false) name = Pez::Base.name(url, ) puts "Retrieving #{name}..." if Pez::Base.git?(url, ) [:type] = "git" system %( mkdir -p #{Pez::Base.destination} cd #{Pez::Base.destination} git clone #{url} #{name} ) if branch = [:branch] system %( cd #{Pez::Base.destination}/#{name} git checkout --track -b #{branch} origin/#{branch} ) end if revision = [:revision] system %( cd #{Pez::Base.destination}/#{name} git branch #{revision} git checkout #{revision} ) end else [:type] = "svn" if revision = [:revision] [:revision] = revision.to_i end system %( mkdir -p #{Pez::Base.destination} cd #{Pez::Base.destination} svn co #{url} #{name} -r #{options[:revision] || 'HEAD'} ) end puts Pez::Base.add_to_config(name, url, ) unless skip_config system %( ln -s #{Pez::Base.destination}/#{name} vendor/plugins/#{name} ) end |
.remove(name = nil, options = {}) ⇒ Object
141 142 143 |
# File 'lib/pez/base.rb', line 141 def self.remove(name=nil, ={}) Pez::Base.plugins(name, ).each {|name| Pez::Base.remove_from_config(name) } end |
.setup ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pez/base.rb', line 76 def self.setup if File.exists?('config/plugins.yml') puts 'Configuration file already generated at config/plugins.yml. Pez will try to install the plugins listed there.' self.update(nil, {:all => 'all'}) else File.open('config/pez.yml', 'w') do |f| base_path = IO.popen('pwd').read.chomp contents = File.read(CONFIG_FILE) contents.gsub!(/%base_path%/, base_path) f << contents end unless File.exists?(File.('~/.pezrc')) File.open('config/plugins.yml', 'w') end end |
.show(name = nil, options = {}) ⇒ Object
198 199 200 201 202 203 204 205 206 |
# File 'lib/pez/base.rb', line 198 def self.show(name=nil, ={}) c = Pez::Base.config Pez::Base.plugins(name, ).each do |name| puts "Plugin: %s" % name puts "Repository: %s" % c[name]['repo'] puts end end |
.symlink ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/pez/base.rb', line 183 def self.symlink c = Pez::Base.config Pez::Base.plugins(nil, {:all => 'all'}).each do |name| dirname = "#{Pez::Base.destination}/#{name}" data = c[name] if File.directory?(dirname) system %( ln -s #{dirname} vendor/plugins/#{name} ) else add(data['repo'], {:type => data['type'], :name => name}, true) end end end |
.update(name = nil, options = {}) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/pez/base.rb', line 145 def self.update(name=nil, ={}) c = Pez::Base.config Pez::Base.plugins(name, ).each do |name| dirname = "#{Pez::Base.destination}/#{name}" data = c[name] puts "Retrieving #{name}..." if File.directory?(dirname) if data['type'] == 'git' if data['revision'] puts "Will not be updated; it's freezed at commit #{data['revision']}" else system %( cd #{dirname} git checkout #{options[:branch] || 'master'} git pull ) end else if data['revision'] puts "Will not be updated; it's freezed at revision #{data['revision']}" else system %( cd #{dirname} svn up ) end end else add(data['repo'], data.merge(:name => name), true) end puts end end |