Module: Pez::Base
- Defined in:
- lib/pez/base.rb
Class Method Summary collapse
- .add_to_config(name, url, options = {}) ⇒ Object
- .config ⇒ Object
- .destination ⇒ Object
- .git?(url, options = {}) ⇒ Boolean
- .name(url, options = {}) ⇒ Object
- .plugins(name, options = {}) ⇒ Object
- .remove_from_config(name) ⇒ Object
Class Method Details
.add_to_config(name, url, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pez/base.rb', line 27 def self.add_to_config(name, url, ={}) c = config c ||= {} c[name] = { 'repo' => url, 'type' => [:type], 'revision' => [:revision], 'branch' => [:branch] }.reject {|key, value| value.nil? } File.open('config/plugins.yml', 'w+') do |f| f << YAML::dump(c) end end |
.config ⇒ Object
23 24 25 |
# File 'lib/pez/base.rb', line 23 def self.config YAML.load_file('config/plugins.yml') end |
.destination ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/pez/base.rb', line 55 def self.destination if File.exists?(File.('~/.pezrc')) c = YAML.load_file(File.('~/.pezrc')) else c = YAML.load_file('config/pez.yml') end File.(c[Rails.env] || 'tmp/plugins') end |
.git?(url, options = {}) ⇒ Boolean
7 8 9 |
# File 'lib/pez/base.rb', line 7 def self.git?(url, ={}) ["type"] == "git" || url =~ /^git:/ || url =~ /\.git$/ end |
.name(url, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/pez/base.rb', line 11 def self.name(url, ={}) return [:name] if [:name] if git?(url, ) m, name = *url.match(/\/([^\/]+)\.git$/) else m, name = *url.match(/\/([^\/]+)\/?(?:trunk\/?)?$/) end name end |
.plugins(name, options = {}) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/pez/base.rb', line 64 def self.plugins(name, ={}) if name [name] elsif [:all] Pez::Base.config ? (Pez::Base.config).keys : [] else [] end end |
.remove_from_config(name) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pez/base.rb', line 42 def self.remove_from_config(name) c = config c ||= {} c.delete(name) File.open('config/plugins.yml', 'w+') do |f| f << YAML::dump(c) end system %( rm -rf #{destination}/#{name} ) system %( rm vendor/plugins/#{name} ) end |