Class: Gemfury::Client

Inherits:
Object
  • Object
show all
Includes:
Filters, Configuration
Defined in:
lib/gemfury/client.rb,
lib/gemfury/client/filters.rb,
lib/gemfury/client/middleware.rb

Defined Under Namespace

Modules: Filters Classes: Handle503, ParseJson

Constant Summary

Constants included from Configuration

Gemfury::Configuration::CONFIGURATION_DEFAULTS

Instance Attribute Summary

Attributes included from Configuration

#account, #adapter, #api_version, #endpoint, #gitpoint, #pushpoint, #user_agent, #user_api_key

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Creates a new API

Parameters:



10
11
12
13
14
15
# File 'lib/gemfury/client.rb', line 10

def initialize(options = {})
  options = Gemfury.options.merge(options)
  Gemfury::VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", options[key])
  end
end

Instance Method Details

#account_infoHash

Get the information for the current account

Returns:



19
20
21
22
23
# File 'lib/gemfury/client.rb', line 19

def 
  ensure_ready!(:authorization)
  response = connection.get('users/me')
  checked_response_body(response)
end

#accountsArray<Hash>

Get the information for the all accounts that this account has some level of access to

Returns:



27
28
29
30
31
# File 'lib/gemfury/client.rb', line 27

def accounts
  ensure_ready!(:authorization)
  response = connection.get('accounts')
  checked_response_body(response)
end

#add_collaborator(login, options = {}) ⇒ Hash

Add a collaborator to the account

Parameters:

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



112
113
114
115
116
117
# File 'lib/gemfury/client.rb', line 112

def add_collaborator(, options = {})
  ensure_ready!(:authorization)
  url = "collaborators/#{escape()}"
  response = connection.put(url, options)
  checked_response_body(response)
end

#get_access_token(*args) ⇒ Object

LEGACY: Authentication token via email/password



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

def get_access_token(*args)
  (*args)['token']
end

#git_config(repo, options = {}) ⇒ Hash

List Git repo’s build configuration

Parameters:

  • repo (String)

    the repo name

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



174
175
176
177
178
179
# File 'lib/gemfury/client.rb', line 174

def git_config(repo, options = {})
  ensure_ready!(:authorization)
  path = "#{git_repo_path(repo)}/config-vars"
  response = connection.get(path, options)
  checked_response_body(response)
end

#git_config_update(repo, updates, options = {}) ⇒ Hash

Update Git repo’s build configuration

Parameters:

  • repo (String)

    the repo name

  • updates (Hash)

    Updates to configuration

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



186
187
188
189
190
191
192
# File 'lib/gemfury/client.rb', line 186

def git_config_update(repo, updates, options = {})
  ensure_ready!(:authorization)
  path = "#{git_repo_path(repo)}/config-vars"
  opts = options.merge(config_vars: updates)
  response = connection.patch(path, opts)
  checked_response_body(response)
end

#git_rebuild(repo, options = {}) ⇒ Hash

Rebuild Git repository package

Parameters:

  • repo (String)

    the repo name

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



163
164
165
166
167
168
# File 'lib/gemfury/client.rb', line 163

def git_rebuild(repo, options = {})
  ensure_ready!(:authorization)
  url = "#{git_repo_path(repo)}/builds"
  api = connection(api_format: :text)
  checked_response_body(api.post(url, options))
end

#git_repos(options = {}) ⇒ Hash

List Git repos for this account

Parameters:

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



133
134
135
136
137
# File 'lib/gemfury/client.rb', line 133

def git_repos(options = {})
  ensure_ready!(:authorization)
  response = connection.get(git_repo_path, options)
  checked_response_body(response)
end

#git_reset(repo, options = {}) ⇒ Hash

Reset repository to initial state

Parameters:

  • repo (String)

    the repo name

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



153
154
155
156
157
# File 'lib/gemfury/client.rb', line 153

def git_reset(repo, options = {})
  ensure_ready!(:authorization)
  response = connection.delete(git_repo_path(repo), options)
  checked_response_body(response)
end

#git_update(repo, options = {}) ⇒ Hash

Update repository name and settings

Parameters:

  • repo (String)

    the repo name

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



143
144
145
146
147
# File 'lib/gemfury/client.rb', line 143

def git_update(repo, options = {})
  ensure_ready!(:authorization)
  response = connection.patch(git_repo_path(repo), options)
  checked_response_body(response)
end

#list(options = {}) ⇒ Array<Hash>

List available artifacts

Parameters:

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



47
48
49
50
51
# File 'lib/gemfury/client.rb', line 47

def list(options = {})
  ensure_ready!(:authorization)
  response = connection.get('gems', options)
  checked_response_body(response)
end

#list_collaborators(options = {}) ⇒ Array<Hash>

List collaborators for this account

Parameters:

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



103
104
105
106
107
# File 'lib/gemfury/client.rb', line 103

def list_collaborators(options = {})
  ensure_ready!(:authorization)
  response = connection.get('collaborators', options)
  checked_response_body(response)
end

#login(email, password, opts = {}) ⇒ Hash

Get authentication info via email/password

Parameters:

  • email (String)

    the account email address

  • password (String)

    the account password

  • opts (Hash) (defaults to: {})

    Faraday client options

Returns:



86
87
88
89
90
# File 'lib/gemfury/client.rb', line 86

def (email, password, opts = {})
  ensure_ready!
  opts = opts.merge(email: email, password: password)
  checked_response_body(connection.post('login', opts))
end

#logoutHash

Invalidate session token

Returns:



94
95
96
97
98
# File 'lib/gemfury/client.rb', line 94

def logout
  ensure_ready!(:authorization)
  response = connection.post('logout')
  checked_response_body(response)
end

#push_gem(file, options = {}) ⇒ Hash

Upload an artifact file

Parameters:

  • file (String)

    the filename to upload

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



37
38
39
40
41
42
# File 'lib/gemfury/client.rb', line 37

def push_gem(file, options = {})
  ensure_ready!(:authorization)
  push_api = connection(url: pushpoint)
  response = push_api.post('uploads', options.merge(file: file))
  checked_response_body(response)
end

#remove_collaborator(login, options = {}) ⇒ Hash

Remove a collaborator to the account

Parameters:

  • login (String)

    the account login

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



123
124
125
126
127
128
# File 'lib/gemfury/client.rb', line 123

def remove_collaborator(, options = {})
  ensure_ready!(:authorization)
  url = "collaborators/#{escape()}"
  response = connection.delete(url, options)
  checked_response_body(response)
end

#versions(name, options = {}) ⇒ Array<Hash>

List versions for an artifact

Parameters:

  • name (String)

    the name of the artifact

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



57
58
59
60
61
62
# File 'lib/gemfury/client.rb', line 57

def versions(name, options = {})
  ensure_ready!(:authorization)
  url = "gems/#{escape(name)}/versions"
  response = connection.get(url, options)
  checked_response_body(response)
end

#yank_version(name, version, options = {}) ⇒ Hash

Delete an artifact version

Parameters:

  • name (String)

    the name of the artifact

  • version (String)

    the version of the artifact

  • options (Hash) (defaults to: {})

    Faraday client options

Returns:



69
70
71
72
73
74
# File 'lib/gemfury/client.rb', line 69

def yank_version(name, version, options = {})
  ensure_ready!(:authorization)
  url = "gems/#{escape(name)}/versions/#{escape(version)}"
  response = connection.delete(url, options)
  checked_response_body(response)
end