Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Jun 25, 2011
0 parents commit 8a66ddc
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,17 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'http://rubygems.org'

# Specify your gem's dependencies in brewdler.gemspec
gemspec
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env rake
require 'bundler/gem_tasks'
51 changes: 51 additions & 0 deletions bin/brewdle
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env ruby

require 'brewdler'
require 'commander/import'

program :version, Brewdler::VERSION
program :description, 'CLI helper for brewdler'

default_command :install

command :install do |c|
c.description = 'Install all homebrew based dependecies'
c.action do |args, options|

begin
dependencies = []
File.open(File.join(Dir.pwd, 'Brewfile')).each { |line|
line.chomp!
if line.length > 0
dependencies << line
end
}
rescue
puts 'No Brewfile found'
end

dependencies.each do |dependency|
installed_version = installed?(dependency)
puts "#{installed_version ? 'Using' : 'Installing'}: #{dependency} #{installed_version}"
install(dependency) unless installed_version
end

puts "All dependencies installed"
end
end

def install(name)
brewable = `brew info #{name}`
if brewable[0..4] != 'Error'
system "brew install #{name}"
else
puts "Error: No available formula for #{name}"
end
end

def installed?(name)
installed = `brew list #{name} -v`
if installed.length > 0
return installed.split(' ').last
end
end
17 changes: 17 additions & 0 deletions brewdler.gemspec
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/brewdler/version', __FILE__)

Gem::Specification.new do |gem|
gem.authors = ["Andrew Nesbitt"]
gem.email = ["andrewnez@gmail.com"]
gem.summary = %q{Bundler for non-ruby dependencies from homebrew}

gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.name = "brewdler"
gem.require_paths = ['lib']
gem.version = Brewdler::VERSION

gem.add_dependency 'commander'
end
1 change: 1 addition & 0 deletions lib/brewdler.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
require "brewdler/version"
3 changes: 3 additions & 0 deletions lib/brewdler/version.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,3 @@
module Brewdler
VERSION = "0.0.1"
end

0 comments on commit 8a66ddc

Please sign in to comment.