Sha256: ba3e5e0202369eda6202518f047da72b0f5a941d50dffed2535843299107a050

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rake/dsl_definition'

# DeployRubygem module helper for rubygem
module DeployRubygem
  # RakeTask to use with DeployRubygem projects
  class RakeDefaultTask
    include ::Rake::DSL if defined?(::Rake::DSL)

    # Define DeployRubygem Rake task
    def initialize(task_name, desc)
      @task_name = task_name
      @desc = desc
      yield self if block_given?
      define_tasks
    end

    def rspec_and_rubocop
      require 'rspec/core/rake_task'
      require 'rubocop/rake_task'

      RSpec::Core::RakeTask.new(:spec)
      RuboCop::RakeTask.new
    end

    def define_tasks # :nodoc:
      rspec_and_rubocop
      test_framework
      default
      cycle
      test_version
      check_local
      compliance
      develop
      push
    end

    def test_framework # :nodoc:
      desc "@desc with #{__method__}"
      task test_framework: %i[clean check_local]
    end

    def default # :nodoc:
      desc "@desc with #{__method__}"
      task default: %i[test_framework build install:local]
    end

    def cycle # :nodoc:
      desc "@desc with #{__method__}"
      task cycle: %i[default test_version]
    end

    def test_version # :nodoc:
      desc "@desc with #{__method__}"
      task test_version: %i[install compliance]
    end

    def check_local # :nodoc:
      desc "@desc with #{__method__}"
      task check_local: %i[rubocop spec]
    end

    def compliance # :nodoc:
      desc "@desc with #{__method__}"
      task :compliance do
        system('inspec exec compliance')
      end
    end

    def develop # :nodoc:
      desc "@desc with #{__method__}"
      task develop: %i[check_local clean push default]
    end

    def push # :nodoc:
      desc "@desc with #{__method__}"
      task :push do
        system('git add .')
        system("git commit -m 'Rake pusing version #{DeployRubygem::VERSION}'")
        system('git push')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deploy_rubygem-0.60.37 lib/deploy_rubygem/rake/default.rb