# 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 chef_install end def chef_install # :nodoc: desc "@desc with #{__method__}" task :install_chef_workstation do extend DeployRubygem install_chef_workstation end 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: :install_chef_workstation 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