Class: Gemfury::Client
- Inherits:
-
Object
- Object
- Gemfury::Client
- 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
-
#account_info ⇒ Hash
Get the information for the current account.
-
#accounts ⇒ Array<Hash>
Get the information for the all accounts that this account has some level of access to.
-
#add_collaborator(login, options = {}) ⇒ Hash
Add a collaborator to the account.
-
#get_access_token(*args) ⇒ Object
LEGACY: Authentication token via email/password.
-
#git_config(repo, options = {}) ⇒ Hash
List Git repo’s build configuration.
-
#git_config_update(repo, updates, options = {}) ⇒ Hash
Update Git repo’s build configuration.
-
#git_rebuild(repo, options = {}) ⇒ Hash
Rebuild Git repository package.
-
#git_repos(options = {}) ⇒ Hash
List Git repos for this account.
-
#git_reset(repo, options = {}) ⇒ Hash
Reset repository to initial state.
-
#git_update(repo, options = {}) ⇒ Hash
Update repository name and settings.
-
#initialize(options = {}) ⇒ Client
constructor
Creates a new API.
-
#list(options = {}) ⇒ Array<Hash>
List available artifacts.
-
#list_collaborators(options = {}) ⇒ Array<Hash>
List collaborators for this account.
-
#login(email, password, opts = {}) ⇒ Hash
Get authentication info via email/password.
-
#logout ⇒ Hash
Invalidate session token.
-
#push_gem(file, options = {}) ⇒ Hash
Upload an artifact file.
-
#remove_collaborator(login, options = {}) ⇒ Hash
Remove a collaborator to the account.
-
#versions(name, options = {}) ⇒ Array<Hash>
List versions for an artifact.
-
#yank_version(name, version, options = {}) ⇒ Hash
Delete an artifact version.
Constructor Details
#initialize(options = {}) ⇒ Client
Creates a new API
10 11 12 13 14 15 |
# File 'lib/gemfury/client.rb', line 10 def initialize( = {}) = Gemfury..merge() Gemfury::VALID_OPTIONS_KEYS.each do |key| send("#{key}=", [key]) end end |
Instance Method Details
#account_info ⇒ Hash
Get the information for the current account
19 20 21 22 23 |
# File 'lib/gemfury/client.rb', line 19 def account_info ensure_ready!(:authorization) response = connection.get('users/me') checked_response_body(response) end |
#accounts ⇒ Array<Hash>
Get the information for the all accounts that this account has some level of access to
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
112 113 114 115 116 117 |
# File 'lib/gemfury/client.rb', line 112 def add_collaborator(login, = {}) ensure_ready!(:authorization) url = "collaborators/#{escape(login)}" response = connection.put(url, ) 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) login(*args)['token'] end |
#git_config(repo, options = {}) ⇒ Hash
List Git repo’s build configuration
174 175 176 177 178 179 |
# File 'lib/gemfury/client.rb', line 174 def git_config(repo, = {}) ensure_ready!(:authorization) path = "#{git_repo_path(repo)}/config-vars" response = connection.get(path, ) checked_response_body(response) end |
#git_config_update(repo, updates, options = {}) ⇒ Hash
Update Git repo’s build configuration
186 187 188 189 190 191 192 |
# File 'lib/gemfury/client.rb', line 186 def git_config_update(repo, updates, = {}) ensure_ready!(:authorization) path = "#{git_repo_path(repo)}/config-vars" opts = .merge(config_vars: updates) response = connection.patch(path, opts) checked_response_body(response) end |
#git_rebuild(repo, options = {}) ⇒ Hash
Rebuild Git repository package
163 164 165 166 167 168 |
# File 'lib/gemfury/client.rb', line 163 def git_rebuild(repo, = {}) ensure_ready!(:authorization) url = "#{git_repo_path(repo)}/builds" api = connection(api_format: :text) checked_response_body(api.post(url, )) end |
#git_repos(options = {}) ⇒ Hash
List Git repos for this account
133 134 135 136 137 |
# File 'lib/gemfury/client.rb', line 133 def git_repos( = {}) ensure_ready!(:authorization) response = connection.get(git_repo_path, ) checked_response_body(response) end |
#git_reset(repo, options = {}) ⇒ Hash
Reset repository to initial state
153 154 155 156 157 |
# File 'lib/gemfury/client.rb', line 153 def git_reset(repo, = {}) ensure_ready!(:authorization) response = connection.delete(git_repo_path(repo), ) checked_response_body(response) end |
#git_update(repo, options = {}) ⇒ Hash
Update repository name and settings
143 144 145 146 147 |
# File 'lib/gemfury/client.rb', line 143 def git_update(repo, = {}) ensure_ready!(:authorization) response = connection.patch(git_repo_path(repo), ) checked_response_body(response) end |
#list(options = {}) ⇒ Array<Hash>
List available artifacts
47 48 49 50 51 |
# File 'lib/gemfury/client.rb', line 47 def list( = {}) ensure_ready!(:authorization) response = connection.get('gems', ) checked_response_body(response) end |
#list_collaborators(options = {}) ⇒ Array<Hash>
List collaborators for this account
103 104 105 106 107 |
# File 'lib/gemfury/client.rb', line 103 def list_collaborators( = {}) ensure_ready!(:authorization) response = connection.get('collaborators', ) checked_response_body(response) end |
#login(email, password, opts = {}) ⇒ Hash
Get authentication info via email/password
86 87 88 89 90 |
# File 'lib/gemfury/client.rb', line 86 def login(email, password, opts = {}) ensure_ready! opts = opts.merge(email: email, password: password) checked_response_body(connection.post('login', opts)) end |
#logout ⇒ Hash
Invalidate session token
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
37 38 39 40 41 42 |
# File 'lib/gemfury/client.rb', line 37 def push_gem(file, = {}) ensure_ready!(:authorization) push_api = connection(url: pushpoint) response = push_api.post('uploads', .merge(file: file)) checked_response_body(response) end |
#remove_collaborator(login, options = {}) ⇒ Hash
Remove a collaborator to the account
123 124 125 126 127 128 |
# File 'lib/gemfury/client.rb', line 123 def remove_collaborator(login, = {}) ensure_ready!(:authorization) url = "collaborators/#{escape(login)}" response = connection.delete(url, ) checked_response_body(response) end |
#versions(name, options = {}) ⇒ Array<Hash>
List versions for an artifact
57 58 59 60 61 62 |
# File 'lib/gemfury/client.rb', line 57 def versions(name, = {}) ensure_ready!(:authorization) url = "gems/#{escape(name)}/versions" response = connection.get(url, ) checked_response_body(response) end |
#yank_version(name, version, options = {}) ⇒ Hash
Delete an artifact version
69 70 71 72 73 74 |
# File 'lib/gemfury/client.rb', line 69 def yank_version(name, version, = {}) ensure_ready!(:authorization) url = "gems/#{escape(name)}/versions/#{escape(version)}" response = connection.delete(url, ) checked_response_body(response) end |