suppository 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +76 -0
- data/.rubocop.yml +5 -0
- data/.ruby-version +1 -0
- data/.travis.yml +19 -0
- data/Gemfile +4 -0
- data/Guardfile +30 -0
- data/LICENSE.txt +674 -0
- data/README.md +103 -0
- data/Rakefile +34 -0
- data/bin/suppository +36 -0
- data/fixtures/curl_7.22.0-3ubuntu4.11_amd64.deb +0 -0
- data/fixtures/vim_7.3.547-7_amd64.deb +0 -0
- data/lib/suppository/add_command.rb +116 -0
- data/lib/suppository/checksummed.rb +24 -0
- data/lib/suppository/cli.rb +26 -0
- data/lib/suppository/command_runner.rb +30 -0
- data/lib/suppository/create_command.rb +75 -0
- data/lib/suppository/dpkg_deb.rb +29 -0
- data/lib/suppository/dpkg_deb_line.rb +28 -0
- data/lib/suppository/exceptions.rb +20 -0
- data/lib/suppository/gzip.rb +14 -0
- data/lib/suppository/help.rb +22 -0
- data/lib/suppository/help_command.rb +13 -0
- data/lib/suppository/logger.rb +24 -0
- data/lib/suppository/master_deb.rb +62 -0
- data/lib/suppository/package.rb +23 -0
- data/lib/suppository/release.rb +57 -0
- data/lib/suppository/repository.rb +16 -0
- data/lib/suppository/tty.rb +43 -0
- data/lib/suppository/version.rb +3 -0
- data/lib/suppository/version_command.rb +12 -0
- data/lib/suppository.rb +5 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/suppository/add_command_spec.rb +141 -0
- data/spec/suppository/cli_spec.rb +50 -0
- data/spec/suppository/command_runner_spec.rb +26 -0
- data/spec/suppository/create_command_spec.rb +80 -0
- data/spec/suppository/dpkg_deb_line_spec.rb +36 -0
- data/spec/suppository/dpkg_deb_spec.rb +65 -0
- data/spec/suppository/gzip_spec.rb.rb +22 -0
- data/spec/suppository/help_command_spec.rb +13 -0
- data/spec/suppository/help_spec.rb +12 -0
- data/spec/suppository/logger_spec.rb +64 -0
- data/spec/suppository/master_deb_spec.rb +84 -0
- data/spec/suppository/package_spec.rb +63 -0
- data/spec/suppository/release_spec.rb +70 -0
- data/spec/suppository/repository_spec.rb +53 -0
- data/spec/suppository/tty_spec.rb +92 -0
- data/spec/suppository/version_command_spec.rb +13 -0
- data/spec/suppository/version_spec.rb +13 -0
- data/spec/suppository_spec.rb +83 -0
- data/suppository.gemspec +34 -0
- metadata +286 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/logger'
|
4
|
+
|
5
|
+
describe Suppository::Logger do
|
6
|
+
|
7
|
+
describe 'log_error' do
|
8
|
+
|
9
|
+
it "decorated output tty? true" do
|
10
|
+
expect($stdout).to receive(:tty?).twice.and_return(true)
|
11
|
+
expect($stderr).to receive(:puts).with("\e[4;31mError\e[0m: Boom")
|
12
|
+
Suppository::Logger.log_error "Boom"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "simple output if tty? false" do
|
16
|
+
expect($stdout).to receive(:tty?).twice.and_return(false)
|
17
|
+
expect($stderr).to receive(:puts).with("Error: Boom")
|
18
|
+
Suppository::Logger.log_error "Boom"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'log_error' do
|
24
|
+
|
25
|
+
it "print to standard out" do
|
26
|
+
expect(Suppository::Logger).to receive(:puts).with('Info Message')
|
27
|
+
Suppository::Logger.log_info 'Info Message'
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'log_verbose' do
|
33
|
+
|
34
|
+
it "decorated output tty? true" do
|
35
|
+
expect($stdout).to receive(:tty?).twice.and_return(true)
|
36
|
+
expect(Suppository::Logger).to receive(:puts).with("\e[1;30mVerbose Message\e[0m")
|
37
|
+
Suppository::Logger.log_verbose 'Verbose Message'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "simple output if tty? false" do
|
41
|
+
expect($stdout).to receive(:tty?).twice.and_return(false)
|
42
|
+
expect(Suppository::Logger).to receive(:puts).with('Verbose Message')
|
43
|
+
Suppository::Logger.log_verbose 'Verbose Message'
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe 'log_success' do
|
49
|
+
|
50
|
+
it "decorated output tty? true" do
|
51
|
+
expect($stdout).to receive(:tty?).exactly(3).times.and_return(true)
|
52
|
+
expect(Suppository::Logger).to receive(:puts).with("\e[1;32m==>\e[1;39m Success Message\e[0m")
|
53
|
+
Suppository::Logger.log_success 'Success Message'
|
54
|
+
end
|
55
|
+
|
56
|
+
it "simple output if tty? false" do
|
57
|
+
expect($stdout).to receive(:tty?).exactly(3).times.and_return(false)
|
58
|
+
expect(Suppository::Logger).to receive(:puts).with('==> Success Message')
|
59
|
+
Suppository::Logger.log_success 'Success Message'
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/master_deb'
|
4
|
+
require 'suppository/dpkg_deb'
|
5
|
+
require 'suppository/repository'
|
6
|
+
|
7
|
+
describe Suppository::MasterDeb do
|
8
|
+
|
9
|
+
before(:all) do
|
10
|
+
@valid_file_name = 'e5ca0a9797acda4bfe8404524f0976b3_b37ce9b17405d93c323c0b8bbe167c6f2dccfe02_5a315c56bc34f1ffed365f9aa50bbb36916e5a8fae8614f00d952983d4316555.deb'
|
11
|
+
end
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
@repository = Suppository::Repository.new "/tmp/supposotory_test_#{Time.now.to_f}"
|
15
|
+
master_deb_file = "#{@repository.suppository}/#{@valid_file_name}"
|
16
|
+
FileUtils.mkdir_p @repository.suppository
|
17
|
+
FileUtils.cp deb_file, master_deb_file
|
18
|
+
@instance = Suppository::MasterDeb.new(master_deb_file)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
after(:each) do
|
23
|
+
FileUtils.rm_r @repository.path
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'valid file' do
|
27
|
+
|
28
|
+
it "md5sum" do
|
29
|
+
expect(@instance.md5sum).to eql 'e5ca0a9797acda4bfe8404524f0976b3'
|
30
|
+
end
|
31
|
+
|
32
|
+
it "sha1" do
|
33
|
+
expect(@instance.sha1).to eql 'b37ce9b17405d93c323c0b8bbe167c6f2dccfe02'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "sha256" do
|
37
|
+
expect(@instance.sha256).to eql '5a315c56bc34f1ffed365f9aa50bbb36916e5a8fae8614f00d952983d4316555'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "size" do
|
41
|
+
expect(@instance.size).to eql 137640
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
describe 'invalid file' do
|
47
|
+
|
48
|
+
it "checks file is in correct folder" do
|
49
|
+
master_deb_file = "/tmp/repo123/#{@valid_file_name}"
|
50
|
+
exception = nil
|
51
|
+
begin
|
52
|
+
Suppository::MasterDeb.new(master_deb_file)
|
53
|
+
rescue InvalidMasterDeb => e
|
54
|
+
exception = e
|
55
|
+
end
|
56
|
+
|
57
|
+
expect(exception.message).to be_eql 'Master deb must be in the .suppository folder'
|
58
|
+
end
|
59
|
+
|
60
|
+
it "checks file has correct name" do
|
61
|
+
master_deb_file = '/tmp/repo123/.suppository/123456_78910.deb'
|
62
|
+
exception = nil
|
63
|
+
begin
|
64
|
+
Suppository::MasterDeb.new(master_deb_file)
|
65
|
+
rescue InvalidMasterDeb => e
|
66
|
+
exception = e
|
67
|
+
end
|
68
|
+
|
69
|
+
expect(exception.message).to be_eql 'Master deb must have the following name {md5}_{sha1}_{sha256}.deb'
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
it "gets attribute" do
|
75
|
+
expect(@instance.full_attr['Package']).to eql 'curl'
|
76
|
+
end
|
77
|
+
|
78
|
+
it "filename" do
|
79
|
+
expect(@instance.filename).to eql 'curl_7.22.0-3ubuntu4.11_amd64.deb'
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/package'
|
4
|
+
require 'suppository/master_deb'
|
5
|
+
|
6
|
+
describe Suppository::Package do
|
7
|
+
|
8
|
+
EXPECTED_DESCRIPTION = <<-EOS
|
9
|
+
Description: Get a file from an HTTP, HTTPS or FTP server curl is a client to get files from servers using any of the supported
|
10
|
+
protocols. The command is designed to work without user interaction
|
11
|
+
or any kind of interactivity.
|
12
|
+
.
|
13
|
+
curl offers a busload of useful tricks like proxy support, user
|
14
|
+
authentication, FTP upload, HTTP post, file transfer resume and more.
|
15
|
+
|
16
|
+
EOS
|
17
|
+
package_info = {
|
18
|
+
'Package' => 'curl',
|
19
|
+
'Version' => '7.22.0-3ubuntu4.11',
|
20
|
+
'Architecture' => 'amd64',
|
21
|
+
'Maintainer' => 'Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>',
|
22
|
+
'Installed-Size' => '3450',
|
23
|
+
'MD5sum' => 'e5ca0a9797acda4bfe8404524f0976b3',
|
24
|
+
'SHA1' => 'b37ce9b17405d93c323c0b8bbe167c6f2dccfe02',
|
25
|
+
'SHA256' => '5a315c56bc34f1ffed365f9aa50bbb36916e5a8fae8614f00d952983d4316555',
|
26
|
+
'Section' => 'web',
|
27
|
+
'Priority' => 'optional',
|
28
|
+
'Homepage' => 'http://www.test.com/',
|
29
|
+
'Description' => "Get a file from an HTTP, HTTPS or FTP server curl is a client to get files from servers using any of the supported\n protocols. The command is designed to work without user interaction\n or any kind of interactivity.\n .\n curl offers a busload of useful tricks like proxy support, user\n authentication, FTP upload, HTTP post, file transfer resume and more.",
|
30
|
+
'Size' => '345'
|
31
|
+
}
|
32
|
+
|
33
|
+
before(:each) do
|
34
|
+
deb = double(Suppository::MasterDeb)
|
35
|
+
@instance = Suppository::Package.new('dists/trusty/internal/binary-amd64',deb)
|
36
|
+
expect(deb).to receive(:filename) { 'curl_7.22.0-3ubuntu4.11_amd64.deb' }
|
37
|
+
expect(deb).to receive(:full_attr) { package_info }
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
it "Outputs the Package" do
|
42
|
+
desc = ''
|
43
|
+
in_desc = false
|
44
|
+
@instance.content.split("\n").each do |line|
|
45
|
+
k, v = line.split(': ')
|
46
|
+
if k == 'Description' || in_desc
|
47
|
+
in_desc = true
|
48
|
+
elsif k == 'Filename'
|
49
|
+
expect(v).to eql 'dists/trusty/internal/binary-amd64/curl_7.22.0-3ubuntu4.11_amd64.deb'
|
50
|
+
else
|
51
|
+
expect(package_info.key?(k)).to be_truthy
|
52
|
+
expect(package_info.value?(v)).to be_truthy
|
53
|
+
end
|
54
|
+
|
55
|
+
desc += line << "\n" if in_desc
|
56
|
+
end
|
57
|
+
desc << "\n"
|
58
|
+
expect(desc).to eql EXPECTED_DESCRIPTION
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/release'
|
4
|
+
require 'suppository/create_command'
|
5
|
+
|
6
|
+
describe Suppository::Release do
|
7
|
+
|
8
|
+
RELEASE_CONTENT = <<-EOS
|
9
|
+
Codename: lucid
|
10
|
+
Architectures: amd64 i386
|
11
|
+
Components: internal
|
12
|
+
Date: Tue, 06 Jan 2015 00:43:13 GMT
|
13
|
+
MD5Sum:
|
14
|
+
d41d8cd98f00b204e9800998ecf8427e 0 dists/lucid/internal/binary-amd64/Packages
|
15
|
+
2f3e2442476f5464c314716ef684c02c 103 dists/lucid/internal/binary-amd64/Packages.gz
|
16
|
+
d41d8cd98f00b204e9800998ecf8427e 0 dists/lucid/internal/binary-i386/Packages
|
17
|
+
7c0c23a67294ee276556e2f7f0ad5bc2 102 dists/lucid/internal/binary-i386/Packages.gz
|
18
|
+
SHA1:
|
19
|
+
da39a3ee5e6b4b0d3255bfef95601890afd80709 0 dists/lucid/internal/binary-amd64/Packages
|
20
|
+
3e9ac8f4be976f1c6a52c13a3a251dfec7c204e7 103 dists/lucid/internal/binary-amd64/Packages.gz
|
21
|
+
da39a3ee5e6b4b0d3255bfef95601890afd80709 0 dists/lucid/internal/binary-i386/Packages
|
22
|
+
14934aa27c0ea7148d5b94b0ff3c769cfa59a297 102 dists/lucid/internal/binary-i386/Packages.gz
|
23
|
+
SHA256:
|
24
|
+
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 dists/lucid/internal/binary-amd64/Packages
|
25
|
+
bce970b56be93d9280b806bf630b3c85332293212002dcb38eb9911c6dcd725c 103 dists/lucid/internal/binary-amd64/Packages.gz
|
26
|
+
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 0 dists/lucid/internal/binary-i386/Packages
|
27
|
+
6e2679e057b8b9fa202677d114914fb9d67d378445449983fc432c27becedc38 102 dists/lucid/internal/binary-i386/Packages.gz
|
28
|
+
SHA512:
|
29
|
+
cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e 0 dists/lucid/internal/binary-amd64/Packages
|
30
|
+
8c5a6c5573e2b5e6e187cb8aa85a7d5cdbc941ba2dfbc705fb33404a643d5ddee64014a4a9d094151400ce4ac58946bff52e53e4b922485f06405637ab9e080b 103 dists/lucid/internal/binary-amd64/Packages.gz
|
31
|
+
cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e 0 dists/lucid/internal/binary-i386/Packages
|
32
|
+
2a977dcc902cb6105c5981d114fb5759b8bd3a0805b30d70b2b519ad17fed233a1bd62b5b705b187ac31ea6e3def0fa598c0731281e8be2de513757d5190be14 102 dists/lucid/internal/binary-i386/Packages.gz
|
33
|
+
|
34
|
+
EOS
|
35
|
+
|
36
|
+
|
37
|
+
before(:each) do
|
38
|
+
@repo_path = "/tmp/suppository_test_#{Time.now.to_f}"
|
39
|
+
@dist = 'lucid'
|
40
|
+
@instance = Suppository::Release.new(@repo_path, @dist, true)
|
41
|
+
Suppository::CreateCommand.new([@repo_path]).run
|
42
|
+
@release_file = "#{@repo_path}/dists/#{@dist}/Release"
|
43
|
+
@release_file_gpg = "#{@release_file}.gpg"
|
44
|
+
end
|
45
|
+
|
46
|
+
after(:each) do
|
47
|
+
FileUtils.rm_r @repo_path if File.exist? @repo_path
|
48
|
+
end
|
49
|
+
|
50
|
+
it "creates file" do
|
51
|
+
@instance.create
|
52
|
+
expect(File.exists?(@release_file)).to eql true
|
53
|
+
end
|
54
|
+
|
55
|
+
it "unsigned" do
|
56
|
+
@instance.create
|
57
|
+
expect(File.exists?(@release_file_gpg)).to eql false
|
58
|
+
end
|
59
|
+
|
60
|
+
it "signed" do
|
61
|
+
command_runner = double(Suppository::CommandRunner)
|
62
|
+
args = "-abs -o #{@release_file_gpg} #{@release_file}"
|
63
|
+
expect(Suppository::CommandRunner).to receive(:new).with('gpg',args) {command_runner}
|
64
|
+
expect(command_runner).to receive(:run) {FileUtils.touch(@release_file_gpg)}
|
65
|
+
|
66
|
+
@instance = Suppository::Release.new(@repo_path, @dist)
|
67
|
+
@instance.create
|
68
|
+
expect(File.exists?(@release_file_gpg)).to eql true
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/repository'
|
4
|
+
|
5
|
+
describe Suppository::Repository do
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@repository = Suppository::Repository.new("/tmp/repo123")
|
9
|
+
@dists = %w(natty lucid precise saucy trusty)
|
10
|
+
@archs = %w(amd64 i386)
|
11
|
+
@suppository ="/tmp/repo123/.suppository"
|
12
|
+
end
|
13
|
+
|
14
|
+
after(:each) do
|
15
|
+
FileUtils.rm_r @repository.path if File.exist? @repository.path
|
16
|
+
end
|
17
|
+
|
18
|
+
it "has a path" do
|
19
|
+
expect(@repository.path).to eql "/tmp/repo123"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "converts relative path to absolute" do
|
23
|
+
repository = Suppository::Repository.new("./repo123")
|
24
|
+
expect(repository.path).to eql File.expand_path('./repo123')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "has a dists" do
|
28
|
+
expect(@repository.dists).to eql @dists
|
29
|
+
end
|
30
|
+
|
31
|
+
it "has a archs" do
|
32
|
+
expect(@repository.archs).to eql @archs
|
33
|
+
end
|
34
|
+
|
35
|
+
it "has a suppository" do
|
36
|
+
expect(@repository.suppository).to eql @suppository
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'exist?' do
|
40
|
+
|
41
|
+
it "false" do
|
42
|
+
expect(@repository.exist?).to be_falsy
|
43
|
+
end
|
44
|
+
|
45
|
+
it "true" do
|
46
|
+
FileUtils.mkdir_p @suppository
|
47
|
+
expect(@repository.exist?).to be_truthy
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,92 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/tty'
|
4
|
+
|
5
|
+
describe Suppository::Tty do
|
6
|
+
|
7
|
+
describe 'gray' do
|
8
|
+
|
9
|
+
it "Outputs returns nothing if not running in tty" do
|
10
|
+
expect($stdout).to receive(:tty?).and_return(false)
|
11
|
+
expect(Suppository::Tty.gray).to be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "Returns if running in tty" do
|
15
|
+
expect($stdout).to receive(:tty?).and_return(true)
|
16
|
+
expect(Suppository::Tty.gray).to eql "\e[1;30m"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'white' do
|
22
|
+
|
23
|
+
it "Outputs returns nothing if not running in tty" do
|
24
|
+
expect($stdout).to receive(:tty?).and_return(false)
|
25
|
+
expect(Suppository::Tty.white).to be_nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it "Returns if running in tty" do
|
29
|
+
expect($stdout).to receive(:tty?).and_return(true)
|
30
|
+
expect(Suppository::Tty.white).to eql "\e[1;39m"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'red' do
|
36
|
+
|
37
|
+
it "Outputs returns nothing if not running in tty" do
|
38
|
+
expect($stdout).to receive(:tty?).and_return(false)
|
39
|
+
expect(Suppository::Tty.red).to be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it "Returns if running in tty" do
|
43
|
+
expect($stdout).to receive(:tty?).and_return(true)
|
44
|
+
expect(Suppository::Tty.red).to eql "\e[4;31m"
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe 'reset' do
|
50
|
+
|
51
|
+
it "Outputs returns nothing if not running in tty" do
|
52
|
+
expect($stdout).to receive(:tty?).and_return(false)
|
53
|
+
expect(Suppository::Tty.reset).to be_nil
|
54
|
+
end
|
55
|
+
|
56
|
+
it "Returns if running in tty" do
|
57
|
+
expect($stdout).to receive(:tty?).and_return(true)
|
58
|
+
expect(Suppository::Tty.reset).to eql "\e[0m"
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'green' do
|
64
|
+
|
65
|
+
it "Outputs returns nothing if not running in tty" do
|
66
|
+
expect($stdout).to receive(:tty?).and_return(false)
|
67
|
+
expect(Suppository::Tty.green).to be_nil
|
68
|
+
end
|
69
|
+
|
70
|
+
it "Returns if running in tty" do
|
71
|
+
expect($stdout).to receive(:tty?).and_return(true)
|
72
|
+
expect(Suppository::Tty.green).to eql "\e[1;32m"
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
describe 'em' do
|
78
|
+
|
79
|
+
it "Outputs returns nothing if not running in tty" do
|
80
|
+
expect($stdout).to receive(:tty?).and_return(false)
|
81
|
+
expect(Suppository::Tty.em).to be_nil
|
82
|
+
end
|
83
|
+
|
84
|
+
it "Returns if running in tty" do
|
85
|
+
expect($stdout).to receive(:tty?).and_return(true)
|
86
|
+
expect(Suppository::Tty.em).to eql "\e[4;39m"
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/version_command'
|
4
|
+
|
5
|
+
describe Suppository::VersionCommand do
|
6
|
+
|
7
|
+
it "shows version number" do
|
8
|
+
command = Suppository::VersionCommand.new([])
|
9
|
+
expect{command.run}.to output("Suppository Version #{Suppository::VERSION}\n").to_stdout
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'suppository/version'
|
4
|
+
require 'English'
|
5
|
+
|
6
|
+
describe 'suppository binary' do
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@cmd = File.expand_path('./bin/suppository')
|
10
|
+
@repository_path = "/tmp/suppository_test_#{Time.now.to_f}"
|
11
|
+
end
|
12
|
+
|
13
|
+
after(:each) do
|
14
|
+
FileUtils.rm_r @repository_path if File.directory? @repository_path
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'fails if no command is given' do
|
18
|
+
output = `"#{@cmd}" 2>&1`
|
19
|
+
expect($CHILD_STATUS.success?).to be_falsy
|
20
|
+
expect(output).to include 'Error: Invalid usage'
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'create' do
|
24
|
+
|
25
|
+
it 'creates folder without error' do
|
26
|
+
`"#{@cmd}" create #{@repository_path}`
|
27
|
+
expect($CHILD_STATUS.success?).to be_truthy
|
28
|
+
expect(File.directory?("#{@repository_path}/dists")).to be_truthy
|
29
|
+
expect(File.directory?(@repository_path)).to be_truthy
|
30
|
+
expect(File.directory?("#{@repository_path}/.suppository")).to be_truthy
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'fails if arguments invalid' do
|
34
|
+
output = `"#{@cmd}" create 2>&1`
|
35
|
+
expect($CHILD_STATUS.success?).to be_falsy
|
36
|
+
expect(output).to include 'Error: Invalid usage'
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'version' do
|
42
|
+
|
43
|
+
it 'runs without error' do
|
44
|
+
output = `"#{@cmd}" version`
|
45
|
+
expect($CHILD_STATUS.success?).to be_truthy
|
46
|
+
expect(output).to include "Suppository Version #{Suppository::VERSION}"
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'help' do
|
52
|
+
|
53
|
+
it 'runs without error' do
|
54
|
+
output = `"#{@cmd}" help`
|
55
|
+
expect($CHILD_STATUS.success?).to be_truthy
|
56
|
+
expect(output).to include "Example usage:"
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'add' do
|
62
|
+
|
63
|
+
it 'runs without error' do
|
64
|
+
`"#{@cmd}" create #{@repository_path}`
|
65
|
+
`"#{@cmd}" add #{@repository_path} trusty internal "#{deb_file}" --unsigned`
|
66
|
+
expect($CHILD_STATUS.success?).to be_truthy
|
67
|
+
expect(File.file?("#{@repository_path}/dists/trusty/internal/binary-amd64/curl_7.22.0-3ubuntu4.11_amd64.deb")).to be_truthy
|
68
|
+
expect(File.file?("#{@repository_path}/dists/trusty/internal/binary-i386/curl_7.22.0-3ubuntu4.11_amd64.deb")).to be_truthy
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'fails if arguments invalid' do
|
72
|
+
output = `"#{@cmd}" add #{@repository_path} trusty internal "#{deb_file} --unsigned" 2>&1`
|
73
|
+
expect($CHILD_STATUS.success?).to be_falsy
|
74
|
+
expect(output).to include "Error: #{@repository_path} is not a valid repository"
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'fails if signing attempted (assumes no certificate)' do
|
78
|
+
output = `"#{@cmd}" add #{@repository_path} trusty internal "#{deb_file}" 2>&1`
|
79
|
+
expect($CHILD_STATUS.success?).to be_falsy
|
80
|
+
expect(output).to include "Error: #{@repository_path} is not a valid repository"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/suppository.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'suppository/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "suppository"
|
8
|
+
spec.version = Suppository::VERSION
|
9
|
+
spec.authors = ["William Griffiths", "Luke Farrar"]
|
10
|
+
spec.email = ["william.griffiths@thebookpeople.co.uk", "luke.farrar@thebookpeople.co.uk"]
|
11
|
+
spec.summary = %q{Super Simple Apt Repository Manager}
|
12
|
+
spec.description = %q{A utility for creating and managing simple apt repositories.}
|
13
|
+
spec.homepage = "https://github.com/TheBookPeople/suppository"
|
14
|
+
spec.license = "GNU"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "rake", "~> 10.4"
|
22
|
+
spec.add_development_dependency "bundler", '~> 1.7'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.1'
|
24
|
+
spec.add_development_dependency 'guard-rspec','~> 4.5'
|
25
|
+
spec.add_development_dependency 'rb-inotify','~> 0.9'
|
26
|
+
spec.add_development_dependency 'rb-fsevent' ,'~> 0.9'
|
27
|
+
spec.add_development_dependency 'rb-fchange', '~> 0.0'
|
28
|
+
spec.add_development_dependency 'terminal-notifier-guard', '~> 1.6'
|
29
|
+
spec.add_development_dependency 'rubocop' , '~> 0.28'
|
30
|
+
spec.add_development_dependency 'fakefs', '~> 0'
|
31
|
+
spec.add_development_dependency 'simplecov', '~> 0.9'
|
32
|
+
spec.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
|
33
|
+
|
34
|
+
end
|