Class: Agentilda::Resync::Dirs

Inherits:
Object
  • Object
show all
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.MM form — a folder written 018-⚪️--foo before the padding rule, or 18.1-⚪️--foo by hand. These read fine and sort wrong, which is the whole reason the rule exists: 018.09 < 018.1 < 018.10 puts a single mixed-width folder in the middle of the range. Both are renamed to 018.00-⚪️--foo and 018.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

Instance Method Summary collapse

Constructor Details

#initialize(tree:) ⇒ Dirs

Returns a new instance of Dirs.

Parameters:



48
49
50
# File 'lib/agentilda/resync.rb', line 48

def initialize(tree:)
  @tree = tree
end

Instance Attribute Details

#treeAgentilda::Tree (readonly)

Returns:



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.

Parameters:

  • commit (Boolean) (defaults to: false)

    actually rename

Returns:



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

#planArray<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) }