gem_hadar 2.23.0 → 2.24.0

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: d10fdd2bde739d7ef7ea7a3d01b62962b3196dadccc0282d5f20688428a4f1b8
4
- data.tar.gz: 9483d422436b594ef2883bb49a3a0ebbc49c52a9be719a939f01d6da8e572a1e
3
+ metadata.gz: 9bcb0f3de989dbb2a8ed97c7005da17514e5590f5911c9fd2e0f80c2ae6b2ff4
4
+ data.tar.gz: 99092fb80536b29ef5c2c260cb5acfe347bae22cabd9a71b7b3f7d5e5c13ea84
5
5
  SHA512:
6
- metadata.gz: 42cd6036f8d4ca5e1d323f30c353f02f6afebe0ffb63d2e6727790d15855602db4f42b25ccbe7abfdc6dd593cf32032a2af21ff7b03026dc77a0a53dbce51b1b
7
- data.tar.gz: 28d7b01134693914644d84b05b9f267e3c699ba8bb7a9d3592eac11e789b8f0bf201e3764e0ee4b0334fc587aaf6612a9d728f66a377b5e4ef6f4d7446f949b5
6
+ metadata.gz: 3fe6dd92699bda6d884621d2d2b519ec64bd8a69feca70c3b51de1e5ab9e7f5e055428a5aa39849af2a031abc3a36d7566ec383793c69530763b0487fa623ee7
7
+ data.tar.gz: fd682bf8b1394f993b3a69af915319b237ead6d50d5579c4810b936df4e87812c0b32f1aa0b1bea44f91a4a3a0edc5b7faea31c41bf1fe410e8049ac59ef9de1
data/gem_hadar.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: gem_hadar 2.23.0 ruby lib
2
+ # stub: gem_hadar 2.24.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "gem_hadar".freeze
6
- s.version = "2.23.0".freeze
6
+ s.version = "2.24.0".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]
@@ -26,8 +26,6 @@ class GemHadar::Setup
26
26
  unless File.exist?('Rakefile')
27
27
  File.open('Rakefile', 'w') do |output|
28
28
  output.puts <<~EOT
29
- # vim: set filetype=ruby et sw=2 ts=2:
30
-
31
29
  require 'gem_hadar'
32
30
 
33
31
  GemHadar do
@@ -5,7 +5,7 @@
5
5
  # by hand; it is rewritten on every `rake version` invocation.
6
6
  class GemHadar
7
7
  # The current version of the GemHadar gem as a String.
8
- VERSION = '2.23.0'
8
+ VERSION = '2.24.0'
9
9
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
10
10
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
11
11
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/lib/gem_hadar.rb CHANGED
@@ -1907,6 +1907,8 @@ class GemHadar
1907
1907
  release_task
1908
1908
  github_workflows_task
1909
1909
  write_ignore_file
1910
+ strip_modeline 'Gemfile'
1911
+ strip_modeline 'Rakefile'
1910
1912
  write_gemfile
1911
1913
  if extensions.full?
1912
1914
  compile_task
@@ -1979,27 +1981,34 @@ class GemHadar
1979
1981
  end
1980
1982
  memoize method: :version_tag_list, freeze: true
1981
1983
 
1984
+ # The strip_modeline method removes the obsolete vim modeline that GemHadar
1985
+ # previously generated at the top of project files.
1986
+ #
1987
+ # @param filename [ String ] the file to check and potentially strip
1988
+ def strip_modeline(filename)
1989
+ return unless File.exist?(filename)
1990
+ modeline = "# vim: set filetype=ruby et sw=2 ts=2:\n\n"
1991
+ content = File.read(filename)
1992
+ if content.start_with?(modeline)
1993
+ secure_write(filename) { |f| f.write content.sub(modeline, '', 1) }
1994
+ puts "Removed obsolete vim modeline from #{filename}."
1995
+ end
1996
+ end
1997
+
1982
1998
  # The write_gemfile method creates and writes the default Gemfile content if
1983
- # it doesn't exist. If a Gemfile exists with the obsolete vim modeline that
1984
- # GemHadar previously generated, it strips those two lines automatically.
1985
- # If a custom Gemfile exists that differs from the default, it displays a
1986
- # warning.
1999
+ # it doesn't exist. If a custom Gemfile exists that differs from the
2000
+ # default, it displays a warning.
1987
2001
  def write_gemfile
1988
- default_gemfile =<<~EOT
2002
+ default_gemfile = <<~EOT
1989
2003
  source 'https://rubygems.org'
1990
2004
 
1991
2005
  gemspec
1992
2006
  EOT
1993
- modeline = "# vim: set filetype=ruby et sw=2 ts=2:\n\n"
1994
2007
  unless File.exist?('Gemfile')
1995
2008
  secure_write('Gemfile') { |f| f.write default_gemfile }
1996
2009
  return
1997
2010
  end
1998
- current = File.read('Gemfile')
1999
- if current.start_with?(modeline)
2000
- secure_write('Gemfile') { |f| f.write current.sub(modeline, '') }
2001
- puts "Removed obsolete vim modeline from Gemfile."
2002
- elsif current != default_gemfile
2011
+ if File.read('Gemfile') != default_gemfile
2003
2012
  warn "INFO: Current Gemfile differs from default Gemfile."
2004
2013
  end
2005
2014
  end
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.23.0
4
+ version: 2.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank