Sha256: 1297772c0913769711d36db9b70ca280adb6dfbc32aa5b07ce9f05bb5e53e8c0
Contents?: true
Size: 1.61 KB
Versions: 6
Compression:
Stored size: 1.61 KB
Contents
require 'rubygems' require 'bivouac/template' require 'fileutils' require 'open-uri' require File.dirname($0) + '/../config/environment.rb' BASE_URL = "http://bivouac.rubyforge.org/svn/trunk/plugins/" module Bivouac class Plugin @@cmds = [:help, :install, :list] def initialize( argv ) # Command (install, list, ...) @command = argv.shift # Plugin arguments. # Example : # script/plugin install roo_s_tent will_paginate # @script_arguments = ['roo_s_tent', 'will_paginate'] @script_arguments = argv.dup # Application environment @app = Bivouac::Environment.new( ) # ... end def run begin send( @command.to_sym ) rescue send( :help ) end end private def help( desc = false ) return "Display this help" if desc puts "Usage : plugin command" puts "Bivouac plugin manager" puts puts "COMMANDS" @@cmds.each do |m| puts " #{(m.to_s + ' :').ljust(15)} #{send(m, true)}" end end def install(desc = false) return "Install plugin" if desc FileUtils::cd( File.dirname($0) + '/../plugins' ) r = system "svn", "co", "#{BASE_URL}#{@script_arguments}" if r == false raise $? end end def list(desc = false) return "List available plugins" if desc open(BASE_URL).read.each do |l| if m = /<li><a href="([^"]*)">(\1)<\/a><\/li>/.match( l ) puts " - " + m[1].gsub( /\//, '' ) end end end end end Bivouac::Plugin.new( ARGV ).run( )
Version data entries
6 entries across 6 versions & 1 rubygems