Class: Checkoff::Resources
- Inherits:
-
Object
- Object
- Checkoff::Resources
- Extended by:
- CacheMethod::ClassMethods
- Defined in:
- lib/checkoff/resources.rb,
sig/checkoff.rbs
Overview
Deal with Asana resources across different resource types
Constant Summary collapse
- MINUTE =
60- HOUR =
MINUTE * 60
- DAY =
24 * HOUR
- REALLY_LONG_CACHE_TIME =
HOUR * 1
- LONG_CACHE_TIME =
MINUTE * 15
- SHORT_CACHE_TIME =
MINUTE
Instance Attribute Summary collapse
-
#client ⇒ Asana::Client
readonly
sord warn - Asana::Client wasn't able to be resolved to a constant in this project.
- #projects ⇒ Checkoff::Projects readonly
- #sections ⇒ Checkoff::Sections readonly
- #tasks ⇒ Checkoff::Tasks readonly
- #workspaces ⇒ Checkoff::Workspaces readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#fetch_project_gid(project_gid) ⇒ Asana::Resources::Project?
sord warn - Asana::Resources::Project wasn't able to be resolved to a constant in this project @param
project_gid. -
#fetch_section_gid(section_gid) ⇒ Asana::Resources::Section?
sord warn - Asana::Resources::Section wasn't able to be resolved to a constant in this project @param
section_gid. -
#fetch_task_gid(gid) ⇒ Asana::Resources::Task?
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project @param
gid. -
#initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), workspaces: Checkoff::Workspaces.new(config:), tasks: Checkoff::Tasks.new(config:), sections: Checkoff::Sections.new(config:), projects: Checkoff::Projects.new(config:), clients: Checkoff::Clients.new(config:), client: clients.client) ⇒ Object
constructor
sord warn - Asana::Client wasn't able to be resolved to a constant in this project @param
config. -
#resource_by_gid(gid, resource_type: nil) ⇒ [untyped, untyped, untyped, untyped]
sord warn - "[Asana::Resource" does not appear to be a type sord warn - "nil]" does not appear to be a type sord warn - "[String" does not appear to be a type sord warn - "nil]" does not appear to be a type Attempt to look up a GID, even in situations where we don't have a resource type provided.
Constructor Details
#initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), workspaces: Checkoff::Workspaces.new(config:), tasks: Checkoff::Tasks.new(config:), sections: Checkoff::Sections.new(config:), projects: Checkoff::Projects.new(config:), clients: Checkoff::Clients.new(config:), client: clients.client) ⇒ Object
sord warn - Asana::Client wasn't able to be resolved to a constant in this project
@param config
@param workspaces
@param tasks
@param sections
@param projects
@param clients
@param client
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/checkoff/resources.rb', line 40 def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), workspaces: Checkoff::Workspaces.new(config:), tasks: Checkoff::Tasks.new(config:), sections: Checkoff::Sections.new(config:), projects: Checkoff::Projects.new(config:), clients: Checkoff::Clients.new(config:), client: clients.client) @workspaces = workspaces @tasks = tasks @sections = sections @projects = projects @client = client end |
Instance Attribute Details
#client ⇒ Asana::Client (readonly)
sord warn - Asana::Client wasn't able to be resolved to a constant in this project
109 110 111 |
# File 'lib/checkoff/resources.rb', line 109 def client @client end |
#projects ⇒ Checkoff::Projects (readonly)
100 101 102 |
# File 'lib/checkoff/resources.rb', line 100 def projects @projects end |
#sections ⇒ Checkoff::Sections (readonly)
103 104 105 |
# File 'lib/checkoff/resources.rb', line 103 def sections @sections end |
#tasks ⇒ Checkoff::Tasks (readonly)
106 107 108 |
# File 'lib/checkoff/resources.rb', line 106 def tasks @tasks end |
#workspaces ⇒ Checkoff::Workspaces (readonly)
97 98 99 |
# File 'lib/checkoff/resources.rb', line 97 def workspaces @workspaces end |
Class Method Details
.run ⇒ void
This method returns an undefined value.
115 116 117 118 119 120 121 122 123 |
# File 'lib/checkoff/resources.rb', line 115 def run # # @type [String] # workspace_name = ARGV[0] || raise('Please pass workspace name as first argument') # # @type [String] # resource_name = ARGV[1] || raise('Please pass resource name as second argument') # resources = Checkoff::Resources.new # resource = resources.resource_or_raise(workspace_name, resource_name) # puts "Results: #{resource}" end |
Instance Method Details
#fetch_project_gid(project_gid) ⇒ Asana::Resources::Project?
sord warn - Asana::Resources::Project wasn't able to be resolved to a constant in this project
@param project_gid
92 93 94 |
# File 'lib/checkoff/resources.rb', line 92 def fetch_project_gid(project_gid) projects.project_by_gid(project_gid) end |
#fetch_section_gid(section_gid) ⇒ Asana::Resources::Section?
sord warn - Asana::Resources::Section wasn't able to be resolved to a constant in this project
@param section_gid
85 86 87 |
# File 'lib/checkoff/resources.rb', line 85 def fetch_section_gid(section_gid) sections.section_by_gid(section_gid) end |
#fetch_task_gid(gid) ⇒ Asana::Resources::Task?
sord warn - Asana::Resources::Task wasn't able to be resolved to a constant in this project
@param gid
78 79 80 |
# File 'lib/checkoff/resources.rb', line 78 def fetch_task_gid(gid) tasks.task_by_gid(gid, only_uncompleted: false) end |
#resource_by_gid(gid, resource_type: nil) ⇒ [untyped, untyped, untyped, untyped]
sord warn - "[Asana::Resource" does not appear to be a type sord warn - "nil]" does not appear to be a type sord warn - "[String" does not appear to be a type sord warn - "nil]" does not appear to be a type Attempt to look up a GID, even in situations where we don't have a resource type provided.
@param gid
@param resource_type
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/checkoff/resources.rb', line 61 def resource_by_gid(gid, resource_type: nil) %w[task section project].each do |resource_type_to_try| next unless [resource_type_to_try, nil].include?(resource_type) # @type [Asana::Resources::Resource, nil] resource = T.cast(method(:"fetch_#{resource_type_to_try}_gid").call(gid), T.nilable(Asana::Resources::Resource)) return [resource, resource_type_to_try] if resource end [nil, nil] end |