Module: RoastBeef
- Defined in:
- lib/roastbeef.rb,
lib/roastbeef/package.rb,
lib/roastbeef/package_manager.rb,
lib/roastbeef/scms/bzr_package.rb,
lib/roastbeef/scms/cvs_package.rb,
lib/roastbeef/scms/git_package.rb,
lib/roastbeef/scms/svn_package.rb
Defined Under Namespace
Classes: BzrPackage, CvsPackage, GitPackage, Package, PackageManager, SvnPackage
Constant Summary collapse
- VERSION =
'0.0.4'
- USAGE =
"roastbeef #{VERSION} uh ok so roast beef is some kind of package manager that uses upstream repositories instead of maintaining its own. basically it helps you download configure and install the newest version of a program. #{File.read(File.dirname(__FILE__) + '/../README.txt').split(/==.*$/)[2].strip} of course you can find out more things at http://roastbeef.rubyforge.org"
- SRC_DIR =
File.("~/src")
- LISTING_FILENAME =
File.('~/.roastbeef/sources.yml')
- UPDATE_SOURCES =
URLs to check for sources. only one is used TODO: allow users to add their own
['http://github.com/technomancy/roast-beef/tree/master/sources.yml?raw=true', 'http://roastbeef.rubyforge.org/sources.yml']
- PACKAGE_TYPES =
{}
Class Method Summary collapse
- .install(package) ⇒ Object
- .listing ⇒ Object
- .remove(package) ⇒ Object
-
.search(term) ⇒ Object
searches the name and description of all packages.
-
.setup ⇒ Object
when we first run we need to do some setup.
- .show(name) ⇒ Object
-
.update ⇒ Object
find the first usable source listing and cache it.
-
.upgrade ⇒ Object
upgrade all installed packages.
Class Method Details
.install(package) ⇒ Object
30 31 32 |
# File 'lib/roastbeef.rb', line 30 def install(package) Package.find(package).install end |
.listing ⇒ Object
64 65 66 67 68 69 |
# File 'lib/roastbeef.rb', line 64 def listing update if !File.exist?(LISTING_FILENAME) or # source list is older than a week File.mtime(LISTING_FILENAME) < Time.now - 604800 @listing ||= YAML.load(File.read(LISTING_FILENAME)) end |
.remove(package) ⇒ Object
50 51 52 |
# File 'lib/roastbeef.rb', line 50 def remove(package) Package.find(package).remove end |
.search(term) ⇒ Object
searches the name and description of all packages
55 56 57 58 |
# File 'lib/roastbeef.rb', line 55 def search(term) term = Regexp.new(Regexp.escape(term)) if term.is_a? String Package.all.select{ |p| p.inspect =~ term }.map{ |pack| puts pack.to_s } end |
.setup ⇒ Object
when we first run we need to do some setup
72 73 74 75 76 77 |
# File 'lib/roastbeef.rb', line 72 def setup puts "ok we are performing some initial setup here..." system "mkdir -p #{File.dirname(LISTING_FILENAME)} #{SRC_DIR}" PackageManager.setup puts "... and now we are done." end |
.show(name) ⇒ Object
60 61 62 |
# File 'lib/roastbeef.rb', line 60 def show(name) p Package.find(name) end |
.update ⇒ Object
find the first usable source listing and cache it
35 36 37 38 39 40 41 42 43 |
# File 'lib/roastbeef.rb', line 35 def update # TODO: eventually a single YAML file will not scale. # will probably have to marshall. setup if !File.exist?(SRC_DIR) or !File.exist?(LISTING_FILENAME) File.open(LISTING_FILENAME, 'w') do |f| UPDATE_SOURCES.select { |s| !f.puts(open(s).read) rescue nil } end @listing = nil # force the in-memory copy to be reloaded end |
.upgrade ⇒ Object
upgrade all installed packages
46 47 48 |
# File 'lib/roastbeef.rb', line 46 def upgrade listing.map { |name, | find(name).upgrade if find(name).checked_out? } end |