Class: Figshare::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/base.rb

Overview

Supporting web calls to the API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(figshare_user:, conf_dir: nil, key_file: nil, conf_file: nil) ⇒ Base

Init reads the Json configuration files, setting @course_codes_to_faculty and @academic_department_code_to_faculty Opens a connection to the LDAP server, setting @ldap for other methods to use.

Parameters:

  • figshare_user (String)

    figshare user, in the figshare_keys.json

  • conf_dir (String|nil) (defaults to: nil)

    directory for figshare_keys.json and figshare_site_params.json

  • key_file (String|nil) (defaults to: nil)

    conf_dir/figshare_keys.json if nil

  • conf_file (String|nil) (defaults to: nil)

    conf_dir/figshare_site_params.json if nil



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/base.rb', line 19

def initialize(figshare_user:, conf_dir: nil, key_file: nil, conf_file: nil)
  raise 'Figshare_api_v2.initialize: Need to specify the conf_dir if key_file or conf_file are nil' if conf_dir.nil? && (key_file.nil? || conf_file.nil?)

  conf_file ||= "#{conf_dir}/figshare_site_params.json"
  key_file ||= "#{conf_dir}/figshare_keys.json"

  figshare_token = load_json_file(key_file)
  @auth_token = figshare_token[figshare_user]

  figshare_site_params = load_json_file(conf_file)

  @hostname = figshare_site_params['host']
  @api_url = figshare_site_params['api_url']
  @institute_id = figshare_site_params['institute_id']
end

Instance Attribute Details

#api_urlObject

Returns the value of attribute api_url.



9
10
11
# File 'lib/base.rb', line 9

def api_url
  @api_url
end

#article_index_fileObject

Returns the value of attribute article_index_file.



7
8
9
# File 'lib/base.rb', line 7

def article_index_file
  @article_index_file
end

#auth_tokenObject

Returns the value of attribute auth_token.



5
6
7
# File 'lib/base.rb', line 5

def auth_token
  @auth_token
end

#base_dirObject

Returns the value of attribute base_dir.



6
7
8
# File 'lib/base.rb', line 6

def base_dir
  @base_dir
end

#hostnameObject

Returns the value of attribute hostname.



8
9
10
# File 'lib/base.rb', line 8

def hostname
  @hostname
end

#institute_idObject

Returns the value of attribute institute_id.



10
11
12
# File 'lib/base.rb', line 10

def institute_id
  @institute_id
end