Class: Terjira::Client::Base

Inherits:
Object
  • Object
show all
Extended by:
AuthOptionBuilder, JQLQueryBuilder
Defined in:
lib/terjira/client/base.rb

Overview

Abstract class to delegate jira-ruby resource class

Constant Summary collapse

DEFAULT_CACHE_SEC =
60
DEFAULT_API_PATH =
"/rest/api/2/"
AGILE_API_PATH =
"/rest/agile/1.0/"

Constants included from JQLQueryBuilder

JQLQueryBuilder::JQL_KEYS

Constants included from AuthOptionBuilder

AuthOptionBuilder::AUTH_CACHE_KEY

Class Method Summary collapse

Methods included from JQLQueryBuilder

build_jql_query

Methods included from AuthOptionBuilder

auth_file_cache, build_auth_options, build_auth_options_by_cached, build_auth_options_by_tty, expire_auth_options

Class Method Details

.cache(options = {}) ⇒ Object



35
36
37
38
# File 'lib/terjira/client/base.rb', line 35

def cache(options = {})
  options[:expiry] ||= DEFAULT_CACHE_SEC
  @cache ||= Terjira::FileCache.new(class_name, expiry)
end

.class_nameObject



31
32
33
# File 'lib/terjira/client/base.rb', line 31

def class_name
  self.to_s.split("::").last
end

.clientObject



19
20
21
# File 'lib/terjira/client/base.rb', line 19

def client
  @@client ||= JIRA::Client.new(build_auth_options)
end

.parse_body(response) ⇒ Object



66
67
68
# File 'lib/terjira/client/base.rb', line 66

def parse_body(response)
  JSON.parse(response.body) if response.body.present?
end

.resourceObject



23
24
25
# File 'lib/terjira/client/base.rb', line 23

def resource
  client.send(class_name) if client.respond_to?(class_name)
end

.usernameObject



27
28
29
# File 'lib/terjira/client/base.rb', line 27

def username
  client.options[:username]
end