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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de74e23c2529c9b89da46be8a61c359b95084faa
4
- data.tar.gz: 3b4f5f5db5896e391ad7e5a67955f69155e0f60f
3
+ metadata.gz: d6ba857abec83ca711b1adcb6709e0bb14b08d86
4
+ data.tar.gz: 0168eda064815ed9c5ac071f331d56c19223a7e9
5
5
  SHA512:
6
- metadata.gz: 2d1ca48b2b6e13740538aaad8d8d432ddc817c11b8c3e743fa61900869fa196ba6fd52b526666aff6a92f7fc1581dc4dd5e3bfb4d9fc7e8ebab9b2d03f7969fb
7
- data.tar.gz: ffec21a1943b8cde6af60a79b471575eb04a51a018da5953939214bec75eaa6015964fb698b6a884799a60049c56156c69224eec222d35b1e73e4f89960db4eb
6
+ metadata.gz: 89f82b8fe2b0c28454e3e2b1f202d8efe6869421fd6624fd73e8f5d9d428c6480d3b283535ccd7ece12cf1f5c7ef5486e73033567950c74c1e91df0b45d3b49c
7
+ data.tar.gz: 27402b1e5fdcc14a345fb551e698fddd14c47c9d99baf568b6fd0e5615185010474a8ab895ef2414e9bbbbf325a3bfca1248bd06a5576f0841046b32e4da81e6
@@ -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
@@ -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
- abort help_msg unless args[0]
35
- abort "unknown command: #{args[0]}\n#{help_msg}" unless COMMANDS.keys.include?(args[0])
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 args[0] == 'help'
70
+ if command == 'help'
38
71
  STDERR.puts help_msg
39
72
  exit 0
40
73
  end
41
74
 
42
- args[0..3]
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 run(args = ARGV)
67
- command, name, supplied_version, homebrew_ruby = process_args(args)
68
- homebrew_ruby_flag = "--homebrew-ruby"
69
- if supplied_version == homebrew_ruby_flag
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
- with_temp_formula(name, version, use_homebrew_ruby) do |filename|
79
- case command
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 #{command} #{filename}"
116
+ system "brew #{arguments.to_args.shelljoin} #{filename}"
84
117
  exit $?.exitstatus unless $?.success?
85
118
  end
86
119
  end
@@ -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 "gem", "fetch", "<%= name %>", "--version", resource.version
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
- rubybindir = '<%= use_homebrew_ruby ? "#{homebrew_prefix}/bin" : "/usr/bin" %>'
42
- gem_path = "#{rubybindir}/gem"
43
- ruby_path = "#{rubybindir}/ruby"
44
- system gem_path, "install", cached_download,
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
- #!#{ruby_path} --disable-gems
84
+ #!#{BREWGEM_RUBY_PATH} --disable-gems
78
85
  ENV['GEM_HOME']="#{prefix}"
79
86
  ENV['GEM_PATH']="#{prefix}"
80
87
  require 'rubygems'
@@ -1,5 +1,5 @@
1
1
  module Brew
2
2
  module Gem
3
- VERSION = "0.8.3"
3
+ VERSION = "0.8.4"
4
4
  end
5
5
  end
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.3
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: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2018-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler