aptly_cli 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.rubocop.yml +3 -0
- data/lib/aptly_cli.rb +3 -3
- data/lib/aptly_cli/version.rb +1 -1
- data/lib/aptly_file.rb +22 -23
- data/lib/aptly_load.rb +18 -15
- data/lib/aptly_misc.rb +10 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWE5OGM3ZDMwNWNiMDMyY2I0YTJkNjQyMWRiY2E3MDJmN2EzMjEwZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmQ5NDc2YThjMTUwM2VmYmNjOTg4OTg1YzM5ZDk2NWU4MTcwMTYxYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzZkMGJiZmQ0YzkxYTIzYTUyNGQ2YzRhZDVlOTgxOTM0OGI3NDYyM2ZjMWU5
|
10
|
+
MjM5Yjg1MTk5ZGFlMmMyZWY1YWI4MWQ5NjIwNTdhODVhYWMwZmYzZjE0NmIw
|
11
|
+
NTc0MjI0OWMxMTcyMThmNzI0ZjlmYzA1Zjk3MGYzMDUwMzA1ZWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTllZGY4MGEzNGE5NTUwNGIyNzVjNmYzNzJlYWNjNTVlZjE5MDU0YjVmNTIz
|
14
|
+
ODVhMTExNTMwMDUyMTliMTQ5YTFkMzA4OTdlY2VmNjZmZGQ2NDRhYjE3YTFi
|
15
|
+
OGVhODljNDQ5ZDNiZTg3MWVjYzFmNDNjNjA1OGQ0OGU0NzI1OTM=
|
data/.rubocop.yml
CHANGED
data/lib/aptly_cli.rb
CHANGED
data/lib/aptly_cli/version.rb
CHANGED
data/lib/aptly_file.rb
CHANGED
@@ -1,54 +1,53 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'aptly_cli/version'
|
2
|
+
require 'aptly_load'
|
3
|
+
require 'httmultiparty'
|
4
4
|
|
5
5
|
module AptlyCli
|
6
|
+
# Uploading file into Aptly
|
6
7
|
class AptlyFile
|
7
|
-
|
8
8
|
include HTTMultiParty
|
9
9
|
attr_accessor :file_uri, :package, :local_file_path
|
10
10
|
|
11
11
|
# Load aptly-cli.conf and establish base_uri
|
12
|
-
config = AptlyCli::AptlyLoad.new.configure_with(
|
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
|
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 initialize(file_uri=nil, package=nil, local_file_path=nil)
|
26
24
|
end
|
27
25
|
|
28
|
-
def file_dir
|
29
|
-
uri =
|
26
|
+
def file_dir
|
27
|
+
uri = '/files'
|
30
28
|
self.class.get uri
|
31
29
|
end
|
32
30
|
|
33
31
|
def file_get(file_uri)
|
34
|
-
if file_uri ==
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
self.class.get uri
|
32
|
+
uri = if file_uri == '/'
|
33
|
+
'/files'
|
34
|
+
else
|
35
|
+
'/files/' + file_uri
|
36
|
+
end
|
37
|
+
self.class.get uri
|
41
38
|
end
|
42
39
|
|
43
40
|
def file_delete(file_uri)
|
44
|
-
uri =
|
45
|
-
self.class.delete uri
|
41
|
+
uri = '/files' + file_uri
|
42
|
+
self.class.delete uri
|
46
43
|
end
|
47
44
|
|
48
45
|
def file_post(post_options = {})
|
49
|
-
api_file_uri =
|
50
|
-
self.class.post(api_file_uri,
|
46
|
+
api_file_uri = '/files' + post_options[:file_uri].to_s
|
47
|
+
self.class.post(api_file_uri,
|
48
|
+
query: {
|
49
|
+
package: post_options[:package],
|
50
|
+
file: File.new(post_options[:local_file]) })
|
51
51
|
end
|
52
|
-
|
53
52
|
end
|
54
53
|
end
|
data/lib/aptly_load.rb
CHANGED
@@ -3,41 +3,44 @@ require 'yaml'
|
|
3
3
|
require 'logger'
|
4
4
|
|
5
5
|
module AptlyCli
|
6
|
+
# Load aptly-cli configuration
|
6
7
|
class AptlyLoad
|
7
|
-
|
8
8
|
def initialize
|
9
9
|
@log = Logger.new(STDOUT)
|
10
10
|
@log.level = Logger::WARN
|
11
|
-
|
11
|
+
|
12
12
|
# Configuration defaults
|
13
13
|
@config = {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
server: '127.0.0.1',
|
15
|
+
port: 8082
|
16
|
+
}
|
17
|
+
|
18
18
|
@valid_config_keys = @config.keys
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
# Configure through hash
|
22
22
|
def configure(opts = {})
|
23
|
-
opts.each
|
23
|
+
opts.each do |k, v|
|
24
|
+
config[k.to_sym] = v if @valid_config_keys.include? k.to_sym
|
25
|
+
end
|
24
26
|
end
|
25
|
-
|
27
|
+
|
26
28
|
# Configure through yaml file
|
27
29
|
def configure_with(path_to_yaml_file)
|
28
30
|
begin
|
29
|
-
config = YAML
|
31
|
+
config = YAML.load(IO.read(path_to_yaml_file))
|
30
32
|
rescue Errno::ENOENT
|
31
|
-
@log.warn(
|
33
|
+
@log.warn('YAML configuration file couldn\'t be found at
|
34
|
+
/etc/aptly-cli.conf. Using defaults.')
|
32
35
|
return @config
|
33
36
|
rescue Psych::SyntaxError
|
34
|
-
@log.warn(
|
35
|
-
|
37
|
+
@log.warn(
|
38
|
+
'YAML configuration file contains invalid syntax. Using defaults.')
|
39
|
+
return @config
|
36
40
|
end
|
37
|
-
|
38
41
|
configure(config)
|
39
42
|
end
|
40
|
-
|
43
|
+
|
41
44
|
def config
|
42
45
|
@config
|
43
46
|
end
|
data/lib/aptly_misc.rb
CHANGED
@@ -1,36 +1,33 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require 'aptly_cli/version'
|
2
|
+
require 'aptly_load'
|
3
|
+
require 'httmultiparty'
|
4
|
+
require 'json'
|
5
5
|
|
6
6
|
module AptlyCli
|
7
|
+
# Misc Aptly Class
|
7
8
|
class AptlyMisc
|
8
|
-
|
9
9
|
include HTTMultiParty
|
10
10
|
|
11
11
|
# Load aptly-cli.conf and establish base_uri
|
12
|
-
config = AptlyCli::AptlyLoad.new.configure_with(
|
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
|
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 get_graph(extension)
|
26
24
|
uri = "/graph.#{extension}"
|
27
25
|
self.class.get(uri)
|
28
26
|
end
|
29
27
|
|
30
|
-
def get_version
|
31
|
-
uri =
|
28
|
+
def get_version
|
29
|
+
uri = '/version'
|
32
30
|
self.class.get(uri)
|
33
31
|
end
|
34
|
-
|
35
32
|
end
|
36
33
|
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.
|
4
|
+
version: 0.2.4
|
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-
|
11
|
+
date: 2016-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|