current_gem 0.0.6 → 0.1.0

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
- metadata.gz: 692cf381bea3b06102a743e46a69a459f9bf90b1
4
- data.tar.gz: f8a832b9f0d2aa934d05770b87ee2f99a10324fb
3
+ metadata.gz: c8971224f3fe87b1cba795193f59550f6dfcb1c6
4
+ data.tar.gz: b5e04718421465e5bc3d4a5a098fc7ad2c4e1724
5
5
  SHA512:
6
- metadata.gz: f17892872129f3c2b3d9854eb5312e74b4b97e261e2327e885b3f2c6118844a0eac269a2d7fbabc5ac937bd8f7680a156c20f9cfbf104b6f0a8c9f3f97f31c68
7
- data.tar.gz: c77d17b68116c49e03dd376191136222ebe1c8ee453bcc8a71b4936c2377dc389c67fb7d0b088b699eb13b7c1da83894f2dc249b0189dbc4aee3f704972cbc51
6
+ metadata.gz: e301a011b8b554410f7089229c5e628aa7759061070f524d1f588e66b40b5f7882a261c5c0bc9ee61c7d7933a236abbd28a947730d8f97b07f1503ad249864ab
7
+ data.tar.gz: ae934417dcf74cbf72cb23df96def57041fac5fb3672306ef82c19decf1fb4d3dbdca55180c72408352adbe500c41ab7743d34c3e13c08da2c9b67c811f1c1ef
data/README CHANGED
@@ -1,14 +1,14 @@
1
- = current_gem - Maintain symlinks to the most recent versions of installed RubyGems.
1
+ = current_gem - Maintain symlinks to the most recent versions of installed Ruby Gems.
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to current_gem version 0.0.6
5
+ This documentation refers to current_gem version 0.1.0
6
6
 
7
7
 
8
8
  == DESCRIPTION
9
9
 
10
10
  CurrentGem maintains symlinks to the most recent versions of your installed
11
- RubyGems by hooking into the install and update process. Thus, you have a
11
+ Ruby Gems by hooking into the install and update process. Thus, you have a
12
12
  stable path at your disposal that always points to the current version of
13
13
  a gem.
14
14
 
@@ -44,57 +44,57 @@ or run
44
44
 
45
45
  > gem spec <gem_name>
46
46
 
47
- in a command shell (this is a built-in command).
47
+ on the command line (this is a built-in command).
48
48
 
49
49
  You can get a gem's current path programmatically with
50
50
 
51
- CurrentGem.path_for(gem_name)
51
+ require 'current_gem'
52
52
 
53
- # or
53
+ CurrentGem.path_for(gem_name)
54
54
  CurrentGem.path_for(spec)
55
55
 
56
- or by executing
56
+ or by running
57
57
 
58
58
  > gem current_path <gem_name>
59
59
 
60
- # resolve link target
61
- > gem current_path <gem_name> -r
62
-
63
- on the command line.
60
+ on the command line (turn on the <tt>--resolve</tt>/<tt>-r</tt> switch to
61
+ resolve the link target).
64
62
 
65
63
  Finally, get the gem's current version with
66
64
 
67
- CurrentGem.version_for(gem_name)
65
+ require 'current_gem'
68
66
 
69
- # or
67
+ CurrentGem.version_for(gem_name)
70
68
  CurrentGem.version_for(spec)
71
69
 
72
70
  or by running
73
71
 
74
72
  > gem current_version <gem_name>
75
73
 
74
+ on the command line.
75
+
76
76
  === Updating
77
77
 
78
78
  In case you want to update all symlinks at once (or you want to get started
79
- after installing CurrentGem for the first time) call
79
+ after installing CurrentGem for the first time), call
80
80
 
81
81
  require 'current_gem'
82
82
  CurrentGem.update_all
83
83
 
84
- or execute
84
+ or run
85
85
 
86
86
  > gem symlink_current
87
87
 
88
- on the command line (turn on the --verbose/-V switch to see the actual links).
88
+ on the command line (turn on the <tt>--verbose</tt>/<tt>-V</tt> switch to see
89
+ the actual links).
89
90
 
90
91
  Whenever you install or update any gems the symlinks will be created/updated
91
- automatically. If you uninstall a gem the symlink will be pointed at the most
92
+ automatically. If you uninstall a gem, the symlink will be pointed at the most
92
93
  recent remaining version or, if none are left, removed as well.
93
94
 
94
95
 
95
96
  == LINKS
96
97
 
97
- <b></b>
98
98
  Documentation:: http://blackwinter.github.com/current_gem
99
99
  Source code:: http://github.com/blackwinter/current_gem
100
100
  RubyGem:: http://rubygems.org/gems/current_gem
@@ -110,7 +110,7 @@ RubyGem:: http://rubygems.org/gems/current_gem
110
110
  Copyright (C) 2009-2012 University of Cologne,
111
111
  Albertus-Magnus-Platz, 50923 Cologne, Germany
112
112
 
113
- Copyright (C) 2013 Jens Wille
113
+ Copyright (C) 2013-2014 Jens Wille
114
114
 
115
115
  current_gem is free software: you can redistribute it and/or modify it under
116
116
  the terms of the GNU Affero General Public License as published by the Free
data/Rakefile CHANGED
@@ -4,16 +4,17 @@ begin
4
4
  require 'hen'
5
5
 
6
6
  Hen.lay! {{
7
- :gem => {
8
- :name => %q{current_gem},
9
- :version => CurrentGem::VERSION,
10
- :summary => %q{Maintain symlinks to the most recent versions of installed RubyGems.},
11
- :author => %q{Jens Wille},
12
- :email => %q{jens.wille@gmail.com},
13
- :license => %q{AGPL-3.0},
14
- :homepage => :blackwinter,
7
+ gem: {
8
+ name: %q{current_gem},
9
+ version: CurrentGem::VERSION,
10
+ summary: %q{Maintain symlinks to the most recent versions of installed Ruby Gems.},
11
+ author: %q{Jens Wille},
12
+ email: %q{jens.wille@gmail.com},
13
+ license: %q{AGPL-3.0},
14
+ homepage: :blackwinter,
15
15
 
16
- :required_rubygems_version => '>= 1.8.0'
16
+ required_ruby_version: '>= 1.9.3',
17
+ required_rubygems_version: '>= 1.8.0'
17
18
  }
18
19
  }}
19
20
  rescue LoadError => err
@@ -3,8 +3,8 @@ module CurrentGem
3
3
  module Version
4
4
 
5
5
  MAJOR = 0
6
- MINOR = 0
7
- TINY = 6
6
+ MINOR = 1
7
+ TINY = 0
8
8
 
9
9
  class << self
10
10
 
data/lib/current_gem.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  #--
2
2
  ###############################################################################
3
3
  # #
4
- # current_gem -- Maintain symlinks to current RubyGems #
4
+ # current_gem -- Maintain symlinks to current Ruby Gems #
5
5
  # #
6
6
  # Copyright (C) 2009-2012 University of Cologne, #
7
7
  # Albertus-Magnus-Platz, #
8
8
  # 50923 Cologne, Germany #
9
9
  # #
10
- # Copyright (C) 2013 Jens Wille #
10
+ # Copyright (C) 2013-2014 Jens Wille #
11
11
  # #
12
12
  # Authors: #
13
13
  # Jens Wille <jens.wille@gmail.com> #
@@ -37,16 +37,16 @@ module CurrentGem
37
37
 
38
38
  extend self
39
39
 
40
- FU = ENV['DRY_RUN'] ? FileUtils::DryRun : FileUtils
40
+ SPEC_DIR = ENV['CURRENT_GEM_SPEC_DIR'] || 'specifications'
41
+ CURR_DIR = ENV['CURRENT_GEM_CURR_DIR'] || 'current'
42
+
43
+ FileUtils = ENV['DRY_RUN'] ? ::FileUtils::DryRun : ::FileUtils
41
44
 
42
45
  def find(arg)
43
46
  case arg
44
- when Gem::Installer, Gem::Uninstaller
45
- find_by_installer(arg)
46
- when Gem::Specification
47
- find_by_spec(arg)
48
- else
49
- find_by_name(arg)
47
+ when Gem::Installer, Gem::Uninstaller then find_by_installer(arg)
48
+ when Gem::Specification then find_by_spec(arg)
49
+ else find_by_name(arg)
50
50
  end
51
51
  end
52
52
 
@@ -62,15 +62,15 @@ module CurrentGem
62
62
  spec.version if spec
63
63
  end
64
64
 
65
- def update(inst_or_uninst)
66
- symlink(find(inst_or_uninst)) if can_symlink?
65
+ def update(installer)
66
+ symlink(find(installer)) if can_symlink?
67
67
  end
68
68
 
69
69
  def update_all(gem_dir = Gem.dir)
70
70
  return unless can_symlink?
71
71
 
72
72
  path = base_path_for(gem_dir)
73
- FU.rm_r(path) if File.directory?(path)
73
+ FileUtils.rm_r(path) if File.directory?(path)
74
74
 
75
75
  Gem::Specification.latest_specs.each { |spec| symlink(spec, path) }
76
76
  end
@@ -84,26 +84,25 @@ module CurrentGem
84
84
  end
85
85
  end
86
86
 
87
- ##############################################################################
88
87
  private
89
- ##############################################################################
90
88
 
91
- def find_by_installer(inst)
92
- spec = inst.spec
93
- ver = "#{inst.is_a?(Gem::Installer) ? '>' : '!='} #{spec.version}"
89
+ def find_by_installer(installer)
90
+ spec, op = installer.spec, installer.is_a?(Gem::Installer) ? '>' : '!='
94
91
 
95
- curr = find_by_spec(spec, ver) || spec
96
- curr.loaded_from ||= File.join(inst.gem_home, 'specifications', curr.spec_name)
92
+ curr = find_by_spec(spec, "#{op} #{spec.version}") || spec
93
+ curr.loaded_from ||= File.join(installer.gem_home, SPEC_DIR, curr.spec_name)
97
94
 
98
95
  curr
99
96
  end
100
97
 
101
- def find_by_spec(spec, ver = Gem::Requirement.default)
102
- find_by_name(spec.name, ver)
98
+ def find_by_spec(spec, req = nil)
99
+ find_by_name(spec.name, req)
103
100
  end
104
101
 
105
- def find_by_name(name, ver = Gem::Requirement.default)
106
- Gem::Specification.find_all_by_name(name.to_s, ver).reject { |spec|
102
+ def find_by_name(name, req = nil)
103
+ req ||= Gem::Requirement.default
104
+
105
+ Gem::Specification.find_all_by_name(name.to_s, req).reject { |spec|
107
106
  spec.version.prerelease?
108
107
  }.last
109
108
  end
@@ -111,19 +110,23 @@ module CurrentGem
111
110
  def symlink(spec, path = base_path_for(spec))
112
111
  return unless can_symlink? && !spec.version.prerelease?
113
112
 
114
- FU.mkdir_p(path) unless File.exists?(path)
115
- raise Gem::FilePermissionError, path unless File.writable?(path) || ENV['DRY_RUN']
113
+ FileUtils.mkdir_p(path) unless File.exist?(path)
114
+
115
+ unless File.writable?(path) || ENV['DRY_RUN']
116
+ raise Gem::FilePermissionError, path
117
+ end
116
118
 
117
- src = spec.full_gem_path
118
- dst = current_path_for(spec, path)
119
+ if File.exist?(dst = current_path_for(spec, path)) || File.symlink?(dst)
120
+ FileUtils.rm(dst)
121
+ end
119
122
 
120
- FU.rm(dst) if File.exists?(dst) || File.symlink?(dst)
121
- FU.symlink(src, dst, :verbose => Gem.configuration.really_verbose) if File.exists?(src)
123
+ if File.exist?(src = spec.full_gem_path)
124
+ FileUtils.symlink(src, dst, verbose: Gem.configuration.really_verbose)
125
+ end
122
126
  end
123
127
 
124
- def base_path_for(gem_dir)
125
- gem_dir = gem_dir.base_dir if gem_dir.is_a?(Gem::Specification)
126
- File.join(gem_dir, 'current')
128
+ def base_path_for(arg)
129
+ File.join(arg.is_a?(Gem::Specification) ? arg.base_dir : arg, CURR_DIR)
127
130
  end
128
131
 
129
132
  def current_path_for(spec, path = base_path_for(spec))
@@ -7,7 +7,7 @@
7
7
  # Albertus-Magnus-Platz, #
8
8
  # 50923 Cologne, Germany #
9
9
  # #
10
- # Copyright (C) 2013 Jens Wille #
10
+ # Copyright (C) 2013-2014 Jens Wille #
11
11
  # #
12
12
  # Authors: #
13
13
  # Jens Wille <jens.wille@gmail.com> #
@@ -32,7 +32,7 @@ class Gem::Commands::CurrentPathCommand < Gem::Command
32
32
 
33
33
  def initialize
34
34
  super 'current_path', "Display the location of a gem's current symlink",
35
- :resolve => false
35
+ resolve: false
36
36
 
37
37
  add_option('-r', '--resolve', 'Display value of symbolic link') { |value, options|
38
38
  options[:resolve] = true
@@ -49,7 +49,7 @@ class Gem::Commands::CurrentPathCommand < Gem::Command
49
49
 
50
50
  def execute
51
51
  path = CurrentGem.path_for(get_one_gem_name)
52
- return unless path && File.exists?(path)
52
+ return unless path && File.exist?(path)
53
53
 
54
54
  path = File.readlink(path) if options[:resolve]
55
55
  say path
@@ -3,13 +3,8 @@ require 'current_gem'
3
3
 
4
4
  if CurrentGem.can_symlink?
5
5
 
6
- Gem.post_install do |inst|
7
- CurrentGem.update(inst)
8
- end
9
-
10
- Gem.post_uninstall do |uninst|
11
- CurrentGem.update(uninst)
12
- end
6
+ Gem.post_install { |installer| CurrentGem.update(installer) }
7
+ Gem.post_uninstall { |uninstaller| CurrentGem.update(uninstaller) }
13
8
 
14
9
  [:symlink_current, :current_path, :current_version].each { |command|
15
10
  Gem::CommandManager.instance.register_command(command)
metadata CHANGED
@@ -1,16 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: current_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-19 00:00:00.000000000 Z
12
- dependencies: []
13
- description: Maintain symlinks to the most recent versions of installed RubyGems.
11
+ date: 2014-09-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hen
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Maintain symlinks to the most recent versions of installed Ruby Gems.
14
42
  email: jens.wille@gmail.com
15
43
  executables: []
16
44
  extensions: []
@@ -19,16 +47,16 @@ extra_rdoc_files:
19
47
  - COPYING
20
48
  - ChangeLog
21
49
  files:
50
+ - COPYING
51
+ - ChangeLog
52
+ - README
53
+ - Rakefile
22
54
  - lib/current_gem.rb
23
55
  - lib/current_gem/version.rb
24
56
  - lib/rubygems/commands/current_path_command.rb
25
57
  - lib/rubygems/commands/current_version_command.rb
26
58
  - lib/rubygems/commands/symlink_current_command.rb
27
59
  - lib/rubygems_plugin.rb
28
- - COPYING
29
- - ChangeLog
30
- - README
31
- - Rakefile
32
60
  homepage: http://github.com/blackwinter/current_gem
33
61
  licenses:
34
62
  - AGPL-3.0
@@ -36,7 +64,7 @@ metadata: {}
36
64
  post_install_message:
37
65
  rdoc_options:
38
66
  - "--title"
39
- - current_gem Application documentation (v0.0.6)
67
+ - current_gem Application documentation (v0.1.0)
40
68
  - "--charset"
41
69
  - UTF-8
42
70
  - "--line-numbers"
@@ -49,7 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
77
  requirements:
50
78
  - - ">="
51
79
  - !ruby/object:Gem::Version
52
- version: '0'
80
+ version: 1.9.3
53
81
  required_rubygems_version: !ruby/object:Gem::Requirement
54
82
  requirements:
55
83
  - - ">="
@@ -57,8 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
85
  version: 1.8.0
58
86
  requirements: []
59
87
  rubyforge_project:
60
- rubygems_version: 2.1.11
88
+ rubygems_version: 2.4.1
61
89
  signing_key:
62
90
  specification_version: 4
63
- summary: Maintain symlinks to the most recent versions of installed RubyGems.
91
+ summary: Maintain symlinks to the most recent versions of installed Ruby Gems.
64
92
  test_files: []