patheditor 1.0.1 → 1.0.2

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/Rakefile +1 -1
  2. data/bin/path_editor +17 -9
  3. metadata +2 -2
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
5
5
  spec = Gem::Specification.new do |s|
6
6
  s.name = "patheditor"
7
7
  s.summary = "A simple program to manage the Windows PATH environment variable."
8
- s.version = "1.0.1"
8
+ s.version = "1.0.2"
9
9
  s.author = "Justin Bailey"
10
10
  s.email = "jgbailey@nospam@gmail.com"
11
11
 
data/bin/path_editor CHANGED
@@ -83,8 +83,13 @@ Forces changes to occur with confirmation. True by default unless paths are bein
83
83
  idx += 1
84
84
  end
85
85
 
86
- remove_paths(duplicates) unless duplicates.empty?
87
- remove_paths(nonexistent) unless nonexistent.empty?
86
+ unless duplicates.empty?
87
+ remove_paths(duplicates) { |p| @hl.say "Removing #{p} (duplicate)" }
88
+ end
89
+
90
+ unless nonexistent.empty?
91
+ remove_paths(nonexistent){ |p| @hl.say "Removing #{p} (doesn't exist)" }
92
+ end
88
93
  end
89
94
 
90
95
  if @add
@@ -138,24 +143,27 @@ Forces changes to occur with confirmation. True by default unless paths are bein
138
143
  (@automatic_confirm && ! @confirm_disabled) || false
139
144
  end
140
145
 
141
- # Takes an array of paths or indices and removes them from the current path
146
+ # Takes an array of paths or indices and removes them from the current path. Yields
147
+ # each path before deleting it, if a block was provided
142
148
  def remove_paths(paths_to_remove)
143
- cnt = 0
149
+ @paths_removed ||= 0
150
+ adjust = 0
144
151
  paths_to_remove.each do |p|
145
152
  if p.is_a?(Fixnum)
146
- idx = p - cnt # adjust index based on paths removed so far.
147
- @hl.say "Removing #{@currPath.paths[idx]}"
153
+ idx = p - adjust # adjust index based on paths removed so far.
154
+ yield @currPath.paths[idx] if block_given?
148
155
  @currPath.paths.delete_at(idx)
149
156
  else
150
- @hl.say "Removing #{p}"
157
+ yield p if block_given?
151
158
  @currPath.paths.delete p
152
159
  end
153
160
 
154
161
  # If more than one path matches and the user did not specify "--no-confirmation", make
155
162
  # sure to enable it here.
156
163
  @path_updated = true
157
- @automatic_confirm = true if cnt > 0
158
- cnt += 1
164
+ @automatic_confirm = true if @paths_removed > 0
165
+ @paths_removed += 1
166
+ adjust += 1
159
167
  end
160
168
  end
161
169
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: patheditor
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.1
7
- date: 2007-02-06 00:00:00 -08:00
6
+ version: 1.0.2
7
+ date: 2007-02-07 00:00:00 -08:00
8
8
  summary: A simple program to manage the Windows PATH environment variable.
9
9
  require_paths:
10
10
  - lib