brew-gem 0.8.3 → 1.1.1

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
- SHA1:
3
- metadata.gz: de74e23c2529c9b89da46be8a61c359b95084faa
4
- data.tar.gz: 3b4f5f5db5896e391ad7e5a67955f69155e0f60f
2
+ SHA256:
3
+ metadata.gz: b03308e1c9977fa2fe4a2ae9fe7f96ad530916371580a0e449c599a5e5cfb679
4
+ data.tar.gz: 30c4329b66cc70c8f09682e5527aad09afc7ac11b4d30aaac728195fb4690e63
5
5
  SHA512:
6
- metadata.gz: 2d1ca48b2b6e13740538aaad8d8d432ddc817c11b8c3e743fa61900869fa196ba6fd52b526666aff6a92f7fc1581dc4dd5e3bfb4d9fc7e8ebab9b2d03f7969fb
7
- data.tar.gz: ffec21a1943b8cde6af60a79b471575eb04a51a018da5953939214bec75eaa6015964fb698b6a884799a60049c56156c69224eec222d35b1e73e4f89960db4eb
6
+ metadata.gz: 91e38d2617924feb0838e4a1ee034216dfe0878157f7563ba90c700e2249a5d47dc36c55a729ef19538648b7009bf4a35883b566fec0870f65e6c53b6c3cfbc2
7
+ data.tar.gz: a43b3610450ae5c3d491cfd44c90ca4a7f3c6202524beb9be18c6fe1baf2cbc6181093cd4726152a21252b8f1f338b112d401bc042cf08707fdfcb4dc56f3651
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.7.2
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,41 @@
1
+ #### v1.1.1
2
+
3
+ * Update fetch signature
4
+
5
+ > https://github.com/sportngin/brew-gem/pull/69
6
+
7
+ #### v1.1.0
8
+
9
+ * Allow arguments after `--` to be passed to `gem install`
10
+
11
+ > https://github.com/sportngin/brew-gem/pull/67
12
+
13
+ #### v1.0.0
14
+
15
+ * Fix homebrew ruby path (thanks Kaleb Lape)
16
+
17
+ > https://github.com/sportngin/brew-gem/pull/59
18
+
19
+ * Fix old ruby gem flags (thanks JuPlutonic)
20
+
21
+ > https://github.com/sportngin/brew-gem/pull/57/
22
+
23
+ #### v0.9.0
24
+
25
+ * Fix compatibility with latest homebrew
26
+
27
+ > Nick Sieger: https://github.com/sportngin/brew-gem/pull/54
28
+
29
+ #### v0.8.4
30
+
31
+ * Install with homebrew ruby by default, if present
32
+
33
+ > Nick Sieger: Emma Sax, Andy Fleener, Unknown User: https://github.com/sportngin/brew-gem/pull/53
34
+
35
+ * Fix gem exe used by RubyGemsDownloadStrategy
36
+
37
+ > Nick Sieger: Andy Fleener, Unknown User: https://github.com/sportngin/brew-gem/pull/51
38
+
1
39
  #### v0.8.3
2
40
 
3
41
  * Add --disable-gems to generated binstubs
data/brew-gem.gemspec CHANGED
@@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ["lib"]
28
28
 
29
- spec.add_development_dependency "bundler", "~> 1.12"
30
29
  spec.add_development_dependency "rake", "~> 10.0"
31
30
  spec.add_development_dependency "rspec", "~> 3.0"
32
31
  spec.add_development_dependency "aruba", "~> 0.14.0"
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,49 @@ 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 flags
44
+ @flags ||= @args.reject {|a| a == gem || a == supplied_version }
45
+ end
46
+
47
+ def to_gem_args
48
+ if start = flags.index('--')
49
+ flags[start..-1]
50
+ else
51
+ []
52
+ end
53
+ end
54
+
55
+ def to_brew_args
56
+ stop_index = (flags.index('--') || 0) - 1
57
+ flags[0..stop_index]
58
+ end
59
+ end
60
+
17
61
  def help_msg
18
62
  (["Please specify a gem name (e.g. brew gem command <name>)"] +
19
63
  COMMANDS.map {|name, desc| " #{name} - #{desc}"}).join("\n")
@@ -31,31 +75,36 @@ module Brew::Gem::CLI
31
75
  end
32
76
 
33
77
  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])
78
+ arguments = Arguments.new(args)
79
+ command = arguments.command
80
+ abort help_msg unless command
81
+ abort "unknown command: #{command}\n#{help_msg}" unless COMMANDS.keys.include?(command)
36
82
 
37
- if args[0] == 'help'
83
+ if command == 'help'
38
84
  STDERR.puts help_msg
39
85
  exit 0
40
86
  end
41
87
 
42
- args[0..3]
88
+ arguments
89
+ end
90
+
91
+ def homebrew_prefix
92
+ ENV['HOMEBREW_PREFIX'] || `brew --prefix`.chomp
43
93
  end
44
94
 
45
- def expand_formula(name, version, use_homebrew_ruby=false)
95
+ def expand_formula(name, version, use_homebrew_ruby = false, gem_arguments = [])
46
96
  klass = 'Gem' + name.capitalize.gsub(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase }.gsub('+', 'x')
47
97
  user_gemrc = "#{ENV['HOME']}/.gemrc"
48
- homebrew_prefix = ENV['HOMEBREW_PREFIX'] || `brew --prefix`.chomp
49
98
  template_file = File.expand_path('../formula.rb.erb', __FILE__)
50
99
  template = ERB.new(File.read(template_file))
51
100
  template.result(binding)
52
101
  end
53
102
 
54
- def with_temp_formula(name, version, use_homebrew_ruby)
103
+ def with_temp_formula(name, version, use_homebrew_ruby, gem_arguments)
55
104
  filename = File.join Dir.tmpdir, "gem-#{name}.rb"
56
105
 
57
106
  open(filename, 'w') do |f|
58
- f.puts expand_formula(name, version, use_homebrew_ruby)
107
+ f.puts expand_formula(name, version, use_homebrew_ruby, gem_arguments)
59
108
  end
60
109
 
61
110
  yield filename
@@ -63,24 +112,21 @@ module Brew::Gem::CLI
63
112
  File.unlink filename
64
113
  end
65
114
 
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)
115
+ def homebrew_ruby?(ruby_flag)
116
+ File.exist?("#{homebrew_prefix}/opt/ruby") &&
117
+ ruby_flag.nil? || ruby_flag == HOMEBREW_RUBY_FLAG
118
+ end
77
119
 
78
- with_temp_formula(name, version, use_homebrew_ruby) do |filename|
79
- case command
120
+ def run(args = ARGV)
121
+ arguments = process_args(args)
122
+ name = arguments.gem
123
+ version = fetch_version(name, arguments.supplied_version)
124
+ with_temp_formula(name, version, homebrew_ruby?(arguments.ruby_flag), arguments.to_gem_args) do |filename|
125
+ case arguments.command
80
126
  when "formula"
81
127
  $stdout.puts File.read(filename)
82
128
  else
83
- system "brew #{command} #{filename}"
129
+ system "brew #{arguments.to_brew_args.shelljoin} --formula #{filename}"
84
130
  exit $?.exitstatus unless $?.success?
85
131
  end
86
132
  end
@@ -3,17 +3,39 @@
3
3
  require 'formula'
4
4
  require 'fileutils'
5
5
 
6
+ USE_HOMEBREW_RUBY = <%= use_homebrew_ruby ? "true" : "false" %>
7
+ GEM_ARGUMENTS = <%= gem_arguments.inspect %>
8
+
9
+ module RubyBin
10
+ def ruby_bin
11
+ USE_HOMEBREW_RUBY ? Formula["ruby"].opt_bin: "/usr/bin"
12
+ end
13
+ end
14
+
6
15
  class RubyGemsDownloadStrategy < AbstractDownloadStrategy
7
- def fetch
16
+ include RubyBin
17
+
18
+ def fetch(timeout: nil, **options)
8
19
  ohai "Fetching <%= name %> from gem source"
9
- HOMEBREW_CACHE.cd do
10
- ENV['GEM_SPEC_CACHE'] = "#{HOMEBREW_CACHE}/gem_spec_cache"
11
- system "gem", "fetch", "<%= name %>", "--version", resource.version
20
+ cache.cd do
21
+ ENV['GEM_SPEC_CACHE'] = "#{cache}/gem_spec_cache"
22
+ system "#{ruby_bin}/gem", "fetch", "<%= name %>", "--version", gem_version
12
23
  end
13
24
  end
14
25
 
15
26
  def cached_location
16
- Pathname.new("#{HOMEBREW_CACHE}/<%= name %>-#{resource.version}.gem")
27
+ Pathname.new("#{cache}/<%= name %>-#{gem_version}.gem")
28
+ end
29
+
30
+ def cache
31
+ @cache ||= HOMEBREW_CACHE
32
+ end
33
+
34
+ def gem_version
35
+ return @version if defined?(@version) && @version
36
+ @version = @resource.version if defined?(@resource)
37
+ raise "Unable to determine version; did Homebrew change?" unless @version
38
+ @version
17
39
  end
18
40
 
19
41
  def clear_cache
@@ -22,8 +44,11 @@ class RubyGemsDownloadStrategy < AbstractDownloadStrategy
22
44
  end
23
45
 
24
46
  class <%= klass %> < Formula
47
+ include RubyBin
48
+
25
49
  url "<%= name %>", :using => RubyGemsDownloadStrategy
26
50
  version "<%= version %>"
51
+ depends_on "ruby"
27
52
 
28
53
  def install
29
54
  # Copy user's RubyGems config to temporary build home.
@@ -38,16 +63,18 @@ class <%= klass %> < Formula
38
63
  ENV['GEM_HOME']="#{prefix}"
39
64
  ENV['GEM_PATH']="#{prefix}"
40
65
 
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
- "--no-ri",
46
- "--no-rdoc",
66
+ # Use /usr/local/bin at the front of the path instead of Homebrew shims,
67
+ # which mess with Ruby's own compiler config when building native extensions
68
+ if defined?(HOMEBREW_SHIMS_PATH)
69
+ ENV['PATH'] = ENV['PATH'].sub(HOMEBREW_SHIMS_PATH.to_s, '/usr/local/bin')
70
+ end
71
+
72
+ system "#{ruby_bin}/gem", "install", cached_download,
73
+ "--no-document",
47
74
  "--no-wrapper",
48
75
  "--no-user-install",
49
76
  "--install-dir", prefix,
50
- "--bindir", bin
77
+ "--bindir", bin, *GEM_ARGUMENTS
51
78
 
52
79
  raise "gem install '<%= name %>' failed with status #{$?.exitstatus}" unless $?.success?
53
80
 
@@ -74,7 +101,7 @@ class <%= klass %> < Formula
74
101
  file = Pathname.new("#{brew_gem_prefix}/#{gemspec.bindir}/#{exe}")
75
102
  (bin+file.basename).open('w') do |f|
76
103
  f << <<-RUBY
77
- #!#{ruby_path} --disable-gems
104
+ #!#{ruby_bin}/ruby --disable-gems
78
105
  ENV['GEM_HOME']="#{prefix}"
79
106
  ENV['GEM_PATH']="#{prefix}"
80
107
  require 'rubygems'
@@ -1,5 +1,5 @@
1
1
  module Brew
2
2
  module Gem
3
- VERSION = "0.8.3"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,29 +1,15 @@
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: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sieger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2021-04-14 00:00:00.000000000 Z
12
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
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -97,7 +83,7 @@ homepage: https://github.com/sportngin/brew-gem
97
83
  licenses: []
98
84
  metadata:
99
85
  allowed_push_host: https://rubygems.org
100
- post_install_message:
86
+ post_install_message:
101
87
  rdoc_options: []
102
88
  require_paths:
103
89
  - lib
@@ -112,9 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
98
  - !ruby/object:Gem::Version
113
99
  version: '0'
114
100
  requirements: []
115
- rubyforge_project:
116
- rubygems_version: 2.6.12
117
- signing_key:
101
+ rubygems_version: 3.1.4
102
+ signing_key:
118
103
  specification_version: 4
119
104
  summary: Generate Homebrew formulas to install standalone ruby gems.
120
105
  test_files: []