executable-hooks 1.2.6 → 1.3.0.rc1

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
  SHA512:
3
- metadata.gz: e35ba7b65ef4ba5f283e9630c4dd721c4ffa09ecb5e7f7314b293f91ebb14f4afc0cbb01de7029b64e831eca600d0de6227647722c52669c9f387080adf894d5
4
- data.tar.gz: 3d49ba9813fe7a7e555373851b46b0306e561b42dc1dff1958926011b7976447c949ea910ccb578d2e67a401895afc1d1a6dea0d69ece5f1acb824cc73982e8c
3
+ data.tar.gz: ac97ad868f8c6e566b51f669c92151457a0740981119cdb204fd0ffba79b84f16f730d182c7e174a2b471b024bdebc9449f24f431585226113d74adffde6c1ae
4
+ metadata.gz: 49f4041aed512b6fcf2ec997c079909a3faa8b6362960cfcce3a37bf83b5da551c05139087257965128cdca3288e2f7fcef2a19c5811e98a981252561d820283
5
5
  SHA1:
6
- metadata.gz: 8fc3bfae3d897325e4e5c076a32bf557d999038f
7
- data.tar.gz: dffd168e778704f26da8439a34b29dedf1cd9b21
6
+ data.tar.gz: d6bff930419c641ed06b5a0d4ab9ed4a27af4b7b
7
+ metadata.gz: cc7ab71d2dd5ffc2a18454a044378bf8654bfe77
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0
4
+ date: 2014-01-11
5
+
6
+ - First try to fix binstubs before installing them, fix wayneeseguin/rvm#2536
7
+
3
8
  ## 1.2.6
4
9
  date: 2013-10-21
5
10
 
@@ -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
- org_gem_path = Gem.path.find{|path|
47
- File.exists? File.join path, 'gems', spec.full_name
48
- } || Gem.dir
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
@@ -1,3 +1,3 @@
1
1
  module ExecutableHooks
2
- VERSION = "1.2.6"
2
+ VERSION = "1.3.0.rc1"
3
3
  end
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.2.6
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: 2013-10-21 00:00:00 Z
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
- - *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.12
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.