class Abt::Providers::Asana::Configuration
Attributes
cli[RW]
Public Class Methods
new(cli:)
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 9 def initialize(cli:) @cli = cli end
Public Instance Methods
access_token()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 60 def access_token return git_global["accessToken"] unless git_global["accessToken"].nil? git_global["accessToken"] = cli.prompt.text([ "Please provide your personal access token for Asana.", "If you don't have one, create one here: https://app.asana.com/0/developer-console", "", "Enter access token" ].join("\n")) end
clear_global(verbose: true)
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 56 def clear_global(verbose: true) git_global.clear(output: verbose ? cli.err_output : nil) end
clear_local(verbose: true)
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 52 def clear_local(verbose: true) git.clear(output: verbose ? cli.err_output : nil) end
finalized_section_gid()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 44 def finalized_section_gid return nil unless local_available? @finalized_section_gid ||= git["finalizedSectionGid"] || directory_config["finalized_section_gid"] || prompt_finalized_section["gid"] end
local_available?()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 13 def local_available? git.available? end
path()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 17 def path Path.new(local_available? && git["path"] || directory_config["path"] || "") end
path=(new_path)
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 21 def path=(new_path) git["path"] = new_path end
wip_section_gid()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 36 def wip_section_gid return nil unless local_available? @wip_section_gid ||= git["wipSectionGid"] || directory_config["wip_section_gid"] || prompt_wip_section["gid"] end
workspace_gid()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 25 def workspace_gid @workspace_gid ||= begin current = git_global["workspaceGid"] if current.nil? prompt_workspace_gid else current end end end
Private Instance Methods
api()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 127 def api Abt::Providers::Asana::Api.new(access_token: access_token) end
directory_config()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 73 def directory_config cli.directory_config.fetch("asana", {}) end
git()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 77 def git @git ||= GitConfig.new("local", "abt.asana") end
git_global()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 81 def git_global @git_global ||= GitConfig.new("global", "abt.asana") end
pick_workspace()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 116 def pick_workspace cli.prompt.choice("Select Asana workspace", workspaces) end
prompt_finalized_section()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 85 def prompt_finalized_section section = prompt_section('Select section for finalized tasks (E.g. "Merged")') git["finalizedSectionGid"] = section["gid"] section end
prompt_section(message)
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 97 def prompt_section(message) cli.warn("Fetching sections...") sections = api.get_paged("projects/#{path.project_gid}/sections", opt_fields: "name") cli.prompt.choice(message, sections) end
prompt_wip_section()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 91 def prompt_wip_section section = prompt_section("Select WIP (Work In Progress) section") git["wipSectionGid"] = section["gid"] section end
prompt_workspace_gid()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 103 def prompt_workspace_gid cli.abort("Your asana access token does not have access to any workspaces") if workspaces.empty? if workspaces.one? workspace = workspaces.first cli.warn("Selected Asana workspace: #{workspace['name']}") else workspace = pick_workspace end git_global["workspaceGid"] = workspace["gid"] end
workspaces()
click to toggle source
# File lib/abt/providers/asana/configuration.rb, line 120 def workspaces @workspaces ||= begin cli.warn("Fetching workspaces...") api.get_paged("workspaces", opt_fields: "name") end end