brew 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +3 -4
- data/Gemfile.lock +24 -1
- data/README.md +22 -14
- data/Rakefile +8 -6
- data/bin/console +4 -3
- data/brew.gemspec +17 -10
- data/lib/brew.rb +2 -0
- data/lib/brew/home_brew.rb +18 -14
- data/lib/brew/version.rb +3 -1
- metadata +58 -3
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea0675ee7f67150e02b5530b472c4f1cf3733e9771ad3f1847a8fe2fe7a76f42
|
4
|
+
data.tar.gz: 01445f5c0eff4a7041592634ef545106cb4bbefbccbe90ec7cb345c3d92e82a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 196d9b4c00805d8a9f576e4ff27113e053b270d27038f94994d8a103e40d272b971588aaad0a93463a5ec87ad7569dc9845abbc3df83d8800e3dcc0e3e380fe8
|
7
|
+
data.tar.gz: e3c4cc946368f2771e54634186d7d239b4435b34a286aa1526dc3c5ef55a2203ead751558a31b428961baf558d34e8acad581b4d06b899d17a918c190063f3c6
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,21 +1,44 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
brew (0.1.
|
4
|
+
brew (0.1.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
ast (2.4.1)
|
10
|
+
bump (0.9.0)
|
9
11
|
minitest (5.14.1)
|
12
|
+
parallel (1.19.2)
|
13
|
+
parser (2.7.1.4)
|
14
|
+
ast (~> 2.4.1)
|
15
|
+
rainbow (3.0.0)
|
10
16
|
rake (12.3.3)
|
17
|
+
regexp_parser (1.7.1)
|
18
|
+
rexml (3.2.4)
|
19
|
+
rubocop (0.89.0)
|
20
|
+
parallel (~> 1.10)
|
21
|
+
parser (>= 2.7.1.1)
|
22
|
+
rainbow (>= 2.2.2, < 4.0)
|
23
|
+
regexp_parser (>= 1.7)
|
24
|
+
rexml
|
25
|
+
rubocop-ast (>= 0.1.0, < 1.0)
|
26
|
+
ruby-progressbar (~> 1.7)
|
27
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
28
|
+
rubocop-ast (0.3.0)
|
29
|
+
parser (>= 2.7.1.4)
|
30
|
+
ruby-progressbar (1.10.1)
|
31
|
+
unicode-display_width (1.7.0)
|
11
32
|
|
12
33
|
PLATFORMS
|
13
34
|
ruby
|
14
35
|
|
15
36
|
DEPENDENCIES
|
16
37
|
brew!
|
38
|
+
bump
|
17
39
|
minitest (~> 5.0)
|
18
40
|
rake (~> 12.0)
|
41
|
+
rubocop
|
19
42
|
|
20
43
|
BUNDLED WITH
|
21
44
|
2.1.4
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# brew
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
A _very_ simple gem to run some [homebrew](https://brew.sh/) commands from your ruby code. If the `brew` executable is not installed, the constructor will throw an exception immediately.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -13,28 +11,38 @@ gem 'brew'
|
|
13
11
|
```
|
14
12
|
|
15
13
|
And then execute:
|
14
|
+
```shell
|
15
|
+
$ bundle install
|
16
|
+
```
|
16
17
|
|
17
|
-
|
18
|
+
## Usage
|
18
19
|
|
19
|
-
|
20
|
+
Two steps!
|
20
21
|
|
21
|
-
|
22
|
+
1) Create a client:
|
23
|
+
```ruby
|
24
|
+
homebrew = Brew::HomeBrew.new
|
25
|
+
```
|
26
|
+
(will raise an exception if `brew` is not installed)
|
22
27
|
|
23
|
-
|
28
|
+
2) Install / Upgrade / Uninstall / Update to your heart's content!
|
29
|
+
```ruby
|
30
|
+
homebrew.update
|
24
31
|
|
25
|
-
|
32
|
+
homebrew.install('rbenv')
|
26
33
|
|
27
|
-
|
34
|
+
homebrew.upgrade('redis')
|
28
35
|
|
29
|
-
|
36
|
+
homebrew.uninstall('rbenv')
|
37
|
+
```
|
38
|
+
(will raise an exception if any of the commands fail)
|
30
39
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
40
|
|
33
41
|
## Contributing
|
34
42
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/acroos/brew-rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct (mentioned below).
|
36
44
|
|
37
45
|
|
38
46
|
## Code of Conduct
|
39
47
|
|
40
|
-
Everyone interacting in the
|
48
|
+
Everyone interacting in the brew-rb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/acroos/brew-rb/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
3
5
|
|
4
6
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
7
|
-
t.test_files = FileList[
|
7
|
+
t.libs << 'test'
|
8
|
+
t.libs << 'lib'
|
9
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
10
|
end
|
9
11
|
|
10
|
-
task :
|
12
|
+
task default: :test
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'brew'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "brew"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/brew.gemspec
CHANGED
@@ -1,27 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'lib/brew/version'
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
4
|
-
spec.name =
|
6
|
+
spec.name = 'brew'
|
5
7
|
spec.version = Brew::VERSION
|
6
|
-
spec.authors = [
|
7
|
-
spec.email = [
|
8
|
+
spec.authors = ['Austin C Roos']
|
9
|
+
spec.email = ['acroos@hey.com']
|
8
10
|
|
9
|
-
spec.summary =
|
10
|
-
spec.description =
|
11
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
11
|
+
spec.summary = 'Run some basic brew commands from ruby'
|
12
|
+
spec.description = 'Run some basic brew commands from ruby'
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
12
14
|
|
13
15
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
14
16
|
|
15
17
|
# spec.metadata["homepage_uri"] = spec.homepage
|
16
|
-
spec.metadata[
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/acroos/brew-rb'
|
17
19
|
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
18
20
|
|
19
21
|
# Specify which files should be added to the gem when it is released.
|
20
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
-
spec.files
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
24
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
25
|
end
|
24
|
-
spec.bindir =
|
26
|
+
spec.bindir = 'exe'
|
25
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
-
spec.require_paths = [
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_development_dependency 'bump'
|
31
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
32
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
33
|
+
spec.add_development_dependency 'rubocop'
|
27
34
|
end
|
data/lib/brew.rb
CHANGED
data/lib/brew/home_brew.rb
CHANGED
@@ -1,58 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'English'
|
4
|
+
|
1
5
|
module Brew
|
2
6
|
class HomeBrewError < StandardError; end
|
3
7
|
class HomeBrewNotInstalled < HomeBrewError; end
|
4
8
|
|
9
|
+
# Main class to call 'brew' functions
|
5
10
|
class HomeBrew
|
6
|
-
|
7
|
-
DEFAULT_BREW_PATH = '/usr/local/bin/brew'.freeze
|
11
|
+
DEFAULT_BREW_PATH = '/usr/local/bin/brew'
|
8
12
|
|
9
13
|
attr_reader :brew_path
|
10
14
|
private :brew_path
|
11
15
|
|
12
|
-
def initialize(brew_path:
|
13
|
-
@brew_path = brew_path
|
14
|
-
raise HomeBrewNotInstalled unless File.executable?(brew_path)
|
16
|
+
def initialize(brew_path: nil)
|
17
|
+
@brew_path = brew_path || DEFAULT_BREW_PATH
|
18
|
+
raise HomeBrewNotInstalled unless File.executable?(@brew_path)
|
15
19
|
end
|
16
20
|
|
17
21
|
def install(formula)
|
18
22
|
install_command = "#{brew_path} install '#{formula}'"
|
19
23
|
run_command(install_command)
|
20
|
-
rescue => e
|
24
|
+
rescue StandardError => e
|
21
25
|
raise HomeBrewError, e
|
22
26
|
end
|
23
27
|
|
24
28
|
def update
|
25
29
|
update_command = "#{brew_path} update"
|
26
30
|
run_command(update_command)
|
27
|
-
rescue => e
|
31
|
+
rescue StandardError => e
|
28
32
|
raise HomeBrewError, e
|
29
33
|
end
|
30
34
|
|
31
35
|
def upgrade(formula)
|
32
36
|
update_command = "#{brew_path} upgrade '#{formula}'"
|
33
37
|
run_command(update_command)
|
34
|
-
rescue => e
|
38
|
+
rescue StandardError => e
|
35
39
|
raise HomeBrewError, e
|
36
40
|
end
|
37
41
|
|
38
42
|
def uninstall(formula)
|
39
43
|
update_command = "#{brew_path} uninstall '#{formula}'"
|
40
44
|
run_command(update_command)
|
41
|
-
rescue => e
|
45
|
+
rescue StandardError => e
|
42
46
|
raise HomeBrewError, e
|
43
47
|
end
|
44
48
|
|
45
49
|
private
|
46
|
-
|
50
|
+
|
47
51
|
def run_command(command)
|
48
52
|
IO.popen(command, 'r+') do |io|
|
49
|
-
while line = io.gets
|
53
|
+
while (line = io.gets)
|
50
54
|
$stdout.puts line
|
51
55
|
end
|
52
56
|
io.close
|
53
57
|
end
|
54
|
-
|
55
|
-
raise HomeBrewError unless
|
58
|
+
|
59
|
+
raise HomeBrewError unless $CHILD_STATUS.success?
|
56
60
|
end
|
57
61
|
end
|
58
|
-
end
|
62
|
+
end
|
data/lib/brew/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brew
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin C Roos
|
@@ -9,7 +9,63 @@ autorequire:
|
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2020-08-07 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bump
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '12.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
13
69
|
description: Run some basic brew commands from ruby
|
14
70
|
email:
|
15
71
|
- acroos@hey.com
|
@@ -18,7 +74,6 @@ extensions: []
|
|
18
74
|
extra_rdoc_files: []
|
19
75
|
files:
|
20
76
|
- ".gitignore"
|
21
|
-
- ".travis.yml"
|
22
77
|
- CODE_OF_CONDUCT.md
|
23
78
|
- Gemfile
|
24
79
|
- Gemfile.lock
|