Sha256: af59dcce868ff9ae53b2a02ad1f30913e5fb05d09ca64aa9a73a7bcbab0c19c6

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

class EcoRake
  module Lib
    module People
      # The top level task that organizes all the people sync
      class SyncRely < EcoRake::Lib::People::BaseTask
        FORWARD_RULES = {
          enviro:     :mirror,
          schema:     :mirror,
          folder:     :mirror,
          only_stats: :mirror,
          no_policy:  :mirror,
          no_get:     :mirror,
          simulate:   :mirror
        }.freeze

        option_forwarding(**FORWARD_RULES)

        attr_const :target_task

        def task(*_args)
          sh_continue rake_sync_command
        end

        private

        def rake_sync_command
          rake_command(namespaced_task, *forward_options(*FORWARD_RULES.keys - [:enviro]))
        end

        def rake_command(task_name, *options)
          string_cmd(base_command(task_name), '--', *options)
        end

        def base_command(task_name = namespaced_task)
          string_cmd('rake', task_name)
        end

        def namespaced_task(task_name = target_task)
          ns             = self.class.namespace || ''
          ns_with_enviro = ns.split(':').any? {|s| s == options[:enviro]}
          ns             = "#{ns}:#{options[:enviro]}" unless ns_with_enviro
          "#{ns}:#{task_name || self.class.task}"
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
eco-rake-0.2.4 lib/eco-rake/lib/people/sync_rely.rb
eco-rake-0.2.3 lib/eco-rake/lib/people/sync_rely.rb
eco-rake-0.2.2 lib/eco-rake/lib/people/sync_rely.rb
eco-rake-0.2.1 lib/eco-rake/lib/people/sync_rely.rb
eco-rake-0.2.0 lib/eco-rake/lib/people/sync_rely.rb