executable-hooks 1.3.2 → 1.4.0.alpha0

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
- data.tar.gz: c6d0e07559a393e32f639010a23c1768c2c17de4
4
- metadata.gz: 7c112f1e4747066cf4a9e229e7d48e9040b47745
3
+ metadata.gz: a3043d0088ce1f3b75f8d6b586c9a63a1bdc9d91
4
+ data.tar.gz: 37aad6f0e9cf450aba70d6ccd31742b11e919365
5
5
  SHA512:
6
- data.tar.gz: bc74ad2e0a9481ee4c386f6b48cb1d71264d967b98d47beef5745187f413cfdcde35cb918acba381810ffcf9c98e1a69ba321221af2f8007fdf002181700e287
7
- metadata.gz: 0780a086ab4873cc086c7e86cf803f3b67f1c06dda798e94e88f022a5dbf9f7cb8eec9a41f416f6afe5b17dd03071e5cf18156361614498ead2b5695aeb2624c
6
+ metadata.gz: b61715a1115ac1499bbf060d026085f87d796472b736c6fb9bfeeea84a7fd32119d653a01ec94aa5b4ce02d876d4dce43e7b4b1084763b570e292e0f8aca433c
7
+ data.tar.gz: 82cd911d40f9b4a6abc76ef6df4740f40b628c2143e2e7e3b39cb1c423d4c87c77b698eafc30fc89d19592c0ce6035e52bccacf33b5c43cfc0f641bb475f8a93
@@ -6,6 +6,18 @@ require 'executable-hooks/wrapper'
6
6
  class RegenerateBinstubsCommand < Gem::Command
7
7
  def initialize
8
8
  super 'regenerate_binstubs', 'Re run generation of executable wrappers for gems.'
9
+
10
+ add_option(:"Install/Update", '-i', '--install-dir DIR',
11
+ 'Gem repository directory to get installed',
12
+ 'gems') do |value, options|
13
+ options[:install_dir] = File.expand_path(value)
14
+ end
15
+
16
+ add_option(:"Install/Update", '-n', '--bindir DIR',
17
+ 'Directory where binary files are',
18
+ 'located') do |value, options|
19
+ options[:bin_dir] = File.expand_path(value)
20
+ end
9
21
  end
10
22
 
11
23
  def arguments # :nodoc:
@@ -33,7 +45,7 @@ class RegenerateBinstubsCommand < Gem::Command
33
45
  # https://github.com/rubygems/rubygems/issues/326
34
46
  puts "try also: gem pristine --binstubs"
35
47
  end
36
- ExecutableHooks::Wrapper.install
48
+ ExecutableHooks::Wrapper.install(options)
37
49
  execute_no_wrapper
38
50
  end
39
51
 
@@ -55,7 +67,7 @@ class RegenerateBinstubsCommand < Gem::Command
55
67
  def try_to_fix_binstubs(spec)
56
68
  executable_paths =
57
69
  spec.executables.map do |executable|
58
- path = expanded_bin_paths.detect{|path| File.exist?(File.join(path, executable)) }
70
+ path = expanded_bin_paths.detect{|bin_path| File.exist?(File.join(bin_path, executable)) }
59
71
  File.join(path, executable) if path
60
72
  end
61
73
  return false if executable_paths.include?(nil) # not found
@@ -63,7 +75,7 @@ class RegenerateBinstubsCommand < Gem::Command
63
75
  executable_paths.map do |path|
64
76
  [path, File.readlines(path).map(&:chomp)]
65
77
  end
66
- return false if executable_shebangs.detect{|path, lines| !lines[0] =~ /^#!\// }
78
+ return false if executable_shebangs.detect{|path, lines| !(lines[0] =~ /^#!\//) }
67
79
  puts "#{spec.name} #{spec.version}"
68
80
  executable_mode = 0111
69
81
  executable_shebangs.map do |path, lines|
@@ -85,19 +97,21 @@ class RegenerateBinstubsCommand < Gem::Command
85
97
  end
86
98
 
87
99
  def try_to_install_binstubs(spec)
88
- org_gem_path = expanded_gem_paths.find{|path|
89
- File.exists? File.join path, 'gems', spec.full_name
90
- } || Gem.dir
100
+ org_gem_path = options[:install_dir] || existing_gem_path(spec.full_name) || Gem.dir
91
101
  cache_gem = File.join(org_gem_path, 'cache', spec.file_name)
92
102
  if File.exist? cache_gem
93
103
  puts "#{spec.name} #{spec.version}"
94
- inst = Gem::Installer.new Dir[cache_gem].first, :wrappers => true, :force => true, :install_dir => org_gem_path
104
+ inst = Gem::Installer.new Dir[cache_gem].first, :wrappers => true, :force => true, :install_dir => org_gem_path, :bin_dir => options[:bin_dir]
95
105
  ExecutableHooksInstaller.bundler_generate_bin(inst)
96
106
  else
97
107
  false
98
108
  end
99
109
  end
100
110
 
111
+ def existing_gem_path(full_name)
112
+ expanded_gem_paths.find{|path| File.exists? File.join path, 'gems', full_name}
113
+ end
114
+
101
115
  def expanded_gem_paths
102
116
  @expanded_gem_paths ||=
103
117
  Gem.path.map do |path|
@@ -1,3 +1,3 @@
1
1
  module ExecutableHooks
2
- VERSION = "1.3.2"
2
+ VERSION = "1.4.0.alpha0"
3
3
  end
@@ -4,35 +4,21 @@ require 'rubygems'
4
4
  require 'executable-hooks/specification'
5
5
 
6
6
  module ExecutableHooks
7
- module Wrapper
7
+ class Wrapper
8
8
  def self.wrapper_name
9
9
  'ruby_executable_hooks'
10
10
  end
11
+
11
12
  def self.expanded_wrapper_name
12
13
  Gem.default_exec_format % self.wrapper_name
13
14
  end
14
- def self.bindir
15
- Gem.respond_to?(:bindir,true) ? Gem.send(:bindir) : File.join(Gem.dir, 'bin')
16
- end
17
- def self.destination
18
- File.expand_path( expanded_wrapper_name, bindir )
19
- end
20
- def self.ensure_custom_shebang
21
- expected_shebang = "$env #{expanded_wrapper_name}"
22
15
 
23
- Gem.configuration[:custom_shebang] ||= expected_shebang
16
+ def initialize(options)
24
17
 
25
- if Gem.configuration[:custom_shebang] != expected_shebang
26
- warn("
27
- Warning:
28
- Found custom_shebang: '#{Gem.configuration[:custom_shebang]}',
29
- Expected custom_shebang: '#{expected_shebang}',
30
- this can potentially break 'executable-hooks' and gem executables overall!
31
- Check your '~/.gemrc' and '/etc/gemrc' for 'custom_shebang' and remove it.
32
- ")
33
- end
34
18
  end
35
- def self.install
19
+
20
+ def install
21
+ @bindir = options[:bin_dir] if options[:bin_dir]
36
22
  ensure_custom_shebang
37
23
 
38
24
  executable_hooks_spec = ExecutableHooks::Specification.find
@@ -42,7 +28,7 @@ Check your '~/.gemrc' and '/etc/gemrc' for 'custom_shebang' and remove it.
42
28
  end
43
29
  end
44
30
 
45
- def self.install_from(full_gem_path)
31
+ def install_from(full_gem_path)
46
32
  wrapper_path = File.expand_path( "bin/#{wrapper_name}", full_gem_path )
47
33
 
48
34
  if File.exist?(wrapper_path) && !File.exist?(destination)
@@ -53,8 +39,36 @@ Check your '~/.gemrc' and '/etc/gemrc' for 'custom_shebang' and remove it.
53
39
  File.chmod(0775, destination)
54
40
  end
55
41
  end
56
- def self.uninstall
42
+
43
+ def uninstall
57
44
  FileUtils.rm_f(destination) if File.exist?(destination)
58
45
  end
46
+
47
+ def calculate_bindir(options)
48
+ return options[:bin_dir] if options[:bin_dir]
49
+ Gem.respond_to?(:bindir,true) ? Gem.send(:bindir) : File.join(Gem.dir, 'bin')
50
+ end
51
+
52
+ def calculate_destination(bindir)
53
+ File.expand_path( expanded_wrapper_name, bindir )
54
+ end
55
+
56
+
57
+ def ensure_custom_shebang
58
+ expected_shebang = "$env #{self.class.expanded_wrapper_name}"
59
+
60
+ Gem.configuration[:custom_shebang] ||= expected_shebang
61
+
62
+ if Gem.configuration[:custom_shebang] != expected_shebang
63
+ warn("
64
+ Warning:
65
+ Found custom_shebang: '#{Gem.configuration[:custom_shebang]}',
66
+ Expected custom_shebang: '#{expected_shebang}',
67
+ this can potentially break 'executable-hooks' and gem executables overall!
68
+ Check your '~/.gemrc' and '/etc/gemrc' for 'custom_shebang' and remove it.
69
+ ")
70
+ end
71
+ end
72
+
59
73
  end
60
74
  end
@@ -12,8 +12,8 @@ if
12
12
  require 'executable-hooks/wrapper'
13
13
 
14
14
  # Set the custom_shebang if user did not set one
15
- Gem.pre_install do |inst|
16
- ExecutableHooks::Wrapper.install
15
+ Gem.pre_install do |gem_installer|
16
+ ExecutableHooks::Wrapper.install(gem_installer.options)
17
17
  end
18
18
 
19
19
  if Gem::Version.new(Gem::VERSION) < Gem::Version.new('2.0') then
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: executable-hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0.alpha0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Papis
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-06-06 00:00:00 Z
12
+ date: 2018-01-26 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tf
@@ -69,11 +69,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
69
  - *id002
70
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - *id002
72
+ - - ">"
73
+ - !ruby/object:Gem::Version
74
+ version: 1.3.1
73
75
  requirements: []
74
76
 
75
77
  rubyforge_project:
76
- rubygems_version: 2.0.14
78
+ rubygems_version: 2.0.17
77
79
  signing_key:
78
80
  specification_version: 4
79
81
  summary: Hook into rubygems executables allowing extra actions to be taken before executable is run.