Class: Agentilda::Linear::Import

Inherits:
Object
  • Object
show all
Defined in:
lib/agentilda/linear/import.rb

Overview

What a plan folder would become in Linear, and what has already become of it. Reads the filesystem; touches nothing else.

One folder is one issue, and the units inside its plan.md are that issue's children. Projects are never created: a team's project list is something a human curated, and every plan is filed under one the caller named on the command line.

Keeping the whole decision offline is what makes --commit honest. The dry run is not an approximation of what a push would do — it is the same object the push consumes, so what gets printed and what gets sent cannot disagree. Everything that needs the network — the project, the repository pull request list — is handed in.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tree:, team:, project:, adopted: {}, since: nil, statuses: nil, force: false) ⇒ Import

Returns a new instance of Import.

Parameters:

  • tree (Agentilda::Tree)
  • team (String)

    the team key, e.g. "TAX"

  • project (Hash)

    the Linear project, {"id", "name", "url"}

  • adopted (Hash{String => Array<Agentilda::PullRequest>}) (defaults to: {})

    pull requests Attribution placed, by folder name

  • since (String, nil) (defaults to: nil)

    skip plans numbered below this

  • statuses (Array<Symbol>, nil) (defaults to: nil)

    only these states

  • force (Boolean) (defaults to: false)

    update everything, matching digest or not



70
71
72
73
74
75
76
77
78
# File 'lib/agentilda/linear/import.rb', line 70

def initialize(tree:, team:, project:, adopted: {}, since: nil, statuses: nil, force: false)
  @tree = tree
  @team = team.to_s.strip.upcase
  @project = project
  @adopted = adopted
  @since = since && Ordinal.parse(since)
  @statuses = statuses
  @force = force
end

Instance Attribute Details

#projectHash (readonly)

Returns the project everything is filed under.

Returns:

  • (Hash)

    the project everything is filed under



84
85
86
# File 'lib/agentilda/linear/import.rb', line 84

def project
  @project
end

#teamString (readonly)

Returns the team key.

Returns:

  • (String)

    the team key



81
82
83
# File 'lib/agentilda/linear/import.rb', line 81

def team
  @team
end

Instance Method Details

#actionsArray<Agentilda::Linear::Action>

Returns each plan's issue, followed by that issue's children.

Returns:



91
# File 'lib/agentilda/linear/import.rb', line 91

def actions = @actions ||= subjects.flat_map { |s| actions_for(s) }

#pendingArray<Agentilda::Linear::Action>

Returns:



94
# File 'lib/agentilda/linear/import.rb', line 94

def pending = actions.select(&:pending?)

#project_nameString

Returns:

  • (String)


87
# File 'lib/agentilda/linear/import.rb', line 87

def project_name = project["name"].to_s

#to_json(*_args) ⇒ String

Returns the whole import, for a pipe.

Returns:

  • (String)

    the whole import, for a pipe



97
98
99
# File 'lib/agentilda/linear/import.rb', line 97

def to_json(*_args)
  JSON.pretty_generate(team:, project: project_name, actions: actions.map(&:to_h_json))
end

#unplacedHash{Agentilda::Status => Array<String>}

Plans in a state nobody has decided how to file, and why not.

Returns:



104
105
106
107
# File 'lib/agentilda/linear/import.rb', line 104

def unplaced
  @unplaced ||= (chosen - subjects).group_by(&:status)
    .transform_values { |group| group.map { |s| s.feature.ordinal.to_s } }
end