packager-dsl 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.rspec +5 -5
- data/Changes +9 -4
- data/Gemfile +12 -12
- data/LICENSE +21 -340
- data/README.md +50 -48
- data/Rakefile +39 -37
- data/bin/packager +8 -8
- data/lib/packager.rb +5 -5
- data/lib/packager/cli.rb +72 -72
- data/lib/packager/dsl.rb +55 -55
- data/lib/packager/executor.rb +63 -63
- data/lib/packager/struct.rb +80 -80
- data/lib/packager/version.rb +3 -3
- data/on_what.rb +15 -15
- data/packager.gemspec +44 -44
- data/spec/cli/context.rb +17 -17
- data/spec/cli/execute_spec.rb +79 -79
- data/spec/cli/validate_spec.rb +47 -47
- data/spec/cli/version_spec.rb +7 -7
- data/spec/dsl/args_spec.rb +16 -16
- data/spec/dsl/context.rb +5 -5
- data/spec/dsl/defaults_spec.rb +19 -19
- data/spec/dsl/dependency_spec.rb +62 -62
- data/spec/dsl/error_spec.rb +48 -48
- data/spec/dsl/files_spec.rb +46 -46
- data/spec/executor/basic_spec.rb +21 -21
- data/spec/executor/command_spec.rb +18 -18
- data/spec/executor/context.rb +4 -4
- data/spec/executor/dependency_spec.rb +46 -46
- data/spec/executor/execute_command_spec.rb +25 -25
- data/spec/executor/files_spec.rb +33 -33
- data/spec/fpm-test_spec.rb +98 -98
- data/spec/integration/context.rb +57 -57
- data/spec/integration/dependency_spec.rb +51 -51
- data/spec/integration/files_spec.rb +104 -104
- data/spec/lib/fpm/package/test.rb +27 -27
- data/spec/shared_context/workdir.rb +18 -18
- data/spec/spec_helper.rb +55 -55
- data/spec/struct/command_spec.rb +67 -67
- data/spec/struct/error_spec.rb +12 -12
- metadata +45 -46
data/spec/executor/basic_spec.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
require './spec/executor/context.rb'
|
2
|
-
describe Packager::Executor do
|
3
|
-
include_context :executor
|
4
|
-
|
5
|
-
it "creates an empty directory" do
|
6
|
-
item = Packager::Struct::Package.new(
|
7
|
-
:name => 'foo',
|
8
|
-
:version => '0.0.1',
|
9
|
-
:type => 'dir',
|
10
|
-
)
|
11
|
-
executor.execute_on([item])
|
12
|
-
expect(executor.commands[0]).to eq(
|
13
|
-
Packager::Struct::Command.new({
|
14
|
-
:name => 'foo',
|
15
|
-
:version => '0.0.1',
|
16
|
-
:source => 'empty',
|
17
|
-
:target => 'dir',
|
18
|
-
})
|
19
|
-
)
|
20
|
-
end
|
21
|
-
end
|
1
|
+
require './spec/executor/context.rb'
|
2
|
+
describe Packager::Executor do
|
3
|
+
include_context :executor
|
4
|
+
|
5
|
+
it "creates an empty directory" do
|
6
|
+
item = Packager::Struct::Package.new(
|
7
|
+
:name => 'foo',
|
8
|
+
:version => '0.0.1',
|
9
|
+
:type => 'dir',
|
10
|
+
)
|
11
|
+
executor.execute_on([item])
|
12
|
+
expect(executor.commands[0]).to eq(
|
13
|
+
Packager::Struct::Command.new({
|
14
|
+
:name => 'foo',
|
15
|
+
:version => '0.0.1',
|
16
|
+
:source => 'empty',
|
17
|
+
:target => 'dir',
|
18
|
+
})
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
describe Packager::Struct::Command do
|
2
|
-
it "creates a FPM command correctly" do
|
3
|
-
cmd = Packager::Struct::Command.new(
|
4
|
-
:name => 'foo',
|
5
|
-
:version => '0.0.1',
|
6
|
-
:target => 'test',
|
7
|
-
)
|
8
|
-
cmd.add_directory('foo')
|
9
|
-
expect(cmd.to_system).to eq([
|
10
|
-
'fpm',
|
11
|
-
'--name', 'foo',
|
12
|
-
'--version', '0.0.1',
|
13
|
-
'-s', 'dir',
|
14
|
-
'-t', 'test',
|
15
|
-
'foo',
|
16
|
-
])
|
17
|
-
end
|
18
|
-
end
|
1
|
+
describe Packager::Struct::Command do
|
2
|
+
it "creates a FPM command correctly" do
|
3
|
+
cmd = Packager::Struct::Command.new(
|
4
|
+
:name => 'foo',
|
5
|
+
:version => '0.0.1',
|
6
|
+
:target => 'test',
|
7
|
+
)
|
8
|
+
cmd.add_directory('foo')
|
9
|
+
expect(cmd.to_system).to eq([
|
10
|
+
'fpm',
|
11
|
+
'--name', 'foo',
|
12
|
+
'--version', '0.0.1',
|
13
|
+
'-s', 'dir',
|
14
|
+
'-t', 'test',
|
15
|
+
'foo',
|
16
|
+
])
|
17
|
+
end
|
18
|
+
end
|
data/spec/executor/context.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
RSpec.shared_context :executor do
|
2
|
-
subject(:executor) { Packager::Executor.new(:dryrun => true) }
|
3
|
-
|
4
|
-
end
|
1
|
+
RSpec.shared_context :executor do
|
2
|
+
subject(:executor) { Packager::Executor.new(:dryrun => true) }
|
3
|
+
|
4
|
+
end
|
@@ -1,46 +1,46 @@
|
|
1
|
-
require './spec/executor/context.rb'
|
2
|
-
describe Packager::Executor do
|
3
|
-
include_context :executor
|
4
|
-
|
5
|
-
context "dependencies" do
|
6
|
-
it "handles a dependency" do
|
7
|
-
item = Packager::Struct::Package.new(
|
8
|
-
:name => 'foo',
|
9
|
-
:version => '0.0.1',
|
10
|
-
:type => 'test',
|
11
|
-
:requires => [ 'foo' ],
|
12
|
-
)
|
13
|
-
executor.execute_on([item])
|
14
|
-
expect(executor.commands[0]).to eq(
|
15
|
-
Packager::Struct::Command.new({
|
16
|
-
:name => 'foo',
|
17
|
-
:version => '0.0.1',
|
18
|
-
:source => 'empty',
|
19
|
-
:target => 'test',
|
20
|
-
:requires => [ 'foo' ],
|
21
|
-
})
|
22
|
-
)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "provides" do
|
27
|
-
it "handles a provides" do
|
28
|
-
item = Packager::Struct::Package.new(
|
29
|
-
:name => 'foo',
|
30
|
-
:version => '0.0.1',
|
31
|
-
:type => 'test',
|
32
|
-
:provides => [ 'foo' ],
|
33
|
-
)
|
34
|
-
executor.execute_on([item])
|
35
|
-
expect(executor.commands[0]).to eq(
|
36
|
-
Packager::Struct::Command.new({
|
37
|
-
:name => 'foo',
|
38
|
-
:version => '0.0.1',
|
39
|
-
:source => 'empty',
|
40
|
-
:target => 'test',
|
41
|
-
:provides => [ 'foo' ],
|
42
|
-
})
|
43
|
-
)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
1
|
+
require './spec/executor/context.rb'
|
2
|
+
describe Packager::Executor do
|
3
|
+
include_context :executor
|
4
|
+
|
5
|
+
context "dependencies" do
|
6
|
+
it "handles a dependency" do
|
7
|
+
item = Packager::Struct::Package.new(
|
8
|
+
:name => 'foo',
|
9
|
+
:version => '0.0.1',
|
10
|
+
:type => 'test',
|
11
|
+
:requires => [ 'foo' ],
|
12
|
+
)
|
13
|
+
executor.execute_on([item])
|
14
|
+
expect(executor.commands[0]).to eq(
|
15
|
+
Packager::Struct::Command.new({
|
16
|
+
:name => 'foo',
|
17
|
+
:version => '0.0.1',
|
18
|
+
:source => 'empty',
|
19
|
+
:target => 'test',
|
20
|
+
:requires => [ 'foo' ],
|
21
|
+
})
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "provides" do
|
27
|
+
it "handles a provides" do
|
28
|
+
item = Packager::Struct::Package.new(
|
29
|
+
:name => 'foo',
|
30
|
+
:version => '0.0.1',
|
31
|
+
:type => 'test',
|
32
|
+
:provides => [ 'foo' ],
|
33
|
+
)
|
34
|
+
executor.execute_on([item])
|
35
|
+
expect(executor.commands[0]).to eq(
|
36
|
+
Packager::Struct::Command.new({
|
37
|
+
:name => 'foo',
|
38
|
+
:version => '0.0.1',
|
39
|
+
:source => 'empty',
|
40
|
+
:target => 'test',
|
41
|
+
:provides => [ 'foo' ],
|
42
|
+
})
|
43
|
+
)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
describe Packager::Executor do
|
2
|
-
class Packager::Struct::TestCommand < Packager::Struct.new(:command)
|
3
|
-
def to_system
|
4
|
-
command
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
context "#execute_command" do
|
9
|
-
it "handles errors" do
|
10
|
-
cmd = Packager::Struct::TestCommand.new(
|
11
|
-
:command => ["echo '{:error=>\"foo\"}'"]
|
12
|
-
)
|
13
|
-
expect {
|
14
|
-
subject.execute_command(cmd)
|
15
|
-
}.to raise_error('foo')
|
16
|
-
end
|
17
|
-
|
18
|
-
it "handles success" do
|
19
|
-
cmd = Packager::Struct::TestCommand.new(
|
20
|
-
:command => ["echo '{:path=>\"foo\"}'"]
|
21
|
-
)
|
22
|
-
expect(subject.execute_command(cmd)).to eq('foo')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
describe Packager::Executor do
|
2
|
+
class Packager::Struct::TestCommand < Packager::Struct.new(:command)
|
3
|
+
def to_system
|
4
|
+
command
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
context "#execute_command" do
|
9
|
+
it "handles errors" do
|
10
|
+
cmd = Packager::Struct::TestCommand.new(
|
11
|
+
:command => ["echo '{:error=>\"foo\"}'"]
|
12
|
+
)
|
13
|
+
expect {
|
14
|
+
subject.execute_command(cmd)
|
15
|
+
}.to raise_error('foo')
|
16
|
+
end
|
17
|
+
|
18
|
+
it "handles success" do
|
19
|
+
cmd = Packager::Struct::TestCommand.new(
|
20
|
+
:command => ["echo '{:path=>\"foo\"}'"]
|
21
|
+
)
|
22
|
+
expect(subject.execute_command(cmd)).to eq('foo')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/executor/files_spec.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
require './spec/executor/context.rb'
|
2
|
-
require './spec/shared_context/workdir.rb'
|
3
|
-
describe Packager::Executor do
|
4
|
-
include_context :executor
|
5
|
-
include_context :workdir
|
6
|
-
|
7
|
-
it "creates a package with one file" do
|
8
|
-
FileUtils.chdir(sourcedir) do
|
9
|
-
FileUtils.touch('file1')
|
10
|
-
end
|
11
|
-
|
12
|
-
item = Packager::Struct::Package.new(
|
13
|
-
:name => 'foo',
|
14
|
-
:version => '0.0.1',
|
15
|
-
:type => 'test',
|
16
|
-
:files => [
|
17
|
-
Packager::Struct::File.new(File.join(sourcedir, 'file1'), '/bar/file2'),
|
18
|
-
]
|
19
|
-
)
|
20
|
-
FileUtils.chdir(workdir) do
|
21
|
-
executor.execute_on([item])
|
22
|
-
end
|
23
|
-
expect(executor.commands[0]).to eq(
|
24
|
-
Packager::Struct::Command.new({
|
25
|
-
:name => 'foo',
|
26
|
-
:version => '0.0.1',
|
27
|
-
:source => 'dir',
|
28
|
-
:target => 'test',
|
29
|
-
:directories => { 'bar' => true },
|
30
|
-
})
|
31
|
-
)
|
32
|
-
end
|
33
|
-
end
|
1
|
+
require './spec/executor/context.rb'
|
2
|
+
require './spec/shared_context/workdir.rb'
|
3
|
+
describe Packager::Executor do
|
4
|
+
include_context :executor
|
5
|
+
include_context :workdir
|
6
|
+
|
7
|
+
it "creates a package with one file" do
|
8
|
+
FileUtils.chdir(sourcedir) do
|
9
|
+
FileUtils.touch('file1')
|
10
|
+
end
|
11
|
+
|
12
|
+
item = Packager::Struct::Package.new(
|
13
|
+
:name => 'foo',
|
14
|
+
:version => '0.0.1',
|
15
|
+
:type => 'test',
|
16
|
+
:files => [
|
17
|
+
Packager::Struct::File.new(File.join(sourcedir, 'file1'), '/bar/file2'),
|
18
|
+
]
|
19
|
+
)
|
20
|
+
FileUtils.chdir(workdir) do
|
21
|
+
executor.execute_on([item])
|
22
|
+
end
|
23
|
+
expect(executor.commands[0]).to eq(
|
24
|
+
Packager::Struct::Command.new({
|
25
|
+
:name => 'foo',
|
26
|
+
:version => '0.0.1',
|
27
|
+
:source => 'dir',
|
28
|
+
:target => 'test',
|
29
|
+
:directories => { 'bar' => true },
|
30
|
+
})
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
data/spec/fpm-test_spec.rb
CHANGED
@@ -1,98 +1,98 @@
|
|
1
|
-
# Q.V. the initial comment in spec/integration/files_spec.rb
|
2
|
-
#
|
3
|
-
# Missing features:
|
4
|
-
# * dependencies
|
5
|
-
# * before/after scripts
|
6
|
-
|
7
|
-
require 'tempfile'
|
8
|
-
|
9
|
-
require './spec/integration/context.rb'
|
10
|
-
require './spec/shared_context/workdir.rb'
|
11
|
-
describe 'FPM::Package::Test' do
|
12
|
-
include_context :workdir
|
13
|
-
include_context :test_package
|
14
|
-
|
15
|
-
# This is to get access to the 'test' FPM type in the FPM executable.
|
16
|
-
before(:all) {
|
17
|
-
includedir = File.join(@dir,'spec/lib')
|
18
|
-
@fpm = "ruby -I#{includedir} -rfpm/package/test `which fpm`"
|
19
|
-
}
|
20
|
-
|
21
|
-
# FIXME: 2>/dev/null is to suppress a Gem::Specification complaint about JSON.
|
22
|
-
# After 'bundle install', Ruby 2.2 has JSON 1.8.3 and 1.8.1 (default) installed
|
23
|
-
# and something gets confused because both are sufficient for JSON >= 1.7.7
|
24
|
-
# You can disable it by setting the envvar VERBOSE=1
|
25
|
-
def execute(cmd)
|
26
|
-
cmd.unshift @fpm
|
27
|
-
cmd.push '2>/dev/null' unless ENV['VERBOSE'] && ENV['VERBOSE'] != '0'
|
28
|
-
return eval `#{cmd.join(' ')}`#
|
29
|
-
end
|
30
|
-
|
31
|
-
it "creates an empty package" do
|
32
|
-
execute([
|
33
|
-
'--name foo',
|
34
|
-
'--version 0.0.1',
|
35
|
-
'-s empty',
|
36
|
-
'-t test',
|
37
|
-
])
|
38
|
-
|
39
|
-
verify_test_package('foo.test', {
|
40
|
-
'name' => 'foo',
|
41
|
-
'version' => '0.0.1',
|
42
|
-
})
|
43
|
-
end
|
44
|
-
|
45
|
-
it "creates an empty package with dependencies" do
|
46
|
-
execute([
|
47
|
-
'--name foo',
|
48
|
-
'--version 0.0.2',
|
49
|
-
'--depends baz',
|
50
|
-
'--depends bar',
|
51
|
-
'-s empty',
|
52
|
-
'-t test',
|
53
|
-
])
|
54
|
-
|
55
|
-
verify_test_package('foo.test', {
|
56
|
-
'name' => 'foo',
|
57
|
-
'version' => '0.0.2',
|
58
|
-
'requires' => [ 'bar', 'baz' ],
|
59
|
-
})
|
60
|
-
end
|
61
|
-
|
62
|
-
it "creates an empty package with provides" do
|
63
|
-
execute([
|
64
|
-
'--name foo',
|
65
|
-
'--version 0.0.2',
|
66
|
-
'--provides baz',
|
67
|
-
'--provides bar',
|
68
|
-
'-s empty',
|
69
|
-
'-t test',
|
70
|
-
])
|
71
|
-
|
72
|
-
verify_test_package('foo.test', {
|
73
|
-
'name' => 'foo',
|
74
|
-
'version' => '0.0.2',
|
75
|
-
'provides' => [ 'bar', 'baz' ],
|
76
|
-
})
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
it "creates a package with files" do
|
81
|
-
append_to_file('foo', 'stuff')
|
82
|
-
|
83
|
-
execute([
|
84
|
-
'--name foo',
|
85
|
-
'--version 0.0.1',
|
86
|
-
'-s dir',
|
87
|
-
'-t test',
|
88
|
-
'foo'
|
89
|
-
])
|
90
|
-
|
91
|
-
verify_test_package('foo.test', {
|
92
|
-
'name' => 'foo',
|
93
|
-
'version' => '0.0.1',
|
94
|
-
}, {
|
95
|
-
'foo' => 'stuff',
|
96
|
-
})
|
97
|
-
end
|
98
|
-
end
|
1
|
+
# Q.V. the initial comment in spec/integration/files_spec.rb
|
2
|
+
#
|
3
|
+
# Missing features:
|
4
|
+
# * dependencies
|
5
|
+
# * before/after scripts
|
6
|
+
|
7
|
+
require 'tempfile'
|
8
|
+
|
9
|
+
require './spec/integration/context.rb'
|
10
|
+
require './spec/shared_context/workdir.rb'
|
11
|
+
describe 'FPM::Package::Test' do
|
12
|
+
include_context :workdir
|
13
|
+
include_context :test_package
|
14
|
+
|
15
|
+
# This is to get access to the 'test' FPM type in the FPM executable.
|
16
|
+
before(:all) {
|
17
|
+
includedir = File.join(@dir,'spec/lib')
|
18
|
+
@fpm = "ruby -I#{includedir} -rfpm/package/test `which fpm`"
|
19
|
+
}
|
20
|
+
|
21
|
+
# FIXME: 2>/dev/null is to suppress a Gem::Specification complaint about JSON.
|
22
|
+
# After 'bundle install', Ruby 2.2 has JSON 1.8.3 and 1.8.1 (default) installed
|
23
|
+
# and something gets confused because both are sufficient for JSON >= 1.7.7
|
24
|
+
# You can disable it by setting the envvar VERBOSE=1
|
25
|
+
def execute(cmd)
|
26
|
+
cmd.unshift @fpm
|
27
|
+
cmd.push '2>/dev/null' unless ENV['VERBOSE'] && ENV['VERBOSE'] != '0'
|
28
|
+
return eval `#{cmd.join(' ')}`#
|
29
|
+
end
|
30
|
+
|
31
|
+
it "creates an empty package" do
|
32
|
+
execute([
|
33
|
+
'--name foo',
|
34
|
+
'--version 0.0.1',
|
35
|
+
'-s empty',
|
36
|
+
'-t test',
|
37
|
+
])
|
38
|
+
|
39
|
+
verify_test_package('foo.test', {
|
40
|
+
'name' => 'foo',
|
41
|
+
'version' => '0.0.1',
|
42
|
+
})
|
43
|
+
end
|
44
|
+
|
45
|
+
it "creates an empty package with dependencies" do
|
46
|
+
execute([
|
47
|
+
'--name foo',
|
48
|
+
'--version 0.0.2',
|
49
|
+
'--depends baz',
|
50
|
+
'--depends bar',
|
51
|
+
'-s empty',
|
52
|
+
'-t test',
|
53
|
+
])
|
54
|
+
|
55
|
+
verify_test_package('foo.test', {
|
56
|
+
'name' => 'foo',
|
57
|
+
'version' => '0.0.2',
|
58
|
+
'requires' => [ 'bar', 'baz' ],
|
59
|
+
})
|
60
|
+
end
|
61
|
+
|
62
|
+
it "creates an empty package with provides" do
|
63
|
+
execute([
|
64
|
+
'--name foo',
|
65
|
+
'--version 0.0.2',
|
66
|
+
'--provides baz',
|
67
|
+
'--provides bar',
|
68
|
+
'-s empty',
|
69
|
+
'-t test',
|
70
|
+
])
|
71
|
+
|
72
|
+
verify_test_package('foo.test', {
|
73
|
+
'name' => 'foo',
|
74
|
+
'version' => '0.0.2',
|
75
|
+
'provides' => [ 'bar', 'baz' ],
|
76
|
+
})
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
it "creates a package with files" do
|
81
|
+
append_to_file('foo', 'stuff')
|
82
|
+
|
83
|
+
execute([
|
84
|
+
'--name foo',
|
85
|
+
'--version 0.0.1',
|
86
|
+
'-s dir',
|
87
|
+
'-t test',
|
88
|
+
'foo'
|
89
|
+
])
|
90
|
+
|
91
|
+
verify_test_package('foo.test', {
|
92
|
+
'name' => 'foo',
|
93
|
+
'version' => '0.0.1',
|
94
|
+
}, {
|
95
|
+
'foo' => 'stuff',
|
96
|
+
})
|
97
|
+
end
|
98
|
+
end
|