aptly_cli 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzcyZmFhOTBmMDQwMzIyMzc2ZjIzNjlmYzhjMGU3ZGEyZGY4NGVlNQ==
4
+ MjgxZjZkOWNiN2IzYTBmNjcwYjg0YzM1NTc5YmZjZDc1ZWM5ZDQ2NQ==
5
5
  data.tar.gz: !binary |-
6
- YWI5NDgwNDE1ZGMzZTA4YWEyNmFmOTBmMjc5Y2NiNDk5MGI1ZTQ4ZQ==
6
+ YTBmMDI4NTI5MDNjNDJjM2U1YzMzZjRhNTQ2YTVlYWNlYjFlMmI2Yg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGRkZDU2YzY4ZDMwMmYyNTBjNmRkMTNlM2I2NzJlMTA1YTU1NzY1OGVlMmZh
10
- Mzk2NGRmMDFjMmFiZGYzMThhMDU3MGQ3YmY4YTg4YTZjOTBmZTRmMTM5ZGY4
11
- NjVhMWEyOTI2MzdmNGJmNTc0YTdmYzdhOTA0NjNlOGQ4ZDgxMTc=
9
+ NWQxMzI2Yzg0YjFiZjI0OGE2MDI5M2ZjNDA2MWQzMjQxNjA3OWQ5OTM3ZTFl
10
+ NWRkM2I5MjMzOTMwYWE4NzEwZWE1MTAxMTFlOGJmZDc5NzNiOGVlNGRkODlj
11
+ ZWM4ZjgyNGM4MGQ0YmE3MDBkNjA5ZjhjODdlNTM5YTQ3MmMyMGU=
12
12
  data.tar.gz: !binary |-
13
- NjczN2E0NmExNTc1Yzc4ZTViYTkwN2U5OTQ5YjI3NmIyNTZkMTc4NDNmOTc3
14
- YTE1YzI2NTVkM2MyMzBmY2FjMDBjMDIyZTVhYmIzZTJmMWQ2Y2NhOTU3MTUw
15
- MjI5MTY5ZjZhMjdhZDVjNWM3ZTZlMjczMzJkODRkMTM2MzI4YmI=
13
+ YTA2NTJhMjZjYjhkMTBkMzM0ZGNiNzllNjkyMDFlMDIzNDg3NDY2MWYwNjYx
14
+ NmQ4OTJjNmVmZDE4NzEyM2I2ZTI3MjIzODE2NGQ4YThjOGZjYTA2MjEzMzFi
15
+ YWE0MzJmMjQzNjVlM2Y0MGM2ZWNkYThiNWQ4ZWZkOGNlZTg5MTc=
data/.rubocop_todo.yml CHANGED
@@ -1,12 +1,12 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2016-03-18 19:51:36 -0700 using RuboCop version 0.38.0.
3
+ # on 2016-03-20 13:34:32 -0700 using RuboCop version 0.38.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 23
9
+ # Offense count: 20
10
10
  # Cop supports --auto-correct.
11
11
  # Configuration parameters: AlignWith, SupportedStyles.
12
12
  # SupportedStyles: either, start_of_block, start_of_line
@@ -14,7 +14,6 @@ Lint/BlockAlignment:
14
14
  Exclude:
15
15
  - 'test/test_aptly_misc.rb'
16
16
  - 'test/test_aptly_package.rb'
17
- - 'test/test_aptly_publish.rb'
18
17
  - 'test/test_aptly_repo.rb'
19
18
  - 'test/test_aptly_snapshot.rb'
20
19
 
@@ -25,7 +24,7 @@ Lint/UnusedBlockArgument:
25
24
  Exclude:
26
25
  - 'bin/aptly-cli'
27
26
 
28
- # Offense count: 60
27
+ # Offense count: 62
29
28
  Lint/UselessAssignment:
30
29
  Exclude:
31
30
  - 'test/test_aptly_cli_configure.rb'
@@ -36,31 +35,31 @@ Lint/UselessAssignment:
36
35
  - 'test/test_aptly_repo.rb'
37
36
  - 'test/test_aptly_snapshot.rb'
38
37
 
39
- # Offense count: 3
38
+ # Offense count: 2
40
39
  Metrics/AbcSize:
41
- Max: 32
40
+ Max: 31
42
41
 
43
42
  # Offense count: 1
44
43
  # Configuration parameters: CountComments.
45
44
  Metrics/ClassLength:
46
- Max: 111
45
+ Max: 108
47
46
 
48
- # Offense count: 2
47
+ # Offense count: 1
49
48
  Metrics/CyclomaticComplexity:
50
49
  Max: 9
51
50
 
52
- # Offense count: 153
51
+ # Offense count: 147
53
52
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
54
53
  # URISchemes: http, https
55
54
  Metrics/LineLength:
56
55
  Max: 524
57
56
 
58
- # Offense count: 8
57
+ # Offense count: 9
59
58
  # Configuration parameters: CountComments.
60
59
  Metrics/MethodLength:
61
- Max: 38
60
+ Max: 34
62
61
 
63
- # Offense count: 2
62
+ # Offense count: 1
64
63
  Metrics/PerceivedComplexity:
65
64
  Max: 10
66
65
 
@@ -75,22 +74,22 @@ Style/AlignArray:
75
74
  Exclude:
76
75
  - 'lib/aptly_publish.rb'
77
76
 
78
- # Offense count: 3
77
+ # Offense count: 8
79
78
  # Cop supports --auto-correct.
80
79
  # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
81
80
  # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
82
81
  Style/AlignHash:
83
82
  Exclude:
84
83
  - 'bin/aptly-cli'
84
+ - 'test/test_aptly_publish.rb'
85
85
 
86
- # Offense count: 3
86
+ # Offense count: 2
87
87
  # Cop supports --auto-correct.
88
88
  # Configuration parameters: EnforcedStyle, SupportedStyles.
89
89
  # SupportedStyles: always, conditionals
90
90
  Style/AndOr:
91
91
  Exclude:
92
92
  - 'bin/aptly-cli'
93
- - 'lib/aptly_repo.rb'
94
93
 
95
94
  # Offense count: 20
96
95
  # Cop supports --auto-correct.
@@ -102,13 +101,6 @@ Style/BracesAroundHashParameters:
102
101
  - 'test/test_aptly_repo.rb'
103
102
  - 'test/test_aptly_snapshot.rb'
104
103
 
105
- # Offense count: 1
106
- # Cop supports --auto-correct.
107
- # Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep, IndentationWidth.
108
- # SupportedStyles: case, end
109
- Style/CaseIndentation:
110
- Enabled: false
111
-
112
104
  # Offense count: 3
113
105
  Style/ClassVars:
114
106
  Exclude:
@@ -116,44 +108,22 @@ Style/ClassVars:
116
108
 
117
109
  # Offense count: 1
118
110
  # Cop supports --auto-correct.
119
- Style/ColonMethodCall:
120
- Exclude:
121
- - 'lib/aptly_load.rb'
122
-
123
- # Offense count: 4
124
- # Cop supports --auto-correct.
125
111
  # Configuration parameters: SingleLineConditionsOnly.
126
112
  Style/ConditionalAssignment:
127
113
  Exclude:
128
- - 'lib/aptly_file.rb'
129
- - 'lib/aptly_repo.rb'
130
114
  - 'lib/aptly_snapshot.rb'
131
115
 
132
- # Offense count: 3
133
- # Cop supports --auto-correct.
134
- Style/DefWithParentheses:
135
- Exclude:
136
- - 'lib/aptly_file.rb'
137
- - 'lib/aptly_misc.rb'
138
- - 'lib/aptly_repo.rb'
139
-
140
116
  # Offense count: 2
141
117
  # Cop supports --auto-correct.
142
118
  Style/DeprecatedHashMethods:
143
119
  Exclude:
144
120
  - 'lib/aptly_snapshot.rb'
145
121
 
146
- # Offense count: 7
122
+ # Offense count: 1
147
123
  Style/Documentation:
148
124
  Exclude:
149
125
  - 'spec/**/*'
150
126
  - 'test/**/*'
151
- - 'lib/aptly_cli.rb'
152
- - 'lib/aptly_file.rb'
153
- - 'lib/aptly_load.rb'
154
- - 'lib/aptly_misc.rb'
155
- - 'lib/aptly_package.rb'
156
- - 'lib/aptly_repo.rb'
157
127
  - 'lib/aptly_snapshot.rb'
158
128
 
159
129
  # Offense count: 2
@@ -163,7 +133,7 @@ Style/EmptyLines:
163
133
  - 'test/test_aptly_file.rb'
164
134
  - 'test/test_aptly_repo.rb'
165
135
 
166
- # Offense count: 50
136
+ # Offense count: 45
167
137
  # Cop supports --auto-correct.
168
138
  # Configuration parameters: EnforcedStyle, SupportedStyles.
169
139
  # SupportedStyles: empty_lines, no_empty_lines
@@ -176,72 +146,38 @@ Style/EmptyLinesAroundBlockBody:
176
146
  - 'test/test_aptly_repo.rb'
177
147
  - 'test/test_aptly_snapshot.rb'
178
148
 
179
- # Offense count: 7
149
+ # Offense count: 2
180
150
  # Cop supports --auto-correct.
181
151
  # Configuration parameters: EnforcedStyle, SupportedStyles.
182
152
  # SupportedStyles: empty_lines, no_empty_lines
183
153
  Style/EmptyLinesAroundClassBody:
184
154
  Exclude:
185
- - 'lib/aptly_misc.rb'
186
- - 'lib/aptly_package.rb'
187
- - 'lib/aptly_repo.rb'
188
155
  - 'lib/aptly_snapshot.rb'
189
156
  - 'test/test_aptly_cli_configure.rb'
190
157
 
191
- # Offense count: 5
158
+ # Offense count: 3
192
159
  # Cop supports --auto-correct.
193
160
  Style/EmptyLinesAroundMethodBody:
194
161
  Exclude:
195
- - 'lib/aptly_repo.rb'
196
162
  - 'lib/aptly_snapshot.rb'
197
163
 
198
- # Offense count: 1
199
- # Cop supports --auto-correct.
200
- # Configuration parameters: EnforcedStyle, SupportedStyles.
201
- # SupportedStyles: empty_lines, no_empty_lines
202
- Style/EmptyLinesAroundModuleBody:
203
- Exclude:
204
- - 'lib/aptly_cli.rb'
205
-
206
- # Offense count: 2
207
- # Cop supports --auto-correct.
208
- Style/EmptyLiteral:
209
- Exclude:
210
- - 'lib/aptly_repo.rb'
211
-
212
- # Offense count: 1
213
- # Configuration parameters: MinBodyLength.
214
- Style/GuardClause:
215
- Exclude:
216
- - 'lib/aptly_repo.rb'
217
-
218
- # Offense count: 162
164
+ # Offense count: 130
219
165
  # Cop supports --auto-correct.
220
166
  # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
221
167
  # SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
222
168
  Style/HashSyntax:
223
169
  Enabled: false
224
170
 
225
- # Offense count: 13
171
+ # Offense count: 7
226
172
  # Cop supports --auto-correct.
227
173
  # Configuration parameters: MaxLineLength.
228
174
  Style/IfUnlessModifier:
229
175
  Exclude:
230
176
  - 'bin/aptly-cli'
231
- - 'lib/aptly_file.rb'
232
- - 'lib/aptly_misc.rb'
233
- - 'lib/aptly_package.rb'
234
- - 'lib/aptly_repo.rb'
177
+ - 'lib/aptly_publish.rb'
235
178
  - 'lib/aptly_snapshot.rb'
236
179
 
237
- # Offense count: 2
238
- # Cop supports --auto-correct.
239
- # Configuration parameters: SupportedStyles, IndentationWidth.
240
- # SupportedStyles: special_inside_parentheses, consistent, align_braces
241
- Style/IndentHash:
242
- EnforcedStyle: align_braces
243
-
244
- # Offense count: 22
180
+ # Offense count: 30
245
181
  # Cop supports --auto-correct.
246
182
  # Configuration parameters: EnforcedStyle, SupportedStyles.
247
183
  # SupportedStyles: normal, rails
@@ -271,14 +207,13 @@ Style/LeadingCommentSpace:
271
207
  Exclude:
272
208
  - 'test/minitest_helper.rb'
273
209
 
274
- # Offense count: 9
210
+ # Offense count: 8
275
211
  # Cop supports --auto-correct.
276
212
  Style/MethodCallParentheses:
277
213
  Exclude:
278
214
  - 'bin/aptly-cli'
279
215
  - 'test/test_aptly_file.rb'
280
216
  - 'test/test_aptly_misc.rb'
281
- - 'test/test_aptly_publish.rb'
282
217
  - 'test/test_aptly_repo.rb'
283
218
 
284
219
  # Offense count: 2
@@ -287,12 +222,6 @@ Style/MethodCallParentheses:
287
222
  Style/MethodName:
288
223
  Enabled: false
289
224
 
290
- # Offense count: 4
291
- # Cop supports --auto-correct.
292
- Style/NilComparison:
293
- Exclude:
294
- - 'lib/aptly_repo.rb'
295
-
296
225
  # Offense count: 2
297
226
  # Cop supports --auto-correct.
298
227
  # Configuration parameters: PreferredDelimiters.
@@ -300,77 +229,64 @@ Style/PercentLiteralDelimiters:
300
229
  Exclude:
301
230
  - 'aptly_cli.gemspec'
302
231
 
303
- # Offense count: 2
232
+ # Offense count: 1
304
233
  # Configuration parameters: SupportedStyles.
305
234
  # SupportedStyles: compact, exploded
306
235
  Style/RaiseArgs:
307
236
  EnforcedStyle: compact
308
237
 
309
- # Offense count: 14
238
+ # Offense count: 15
310
239
  # Cop supports --auto-correct.
311
240
  Style/RedundantParentheses:
312
241
  Exclude:
313
242
  - 'test/test_aptly_file.rb'
314
243
  - 'test/test_aptly_misc.rb'
244
+ - 'test/test_aptly_publish.rb'
315
245
  - 'test/test_aptly_snapshot.rb'
316
246
 
317
- # Offense count: 1
247
+ # Offense count: 2
318
248
  # Cop supports --auto-correct.
319
249
  # Configuration parameters: AllowMultipleReturnValues.
320
250
  Style/RedundantReturn:
321
251
  Exclude:
252
+ - 'lib/aptly_publish.rb'
322
253
  - 'lib/aptly_repo.rb'
323
254
 
324
- # Offense count: 8
255
+ # Offense count: 7
325
256
  # Cop supports --auto-correct.
326
257
  Style/SpaceAfterComma:
327
258
  Exclude:
328
- - 'lib/aptly_load.rb'
329
259
  - 'test/test_aptly_snapshot.rb'
330
260
 
331
- # Offense count: 8
261
+ # Offense count: 6
332
262
  # Cop supports --auto-correct.
333
263
  # Configuration parameters: AllowForAlignment.
334
264
  Style/SpaceAroundOperators:
335
265
  Exclude:
336
- - 'lib/aptly_repo.rb'
337
266
  - 'lib/aptly_snapshot.rb'
338
267
  - 'test/test_aptly_snapshot.rb'
339
268
 
340
- # Offense count: 3
269
+ # Offense count: 1
341
270
  # Cop supports --auto-correct.
342
271
  # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
343
272
  # SupportedStyles: space, no_space
344
273
  Style/SpaceInsideBlockBraces:
345
274
  Enabled: false
346
275
 
347
- # Offense count: 65
276
+ # Offense count: 51
348
277
  # Cop supports --auto-correct.
349
278
  # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
350
279
  # SupportedStyles: space, no_space
351
280
  Style/SpaceInsideHashLiteralBraces:
352
281
  Enabled: false
353
282
 
354
- # Offense count: 1
355
- # Cop supports --auto-correct.
356
- Style/SpaceInsideParens:
357
- Exclude:
358
- - 'lib/aptly_file.rb'
359
-
360
- # Offense count: 249
283
+ # Offense count: 189
361
284
  # Cop supports --auto-correct.
362
285
  # Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
363
286
  # SupportedStyles: single_quotes, double_quotes
364
287
  Style/StringLiterals:
365
288
  Enabled: false
366
289
 
367
- # Offense count: 3
368
- # Cop supports --auto-correct.
369
- # Configuration parameters: EnforcedStyle, SupportedStyles.
370
- # SupportedStyles: single_quotes, double_quotes
371
- Style/StringLiteralsInInterpolation:
372
- Enabled: false
373
-
374
290
  # Offense count: 2
375
291
  # Cop supports --auto-correct.
376
292
  # Configuration parameters: EnforcedStyle, SupportedStyles.
@@ -380,15 +296,12 @@ Style/TrailingBlankLines:
380
296
  - 'bin/aptly-cli'
381
297
  - 'test/test_aptly_file.rb'
382
298
 
383
- # Offense count: 104
299
+ # Offense count: 66
384
300
  # Cop supports --auto-correct.
385
301
  Style/TrailingWhitespace:
386
302
  Exclude:
387
303
  - 'aptly_cli.gemspec'
388
304
  - 'bin/aptly-cli'
389
- - 'lib/aptly_file.rb'
390
- - 'lib/aptly_load.rb'
391
- - 'lib/aptly_repo.rb'
392
305
  - 'lib/aptly_snapshot.rb'
393
306
  - 'test/test_aptly_cli_configure.rb'
394
307
  - 'test/test_aptly_file.rb'
@@ -412,14 +325,10 @@ Style/UnlessElse:
412
325
  Exclude:
413
326
  - 'lib/aptly_snapshot.rb'
414
327
 
415
- # Offense count: 11
328
+ # Offense count: 3
416
329
  # Cop supports --auto-correct.
417
330
  Style/UnneededInterpolation:
418
331
  Exclude:
419
- - 'lib/aptly_file.rb'
420
- - 'lib/aptly_misc.rb'
421
- - 'lib/aptly_package.rb'
422
- - 'lib/aptly_repo.rb'
423
332
  - 'lib/aptly_snapshot.rb'
424
333
 
425
334
  # Offense count: 2
@@ -427,3 +336,10 @@ Style/UnneededInterpolation:
427
336
  Style/UnneededPercentQ:
428
337
  Exclude:
429
338
  - 'aptly_cli.gemspec'
339
+
340
+ # Offense count: 1
341
+ # Cop supports --auto-correct.
342
+ # Configuration parameters: SupportedStyles, MinSize, WordRegex.
343
+ # SupportedStyles: percent, brackets
344
+ Style/WordArray:
345
+ EnforcedStyle: brackets
@@ -1,3 +1,3 @@
1
1
  module AptlyCli
2
- VERSION = '0.2.5'.freeze
2
+ VERSION = '0.2.6'.freeze
3
3
  end
data/lib/aptly_load.rb CHANGED
@@ -5,6 +5,10 @@ require 'logger'
5
5
  module AptlyCli
6
6
  # Load aptly-cli configuration
7
7
  class AptlyLoad
8
+ def config
9
+ @config
10
+ end
11
+
8
12
  def initialize
9
13
  @log = Logger.new(STDOUT)
10
14
  @log.level = Logger::WARN
@@ -30,8 +34,8 @@ module AptlyCli
30
34
  begin
31
35
  config = YAML.load(IO.read(path_to_yaml_file))
32
36
  rescue Errno::ENOENT
33
- @log.warn('YAML configuration file couldn\'t be found at
34
- /etc/aptly-cli.conf. Using defaults.')
37
+ @log.warn(
38
+ 'YAML configuration file couldn\'t be found at /etc/aptly-cli.conf. Using defaults.')
35
39
  return @config
36
40
  rescue Psych::SyntaxError
37
41
  @log.warn(
@@ -40,9 +44,5 @@ module AptlyCli
40
44
  end
41
45
  configure(config)
42
46
  end
43
-
44
- def config
45
- @config
46
- end
47
47
  end
48
48
  end
data/lib/aptly_package.rb CHANGED
@@ -1,31 +1,28 @@
1
- require "aptly_cli/version"
2
- require "aptly_load"
3
- require "httmultiparty"
4
- require "json"
1
+ require 'aptly_cli/version'
2
+ require 'aptly_load'
3
+ require 'httmultiparty'
4
+ require 'json'
5
5
 
6
6
  module AptlyCli
7
+ # Aptly Package API
7
8
  class AptlyPackage
8
-
9
9
  include HTTMultiParty
10
10
 
11
11
  # Load aptly-cli.conf and establish base_uri
12
- config = AptlyCli::AptlyLoad.new.configure_with("/etc/aptly-cli.conf")
12
+ config = AptlyCli::AptlyLoad.new.configure_with('/etc/aptly-cli.conf')
13
13
  base_uri "http://#{config[:server]}:#{config[:port]}/api"
14
14
 
15
15
  if config[:username]
16
16
  if config[:password]
17
- basic_auth "#{config[:username]}", "#{config[:password]}"
17
+ basic_auth config[:username].to_s, config[:password].to_s
18
18
  end
19
19
  end
20
20
 
21
- if config[:debug] == true
22
- debug_output $stdout
23
- end
21
+ debug_output $stdout if config[:debug] == true
24
22
 
25
23
  def package_show(package_key)
26
24
  uri = "/packages/#{package_key}"
27
25
  self.class.get(uri)
28
26
  end
29
-
30
27
  end
31
28
  end
data/lib/aptly_repo.rb CHANGED
@@ -1,154 +1,135 @@
1
- require "aptly_cli/version"
2
- require "aptly_load"
3
- require "httmultiparty"
4
- require "json"
1
+ require 'aptly_cli/version'
2
+ require 'aptly_load'
3
+ require 'httmultiparty'
4
+ require 'json'
5
5
 
6
6
  module AptlyCli
7
+ # Aplty class to work with Repo API
7
8
  class AptlyRepo
8
-
9
9
  include HTTMultiParty
10
-
11
10
  # Load aptly-cli.conf and establish base_uri
12
- config = AptlyCli::AptlyLoad.new.configure_with("/etc/aptly-cli.conf")
11
+ config = AptlyCli::AptlyLoad.new.configure_with('/etc/aptly-cli.conf')
13
12
  base_uri "http://#{config[:server]}:#{config[:port]}/api"
14
13
 
15
14
  if config[:username]
16
15
  if config[:password]
17
- basic_auth "#{config[:username]}", "#{config[:password]}"
16
+ basic_auth config[:username].to_s, config[:password].to_s
18
17
  end
19
18
  end
19
+ debug_output $stdout if config[:debug] == true
20
20
 
21
- if config[:debug] == true
22
- debug_output $stdout
23
- end
24
-
25
- def repo_create(repo_options = {:name => nil, :comment => nil, :DefaultDistribution => nil, :DefaultComponent => nil})
26
- uri = "/repos"
21
+ def repo_create(repo_options = { name: nil,
22
+ comment: nil,
23
+ DefaultDistribution: nil,
24
+ DefaultComponent: nil })
25
+ uri = '/repos'
27
26
  name = repo_options[:name]
28
27
  comment = repo_options[:comment]
29
28
  default_distribution = repo_options[:DefaultDistribution]
30
29
  default_component = repo_options[:DefaultComponent]
31
-
32
- self.class.post(uri, :query => { 'Name' => name, 'Comment' => comment, 'DefaultDistribution' => default_distribution, 'DefaultComponent' => default_component }.to_json, :headers => {'Content-Type'=>'application/json'})
30
+ self.class.post(uri,
31
+ query:
32
+ { 'Name' => name, 'Comment' => comment,
33
+ 'DefaultDistribution' => default_distribution,
34
+ 'DefaultComponent' => default_component }.to_json,
35
+ headers: { 'Content-Type' => 'application/json' })
33
36
  end
34
37
 
35
- def repo_delete(repo_options = {:name => nil, :force => nil})
36
- uri = "/repos/" + repo_options[:name]
37
-
38
- if repo_options[:force] == true
39
- uri += "?force=1"
40
- end
41
-
38
+ def repo_delete(repo_options = { name: nil, force: nil })
39
+ uri = '/repos/' + repo_options[:name]
40
+ uri += '?force=1' if repo_options[:force] == true
42
41
  self.class.delete(uri)
43
42
  end
44
43
 
45
44
  def repo_edit(name, repo_options = { k => v })
46
- repo_option = String.new
47
- repo_value = String.new
48
-
49
- if name == nil
50
- raise ArgumentError.new('Must pass a repository name')
51
- else
52
- uri = "/repos/" + name
53
- end
54
-
45
+ repo_option = ''
46
+ repo_value = ''
47
+ uri = '/repos/' + name unless name.nil?
55
48
  repo_options.each do |k, v|
56
49
  repo_option = k
57
50
  repo_value = v
58
51
  end
59
52
 
60
- self.class.put(uri, :query => { repo_option => repo_value }.to_json, :headers => {'Content-Type'=>'application/json'})
53
+ self.class.put(uri, query: { repo_option => repo_value }.to_json,
54
+ headers: { 'Content-Type' => 'application/json' })
61
55
  end
62
56
 
63
- def repo_list()
64
- uri = "/repos"
65
-
57
+ def repo_list
58
+ uri = '/repos'
66
59
  self.class.get(uri)
67
60
  end
68
-
69
- def repo_package_query(repo_options = {:name => nil, :query => nil, :withdeps => false, :format => nil})
70
- if repo_options[:name] == nil
61
+
62
+ def repo_package_query(repo_options = { name: nil, query: nil,
63
+ with_deps: false,
64
+ format: nil })
65
+ if repo_options[:name].nil?
71
66
  raise ArgumentError.new('Must pass a repository name')
72
67
  else
73
- uri = "/repos/" + repo_options[:name] + "/packages"
74
- end
75
-
76
- if repo_options[:query]
77
- uri += "?q=" + repo_options[:query]
78
- if repo_options[:withdeps] or repo_options[:format]
79
- puts "When specifiying specific package query, other options are invalid."
80
- end
81
- elsif repo_options[:format]
82
- uri += "?format=#{repo_options[:format]}"
83
- elsif repo_options[:withdeps] == true
84
- uri += "?withDeps=1"
68
+ uri = '/repos/' + repo_options[:name] + '/packages'
85
69
  end
86
-
87
- self.class.get uri
88
-
70
+ uri += if repo_options[:query]
71
+ "?q=#{repo_options[:query]}"
72
+ elsif repo_options[:format]
73
+ "?format=#{repo_options[:format]}"
74
+ elsif repo_options[:with_deps]
75
+ '?withDeps=1'
76
+ else
77
+ ''
78
+ end
79
+ self.class.get uri
89
80
  end
90
81
 
91
82
  def repo_show(name)
92
- if name == nil
93
- uri = "/repos"
94
- else
95
- uri = "/repos/" + name
96
- end
97
-
98
- self.class.get uri
83
+ uri = if name.nil?
84
+ '/repos'
85
+ else
86
+ '/repos/' + name
87
+ end
88
+ self.class.get uri
99
89
  end
100
90
 
101
- def repo_upload(repo_options = {:name => nil, :dir => nil, :file => nil,
102
- :noremove => false, :forcereplace => false})
91
+ def repo_upload(repo_options = { name: nil, dir: nil, file: nil,
92
+ noremove: false, forcereplace: false })
103
93
 
104
94
  name = repo_options[:name]
105
95
  dir = repo_options[:dir]
106
96
  file = repo_options[:file]
107
97
  noremove = repo_options[:noremove]
108
98
  forcereplace = repo_options[:forcereplace]
109
-
110
- if file == nil
111
- uri = "/repos/#{name}/file/#{dir}"
112
- else
113
- uri = "/repos/#{name}/file/#{dir}/#{file}"
114
- end
115
-
116
- if forcereplace == true
117
- uri += "?forceReplace=1"
118
- end
119
-
120
- if noremove == true
121
- uri += "?noRemove=1"
122
- end
123
-
99
+ uri = if file.nil?
100
+ "/repos/#{name}/file/#{dir}"
101
+ else
102
+ "/repos/#{name}/file/#{dir}/#{file}"
103
+ end
104
+
105
+ uri += '?forceReplace=1' if forcereplace == true
106
+ uri += '?noRemove=1' if noremove == true
124
107
  response = self.class.post(uri)
125
-
108
+
126
109
  case response.code
127
- when 404
128
- puts 'repository with such name does not exist'
110
+ when 404
111
+ puts 'repository with such name does not exist'
129
112
  end
130
113
 
131
114
  json_response = JSON.parse(response.body)
132
-
133
- unless json_response["FailedFiles"].empty?
115
+
116
+ unless json_response['FailedFiles'].empty?
134
117
  begin
135
118
  rescue StandardError => e
136
- puts "Files that failed to upload... #{json_response["FailedFiles"]}"
119
+ puts "Files that failed to upload... #{json_response['FailedFiles']}"
137
120
  puts e
138
121
  end
139
122
  end
140
123
 
141
- unless json_response["Report"]["Warnings"].empty?
124
+ unless json_response['Report']['Warnings'].empty?
142
125
  begin
143
126
  rescue StandardError => e
144
- puts "File upload warning message[s]...#{json_response["Report"]["Warnings"]}"
127
+ puts "File upload warning message[s]...\
128
+ #{json_response['Report']['Warnings']}"
145
129
  puts e
146
130
  end
147
131
  end
148
-
149
132
  return response
150
-
151
- end
152
-
133
+ end
153
134
  end
154
135
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptly_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler