brew-gem 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +10 -0
- data/lib/brew/gem/cli.rb +52 -19
- data/lib/brew/gem/formula.rb.erb +13 -6
- data/lib/brew/gem/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6ba857abec83ca711b1adcb6709e0bb14b08d86
|
4
|
+
data.tar.gz: 0168eda064815ed9c5ac071f331d56c19223a7e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89f82b8fe2b0c28454e3e2b1f202d8efe6869421fd6624fd73e8f5d9d428c6480d3b283535ccd7ece12cf1f5c7ef5486e73033567950c74c1e91df0b45d3b49c
|
7
|
+
data.tar.gz: 27402b1e5fdcc14a345fb551e698fddd14c47c9d99baf568b6fd0e5615185010474a8ab895ef2414e9bbbbf325a3bfca1248bd06a5576f0841046b32e4da81e6
|
data/CHANGELOG.markdown
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
#### v0.8.4
|
2
|
+
|
3
|
+
* Install with homebrew ruby by default, if present
|
4
|
+
|
5
|
+
> Nick Sieger: Emma Sax, Andy Fleener, Unknown User: https://github.com/sportngin/brew-gem/pull/53
|
6
|
+
|
7
|
+
* Fix gem exe used by RubyGemsDownloadStrategy
|
8
|
+
|
9
|
+
> Nick Sieger: Andy Fleener, Unknown User: https://github.com/sportngin/brew-gem/pull/51
|
10
|
+
|
1
11
|
#### v0.8.3
|
2
12
|
|
3
13
|
* Add --disable-gems to generated binstubs
|
data/lib/brew/gem/cli.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'erb'
|
2
2
|
require 'tempfile'
|
3
|
+
require 'shellwords'
|
3
4
|
|
4
5
|
module Brew::Gem::CLI
|
5
6
|
module_function
|
@@ -14,6 +15,36 @@ module Brew::Gem::CLI
|
|
14
15
|
"help" => "This message"
|
15
16
|
}
|
16
17
|
|
18
|
+
HOMEBREW_RUBY_FLAG = "--homebrew-ruby"
|
19
|
+
SYSTEM_RUBY_FLAG = "--system-ruby"
|
20
|
+
RUBY_FLAGS = [HOMEBREW_RUBY_FLAG, SYSTEM_RUBY_FLAG]
|
21
|
+
|
22
|
+
class Arguments
|
23
|
+
attr_reader :ruby_flag
|
24
|
+
|
25
|
+
def initialize(args)
|
26
|
+
@ruby_flag = args.select {|a| RUBY_FLAGS.include?(a) }.last
|
27
|
+
@args = args.reject {|a| RUBY_FLAGS.include?(a) }
|
28
|
+
@args_without_flags = @args.reject {|a| a.start_with?('-') }
|
29
|
+
end
|
30
|
+
|
31
|
+
def command
|
32
|
+
@args_without_flags[0]
|
33
|
+
end
|
34
|
+
|
35
|
+
def gem
|
36
|
+
@args_without_flags[1]
|
37
|
+
end
|
38
|
+
|
39
|
+
def supplied_version
|
40
|
+
@args_without_flags[2]
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_args
|
44
|
+
@args.reject {|a| a == gem || a == supplied_version }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
17
48
|
def help_msg
|
18
49
|
(["Please specify a gem name (e.g. brew gem command <name>)"] +
|
19
50
|
COMMANDS.map {|name, desc| " #{name} - #{desc}"}).join("\n")
|
@@ -31,21 +62,26 @@ module Brew::Gem::CLI
|
|
31
62
|
end
|
32
63
|
|
33
64
|
def process_args(args)
|
34
|
-
|
35
|
-
|
65
|
+
arguments = Arguments.new(args)
|
66
|
+
command = arguments.command
|
67
|
+
abort help_msg unless command
|
68
|
+
abort "unknown command: #{command}\n#{help_msg}" unless COMMANDS.keys.include?(command)
|
36
69
|
|
37
|
-
if
|
70
|
+
if command == 'help'
|
38
71
|
STDERR.puts help_msg
|
39
72
|
exit 0
|
40
73
|
end
|
41
74
|
|
42
|
-
|
75
|
+
arguments
|
76
|
+
end
|
77
|
+
|
78
|
+
def homebrew_prefix
|
79
|
+
ENV['HOMEBREW_PREFIX'] || `brew --prefix`.chomp
|
43
80
|
end
|
44
81
|
|
45
82
|
def expand_formula(name, version, use_homebrew_ruby=false)
|
46
83
|
klass = 'Gem' + name.capitalize.gsub(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase }.gsub('+', 'x')
|
47
84
|
user_gemrc = "#{ENV['HOME']}/.gemrc"
|
48
|
-
homebrew_prefix = ENV['HOMEBREW_PREFIX'] || `brew --prefix`.chomp
|
49
85
|
template_file = File.expand_path('../formula.rb.erb', __FILE__)
|
50
86
|
template = ERB.new(File.read(template_file))
|
51
87
|
template.result(binding)
|
@@ -63,24 +99,21 @@ module Brew::Gem::CLI
|
|
63
99
|
File.unlink filename
|
64
100
|
end
|
65
101
|
|
66
|
-
def
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
supplied_version = nil
|
71
|
-
homebrew_ruby = homebrew_ruby_flag
|
72
|
-
end
|
73
|
-
|
74
|
-
use_homebrew_ruby = homebrew_ruby == homebrew_ruby_flag
|
75
|
-
|
76
|
-
version = fetch_version(name, supplied_version)
|
102
|
+
def homebrew_ruby?(ruby_flag)
|
103
|
+
File.exist?("#{homebrew_prefix}/opt/ruby") &&
|
104
|
+
ruby_flag.nil? || ruby_flag == HOMEBREW_RUBY_FLAG
|
105
|
+
end
|
77
106
|
|
78
|
-
|
79
|
-
|
107
|
+
def run(args = ARGV)
|
108
|
+
arguments = process_args(args)
|
109
|
+
name = arguments.gem
|
110
|
+
version = fetch_version(name, arguments.supplied_version)
|
111
|
+
with_temp_formula(name, version, homebrew_ruby?(arguments.ruby_flag)) do |filename|
|
112
|
+
case arguments.command
|
80
113
|
when "formula"
|
81
114
|
$stdout.puts File.read(filename)
|
82
115
|
else
|
83
|
-
system "brew #{
|
116
|
+
system "brew #{arguments.to_args.shelljoin} #{filename}"
|
84
117
|
exit $?.exitstatus unless $?.success?
|
85
118
|
end
|
86
119
|
end
|
data/lib/brew/gem/formula.rb.erb
CHANGED
@@ -3,12 +3,16 @@
|
|
3
3
|
require 'formula'
|
4
4
|
require 'fileutils'
|
5
5
|
|
6
|
+
BREWGEM_RUBYBINDIR = '<%= use_homebrew_ruby ? "#{homebrew_prefix}/bin" : "/usr/bin" %>'
|
7
|
+
BREWGEM_GEM_PATH = "#{BREWGEM_RUBYBINDIR}/gem"
|
8
|
+
BREWGEM_RUBY_PATH = "#{BREWGEM_RUBYBINDIR}/ruby"
|
9
|
+
|
6
10
|
class RubyGemsDownloadStrategy < AbstractDownloadStrategy
|
7
11
|
def fetch
|
8
12
|
ohai "Fetching <%= name %> from gem source"
|
9
13
|
HOMEBREW_CACHE.cd do
|
10
14
|
ENV['GEM_SPEC_CACHE'] = "#{HOMEBREW_CACHE}/gem_spec_cache"
|
11
|
-
system
|
15
|
+
system BREWGEM_GEM_PATH, "fetch", "<%= name %>", "--version", resource.version
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
@@ -38,10 +42,13 @@ class <%= klass %> < Formula
|
|
38
42
|
ENV['GEM_HOME']="#{prefix}"
|
39
43
|
ENV['GEM_PATH']="#{prefix}"
|
40
44
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
# Use /usr/local/bin at the front of the path instead of Homebrew shims,
|
46
|
+
# which mess with Ruby's own compiler config when building native extensions
|
47
|
+
if defined?(HOMEBREW_SHIMS_PATH)
|
48
|
+
ENV['PATH'] = ENV['PATH'].sub(HOMEBREW_SHIMS_PATH.to_s, '/usr/local/bin')
|
49
|
+
end
|
50
|
+
|
51
|
+
system BREWGEM_GEM_PATH, "install", cached_download,
|
45
52
|
"--no-ri",
|
46
53
|
"--no-rdoc",
|
47
54
|
"--no-wrapper",
|
@@ -74,7 +81,7 @@ class <%= klass %> < Formula
|
|
74
81
|
file = Pathname.new("#{brew_gem_prefix}/#{gemspec.bindir}/#{exe}")
|
75
82
|
(bin+file.basename).open('w') do |f|
|
76
83
|
f << <<-RUBY
|
77
|
-
#!#{
|
84
|
+
#!#{BREWGEM_RUBY_PATH} --disable-gems
|
78
85
|
ENV['GEM_HOME']="#{prefix}"
|
79
86
|
ENV['GEM_PATH']="#{prefix}"
|
80
87
|
require 'rubygems'
|
data/lib/brew/gem/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brew-gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sieger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|