gemfury 0.11.0 → 0.12.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d12fa40cc9a3b147996465039acb3ff1c44e121bc4c71679921f6db4c4729e9e
4
- data.tar.gz: f0bf5539051922fd64bf240badf8b20e44d14cef36cd07de055b4710e764e05f
3
+ metadata.gz: fa1399aeab2f739da48ef55e4a7a6654ce9bb8527d722a9b7ce022ac082f2c2f
4
+ data.tar.gz: 176541eb909afc8610b8a4f94b3653dece97f898518a69fc137a7bd46533df25
5
5
  SHA512:
6
- metadata.gz: 71a4bff9746b91c43de50d4f75796fd832e8b3cb2bc1b3b14be952be17c1a93a41b9725d4fc33b878d2a06620060748c8d29a607f1d74988b50ee613cef546d2
7
- data.tar.gz: 3727b26c52de5c5f218f6fa81c5ed34a179e8a88805bd3e2846dc55f37e3fc931c047a723ba085c52dc68cb2b628fb88aa1932ea1ac87acc3584350b328f4c8f
6
+ metadata.gz: c69342a8284196e6e43b9a3dc3bead88cfe17b2ae098db213d5055314d703aefada6e5df8f4cd3d08a8c6a413bc27f211bd8f8be3dd802f4a8000f3c35121666
7
+ data.tar.gz: ed29f372dbec0526a614d2d8bb4ca8982ab47114a0c3d42857c4f06a480db690f7d9c898221b3be654b1e177f5d20f78382aa2069318a732b2a1ee08fb2ea71c
data/README.md CHANGED
@@ -4,6 +4,8 @@ Gemfury CLI
4
4
  [![Gem Version](https://badge.fury.io/rb/gemfury.svg)](http://badge.fury.io/rb/gemfury)
5
5
  [![Build Status](https://secure.travis-ci.org/gemfury/gemfury.svg?branch=master)](https://travis-ci.org/gemfury/gemfury)
6
6
  [![Code Climate](https://codeclimate.com/github/gemfury/gemfury/badges/gpa.svg)](https://codeclimate.com/github/gemfury/gemfury)
7
+ [![Documentation](https://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/gemfury)
8
+ [![Documentation completeness](https://inch-ci.org/github/gemfury/gemfury.svg?branch=master)](http://inch-ci.org/github/gemfury/gemfury)
7
9
 
8
10
  This is the Gemfury CLI used to manage your Gemfury packages from the command line. If you're
9
11
  familiar with the service and want to jump straight into command line action, please proceed to
@@ -30,6 +32,29 @@ any package to any host. It's simple, reliable, and hassle-free.
30
32
  * [Install private Composer packages](https://gemfury.com/help/php-composer-server)
31
33
  * [Private RubyGems on Heroku](https://gemfury.com/help/private-gems-on-heroku)
32
34
 
35
+
36
+ ## Using the Gemfury Client
37
+
38
+ You can also use the client directly via Ruby; you will need a "Full access token" (API token) from `https://manage.fury.io/manage/YOUR-ACCOUNT-NAME/tokens/api`
39
+
40
+ ```ruby
41
+ require 'gemfury'
42
+
43
+ client = Gemfury::Client.new(user_api_key: "YOUR API TOKEN")
44
+
45
+ all_artifacts = client.list
46
+ puts "Available artifacts:"
47
+ puts all_artifacts
48
+
49
+ one_artifact = all_artifacts[0]
50
+ puts "Versions of the #{one_artifact['language']} artifact #{one_artifact['name']}:"
51
+ artifact_versions = client.versions(one_artifact["name"])
52
+ puts artifact_versions.map { |v| v["version"] }
53
+ ```
54
+
55
+ More information about the `Gemfury::Client` API is [hosted on rubydoc.info](https://rubydoc.info/gems/gemfury/Gemfury/Client).
56
+
57
+
33
58
  ## Contribution and Improvements
34
59
 
35
60
  Please [email us](mailto:support@gemfury.com) if we've missed some key functionality or you have problems installing the CLI client. Better yet, fork the code, make the changes, and submit a pull request to speed things along.
@@ -59,4 +84,4 @@ Over time, dependencies for this gem will get stale and may interfere with your
59
84
 
60
85
  ## Questions
61
86
 
62
- Please email support@gemfury.com or file a Github Issue if you have any other questions or problems.
87
+ Please email support@gemfury.com or file a Github Issue if you have any other questions or problems.
@@ -1,5 +1,5 @@
1
1
  gem "multi_json", "~> 1.10"
2
- gem "faraday", ">= 0.9.0", "< 0.16.0.pre"
2
+ gem "faraday", ">= 0.9.0", "< 1.1.0.pre"
3
3
  gem "netrc", ">= 0.10.0", "< 0.12.0.pre"
4
4
 
5
5
  require 'time'
@@ -23,6 +23,8 @@ require 'gemfury/client'
23
23
 
24
24
  module Gemfury
25
25
  extend Configuration
26
+ VALID_OPTIONS_KEYS = Configuration::CONFIGURATION_DEFAULTS.keys.freeze
27
+
26
28
  class << self
27
29
  # Alias for Gemfury::Client.new
28
30
  #
@@ -31,6 +33,27 @@ module Gemfury
31
33
  Gemfury::Client.new(options)
32
34
  end
33
35
 
36
+ # Convenience method to allow configuration options to be set in a block
37
+ def configure
38
+ yield self
39
+ end
40
+
41
+ # Create a hash of options and their values
42
+ # @return [Hash] the options and their values
43
+ def options
44
+ VALID_OPTIONS_KEYS.inject({}) do |options, k|
45
+ options[k] = send(k)
46
+ options
47
+ end
48
+ end
49
+
50
+ # Reset all configuration options to defaults
51
+ # @return [Configuration] The default configuration
52
+ def reset
53
+ CONFIGURATION_DEFAULTS.each { |k, v| send("#{k}=", v) }
54
+ self
55
+ end
56
+
34
57
  # Delegate to Gemfury::Client
35
58
  def method_missing(method, *args, &block)
36
59
  return super unless new.respond_to?(method)
@@ -40,14 +63,20 @@ module Gemfury
40
63
  def respond_to?(method, include_private = false)
41
64
  new.respond_to?(method, include_private) || super(method, include_private)
42
65
  end
66
+
43
67
  end
44
68
  end
45
69
 
70
+ # Initialize configuration
71
+ Gemfury.reset
72
+
73
+ # Polyfill #dig for Ruby 2.2 and earlier
46
74
  class Hash
47
- # Access nested hashes as a period-separated path
48
- def path(path, separator = '.')
49
- path.split(separator).inject(self) do |hash, part|
50
- hash.is_a?(Hash) ? hash[part] : nil
75
+ unless self.instance_methods.include?(:dig)
76
+ def dig(*parts)
77
+ parts.inject(self) do |hash, part|
78
+ hash.is_a?(Hash) ? hash[part] : nil
79
+ end
51
80
  end
52
81
  end
53
82
  end
@@ -1,31 +1,37 @@
1
1
  module Gemfury
2
2
  class Client
3
3
  include Gemfury::Client::Filters
4
- attr_accessor *Configuration::VALID_OPTIONS_KEYS
4
+ include Gemfury::Configuration
5
5
 
6
6
  # Creates a new API
7
+ # @param options [Hash] values for attributes described in {Gemfury::Configuration}
7
8
  def initialize(options={})
8
9
  options = Gemfury.options.merge(options)
9
- Configuration::VALID_OPTIONS_KEYS.each do |key|
10
+ Gemfury::VALID_OPTIONS_KEYS.each do |key|
10
11
  send("#{key}=", options[key])
11
12
  end
12
13
  end
13
14
 
14
15
  # Get the information for the current account
16
+ # @return [Hash]
15
17
  def account_info
16
18
  ensure_ready!(:authorization)
17
19
  response = connection.get('users/me')
18
20
  checked_response_body(response)
19
21
  end
20
22
 
21
- # Get the information for the current account
23
+ # Get the information for the all accounts that this account has some level of access to
24
+ # @return [Array<Hash>]
22
25
  def accounts
23
26
  ensure_ready!(:authorization)
24
27
  response = connection.get('accounts')
25
28
  checked_response_body(response)
26
29
  end
27
30
 
28
- # Uploading a gem file
31
+ # Upload an artifact file
32
+ # @param file [String] the filename to upload
33
+ # @param options [Hash] Faraday client options
34
+ # @return [Hash]
29
35
  def push_gem(file, options = {})
30
36
  ensure_ready!(:authorization)
31
37
  push_api = connection(:url => self.pushpoint)
@@ -33,14 +39,19 @@ module Gemfury
33
39
  checked_response_body(response)
34
40
  end
35
41
 
36
- # List available gems
42
+ # List available artifacts
43
+ # @param options [Hash] Faraday client options
44
+ # @return [Array<Hash>]
37
45
  def list(options = {})
38
46
  ensure_ready!(:authorization)
39
47
  response = connection.get('gems', options)
40
48
  checked_response_body(response)
41
49
  end
42
50
 
43
- # List versions for a gem
51
+ # List versions for an artifact
52
+ # @param name [String] the name of the artifact
53
+ # @param options [Hash] Faraday client options
54
+ # @return [Array<Hash>]
44
55
  def versions(name, options = {})
45
56
  ensure_ready!(:authorization)
46
57
  url = "gems/#{escape(name)}/versions"
@@ -48,7 +59,11 @@ module Gemfury
48
59
  checked_response_body(response)
49
60
  end
50
61
 
51
- # Delete a gem version
62
+ # Delete an artifact version
63
+ # @param name [String] the name of the artifact
64
+ # @param version [String] the version of the artifact
65
+ # @param options [Hash] Faraday client options
66
+ # @return [Hash]
52
67
  def yank_version(name, version, options = {})
53
68
  ensure_ready!(:authorization)
54
69
  url = "gems/#{escape(name)}/versions/#{escape(version)}"
@@ -62,6 +77,10 @@ module Gemfury
62
77
  end
63
78
 
64
79
  # Get authentication info via email/password
80
+ # @param email [String] the account email address
81
+ # @param password [String] the account password
82
+ # @param opts [Hash] Faraday client options
83
+ # @return [Hash]
65
84
  def login(email, password, opts = {})
66
85
  ensure_ready!
67
86
  opts = opts.merge(:email => email, :password => password)
@@ -69,6 +88,7 @@ module Gemfury
69
88
  end
70
89
 
71
90
  # Invalidate session token
91
+ # @return [Hash]
72
92
  def logout
73
93
  ensure_ready!(:authorization)
74
94
  response = connection.post('logout')
@@ -76,6 +96,8 @@ module Gemfury
76
96
  end
77
97
 
78
98
  # List collaborators for this account
99
+ # @param options [Hash] Faraday client options
100
+ # @return [Array<Hash>]
79
101
  def list_collaborators(options = {})
80
102
  ensure_ready!(:authorization)
81
103
  response = connection.get('collaborators', options)
@@ -83,6 +105,8 @@ module Gemfury
83
105
  end
84
106
 
85
107
  # Add a collaborator to the account
108
+ # @param options [Hash] Faraday client options
109
+ # @return [Hash]
86
110
  def add_collaborator(login, options = {})
87
111
  ensure_ready!(:authorization)
88
112
  url = "collaborators/#{escape(login)}"
@@ -91,6 +115,9 @@ module Gemfury
91
115
  end
92
116
 
93
117
  # Remove a collaborator to the account
118
+ # @param login [String] the account login
119
+ # @param options [Hash] Faraday client options
120
+ # @return [Hash]
94
121
  def remove_collaborator(login, options = {})
95
122
  ensure_ready!(:authorization)
96
123
  url = "collaborators/#{escape(login)}"
@@ -99,6 +126,8 @@ module Gemfury
99
126
  end
100
127
 
101
128
  # List Git repos for this account
129
+ # @param options [Hash] Faraday client options
130
+ # @return [Hash]
102
131
  def git_repos(options = {})
103
132
  ensure_ready!(:authorization)
104
133
  response = connection.get(git_repo_path, options)
@@ -106,6 +135,9 @@ module Gemfury
106
135
  end
107
136
 
108
137
  # Update repository name and settings
138
+ # @param repo [String] the repo name
139
+ # @param options [Hash] Faraday client options
140
+ # @return [Hash]
109
141
  def git_update(repo, options = {})
110
142
  ensure_ready!(:authorization)
111
143
  response = connection.patch(git_repo_path(repo), options)
@@ -113,6 +145,9 @@ module Gemfury
113
145
  end
114
146
 
115
147
  # Reset repository to initial state
148
+ # @param repo [String] the repo name
149
+ # @param options [Hash] Faraday client options
150
+ # @return [Hash]
116
151
  def git_reset(repo, options = {})
117
152
  ensure_ready!(:authorization)
118
153
  response = connection.delete(git_repo_path(repo), options)
@@ -120,6 +155,9 @@ module Gemfury
120
155
  end
121
156
 
122
157
  # Rebuild Git repository package
158
+ # @param repo [String] the repo name
159
+ # @param options [Hash] Faraday client options
160
+ # @return [Hash]
123
161
  def git_rebuild(repo, options = {})
124
162
  ensure_ready!(:authorization)
125
163
  url = "#{git_repo_path(repo)}/builds"
@@ -127,6 +165,30 @@ module Gemfury
127
165
  checked_response_body(api.post(url, options))
128
166
  end
129
167
 
168
+ # List Git repo's build configuration
169
+ # @param repo [String] the repo name
170
+ # @param options [Hash] Faraday client options
171
+ # @return [Hash]
172
+ def git_config(repo, options = {})
173
+ ensure_ready!(:authorization)
174
+ path = "#{git_repo_path(repo)}/config-vars"
175
+ response = connection.get(path, options)
176
+ checked_response_body(response)
177
+ end
178
+
179
+ # Update Git repo's build configuration
180
+ # @param repo [String] the repo name
181
+ # @param updates [Hash] Updates to configuration
182
+ # @param options [Hash] Faraday client options
183
+ # @return [Hash]
184
+ def git_config_update(repo, updates, options = {})
185
+ ensure_ready!(:authorization)
186
+ path = "#{git_repo_path(repo)}/config-vars"
187
+ opts = options.merge(:config_vars => updates)
188
+ response = connection.patch(path, opts)
189
+ checked_response_body(response)
190
+ end
191
+
130
192
  private
131
193
  def escape(str)
132
194
  CGI.escape(str)
@@ -1,5 +1,6 @@
1
+ gem "progressbar", ">= 1.10.1", "< 2.0.0.pre"
1
2
  gem "highline", ">= 1.6.0", "< 2.1.0.pre"
2
- gem "thor", ">= 0.14.0", "< 1.0.0.pre"
3
+ gem "thor", ">= 0.14.0", "< 1.1.0.pre"
3
4
 
4
5
  require 'thor'
5
6
  require 'yaml'
@@ -35,7 +35,7 @@ class Gemfury::Command::App < Thor
35
35
  va = [ %w{ name kind version privacy } ]
36
36
  gems.each do |g|
37
37
  va << [ g['name'], g['language'],
38
- g.path('latest_version.version') || 'beta',
38
+ g.dig('latest_version', 'version') || 'beta',
39
39
  g['private'] ? 'private' : 'public ' ]
40
40
  end
41
41
 
@@ -224,6 +224,40 @@ class Gemfury::Command::App < Thor
224
224
  end
225
225
  end
226
226
 
227
+ ### GIT REPOSITORY BUILD CONFIG ###
228
+ map 'git:config' => 'git_config'
229
+ map 'git:config:set' => 'git_config_set'
230
+ map 'git:config:unset' => 'git_config_unset'
231
+
232
+ desc "git:config", "List Git repository's build environment"
233
+ def git_config(repo)
234
+ with_checks_and_rescues do
235
+ vars = client.git_config(repo)['config_vars']
236
+ shell.say "*** #{repo} build config ***\n"
237
+ shell.print_table(vars.map { |kv|
238
+ ["#{kv[0]}:", kv[1]]
239
+ })
240
+ end
241
+ end
242
+
243
+ desc "git:config:set", "Update Git repository's build environment"
244
+ def git_config_set(repo, *vars)
245
+ with_checks_and_rescues do
246
+ updates = Hash[vars.map { |v| v.split("=", 2) }]
247
+ client.git_config_update(repo, updates)
248
+ shell.say "Updated #{repo} build config"
249
+ end
250
+ end
251
+
252
+ desc "git:config:unset", "Remove variables from Git repository's build environment"
253
+ def git_config_unset(repo, *vars)
254
+ with_checks_and_rescues do
255
+ updates = Hash[vars.map { |v| [v, nil] }]
256
+ client.git_config_update(repo, updates)
257
+ shell.say "Updated #{repo} build config"
258
+ end
259
+ end
260
+
227
261
  private
228
262
  def client
229
263
  opts = {}
@@ -1,72 +1,48 @@
1
1
  module Gemfury
2
- # Defines constants and methods related to configuration
3
2
  module Configuration
4
- # An array of valid keys in the options hash when configuring
5
- VALID_OPTIONS_KEYS = [
6
- :user_api_key,
7
- :adapter,
8
- :endpoint,
9
- :gitpoint,
10
- :pushpoint,
11
- :user_agent,
12
- :api_version,
13
- :account].freeze
14
3
 
15
- # The adapter that will be used to connect if none is set
16
- DEFAULT_ADAPTER = :net_http
17
-
18
- # The endpoint that will be used to connect if none is set
19
- DEFAULT_ENDPOINT = 'https://api.fury.io/'.freeze
4
+ CONFIGURATION_DEFAULTS = {
5
+ :user_api_key => nil,
6
+ :adapter => :net_http,
7
+ :endpoint => 'https://api.fury.io/',
8
+ :gitpoint => 'https://git.fury.io/',
9
+ :pushpoint => 'https://push.fury.io/',
10
+ :user_agent => "Gemfury RubyGem #{Gemfury::VERSION} (Ruby #{RUBY_VERSION})",
11
+ :api_version => 1,
12
+ :account => nil
13
+ }.freeze
14
+
15
+ # user API key, also known as "full access token"
16
+ # @return [String]
17
+ attr_accessor :user_api_key
18
+
19
+ # The adapter that will be used to connect
20
+ # @return [Symbol]
21
+ attr_accessor :adapter
22
+
23
+ # The endpoint that will be used to connect
24
+ # @return [String]
25
+ attr_accessor :endpoint
20
26
 
21
27
  # The HTTP endpoint for git repo (used for .netrc credentials)
22
- DEFAULT_GITPOINT = 'https://git.fury.io/'.freeze
23
-
24
- # The endpoint for the Push API if not set
25
- DEFAULT_PUSHPOINT = 'https://push.fury.io/'.freeze
26
-
27
- # The value sent in the 'User-Agent' header if none is set
28
- DEFAULT_USER_AGENT = "Gemfury RubyGem #{Gemfury::VERSION}".freeze
29
-
30
- # Default API version
31
- DEFAULT_API_VERSION = 1
32
-
33
- # Default user API key
34
- DEFAULT_API_KEY = nil
35
-
36
- # Use the current account (no impersonation)
37
- DEFAULT_ACCOUNT = nil
38
-
39
- # @private
40
- attr_accessor *VALID_OPTIONS_KEYS
28
+ # @return [String]
29
+ attr_accessor :gitpoint
41
30
 
42
- # When this module is extended, set all configuration options to their default values
43
- def self.extended(base)
44
- base.reset
45
- end
31
+ # The endpoint for the Push API
32
+ # @return [String]
33
+ attr_accessor :pushpoint
46
34
 
47
- # Convenience method to allow configuration options to be set in a block
48
- def configure
49
- yield self
50
- end
35
+ # The value sent in the 'User-Agent' header
36
+ # @return [String]
37
+ attr_accessor :user_agent
51
38
 
52
- # Create a hash of options and their values
53
- def options
54
- options = {}
55
- VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
56
- options
57
- end
39
+ # Gemfury remote API version
40
+ # @return [Integer]
41
+ attr_accessor :api_version
58
42
 
59
- # Reset all configuration options to defaults
60
- def reset
61
- self.user_api_key = DEFAULT_API_KEY
62
- self.adapter = DEFAULT_ADAPTER
63
- self.endpoint = DEFAULT_ENDPOINT
64
- self.gitpoint = DEFAULT_GITPOINT
65
- self.pushpoint = DEFAULT_PUSHPOINT
66
- self.user_agent = DEFAULT_USER_AGENT
67
- self.api_version = DEFAULT_API_VERSION
68
- self.account = DEFAULT_ACCOUNT
69
- self
70
- end
43
+ # The account to impersonate, if you have permissions for multiple accounts
44
+ # (If nil, no impersonation)
45
+ # @return [String]
46
+ attr_accessor :account
71
47
  end
72
48
  end
@@ -1,3 +1,3 @@
1
1
  module Gemfury
2
- VERSION = '0.11.0'
2
+ VERSION = '0.12.0.rc1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemfury
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Rykov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-20 00:00:00.000000000 Z
11
+ date: 2020-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 0.14.0
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: 1.0.0.pre
36
+ version: 1.1.0.pre
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.14.0
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: 1.0.0.pre
46
+ version: 1.1.0.pre
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: netrc
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +73,7 @@ dependencies:
73
73
  version: 0.9.0
74
74
  - - "<"
75
75
  - !ruby/object:Gem::Version
76
- version: 0.16.0.pre
76
+ version: 1.1.0.pre
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
@@ -83,7 +83,7 @@ dependencies:
83
83
  version: 0.9.0
84
84
  - - "<"
85
85
  - !ruby/object:Gem::Version
86
- version: 0.16.0.pre
86
+ version: 1.1.0.pre
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: highline
89
89
  requirement: !ruby/object:Gem::Requirement
@@ -111,6 +111,9 @@ dependencies:
111
111
  - - ">="
112
112
  - !ruby/object:Gem::Version
113
113
  version: 1.10.1
114
+ - - "<"
115
+ - !ruby/object:Gem::Version
116
+ version: 2.0.0.pre
114
117
  type: :runtime
115
118
  prerelease: false
116
119
  version_requirements: !ruby/object:Gem::Requirement
@@ -118,6 +121,9 @@ dependencies:
118
121
  - - ">="
119
122
  - !ruby/object:Gem::Version
120
123
  version: 1.10.1
124
+ - - "<"
125
+ - !ruby/object:Gem::Version
126
+ version: 2.0.0.pre
121
127
  description: 'Hosted repo for your public and private packages at https://gemfury.com
122
128
 
123
129
  '
@@ -179,9 +185,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
185
  version: '0'
180
186
  required_rubygems_version: !ruby/object:Gem::Requirement
181
187
  requirements:
182
- - - ">="
188
+ - - ">"
183
189
  - !ruby/object:Gem::Version
184
- version: '0'
190
+ version: 1.3.1
185
191
  requirements: []
186
192
  rubyforge_project:
187
193
  rubygems_version: 2.7.8