executable-hooks 1.2.6 → 1.3.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/executable-hooks/regenerate_binstubs_command.rb +59 -11
- data/lib/executable-hooks/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA512:
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
data.tar.gz: ac97ad868f8c6e566b51f669c92151457a0740981119cdb204fd0ffba79b84f16f730d182c7e174a2b471b024bdebc9449f24f431585226113d74adffde6c1ae
|
|
4
|
+
metadata.gz: 49f4041aed512b6fcf2ec997c079909a3faa8b6362960cfcce3a37bf83b5da551c05139087257965128cdca3288e2f7fcef2a19c5811e98a981252561d820283
|
|
5
5
|
SHA1:
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
data.tar.gz: d6bff930419c641ed06b5a0d4ab9ed4a27af4b7b
|
|
7
|
+
metadata.gz: cc7ab71d2dd5ffc2a18454a044378bf8654bfe77
|
data/CHANGELOG.md
CHANGED
|
@@ -43,22 +43,70 @@ class RegenerateBinstubsCommand < Gem::Command
|
|
|
43
43
|
specs = installed_gems.select{|spec| spec.name =~ /^#{name}/i }
|
|
44
44
|
specs.each do |spec|
|
|
45
45
|
unless spec.executables.empty?
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
cache_gem = File.join(org_gem_path, 'cache', spec.file_name)
|
|
50
|
-
if File.exist? cache_gem
|
|
51
|
-
puts "#{spec.name} #{spec.version}"
|
|
52
|
-
inst = Gem::Installer.new Dir[cache_gem].first, :wrappers => true, :force => true, :install_dir => org_gem_path
|
|
53
|
-
ExecutableHooksInstaller.bundler_generate_bin(inst)
|
|
54
|
-
else
|
|
55
|
-
$stderr.puts "##{spec.name} #{spec.version} not found in GEM_PATH"
|
|
56
|
-
end
|
|
46
|
+
try_to_fix_binstubs(spec) or
|
|
47
|
+
try_to_install_binstubs(spec) or
|
|
48
|
+
$stderr.puts "##{spec.name} #{spec.version} not found in GEM_PATH"
|
|
57
49
|
end
|
|
58
50
|
end
|
|
59
51
|
end
|
|
60
52
|
|
|
61
53
|
private
|
|
54
|
+
|
|
55
|
+
def try_to_fix_binstubs(spec)
|
|
56
|
+
executable_paths =
|
|
57
|
+
spec.executables.map do |executable|
|
|
58
|
+
path = expanded_bin_paths.detect{|path| File.exist?(File.join(path, executable)) }
|
|
59
|
+
File.join(path, executable) if path
|
|
60
|
+
end
|
|
61
|
+
return false if executable_paths.include?(nil) # not found
|
|
62
|
+
executable_shebangs =
|
|
63
|
+
executable_paths.map do |path|
|
|
64
|
+
[path, File.readlines(path).map(&:chomp)]
|
|
65
|
+
end
|
|
66
|
+
return false if executable_shebangs.detect{|path, lines| !lines[0] =~ /^#!\// }
|
|
67
|
+
puts "#{spec.name} #{spec.version}"
|
|
68
|
+
executable_shebangs.map do |path, lines|
|
|
69
|
+
lines[0] = "#!/usr/bin/env ruby_executable_hooks"
|
|
70
|
+
File.open(path, "w") do |file|
|
|
71
|
+
file.puts(lines)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def expanded_bin_paths
|
|
77
|
+
@expanded_bin_paths ||= begin
|
|
78
|
+
paths = expanded_gem_paths.map{|path| File.join(path, "bin") }
|
|
79
|
+
paths << RbConfig::CONFIG["bindir"]
|
|
80
|
+
paths
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def try_to_install_binstubs(spec)
|
|
85
|
+
org_gem_path = expanded_gem_paths.find{|path|
|
|
86
|
+
File.exists? File.join path, 'gems', spec.full_name
|
|
87
|
+
} || Gem.dir
|
|
88
|
+
cache_gem = File.join(org_gem_path, 'cache', spec.file_name)
|
|
89
|
+
if File.exist? cache_gem
|
|
90
|
+
puts "#{spec.name} #{spec.version}"
|
|
91
|
+
inst = Gem::Installer.new Dir[cache_gem].first, :wrappers => true, :force => true, :install_dir => org_gem_path
|
|
92
|
+
ExecutableHooksInstaller.bundler_generate_bin(inst)
|
|
93
|
+
else
|
|
94
|
+
false
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def expanded_gem_paths
|
|
99
|
+
@expanded_gem_paths ||=
|
|
100
|
+
Gem.path.map do |path|
|
|
101
|
+
paths = [path]
|
|
102
|
+
while File.symlink?(path)
|
|
103
|
+
path = File.readlink(path)
|
|
104
|
+
paths << path
|
|
105
|
+
end
|
|
106
|
+
paths
|
|
107
|
+
end.flatten
|
|
108
|
+
end
|
|
109
|
+
|
|
62
110
|
def installed_gems
|
|
63
111
|
if Gem::VERSION > '1.8' then
|
|
64
112
|
Gem::Specification.to_a
|
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.
|
|
4
|
+
version: 1.3.0.rc1
|
|
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:
|
|
12
|
+
date: 2014-01-11 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
|
-
-
|
|
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.
|
|
78
|
+
rubygems_version: 2.0.14
|
|
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.
|