class GemHadar

def version_task

writing to prevent permission issues.
section. The task ensures the target directory exists and uses secure file
for the version and its components, as well as an optional epilogue
to a Ruby file in the lib directory. The generated file contains constants
This method creates a task named :version that writes version information

for the gem.
The version_task method defines a Rake task that generates a version file
def version_task
  desc m = "Writing version information for #{name}-#{version}"
  task :version do
    puts m
    mkdir_p dir = File.join('lib', path_name)
    secure_write(File.join(dir, 'version.rb')) do |v|
      v.puts <<~EOT
        #{module_type} #{path_module}
          # #{path_module} version
          VERSION         = '#{version}'
          VERSION_ARRAY   = VERSION.split('.').map(&:to_i) # :nodoc:
          VERSION_MAJOR   = VERSION_ARRAY[0] # :nodoc:
          VERSION_MINOR   = VERSION_ARRAY[1] # :nodoc:
          VERSION_BUILD   = VERSION_ARRAY[2] # :nodoc:
        end
      EOT
      version_epilogue.full? { |ve| v.puts ve }
    end
  end
end