Sha256: 7b54bd7c95030f0e40808ff41dd2c06ce351aaffb5264fd118eb807f93220728

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require 'facets/file/atomic_write'
require 'find'
require 'json'
require 'xezat'
require 'xezat/command/bump/changelog'
require 'xezat/command/bump/development_package'
require 'xezat/command/bump/file'
require 'xezat/command/bump/runtime_package'
require 'xezat/command/bump/src_uri'
require 'xezat/cygchangelog'
require 'xezat/cygclasses'
require 'xezat/packages'
require 'xezat/variables'

module Xezat
  module Command
    class Bump
      include Xezat

      def initialize(options, cygport)
        @options = options
        @cygport = cygport
      end

      def execute
        Xezat.logger.debug('Start bumping')
        pkgs = packages
        vars = variables(@cygport)
        readme_file = File.expand_path(File.join(vars[:C], 'README'))

        info = {
          src_uri: get_src_uri(vars),
          runtimes: get_runtime_packages(vars, pkgs, @cygport),
          developments: get_development_packages(vars, pkgs),
          files: get_files(vars),
          changelog: get_changelog(vars, @options, readme_file)
        }

        Xezat.logger.debug('  Write ChangeLog atomically')
        File.atomic_write(readme_file) do |f|
          f.write(get_embedded_contents(vars, info))
        end

        Xezat.logger.debug('End bumping')
      end

      def get_embedded_contents(variables, info)
        erb = File.expand_path(File.join(TEMPLATE_DIR, 'README.erb'))
        ERB.new(File.readlines(erb).join(nil), trim_mode: '%-').result(binding).chop # remove redundant new line
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xezat-0.2.2 lib/xezat/command/bump.rb