pathfixer 1.0

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.
Files changed (3) hide show
  1. data/README +6 -0
  2. data/lib/rubygems_plugin.rb +45 -0
  3. metadata +56 -0
data/README ADDED
@@ -0,0 +1,6 @@
1
+ = Path fixer: a gem plugin that ensures that all binaries from gems are symlinked to /usr/local/bin
2
+
3
+ SUBJ
4
+
5
+ This fixes known issue with rubygems on Debian & Ubuntu which install gem binaries to /var/lib/gems/1.{8,9}/bin.
6
+ And that directory is not in default PATH.
@@ -0,0 +1,45 @@
1
+ require 'fileutils'
2
+
3
+ module ::PathFixer
4
+ module_function
5
+ def sync_bin_symlinks(*args)
6
+ return if Gem.win_platform?
7
+
8
+ global_bindir = '/usr/local/bin'
9
+ bindir = File.expand_path(Gem.bindir)
10
+
11
+ return if bindir == global_bindir
12
+ return if ENV['PATH'].split(':').include?(bindir)
13
+
14
+ if !File.directory?(global_bindir) || !File.writable?('/usr/local/bin')
15
+ Gem.ui.say "PathFixer: skipping #{global_bindir} synchronization because this directory doesn't exist or is not writable"
16
+ return
17
+ end
18
+
19
+ installed_binaries = Dir.entries(bindir)
20
+ installed_binaries.reject! do |entry|
21
+ !File.file?(File.join(bindir, entry))
22
+ end
23
+
24
+ target_binaries = Dir.entries(global_bindir).select do |entry|
25
+ full_path = File.join(global_bindir, entry)
26
+ File.symlink?(full_path) && begin
27
+ target = File.expand_path(File.readlink(full_path), File.dirname(full_path))
28
+ File.dirname(target) == bindir
29
+ end
30
+ end
31
+
32
+ (installed_binaries - target_binaries).each do |missing|
33
+ Gem.ui.say "PathFixer: installing symlink on new gem binary '#{missing}' into #{global_bindir}"
34
+ FileUtils.ln_s(File.join(bindir, missing), File.join(global_bindir, missing))
35
+ end
36
+
37
+ (target_binaries - installed_binaries).each do |obsolete|
38
+ Gem.ui.say "PathFixer: removing symlink on uninstalled gem binary '#{obsolete}' from #{global_bindir}"
39
+ FileUtils.rm_r(File.join(global_bindir, obsolete))
40
+ end
41
+ end
42
+ end
43
+
44
+ Gem.post_install_hooks << PathFixer.method(:sync_bin_symlinks)
45
+ Gem.post_uninstall_hooks << PathFixer.method(:sync_bin_symlinks)
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pathfixer
3
+ version: !ruby/object:Gem::Version
4
+ version: "1.0"
5
+ platform: ruby
6
+ authors:
7
+ - Aliaksey Kandratsenka
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-10 00:00:00 +03:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: pathfixer is a gem plugin that synchronizes gem bindir with /usr/local/bin
17
+ email: alk@tut.by
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - README
26
+ - lib/rubygems_plugin.rb
27
+ has_rdoc: true
28
+ homepage:
29
+ licenses: []
30
+
31
+ post_install_message:
32
+ rdoc_options: []
33
+
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ version:
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ requirements: []
49
+
50
+ rubyforge_project:
51
+ rubygems_version: 1.3.5
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: gem plugin that synchronizes gem bindir with /usr/local/bin
55
+ test_files: []
56
+