How to determine whether any prerequisite tasks needed to run at the time they were defined?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 42/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- ruby
- Ambito
- build-system
Direzione di ricerca
Inizia dai punti di ingresso di Rake::Task mostrati nell’issue: #needed?, #already_invoked, #execute, #enhance e invoke_prerequisites. Traccia quando cambia ciascuno stato e determina come distinguere un prerequisito che è stato effettivamente eseguito da uno che è stato solo invocato. Il lavoro è completato quando il comportamento è specificato e coperto da test per entrambi i casi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I have a use-case in which I need to run a task if and only if at least one of its prerequisite tasks either (1) currently needs to run or (2) needed to run at the time the prerequisite task was defined. Here are some attempts at a Rake::Task subclass:
class MyTask < Rake::Task
def needed?
prerequisite_tasks.any?(&:needed?)
end
end
This approach does not work, since at the time MyTask#needed? is called, prerequisite tasks may have run and therefore return false for #needed?.
class MyTask < Rake::Task
def needed?
prerequisite_tasks.any? { |p| p.needed? or p.already_invoked }
end
end
This also doesn't work, since #already_invoked can return true [even if the task's #execute method was never called]:
@already_invoked = true
invoke_prerequisites(task_args, new_chain)
execute(task_args) if needed?
What ended up working was:
class MyTask < Rake::Task
def initialize(*)
@needed = false
super
end
def enhance(*)
super.tap { @needed |= prerequisite_tasks.any?(&:needed?) }
end
def needed?
@needed
end
end
But that just feels... wrong. Is there something I'm missing here? I'd be more than happy to open a PR implementing what I'm looking for (maybe an #already_executed method?) if this functionality doesn't already exist.
Thanks!
- Lingua principale
- Ruby
- Stelle
- 2.5k
- Fork
- 650
- Merge medio
- 6m
- PR unite (30g)
- 3
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ruby/rake
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 45/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
palladius/rails8-app-on-gcp#145 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
rubocop/rubocop-rspec#2236 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
riscv/riscv-unified-db#2624 · 1 reazione ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100