brew-gem 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.octopolo.yml +4 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +117 -0
- data/Rakefile +9 -0
- data/bin/brew-gem +7 -0
- data/brew-gem.gemspec +33 -0
- data/lib/brew/gem.rb +7 -0
- data/lib/brew/gem/cli.rb +73 -0
- data/lib/brew/gem/formula.rb.erb +77 -0
- data/lib/brew/gem/version.rb +5 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 710d6f487fd462a1478ddada3e77c146b759fc18
|
4
|
+
data.tar.gz: 8b394fa5ad0673baf4e52688228ad807ab8e2f6c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f2f3c3ba3f2f74b6d306af0520dfe70f19309a9dfa38e59e55f63ab7fc3099886b1bfd6f1c811bdaa3442c93f3b8ea56127e8ec33e2670f8a0276d5610a72c24
|
7
|
+
data.tar.gz: d23b7955885e592f99871d4b685a6645bcd9c1eab162c81f3aa66ec8c87f94da784c70d2525d3452c41f37f4ff9370c0ddc8c920f00ad0b1c1ebeaaaeb80246f
|
data/.gitignore
ADDED
data/.octopolo.yml
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Joshua Peek
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
brew-gem -- install gems as homebrew formulas
|
2
|
+
=============================================
|
3
|
+
|
4
|
+
`brew gem` allows you to install any rubygem as a homebrew formula.
|
5
|
+
|
6
|
+
It works by generating a stub formula for homebrew, which looks something like this:
|
7
|
+
|
8
|
+
class Ronn < Formula
|
9
|
+
def initialize(*args)
|
10
|
+
@name = "ronn"
|
11
|
+
@version = "0.7.3"
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def install
|
16
|
+
system "gem", "install", name, "--version", version, "--install-dir", prefix
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
This formula installs and unpacks all the dependencies under the Cellar path. So the package is completely self contained.
|
21
|
+
|
22
|
+
|
23
|
+
Dependencies
|
24
|
+
------------
|
25
|
+
This requires a system rubygems version of 2.3 or greater
|
26
|
+
There is a bug prior to 2.3 that doesn't install the full dependency tree properly when you use the install-dir flag.
|
27
|
+
|
28
|
+
```
|
29
|
+
sudo /usr/bin/gem update --system
|
30
|
+
```
|
31
|
+
|
32
|
+
|
33
|
+
Install
|
34
|
+
-------
|
35
|
+
|
36
|
+
There are two ways to install `brew-gem`, via Homebrew or via Rubygems. Usually
|
37
|
+
the Rubygems release will track ahead of the Homebrew recipe, so to receive the
|
38
|
+
latest features, use the Rubygems install instructions.
|
39
|
+
|
40
|
+
Via Rubygems:
|
41
|
+
|
42
|
+
gem install brew-gem
|
43
|
+
brew-gem install brew-gem
|
44
|
+
|
45
|
+
Via Homebrew:
|
46
|
+
|
47
|
+
brew install brew-gem
|
48
|
+
|
49
|
+
|
50
|
+
Usage
|
51
|
+
-----
|
52
|
+
|
53
|
+
brew gem install heroku
|
54
|
+
|
55
|
+
To install a specific version:
|
56
|
+
|
57
|
+
brew gem install heroku 3.8.3
|
58
|
+
|
59
|
+
To upgrade:
|
60
|
+
|
61
|
+
brew gem upgrade heroku
|
62
|
+
|
63
|
+
To uninstall:
|
64
|
+
|
65
|
+
brew gem uninstall heroku
|
66
|
+
|
67
|
+
To check information:
|
68
|
+
|
69
|
+
brew gem info heroku
|
70
|
+
|
71
|
+
Note:
|
72
|
+
|
73
|
+
Installed gems are listed in `brew list` with prefix of `gem-`,
|
74
|
+
like `gem-heroku`.
|
75
|
+
|
76
|
+
### BASH/ZSH Completions
|
77
|
+
|
78
|
+
To make use of completions for your gem, you need to install the
|
79
|
+
`bash-completion` formula:
|
80
|
+
|
81
|
+
brew install bash-completion
|
82
|
+
|
83
|
+
And then install a gem with the completion files in the following locations:
|
84
|
+
|
85
|
+
* A directory named either `completion` or `completions` with the file being
|
86
|
+
the name of the gem appended with the completion type.
|
87
|
+
|
88
|
+
For example: `completions/tmuxinator.bash`
|
89
|
+
* A file somewhere in your repo named `<your_gem_name>_completion.zsh`.
|
90
|
+
|
91
|
+
Files with `.bash` and `.sh` will be associated with bash and files ending in
|
92
|
+
`.zsh` will be associated with zsh.
|
93
|
+
|
94
|
+
|
95
|
+
Philosophy
|
96
|
+
----------
|
97
|
+
|
98
|
+
This is **not** for installing development libraries, but for standalone binary tools that you want system wide.
|
99
|
+
|
100
|
+
|
101
|
+
Troubleshooting
|
102
|
+
----------
|
103
|
+
|
104
|
+
If your seeing build errors similar to this:
|
105
|
+
```shell
|
106
|
+
==> Fetching opsicle from gem source
|
107
|
+
==> gem install /Library/Caches/Homebrew/opsicle-0.4.2.gem --no-rdoc --no-ri --no-user-install --install-dir /usr/local/Cellar/opsicle/0.4.2 --bindir /usr/local/Cellar/opsicle/0.4.2/bin
|
108
|
+
make: *** [generator.bundle] Error 1
|
109
|
+
Gem files will remain installed in /usr/local/Cellar/opsicle/0.4.2/gems/json-1.8.1 for inspection.
|
110
|
+
Results logged to /usr/local/Cellar/opsicle/0.4.2/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
|
111
|
+
READ THIS: https://github.com/Homebrew/homebrew/wiki/troubleshooting
|
112
|
+
```
|
113
|
+
|
114
|
+
You probably have xcode 5.1 installed which changed the way the compilers handle flags.
|
115
|
+
|
116
|
+
You'll need to set `ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future` before installing.
|
117
|
+
_You may want to add this to your profile so you don't have to set it each time._
|
data/Rakefile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
5
|
+
# Specify RSPECOPTS=... on the rake command line to set extra RSpec flags
|
6
|
+
t.rspec_opts = ENV['RSPECOPTS'] if ENV['RSPECOPTS']
|
7
|
+
end
|
8
|
+
|
9
|
+
task :default => :spec
|
data/bin/brew-gem
ADDED
data/brew-gem.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'brew/gem/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "brew-gem"
|
8
|
+
spec.version = Brew::Gem::VERSION
|
9
|
+
spec.authors = ["Nick Sieger"]
|
10
|
+
spec.email = ["nick@nicksieger.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Generate Homebrew formulas to install standalone ruby gems.}
|
13
|
+
spec.description = %q{This gem can be installed with "brew install brew-gem" and used to install gems with "brew gem install <gem>".}
|
14
|
+
spec.homepage = "https://github.com/sportngin/brew-gem"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org/"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
spec.add_development_dependency "aruba", "~> 0.14.0"
|
33
|
+
end
|
data/lib/brew/gem.rb
ADDED
data/lib/brew/gem/cli.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
module Brew::Gem::CLI
|
5
|
+
module_function
|
6
|
+
|
7
|
+
COMMANDS = {
|
8
|
+
"install" => ("Install a brew gem, accepts an optional version argument\n" +
|
9
|
+
" (e.g. brew gem install <name> [version])"),
|
10
|
+
"upgrade" => "Upgrade to the latest version of a brew gem",
|
11
|
+
"uninstall" => "Uninstall a brew gem",
|
12
|
+
"info" => "Show information for an installed gem",
|
13
|
+
"help" => "This message"
|
14
|
+
}
|
15
|
+
|
16
|
+
def help_msg
|
17
|
+
(["Please specify a gem name (e.g. brew gem command <name>)"] +
|
18
|
+
COMMANDS.map {|name, desc| " #{name} - #{desc}"}).join("\n")
|
19
|
+
end
|
20
|
+
|
21
|
+
def fetch_version(name, version = nil)
|
22
|
+
gems = `gem list --remote "^#{name}$"`.lines
|
23
|
+
|
24
|
+
unless gems.detect { |f| f =~ /^#{name} \(([^\s,]+).*\)/ }
|
25
|
+
abort "Could not find a valid gem '#{name}'"
|
26
|
+
end
|
27
|
+
|
28
|
+
version ||= $1
|
29
|
+
version
|
30
|
+
end
|
31
|
+
|
32
|
+
def process_args(args)
|
33
|
+
abort help_msg unless args[0]
|
34
|
+
abort "unknown command: #{args[0]}\n#{help_msg}" unless COMMANDS.keys.include?(args[0])
|
35
|
+
|
36
|
+
if args[0] == 'help'
|
37
|
+
STDERR.puts help_msg
|
38
|
+
exit 0
|
39
|
+
end
|
40
|
+
|
41
|
+
args[0..2]
|
42
|
+
end
|
43
|
+
|
44
|
+
def expand_formula(name, version)
|
45
|
+
klass = 'Gem' + name.capitalize.gsub(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase }.gsub('+', 'x')
|
46
|
+
user_gemrc = "#{ENV['HOME']}/.gemrc"
|
47
|
+
template_file = File.expand_path('../formula.rb.erb', __FILE__)
|
48
|
+
template = ERB.new(File.read(template_file))
|
49
|
+
template.result(binding)
|
50
|
+
end
|
51
|
+
|
52
|
+
def with_temp_formula(name, version)
|
53
|
+
filename = File.join Dir.tmpdir, "gem-#{name}.rb"
|
54
|
+
|
55
|
+
open(filename, 'w') do |f|
|
56
|
+
f.puts expand_formula(name, version)
|
57
|
+
end
|
58
|
+
|
59
|
+
yield filename
|
60
|
+
ensure
|
61
|
+
File.unlink filename
|
62
|
+
end
|
63
|
+
|
64
|
+
def run(args = ARGV)
|
65
|
+
command, name, supplied_version = process_args(args)
|
66
|
+
|
67
|
+
version = fetch_version(name, supplied_version)
|
68
|
+
|
69
|
+
with_temp_formula(name, version) do |filename|
|
70
|
+
system "brew #{command} #{filename}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'formula'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
class RubyGemsDownloadStrategy < AbstractDownloadStrategy
|
7
|
+
def fetch
|
8
|
+
ohai "Fetching <%= name %> from gem source"
|
9
|
+
HOMEBREW_CACHE.cd do
|
10
|
+
system "gem", "fetch", "<%= name %>", "--version", resource.version
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def cached_location
|
15
|
+
Pathname.new("#{HOMEBREW_CACHE}/<%= name %>-#{resource.version}.gem")
|
16
|
+
end
|
17
|
+
|
18
|
+
def clear_cache
|
19
|
+
cached_location.unlink if cached_location.exist?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class <%= klass %> < Formula
|
24
|
+
url "<%= name %>", :using => RubyGemsDownloadStrategy
|
25
|
+
version "<%= version %>"
|
26
|
+
|
27
|
+
def install
|
28
|
+
# Copy user's RubyGems config to temporary build home.
|
29
|
+
buildpath_gemrc = "#{ENV['HOME']}/.gemrc"
|
30
|
+
if File.exists?('<%= user_gemrc %>') && !File.exists?(buildpath_gemrc)
|
31
|
+
FileUtils.cp('<%= user_gemrc %>', buildpath_gemrc)
|
32
|
+
end
|
33
|
+
|
34
|
+
# set GEM_HOME and GEM_PATH to make sure we package all the dependent gems
|
35
|
+
# together without accidently picking up other gems on the gem path since
|
36
|
+
# they might not be there if, say, we change to a different rvm gemset
|
37
|
+
ENV['GEM_HOME']="#{prefix}"
|
38
|
+
ENV['GEM_PATH']="#{prefix}"
|
39
|
+
system "gem", "install", cached_download,
|
40
|
+
"--no-ri",
|
41
|
+
"--no-rdoc",
|
42
|
+
"--no-wrapper",
|
43
|
+
"--no-user-install",
|
44
|
+
"--install-dir", prefix,
|
45
|
+
"--bindir", bin
|
46
|
+
|
47
|
+
bin.rmtree if bin.exist?
|
48
|
+
bin.mkpath
|
49
|
+
|
50
|
+
brew_gem_prefix = prefix+"gems/<%= name %>-#{version}"
|
51
|
+
|
52
|
+
completion_for_bash = Dir[
|
53
|
+
"#{brew_gem_prefix}/completion{s,}/<%= name %>.{bash,sh}",
|
54
|
+
"#{brew_gem_prefix}/**/<%= name %>_completion{s,}.{bash,sh}"
|
55
|
+
].first
|
56
|
+
bash_completion.install completion_for_bash if completion_for_bash
|
57
|
+
|
58
|
+
completion_for_zsh = Dir[
|
59
|
+
"#{brew_gem_prefix}/completions/<%= name %>.zsh",
|
60
|
+
"#{brew_gem_prefix}/**/<%= name %>_completion{s,}.zsh"
|
61
|
+
].first
|
62
|
+
zsh_completion.install completion_for_zsh if completion_for_zsh
|
63
|
+
|
64
|
+
ruby_libs = Dir.glob("#{prefix}/gems/*/lib")
|
65
|
+
Pathname.glob("#{brew_gem_prefix}/bin/*").each do |file|
|
66
|
+
(bin+file.basename).open('w') do |f|
|
67
|
+
f << <<-RUBY
|
68
|
+
#!/usr/bin/ruby
|
69
|
+
ENV['GEM_HOME']="#{prefix}"
|
70
|
+
ENV['GEM_PATH']="#{prefix}"
|
71
|
+
$:.unshift(#{ruby_libs.map(&:inspect).join(",")})
|
72
|
+
load "#{file}"
|
73
|
+
RUBY
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brew-gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Sieger
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aruba
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.14.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.14.0
|
69
|
+
description: This gem can be installed with "brew install brew-gem" and used to install
|
70
|
+
gems with "brew gem install <gem>".
|
71
|
+
email:
|
72
|
+
- nick@nicksieger.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".octopolo.yml"
|
79
|
+
- ".rspec"
|
80
|
+
- ".ruby-version"
|
81
|
+
- ".travis.yml"
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/brew-gem
|
87
|
+
- brew-gem.gemspec
|
88
|
+
- lib/brew/gem.rb
|
89
|
+
- lib/brew/gem/cli.rb
|
90
|
+
- lib/brew/gem/formula.rb.erb
|
91
|
+
- lib/brew/gem/version.rb
|
92
|
+
homepage: https://github.com/sportngin/brew-gem
|
93
|
+
licenses: []
|
94
|
+
metadata:
|
95
|
+
allowed_push_host: https://rubygems.org/
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.5.1
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Generate Homebrew formulas to install standalone ruby gems.
|
116
|
+
test_files: []
|