aptly-api 0.4.1 → 0.5.0

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
  SHA1:
3
- metadata.gz: 2ad1e37dd7595391142d77328208cd96f2b57aa1
4
- data.tar.gz: 6d7901b8f560056366b7cdf8c6a58d054ced4345
3
+ metadata.gz: f4366fc69e420aae0067501a98a0cc13de7e78b9
4
+ data.tar.gz: 34924e0d41b9f8c7779e7bd00aa63ae670acde88
5
5
  SHA512:
6
- metadata.gz: 4c4943d6505487279027b4fa866018bba678f4768f456d20877a9fa5ed767fddc3bf8c52e1d0c5f456bb5674ed9bb7ef32e78f8857686f9afafbe2391c0106b3
7
- data.tar.gz: a510b670bf6afde990e3373bc98b2375f93414ae2ea6b074181724f01cbecad364236a84a904cb33d4a9e0d5af4174a4ecdfa85c203d98b1ce0643dc31bdef41
6
+ metadata.gz: cd772f0145fef0826037da2b127d4c661aa939bde965355ae17626fccda320cd34e590819f0c7646d88ab2c6a002e97fbd3792b74159520b6b71bb6492ef8067
7
+ data.tar.gz: 262cb466331fdd8c08992174c8827604d2b0d26265de412927128e17059b11a5307120ab9676251e2af5c13e557432c364877dc57ac884a00cb05f9ac1c32aa5
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.1
4
+ - 2.3.0
4
5
  before_install: gem install bundler -v 1.10.6
data/README.md CHANGED
@@ -28,8 +28,7 @@ Or install it yourself as:
28
28
  require 'aptly'
29
29
 
30
30
  Aptly.configure do |config|
31
- config.host = 'localhost'
32
- config.port = 8080
31
+ config.uri = URI::HTTP.build(host: 'localhost', port: 8080)
33
32
  end
34
33
 
35
34
  repo = Aptly::Repository.create('kewl-new-repo')
@@ -40,6 +39,9 @@ end
40
39
  repo.publish('public-name', Distribution: 'wily', Architectures: %w(amd64 i386))
41
40
  ```
42
41
 
42
+ ## Documentation
43
+ http://www.rubydoc.info/gems/aptly-api/Aptly/
44
+
43
45
  ## Development
44
46
 
45
47
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,36 +1,63 @@
1
+ require 'rubygems/deprecate'
2
+
1
3
  module Aptly
2
4
  # Configuration.
3
5
  class Configuration
6
+ extend Gem::Deprecate
7
+
8
+ # @!attribute uri
9
+ # @return [URI] the base URI for the API (http://localhost by default)
10
+ attr_accessor :uri
11
+
12
+ # Creates a new instance.
13
+ # @param uri see {#uri}
14
+ # @param host DEPRECATED use uri
15
+ # @param port DEPRECATED use uri
16
+ # @param path DEPRECATED use uri
17
+ def initialize(uri: URI::HTTP.build(host: 'localhost',
18
+ port: 80,
19
+ path: '/'),
20
+ host: nil, port: nil, path: nil)
21
+ @uri = uri unless host || port || path
22
+ return if @uri
23
+ @uri = fallback_uri(host, port, path)
24
+ end
25
+
4
26
  # @!attribute host
27
+ # @deprecated use {#uri}
5
28
  # @return [String] host name to talk to
6
- attr_accessor :host
7
29
 
8
30
  # @!attribute port
31
+ # @deprecated use {#uri}
9
32
  # @return [Integer] port to talk to host to on
10
- attr_accessor :port
11
33
 
12
34
  # @!attribute path
35
+ # @deprecated use {#uri}
13
36
  # @return [String] path to use (defaults to /)
14
- attr_accessor :path
15
37
 
16
- # Creates a new instance.
17
- # @param host see {#host}
18
- # @param port see {#port}
19
- def initialize(host: 'localhost', port: 80, path: '/')
20
- @host = host
21
- @port = port
22
- @path = path
38
+ # Fake deprecated attributes and redirect them to @uri
39
+ [:host, :port, :path].each do |uri_attr|
40
+ define_method(uri_attr.to_s) do
41
+ @uri.send(uri_attr)
42
+ end
43
+ deprecate uri_attr, :uri, 2017, 1
44
+ define_method("#{uri_attr}=") do |x|
45
+ # Ruby < 2.3 does not manage to handle string ports, so we need
46
+ # to manually convert to integer.
47
+ @uri.send("#{uri_attr}=", uri_attr == :port ? safe_port(x) : x)
48
+ end
49
+ deprecate "#{uri_attr}=".to_sym, :uri, 2017, 1
50
+ end
51
+
52
+ private
53
+
54
+ def safe_port(port)
55
+ port ? port.to_i : port
23
56
  end
24
57
 
25
- def uri
26
- # FIXME: maybe we should simply configure a URI instead of configuring
27
- # each part?
28
- uri = URI.parse('')
29
- uri.scheme = 'http'
30
- uri.host = host
31
- uri.port = port
32
- uri.path = path
33
- uri
58
+ def fallback_uri(host, port, path)
59
+ URI::HTTP.build(host: host || 'localhost', port: safe_port(port || 80),
60
+ path: path || '/')
34
61
  end
35
62
  end
36
63
  end
data/lib/aptly/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # Aptly API
2
2
  module Aptly
3
- VERSION = '0.4.1'.freeze
3
+ VERSION = '0.5.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptly-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harald Sitter
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-09-21 00:00:00.000000000 Z
12
+ date: 2016-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler