Class: Figshare::Init

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

Overview

HACK: to do a lazy initialization of the Figshare subclasses. i.e. only if they get called. Usage: @figshare = Figshare::Init.new(figshare_user: ‘figshare_admin’, conf_dir: “#<strong>dir</strong>/conf”)

@figshare.authors.detail(author_id: 12345) { |a| puts a } @figshare.institutions.private_articles { |article| puts article } …

Instance Method Summary collapse

Constructor Details

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

Intitialize the Init class, so it can dynamically initialize the Figshare subclasses

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



39
40
41
42
43
44
# File 'lib/figshare_api_v2.rb', line 39

def initialize(figshare_user:, conf_dir: nil, key_file: nil, conf_file: nil)
  @figshare_user = figshare_user
  @conf_dir = conf_dir
  @key_file = key_file
  @conf_file = conf_file
end

Instance Method Details

#authorsFigshare::Authors

Create Figshare::Authors, if it doesn’t exist. Initialized with @figshare_user and @conf_dir

Returns:



49
50
51
# File 'lib/figshare_api_v2.rb', line 49

def authors
  @authors ||= Authors.new(figshare_user: @figshare_user, conf_dir: @conf_dir, key_file: @key_file, conf_file: @conf_file)
end

#institutionsFigshare::Institutions

Create Figshare::Institutions, if it doesn’t exist. Initialized with @figshare_user and @conf_dir



56
57
58
# File 'lib/figshare_api_v2.rb', line 56

def institutions
  @institutions ||= Institutions.new(figshare_user: @figshare_user, conf_dir: @conf_dir, key_file: @key_file, conf_file: @conf_file)
end

#oai_pmhFigshare::OAI_PMH

Create Figshare::OAI_PMH, if it doesn’t exist. Initialized with @figshare_user and @conf_dir

Returns:



126
127
128
# File 'lib/figshare_api_v2.rb', line 126

def oai_pmh
  @oai_pmh ||= OAI_PMH.new(figshare_user: @figshare_user, conf_dir: @conf_dir, key_file: @key_file, conf_file: @conf_file)
end

#otherFigshare::Other

Create Figshare::Other, if it doesn’t exist. Initialized with @figshare_user and @conf_dir

Returns:



63
64
65
# File 'lib/figshare_api_v2.rb', line 63

def other
  @other ||= Other.new(figshare_user: @figshare_user, conf_dir: @conf_dir, key_file: @key_file, conf_file: @conf_file)
end

#private_articlesFigshare::PrivateArticles

Create Figshare::PrivateArticles, if it doesn’t exist. Initialized with @figshare_user and @conf_dir



70
71
72
# File 'lib/figshare_api_v2.rb', line 70

def private_articles
  @private_articles ||= PrivateArticles.new(figshare_user: @figshare_user, conf_dir: @conf_dir, key_file: @key_file, conf_file: @conf_file)
end

#private_collectionsFigshare::PrivateCollections

Create Figshare::PrivateCollections, if it doesn’t exist. Initialized with @figshare_user and @conf_dir



77
78
79
# File 'lib/figshare_api_v2.rb', line 77

def private_collections
  @private_collections ||= PrivateCollections.new(figshare_user: @figshare_user, conf_dir: @conf_dir, key_file: @key_file, conf_file: @conf_file)
end

#private_projectsFigshare::PrivateProjects

Create Figshare::PrivateProjects, if it doesn’t exist. Initialized with @figshare_user and @conf_dir



84
85
86
# File 'lib/figshare_api_v2.rb', line 84

def private_projects
  @private_projects ||= PrivateProjects.new(figshare_user: @figshare_user, conf_dir: @conf_dir, key_file: @key_file, conf_file: @conf_file)
end

#public_articlesFigshare::PublicArticles

Create Figshare::PublicArticles, if it doesn’t exist. Initialized with @figshare_user and @conf_dir



91
92
93
# File 'lib/figshare_api_v2.rb', line 91

def public_articles
  @public_articles ||= PublicArticles.new(figshare_user: @figshare_user, conf_dir: @conf_dir, key_file: @key_file, conf_file: @conf_file)
end

#public_collectionsFigshare::PublicCollections

Create Figshare::PublicCollections, if it doesn’t exist. Initialized with @figshare_user and @conf_dir



98
99
100
# File 'lib/figshare_api_v2.rb', line 98

def public_collections
  @public_collections ||= PublicCollections.new(figshare_user: @figshare_user, conf_dir: @conf_dir, key_file: @key_file, conf_file: @conf_file)
end

#public_projectsFigshare::PublicProjects

Create Figshare::PublicProjects, if it doesn’t exist. Initialized with @figshare_user and @conf_dir



105
106
107
# File 'lib/figshare_api_v2.rb', line 105

def public_projects
  @public_projects ||= PublicProjects.new(figshare_user: @figshare_user, conf_dir: @conf_dir, key_file: @key_file, conf_file: @conf_file)
end

#statsFigshare::Stats

Create Figshare::Stats, if it doesn’t exist. Initialized with @figshare_user and @conf_dir

Returns:



119
120
121
# File 'lib/figshare_api_v2.rb', line 119

def stats
  @stats ||= Stats.new(figshare_user: @figshare_user, conf_dir: @conf_dir, key_file: @key_file, conf_file: @conf_file)
end

#uploadFigshare::Upload

Create Figshare::Upload, if it doesn’t exist. Initialized with @figshare_user and @conf_dir

Returns:



112
113
114
# File 'lib/figshare_api_v2.rb', line 112

def upload
  @upload ||= Upload.new(figshare_user: @figshare_user, conf_dir: @conf_dir, key_file: @key_file, conf_file: @conf_file)
end