aptly-api 0.6.2 → 0.7.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: 79ced71b1cd9922919fe97c154e793f0f9bc21db
4
- data.tar.gz: 1d2e0d76380078c95a75c35691d3d337f0ad8e22
3
+ metadata.gz: 9efbe6f74dd549cd105d0fcb98789e58ab3e4d79
4
+ data.tar.gz: 8f2ec5e7dc006199444dcb714c3aea3e34a0940b
5
5
  SHA512:
6
- metadata.gz: 34774e02ed4bfeb26c39d6e16923012e768ac997539c945f11f65c72ef0bd1f48c2ba563852e8cb7415c62d21c8a3f150cb8aefcf40b3b6266c6b9edb14c4b41
7
- data.tar.gz: fde5d5743c21e7dbacf7edd0ad6a1d71aa5a8a2c151667c79e437e0495b28f2c22d3ce0dced080da752a9e7614d7b33160fe530694db1f76c7e471679e812477
6
+ metadata.gz: 3c899648d86ab6eeddc83d38368958adf3c829a1881c148beca3bb3b40c48cec0f9232c4dc6f969fbf1dffad3215f6b15fb4c0c2bffe04918e2320f702e69b18
7
+ data.tar.gz: 29231774db283cfaad31859c0d6feb2355c010e1e8791ea9ec7df1d85d6b3388a2304db98b81175e054d306fecd279a9a028b355629adc8d0a0d3eca6ff445f8
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Change Log
2
+
3
+ ## [0.7.0]
4
+ ### Added
5
+ - Aptly.escape_prefix is a new helper method to turn prefixes into
6
+ REST API format.
7
+
8
+ ### Changed
9
+ - Aptly.publish and all publishing methods built on top of it now raise an
10
+ InvalidPrefixError when they encounter a forward-slash in the publishing
11
+ prefix. Aptly's REST API enforces prefixes to be encoded with _ as __ and
12
+ / as _ unfortuantely as this is ambiguous we cannot automatically determine
13
+ if a prefix is encoded or unencoded. To retain backwards compatibility the
14
+ assumption is that is is encoded and if it clearly is not an error is raised.
15
+ For 1.0 this expectation is changing to assume the prefix is unencoded and
16
+ will be forcefully encoded!
data/lib/aptly.rb CHANGED
@@ -35,11 +35,14 @@ module Aptly
35
35
 
36
36
  # Publish 1 or more sources into a public repository prefix.
37
37
  # @param sources [Array<Repository>] array of repositories to source
38
- # @param prefix [String] the prefix to publish under
38
+ # @param prefix [String] the prefix to publish under (must be escaped see
39
+ # {#escape_prefix})
39
40
  # @param source_kind [String] the source kind (local or snapshot)
40
41
  # @return [PublishedRepository] newly published repository
41
42
  def publish(sources, prefix = '', source_kind = 'local',
42
43
  connection = Connection.new, **kwords)
44
+ # TODO: 1.0 break compat and invert the assertion to want unescaped
45
+ raise Errors::InvalidPrefixError if prefix.include?('/')
43
46
  kwords = kwords.map { |k, v| [k.to_s.capitalize, v] }.to_h
44
47
  options = kwords.merge(
45
48
  SourceKind: source_kind,
@@ -49,5 +52,14 @@ module Aptly
49
52
  body: JSON.generate(options))
50
53
  PublishedRepository.new(connection, JSON.parse(response.body))
51
54
  end
55
+
56
+ # Translates a pathish prefix (e.g. 'dev/unstable_x') to an API-safe prefix
57
+ # (e.g. 'dev_unstable__x')
58
+ # See prefix format description on https://www.aptly.info/doc/api/publish/
59
+ # @return [String] API-safe prefix notation
60
+ # @since 0.7.0
61
+ def escape_prefix(prefix_path)
62
+ prefix_path.tr('_', '__').tr('/', '_')
63
+ end
52
64
  end
53
65
  end
data/lib/aptly/errors.rb CHANGED
@@ -67,5 +67,13 @@ module Aptly
67
67
  end
68
68
  end
69
69
  end
70
+
71
+ # Raised when a publishing prefix contains a slash when it was expected to
72
+ # be in API-safe format.
73
+ # Unfortunately we cannot automatically coerce as the safe format has
74
+ # character overlap with an unsafe format (_ means something in both), so
75
+ # we'll expect the API consumer to only hand us suitable prefixes.
76
+ # https://www.aptly.info/doc/api/publish/
77
+ class InvalidPrefixError < StandardError; end
70
78
  end
71
79
  end
data/lib/aptly/publish.rb CHANGED
@@ -50,7 +50,7 @@ module Aptly
50
50
  # _ => __
51
51
  # / => _
52
52
  def api_prefix
53
- self.Prefix.tr('_', '__').tr('/', '_')
53
+ ::Aptly.escape_prefix(self.Prefix)
54
54
  end
55
55
 
56
56
  def parse_sources
data/lib/aptly/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # Aptly API
2
2
  module Aptly
3
- VERSION = '0.6.2'.freeze
3
+ VERSION = '0.7.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.6.2
4
+ version: 0.7.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: 2017-03-23 00:00:00.000000000 Z
12
+ date: 2017-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -161,6 +161,7 @@ files:
161
161
  - ".gitignore"
162
162
  - ".rubocop.yml"
163
163
  - ".travis.yml"
164
+ - CHANGELOG.md
164
165
  - CODE_OF_CONDUCT.md
165
166
  - COPYING.lib
166
167
  - Gemfile
@@ -201,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
202
  version: '0'
202
203
  requirements: []
203
204
  rubyforge_project:
204
- rubygems_version: 2.6.10
205
+ rubygems_version: 2.6.11
205
206
  signing_key:
206
207
  specification_version: 4
207
208
  summary: REST client for the Aptly API