Sha256: 243a33bc28f2e2857fc32872487a4a7542b50329e52a3155273f692cd3e6332f

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 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(@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), nil, '%-').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.1.2 lib/xezat/command/bump.rb