gem-new 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -219,19 +219,25 @@ private
|
|
219
219
|
old_content = File.read(path)
|
220
220
|
return false if old_content == new_content
|
221
221
|
|
222
|
-
|
222
|
+
puts diff(configuration, path, new_content) if configuration.auto_diff
|
223
|
+
|
224
|
+
loop do
|
223
225
|
print("File already exists, replace? ([N]o, [y]es, [d]iff) ")
|
224
226
|
$stdout.flush
|
225
227
|
case $stdin.gets
|
226
228
|
when nil then abort("Terminated")
|
227
229
|
when /^y(?:es)?$/i then return true
|
228
|
-
when /^n(?:o)?$/i then return false
|
229
|
-
when /^d(?:iff)?$/i then puts
|
230
|
+
when /^n(?:o)?$/i, /^$/ then return false
|
231
|
+
when /^d(?:iff)?$/i then puts diff(configuration, path, new_content)
|
230
232
|
else puts "Invalid reply"
|
231
233
|
end
|
232
234
|
end
|
233
235
|
end
|
234
236
|
|
237
|
+
def diff(configuration, path, new_content)
|
238
|
+
Open3.popen3(configuration.diff_tool % path) { |i,o,e| i.puts new_content; i.close; o.read }
|
239
|
+
end
|
240
|
+
|
235
241
|
def prompt(question, default=:yes)
|
236
242
|
print "#{question} #{default == :yes ? '([Y]es, [n]o)' : '([N]o, [y]es)'} "
|
237
243
|
$stdout.flush
|
@@ -250,7 +256,7 @@ private
|
|
250
256
|
# the template used without -t option
|
251
257
|
default_template: default
|
252
258
|
# the diff command used to show diffs on update, %s is the path to the old file
|
253
|
-
diff_tool: diff -
|
259
|
+
diff_tool: diff -u --label old --label new %s -
|
254
260
|
# whether a diff should be shown right away in updates, without asking first
|
255
261
|
auto_diff: true
|
256
262
|
# content variables are used for subsitution in template files, also see path_variables
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem-new
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,7 +43,7 @@ files:
|
|
43
43
|
- lib/gem/commands/new_command/version.rb
|
44
44
|
- lib/gem/commands/new_command.rb
|
45
45
|
- lib/rubygems_plugin.rb
|
46
|
-
homepage:
|
46
|
+
homepage: https://github.com/apeiros/gem-new
|
47
47
|
licenses: []
|
48
48
|
post_install_message:
|
49
49
|
rdoc_options: []
|