brewdler 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.mdown CHANGED
@@ -12,6 +12,8 @@ Bundler for non-ruby dependencies from homebrew
12
12
 
13
13
  [Homebrew](http://github.com/mxcl/homebrew) is used for installing the dependencies, it only works on a mac and so does this gem.
14
14
 
15
+ [Homebrew brew-tap](https://github.com/mxcl/homebrew/wiki/brew-tap) is new feature in Homebrew-0.9, add more Github repos to the list of formulae.
16
+
15
17
  [Homebrew-cask](http://github.com/phinze/homebrew-cask) is optional and used for installing Mac applications.
16
18
 
17
19
  ## Usage
@@ -26,6 +28,7 @@ then create a `Brewfile` in the root of your project:
26
28
 
27
29
  Then list your homebrew based dependencies in your `Brewfile`:
28
30
 
31
+ tap 'phinze/cask'
29
32
  brew 'redis'
30
33
  brew 'mongodb'
31
34
  brew 'sphinx'
data/bin/brewdle CHANGED
@@ -11,17 +11,6 @@ default_command :install
11
11
  command :install do |c|
12
12
  c.description = 'Install all homebrew based dependecies'
13
13
  c.action do |args, options|
14
- begin
15
- file = File.read(File.join(Dir.pwd, "Brewfile"))
16
- Brewdler::Dsl.new(file).process
17
- rescue Errno::ENOENT => e
18
- raise "No Brewfile found\n#{e.message}"
19
- rescue NameError
20
- file = File.open(File.join(Dir.pwd, "Brewfile"))
21
- file.find_all do |name|
22
- name.chomp!
23
- Brewdler::BrewInstaller.install(name) if name.length > 0 && name !~ /^ *#/
24
- end
25
- end
14
+ Brewdler::Commands::Install.run
26
15
  end
27
16
  end
data/brewdler.gemspec CHANGED
@@ -5,6 +5,7 @@ Gem::Specification.new do |gem|
5
5
  gem.authors = ["Andrew Nesbitt", "James A. Anderson", "Amos King"]
6
6
  gem.email = ["andrewnez@gmail.com", "me@jamesaanderson.com", "amos.l.king@gmail.com"]
7
7
  gem.summary = %q{Bundler for non-ruby dependencies from homebrew}
8
+ gem.licenses = ['MIT']
8
9
 
9
10
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
10
11
  gem.files = `git ls-files`.split("\n")
data/lib/brewdler.rb CHANGED
@@ -2,3 +2,5 @@ require "brewdler/version"
2
2
  require "brewdler/dsl"
3
3
  require "brewdler/brew_installer"
4
4
  require "brewdler/cask_installer"
5
+ require "brewdler/repo_installer"
6
+ require "brewdler/commands/install"
@@ -1,7 +1,11 @@
1
1
  module Brewdler
2
2
  class BrewInstaller
3
3
  def self.install(name)
4
- `brew install #{name}`
4
+ if system 'brew info'
5
+ `brew install #{name}`
6
+ else
7
+ raise "Unable to install #{name}. Homebrew is not currently installed on your system"
8
+ end
5
9
  end
6
10
  end
7
11
  end
@@ -1,7 +1,11 @@
1
1
  module Brewdler
2
2
  class CaskInstaller
3
3
  def self.install(name)
4
- `brew cask install #{name}`
4
+ if system 'brew cask info'
5
+ `brew cask install #{name}`
6
+ else
7
+ raise "Unable to install #{name}. Homebrew-cask is not currently installed on your system"
8
+ end
5
9
  end
6
10
  end
7
11
  end
@@ -0,0 +1,18 @@
1
+ module Brewdler::Commands
2
+ class Install
3
+ def self.run
4
+ begin
5
+ file = File.read(File.join(Dir.pwd, "Brewfile"))
6
+ Brewdler::Dsl.new(file).process
7
+ rescue Errno::ENOENT => e
8
+ raise "No Brewfile found"
9
+ rescue NameError
10
+ file = File.open(File.join(Dir.pwd, "Brewfile"))
11
+ file.find_all do |name|
12
+ name.chomp!
13
+ Brewdler::BrewInstaller.install(name) if name.length > 0 && name !~ /^ *#/
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
data/lib/brewdler/dsl.rb CHANGED
@@ -15,5 +15,9 @@ module Brewdler
15
15
  def cask(name)
16
16
  Brewdler::CaskInstaller.install(name)
17
17
  end
18
+
19
+ def tap(name)
20
+ Brewdler::RepoInstaller.install(name)
21
+ end
18
22
  end
19
23
  end
@@ -0,0 +1,11 @@
1
+ module Brewdler
2
+ class RepoInstaller
3
+ def self.install(name)
4
+ if system 'brew tap'
5
+ `brew tap #{name}`
6
+ else
7
+ raise "Unable to tap #{name}. Homebrew is not currently installed on your system"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Brewdler
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
data/spec/dsl_spec.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Brewdler::Dsl do
4
- let(:dsl) { Brewdler::Dsl.new("brew 'git'\ncask 'google-chrome'") }
4
+ let(:dsl) { Brewdler::Dsl.new("tap 'phinze/cask'\nbrew 'git'\ncask 'google-chrome'") }
5
5
 
6
6
  it "processes input" do
7
+ dsl.should_receive(:tap).with('phinze/cask')
7
8
  dsl.should_receive(:brew).with('git')
8
9
  dsl.should_receive(:cask).with('google-chrome')
9
10
  dsl.process
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe Brewdler::Commands::Install do
4
+ context "when a Brewfile is not found" do
5
+ it "raises an error" do
6
+ expect { Brewdler::Commands::Install.run }.to raise_error
7
+ end
8
+ end
9
+
10
+ context "when a Brewfile is found" do
11
+ it "does not raise an error" do
12
+ File.stub(:read).and_return("tap 'phinze/cask'\nbrew 'git'\ncask 'google-chrome'")
13
+ expect { Brewdler::Commands::Install.run }.to_not raise_error('No Brewfile found')
14
+
15
+ File.stub(:read => 'git', :open => ['git'])
16
+ expect { Brewdler::Commands::Install.run }.to_not raise_error('No Brewfile found')
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brewdler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-07-08 00:00:00.000000000 Z
14
+ date: 2013-08-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: commander
@@ -116,12 +116,16 @@ files:
116
116
  - lib/brewdler.rb
117
117
  - lib/brewdler/brew_installer.rb
118
118
  - lib/brewdler/cask_installer.rb
119
+ - lib/brewdler/commands/install.rb
119
120
  - lib/brewdler/dsl.rb
121
+ - lib/brewdler/repo_installer.rb
120
122
  - lib/brewdler/version.rb
121
123
  - spec/dsl_spec.rb
124
+ - spec/install_command_spec.rb
122
125
  - spec/spec_helper.rb
123
126
  homepage:
124
- licenses: []
127
+ licenses:
128
+ - MIT
125
129
  post_install_message:
126
130
  rdoc_options: []
127
131
  require_paths:
@@ -146,5 +150,6 @@ specification_version: 3
146
150
  summary: Bundler for non-ruby dependencies from homebrew
147
151
  test_files:
148
152
  - spec/dsl_spec.rb
153
+ - spec/install_command_spec.rb
149
154
  - spec/spec_helper.rb
150
155
  has_rdoc: