gem_hadar 2.0.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55a40671999265ec05699a78ed77f0c003572b124c3e678ae43b16ed1edf036e
4
- data.tar.gz: a18e12241478f62fabbe29ecc3126acb14bcc670e661c20d70c0b517ad6374a7
3
+ metadata.gz: ca4918a475147350c004d6952b906489dd4f0ecaa9c95695301638e00a2ef68c
4
+ data.tar.gz: fd7bec7396866c169b09941646c8ac297a2b976e3a7369e4c78a5d969091c53e
5
5
  SHA512:
6
- metadata.gz: f9ac1a658a76dabf415c798778edb0533ac86768ac005237afa1fb3ca67aba8db94ecdbd52dc72730f7a79811fb2adaacc4744d62ced5d0ab12608d245ee0935
7
- data.tar.gz: 8bd28eecf26369f803b3a66d17482d9e814cac42c8a1f4932525e27926e5c404f8544ff903f7a8fe4e75ed53559e0b3ac16e51d265753a7784a19d0e9824ec33
6
+ metadata.gz: 3dee9e9bfead123d2e51b9aa93d80f6969b043962a2ea0934d3104e4f4be7d3fb653d4a1dce2c26f3eb92d981ea3d5a4f1d32814a7d21f13c1be4378db369923
7
+ data.tar.gz: ee7934c5eb08fdd895d0656fbf78ac71dbeb4be12147951f6d0ba3518468d03097de05876c0793e70b2679fa8b36dec579a160118e868335a4ac33dda153b95f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.2
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 ruby lib
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.2".freeze
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]
@@ -1,6 +1,6 @@
1
1
  class GemHadar
2
2
  # GemHadar version
3
- VERSION = '2.0.2'
3
+ VERSION = '2.0.3'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
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
- # @param content [ String ] the initial content to write to the temporary file
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('changelog.md')
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_hadar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank