Formatters/GitHubGists.Format.ps1xml

<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
  <ViewDefinitions>
    <!--================== GitHub.Gist Type View =================-->
    <View>
      <Name>GitHub.Gist</Name>
      <ViewSelectedBy>
        <TypeName>GitHub.Gist</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label>ID</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>User</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Description</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Public</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Files</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Created</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Updated</Label>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <PropertyName>id</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                  $_.owner.login
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>description</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>public</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                  ($_.files |
                    Get-Member -MemberType NoteProperty |
                    Select-Object -ExpandProperty Name) -join ', '
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>created_at</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>updated_at</PropertyName>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>
    <!--=============== GitHub.GistCommit Type View ===============-->
    <View>
      <Name>GitHub.GistCommit</Name>
      <ViewSelectedBy>
        <TypeName>GitHub.GistCommit</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label>ID</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Sha</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>User</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Committed</Label>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <PropertyName>GistId</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>version</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                  ($_.user.login)
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>committed_at</PropertyName>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>
    <!--================== GitHub.GistDetail Type View =================-->
    <View>
      <Name>GitHub.GistDetail</Name>
      <ViewSelectedBy>
        <TypeName>GitHub.GistDetail</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label>ID</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>owner</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Description</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Public</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Files</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Forks</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Created</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Updated</Label>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <PropertyName>id</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                  ($_.owner.login)
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>description</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>public</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                  ($_.files |
                    Get-Member -MemberType NoteProperty |
                    Select-Object -ExpandProperty Name) -join ', '
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                  ($_.forks.Count)
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>created_at</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>updated_at</PropertyName>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>
    <!--=============== GitHub.GistFork Type View ===============-->
    <View>
      <Name>GitHub.GistFork</Name>
      <ViewSelectedBy>
        <TypeName>GitHub.GistFork</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label>ID</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>User</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Created</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Updated</Label>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <PropertyName>id</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                  # There appears to be a bug in the GitHub API.
                  # Documentation says that the property should alway be "user",
                  # but it switches between "owner" and "user" depending on if it's a property
                  # of a gist, or the direct result from a gist forks query.
                  # https://github.community/t/gist-api-v3-documentation-incorrect-for-forks/122545
                  if ($null -eq $_.user)
                  {
                     $_.owner.login
                  }
                  else
                  {
                     $_.user.login
                  }
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>created_at</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>updated_at</PropertyName>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>
  </ViewDefinitions>
</Configuration>