gem_hadar 2.0.1 → 2.0.3
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/gem_hadar.gemspec +2 -2
- data/lib/gem_hadar/version.rb +1 -1
- data/lib/gem_hadar.rb +32 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca4918a475147350c004d6952b906489dd4f0ecaa9c95695301638e00a2ef68c
|
4
|
+
data.tar.gz: fd7bec7396866c169b09941646c8ac297a2b976e3a7369e4c78a5d969091c53e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dee9e9bfead123d2e51b9aa93d80f6969b043962a2ea0934d3104e4f4be7d3fb653d4a1dce2c26f3eb92d981ea3d5a4f1d32814a7d21f13c1be4378db369923
|
7
|
+
data.tar.gz: ee7934c5eb08fdd895d0656fbf78ac71dbeb4be12147951f6d0ba3518468d03097de05876c0793e70b2679fa8b36dec579a160118e868335a4ac33dda153b95f
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.3
|
data/gem_hadar.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: gem_hadar 2.0.
|
2
|
+
# stub: gem_hadar 2.0.3 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "gem_hadar".freeze
|
6
|
-
s.version = "2.0.
|
6
|
+
s.version = "2.0.3".freeze
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
data/lib/gem_hadar/version.rb
CHANGED
data/lib/gem_hadar.rb
CHANGED
@@ -1190,14 +1190,44 @@ class GemHadar
|
|
1190
1190
|
# content, opens it in an editor for user modification, and returns the
|
1191
1191
|
# updated content.
|
1192
1192
|
#
|
1193
|
-
#
|
1193
|
+
# This method first determines the editor to use from the EDITOR environment
|
1194
|
+
# variable or defaults to vi. If the editor cannot be found, it issues a
|
1195
|
+
# warning and returns nil. It then creates a temporary file, writes the
|
1196
|
+
# initial content to it, and opens the file in the editor. After the user
|
1197
|
+
# saves and closes the editor, it reads the modified content from the
|
1198
|
+
# temporary file. The temporary file is automatically cleaned up after use.
|
1199
|
+
#
|
1200
|
+
# @param content [ String ] the initial content to write to the temporary
|
1201
|
+
# file
|
1202
|
+
#
|
1203
|
+
# @return [ String, nil ] the content of the temporary file after editing, or
|
1204
|
+
# nil if the editor could not be found or failed
|
1194
1205
|
def edit_temp_file(content)
|
1195
1206
|
editor = ENV.fetch('EDITOR', `which vi`.chomp)
|
1196
1207
|
unless File.exist?(editor)
|
1197
1208
|
warn "Can't find EDITOR. => Returning."
|
1198
1209
|
return
|
1199
1210
|
end
|
1200
|
-
temp_file = Tempfile.new(
|
1211
|
+
temp_file = Tempfile.new(%w[ changelog .md ])
|
1212
|
+
temp_file.write(content)
|
1213
|
+
temp_file.close
|
1214
|
+
|
1215
|
+
unless system("#{editor} #{temp_file.path}")
|
1216
|
+
warn "#{editor} returned #{$?.exitstatus} => Returning."
|
1217
|
+
return
|
1218
|
+
end
|
1219
|
+
|
1220
|
+
File.read(temp_file.path)
|
1221
|
+
ensure
|
1222
|
+
temp_file&.close&.unlink
|
1223
|
+
end
|
1224
|
+
def edit_temp_file(content)
|
1225
|
+
editor = ENV.fetch('EDITOR', `which vi`.chomp)
|
1226
|
+
unless File.exist?(editor)
|
1227
|
+
warn "Can't find EDITOR. => Returning."
|
1228
|
+
return
|
1229
|
+
end
|
1230
|
+
temp_file = Tempfile.new(%w[ changelog .md ])
|
1201
1231
|
temp_file.write(content)
|
1202
1232
|
temp_file.close
|
1203
1233
|
|