Class: Agentilda::Resync::Dirs
- Inherits:
-
Object
- Object
- Agentilda::Resync::Dirs
- Defined in:
- lib/agentilda/resync.rb
Overview
resync dirs — makes every folder's name say what the folder is.
Two things can be wrong with a name, and both are repaired here:
- The emoji is wrong — the contents justify a different state. A folder whose status already holds is left alone, which is what stops ⭕️ Blocked and 🅱️ Product Blocked — deliberately identical invariants, distinguished only by the name — from collapsing into one.
- The number is not in
NNN.MMform — a folder written018-⚪️--foobefore the padding rule, or18.1-⚪️--fooby hand. These read fine and sort wrong, which is the whole reason the rule exists:018.09<018.1<018.10puts a single mixed-width folder in the middle of the range. Both are renamed to018.00-⚪️--fooand018.01-⚪️--foo.
The two cases collapse into one rule — rename any folder that is not already named what it should be named — which is why the emoji fix and the renumber cannot disagree about the target.
Defined Under Namespace
Classes: Change
Instance Attribute Summary collapse
- #tree ⇒ Agentilda::Tree readonly
Instance Method Summary collapse
-
#call(commit: false) ⇒ Array<Agentilda::Resync::Dirs::Change>
What was proposed.
-
#initialize(tree:) ⇒ Dirs
constructor
A new instance of Dirs.
-
#plan ⇒ Array<Agentilda::Resync::Dirs::Change>
What would change, without changing anything.
Constructor Details
#initialize(tree:) ⇒ Dirs
Returns a new instance of Dirs.
48 49 50 |
# File 'lib/agentilda/resync.rb', line 48 def initialize(tree:) @tree = tree end |
Instance Attribute Details
#tree ⇒ Agentilda::Tree (readonly)
53 54 55 |
# File 'lib/agentilda/resync.rb', line 53 def tree @tree end |
Instance Method Details
#call(commit: false) ⇒ Array<Agentilda::Resync::Dirs::Change>
Returns what was proposed.
62 63 64 65 66 67 68 69 |
# File 'lib/agentilda/resync.rb', line 62 def call(commit: false) changes = plan return changes unless commit UI.stepping(changes, "Renaming") { |change| rename(change) } tree.reload changes end |
#plan ⇒ Array<Agentilda::Resync::Dirs::Change>
What would change, without changing anything.
58 |
# File 'lib/agentilda/resync.rb', line 58 def plan = tree.subjects.filter_map { |subject| change_for(subject) } |