aptly-api 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aptly/connection.rb +11 -2
- data/lib/aptly/repository.rb +35 -2
- data/lib/aptly/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50c0d2cde02dbc8cf5b02b56e74262b0dd087dbe
|
4
|
+
data.tar.gz: f7bdcbcfe2059813f9518c555ebdbaf9dbf4cf9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07024dad873ce1672950e0e035a988af09b01e277822c1d7a2887886b9295ea4d038beaf936e76b57b4eda651ce153bb27ecc5646b0247f44db08bc50cc2d78c
|
7
|
+
data.tar.gz: b4ae271870390480f2a5bd9da9c28e9f86205bece7cb376e1c4b391c880f39dc8f56df60a431a77aa456d516fd0724bc96597531f98f8caf5bd94bb568d37616
|
data/lib/aptly/connection.rb
CHANGED
@@ -51,7 +51,9 @@ module Aptly
|
|
51
51
|
|
52
52
|
def build_query(kwords)
|
53
53
|
query = @query.merge(kwords.delete(:query) { {} })
|
54
|
-
|
54
|
+
if kwords.delete(:query_mangle) { true }
|
55
|
+
query = query.map { |k, v| [k.to_s.capitalize, v] }.to_h
|
56
|
+
end
|
55
57
|
query
|
56
58
|
end
|
57
59
|
|
@@ -84,9 +86,16 @@ module Aptly
|
|
84
86
|
end
|
85
87
|
|
86
88
|
def run_getish(action, path, kwords)
|
89
|
+
body = kwords.delete(:body)
|
87
90
|
params = kwords.delete(:query)
|
88
91
|
headers = kwords.delete(:headers)
|
89
|
-
|
92
|
+
|
93
|
+
@connection.send(action, path, params, headers) do |request|
|
94
|
+
if body
|
95
|
+
request.headers[:content_type] = 'application/json'
|
96
|
+
request.body = body
|
97
|
+
end
|
98
|
+
end
|
90
99
|
end
|
91
100
|
|
92
101
|
def http_call(action, path, kwords)
|
data/lib/aptly/repository.rb
CHANGED
@@ -40,10 +40,35 @@ module Aptly
|
|
40
40
|
# @return [Array<String>] list of packages in the repository
|
41
41
|
def packages(**kwords)
|
42
42
|
response = connection.send(:get, "/repos/#{self.Name}/packages",
|
43
|
-
query: kwords
|
43
|
+
query: kwords,
|
44
|
+
query_mangle: false)
|
44
45
|
JSON.parse(response.body)
|
45
46
|
end
|
46
47
|
|
48
|
+
# Add a package (by key) to the repository.
|
49
|
+
# @param packages [Array<String>, String] a list of package keys or
|
50
|
+
# a single package key to add to the repository. The package key(s)
|
51
|
+
# must already be in the aptly database.
|
52
|
+
def add_package(packages, **kwords)
|
53
|
+
connection.send(:post, "/repos/#{self.Name}/packages",
|
54
|
+
query: kwords,
|
55
|
+
body: JSON.generate(PackageRefs: [*packages]))
|
56
|
+
self
|
57
|
+
end
|
58
|
+
alias_method :add_packages, :add_package
|
59
|
+
|
60
|
+
# Deletes a package (by key) from the repository.
|
61
|
+
# @param packages [Array<String>, String] a list of package keys or
|
62
|
+
# a single package key to add to the repository. The package key(s)
|
63
|
+
# must already be in the aptly database.
|
64
|
+
def delete_package(packages, **kwords)
|
65
|
+
connection.send(:delete, "/repos/#{self.Name}/packages",
|
66
|
+
query: kwords,
|
67
|
+
body: JSON.generate(PackageRefs: [*packages]))
|
68
|
+
self
|
69
|
+
end
|
70
|
+
alias_method :delete_packages, :delete_package
|
71
|
+
|
47
72
|
# Convenience wrapper around {Aptly.publish}, publishing this repository
|
48
73
|
# locally and as only source of prefix.
|
49
74
|
# @param prefix [String] prefix to publish under (i.e. published repo name)
|
@@ -102,13 +127,21 @@ module Aptly
|
|
102
127
|
# Check if a repository exists.
|
103
128
|
# @param name [String] the name of the repository which might exist
|
104
129
|
# @param connection [Connection] connection to use for the instance
|
105
|
-
# @return [Boolean] whether or not the
|
130
|
+
# @return [Boolean] whether or not the repository exists
|
106
131
|
def exist?(name, connection = Connection.new, **kwords)
|
107
132
|
get(name, connection, **kwords)
|
108
133
|
true
|
109
134
|
rescue Aptly::Errors::NotFoundError
|
110
135
|
false
|
111
136
|
end
|
137
|
+
|
138
|
+
# List all known repositories.
|
139
|
+
# @param connection [Connection] connection to use for the instance
|
140
|
+
# @return [Array<Repository>] all known repositories
|
141
|
+
def list(connection = Connection.new, **kwords)
|
142
|
+
response = connection.send(:get, '/repos', query: kwords)
|
143
|
+
JSON.parse(response.body).collect { |r| new(connection, r) }
|
144
|
+
end
|
112
145
|
end
|
113
146
|
end
|
114
147
|
end
|
data/lib/aptly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aptly-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harald Sitter
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
183
|
version: '0'
|
184
184
|
requirements: []
|
185
185
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.5.1
|
187
187
|
signing_key:
|
188
188
|
specification_version: 4
|
189
189
|
summary: REST client for the Aptly API
|