Class: Afterlife::Clickup::UpdateTaskStatus
- Inherits:
-
Object
- Object
- Afterlife::Clickup::UpdateTaskStatus
- Defined in:
- lib/afterlife/clickup/update_task_status.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#dry_run ⇒ Object
readonly
Returns the value of attribute dry_run.
-
#force ⇒ Object
readonly
Returns the value of attribute force.
-
#precedence_checker ⇒ Object
readonly
Returns the value of attribute precedence_checker.
-
#target_status ⇒ Object
readonly
Returns the value of attribute target_status.
Class Method Summary collapse
Instance Method Summary collapse
-
#call(task_ids, target_status) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength.
-
#initialize(force: false, dry_run: false) ⇒ UpdateTaskStatus
constructor
A new instance of UpdateTaskStatus.
Constructor Details
#initialize(force: false, dry_run: false) ⇒ UpdateTaskStatus
12 13 14 15 16 17 18 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 12 def initialize(force: false, dry_run: false) @force = force @dry_run = dry_run token = ENV['CLICKUP_TOKEN'] || fail('CLICKUP_TOKEN required, put `export CLICKUP_TOKEN=...` or the equivalent in your shell') # rubocop:disable Layout/LineLength @api = Api.new(token: token) @precedence_checker = StatusPrecedenceChecker.new end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
6 7 8 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 6 def api @api end |
#dry_run ⇒ Object (readonly)
Returns the value of attribute dry_run.
6 7 8 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 6 def dry_run @dry_run end |
#force ⇒ Object (readonly)
Returns the value of attribute force.
6 7 8 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 6 def force @force end |
#precedence_checker ⇒ Object (readonly)
Returns the value of attribute precedence_checker.
6 7 8 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 6 def precedence_checker @precedence_checker end |
#target_status ⇒ Object (readonly)
Returns the value of attribute target_status.
6 7 8 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 6 def target_status @target_status end |
Class Method Details
.call(task_ids, target_status, force: false, dry_run: false) ⇒ Object
8 9 10 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 8 def self.call(task_ids, target_status, force: false, dry_run: false) new(force: force, dry_run: dry_run).call(task_ids, target_status) end |
Instance Method Details
#call(task_ids, target_status) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/MethodLength
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/afterlife/clickup/update_task_status.rb', line 20 def call(task_ids, target_status) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength if task_ids.empty? puts 'No tasks to update' return [] end puts 'WARNING: Forcing status updates...' if force puts 'WARNING: Dry run, no tasks will be updated' if dry_run puts "Updating #{task_ids.length} tasks to '#{target_status}'" moved_task_ids = task_ids.map { |task_id| move_task(task_id, target_status) }.compact puts "#{dry_run ? 'Would have moved' : 'Moved'} #{moved_task_ids.length} tasks:" moved_task_ids.each do |task| puts "- #{task[:link]} (from '#{task[:previous_status]}' to '#{task[:new_status]}')" end moved_task_ids end |