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- 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_gid_by_type(resource_type, gid) ⇒ Asana::Resources::Resource?
@param
resource_type. -
#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
120 121 122 |
# File 'lib/checkoff/resources.rb', line 120 def client @client end |
#projects ⇒ Checkoff::Projects (readonly)
111 112 113 |
# File 'lib/checkoff/resources.rb', line 111 def projects @projects end |
#sections ⇒ Checkoff::Sections (readonly)
114 115 116 |
# File 'lib/checkoff/resources.rb', line 114 def sections @sections end |
#tasks ⇒ Checkoff::Tasks (readonly)
117 118 119 |
# File 'lib/checkoff/resources.rb', line 117 def tasks @tasks end |
#workspaces ⇒ Checkoff::Workspaces (readonly)
108 109 110 |
# File 'lib/checkoff/resources.rb', line 108 def workspaces @workspaces end |
Class Method Details
.run ⇒ void
This method returns an undefined value.
126 127 128 129 130 131 132 133 134 |
# File 'lib/checkoff/resources.rb', line 126 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_gid_by_type(resource_type, gid) ⇒ Asana::Resources::Resource?
@param resource_type
@param gid
77 78 79 80 81 82 83 84 |
# File 'lib/checkoff/resources.rb', line 77 def fetch_gid_by_type(resource_type, gid) case resource_type when 'task' then fetch_task_gid(gid) when 'section' then fetch_section_gid(gid) when 'project' then fetch_project_gid(gid) else raise "Unexpected resource_type: #{resource_type}" end end |
#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
103 104 105 |
# File 'lib/checkoff/resources.rb', line 103 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
96 97 98 |
# File 'lib/checkoff/resources.rb', line 96 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
89 90 91 |
# File 'lib/checkoff/resources.rb', line 89 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 |
# 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) resource = fetch_gid_by_type(resource_type_to_try, gid) return [resource, resource_type_to_try] if resource end [nil, nil] end |