packager-dsl 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/cli/validate_spec.rb
CHANGED
@@ -1,47 +1,47 @@
|
|
1
|
-
require './spec/cli/context.rb'
|
2
|
-
describe Packager::CLI do
|
3
|
-
context '#validate' do
|
4
|
-
include_context :cli
|
5
|
-
|
6
|
-
it "handles nothing passed" do
|
7
|
-
expect {
|
8
|
-
cli.validate
|
9
|
-
}.to raise_error(Thor::Error, "No filenames provided for validate")
|
10
|
-
end
|
11
|
-
|
12
|
-
it "handles a non-existent filename" do
|
13
|
-
expect {
|
14
|
-
cli.validate('foo')
|
15
|
-
}.to raise_error(Thor::Error, "'foo' cannot be found")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "handles an empty file" do
|
19
|
-
FileUtils.touch('definition')
|
20
|
-
expect {
|
21
|
-
cli.validate('definition')
|
22
|
-
}.to raise_error(Thor::Error, "'definition' produces nothing")
|
23
|
-
end
|
24
|
-
|
25
|
-
it "handles a bad file" do
|
26
|
-
append_to_file('definition', 'package {}')
|
27
|
-
|
28
|
-
expect {
|
29
|
-
cli.validate('definition')
|
30
|
-
}.to raise_error(Thor::Error, "'definition' has the following errors:\nEvery package must have a name")
|
31
|
-
end
|
32
|
-
|
33
|
-
it "handles a file that works" do
|
34
|
-
append_to_file('definition', "
|
35
|
-
package {
|
36
|
-
name 'foo'
|
37
|
-
version '0.0.1'
|
38
|
-
type 'dir'
|
39
|
-
}
|
40
|
-
")
|
41
|
-
|
42
|
-
expect(
|
43
|
-
capture(:stdout) { cli.validate('definition') }
|
44
|
-
).to eq("'definition' parses cleanly\n")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
1
|
+
require './spec/cli/context.rb'
|
2
|
+
describe Packager::CLI do
|
3
|
+
context '#validate' do
|
4
|
+
include_context :cli
|
5
|
+
|
6
|
+
it "handles nothing passed" do
|
7
|
+
expect {
|
8
|
+
cli.validate
|
9
|
+
}.to raise_error(Thor::Error, "No filenames provided for validate")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "handles a non-existent filename" do
|
13
|
+
expect {
|
14
|
+
cli.validate('foo')
|
15
|
+
}.to raise_error(Thor::Error, "'foo' cannot be found")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "handles an empty file" do
|
19
|
+
FileUtils.touch('definition')
|
20
|
+
expect {
|
21
|
+
cli.validate('definition')
|
22
|
+
}.to raise_error(Thor::Error, "'definition' produces nothing")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "handles a bad file" do
|
26
|
+
append_to_file('definition', 'package {}')
|
27
|
+
|
28
|
+
expect {
|
29
|
+
cli.validate('definition')
|
30
|
+
}.to raise_error(Thor::Error, "'definition' has the following errors:\nEvery package must have a name")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "handles a file that works" do
|
34
|
+
append_to_file('definition', "
|
35
|
+
package {
|
36
|
+
name 'foo'
|
37
|
+
version '0.0.1'
|
38
|
+
type 'dir'
|
39
|
+
}
|
40
|
+
")
|
41
|
+
|
42
|
+
expect(
|
43
|
+
capture(:stdout) { cli.validate('definition') }
|
44
|
+
).to eq("'definition' parses cleanly\n")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/cli/version_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
describe Packager::CLI do
|
2
|
-
it "displays the version" do
|
3
|
-
expect(
|
4
|
-
capture(:stdout) { Packager::CLI.start(['--version']) }
|
5
|
-
).to eq("#{Packager::VERSION}\n")
|
6
|
-
end
|
7
|
-
end
|
1
|
+
describe Packager::CLI do
|
2
|
+
it "displays the version" do
|
3
|
+
expect(
|
4
|
+
capture(:stdout) { Packager::CLI.start(['--version']) }
|
5
|
+
).to eq("#{Packager::VERSION}\n")
|
6
|
+
end
|
7
|
+
end
|
data/spec/dsl/args_spec.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require './spec/dsl/context.rb'
|
2
|
-
describe Packager::DSL do
|
3
|
-
context "arguments" do
|
4
|
-
include_context :dsl
|
5
|
-
|
6
|
-
it "handles a name in the arguments" do
|
7
|
-
items = parse_dsl {
|
8
|
-
package 'foo' do
|
9
|
-
version '0.0.1'
|
10
|
-
type 'test'
|
11
|
-
end
|
12
|
-
}
|
13
|
-
expect(items[0].name).to eq('foo')
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
1
|
+
require './spec/dsl/context.rb'
|
2
|
+
describe Packager::DSL do
|
3
|
+
context "arguments" do
|
4
|
+
include_context :dsl
|
5
|
+
|
6
|
+
it "handles a name in the arguments" do
|
7
|
+
items = parse_dsl {
|
8
|
+
package 'foo' do
|
9
|
+
version '0.0.1'
|
10
|
+
type 'test'
|
11
|
+
end
|
12
|
+
}
|
13
|
+
expect(items[0].name).to eq('foo')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/spec/dsl/context.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
RSpec.shared_context :dsl do
|
2
|
-
def parse_dsl(&block)
|
3
|
-
Packager::DSL.execute_dsl(&block)
|
4
|
-
end
|
5
|
-
end
|
1
|
+
RSpec.shared_context :dsl do
|
2
|
+
def parse_dsl(&block)
|
3
|
+
Packager::DSL.execute_dsl(&block)
|
4
|
+
end
|
5
|
+
end
|
data/spec/dsl/defaults_spec.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
require './spec/dsl/context.rb'
|
2
|
-
describe Packager::DSL do
|
3
|
-
context "default type" do
|
4
|
-
include_context :dsl
|
5
|
-
|
6
|
-
before(:all) { Packager::DSL.default_type('unknown') }
|
7
|
-
after(:all) { Packager::DSL.default_type = nil }
|
8
|
-
|
9
|
-
it "will use the default type" do
|
10
|
-
items = parse_dsl {
|
11
|
-
package {
|
12
|
-
name 'foo'
|
13
|
-
version '0.0.1'
|
14
|
-
}
|
15
|
-
}
|
16
|
-
expect(items[0].type).to eq('unknown')
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
1
|
+
require './spec/dsl/context.rb'
|
2
|
+
describe Packager::DSL do
|
3
|
+
context "default type" do
|
4
|
+
include_context :dsl
|
5
|
+
|
6
|
+
before(:all) { Packager::DSL.default_type('unknown') }
|
7
|
+
after(:all) { Packager::DSL.default_type = nil }
|
8
|
+
|
9
|
+
it "will use the default type" do
|
10
|
+
items = parse_dsl {
|
11
|
+
package {
|
12
|
+
name 'foo'
|
13
|
+
version '0.0.1'
|
14
|
+
}
|
15
|
+
}
|
16
|
+
expect(items[0].type).to eq('unknown')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/dsl/dependency_spec.rb
CHANGED
@@ -1,62 +1,62 @@
|
|
1
|
-
require './spec/dsl/context.rb'
|
2
|
-
describe Packager::DSL do
|
3
|
-
include_context :dsl
|
4
|
-
|
5
|
-
context "requires" do
|
6
|
-
it "handles a dependency" do
|
7
|
-
items = parse_dsl {
|
8
|
-
package {
|
9
|
-
name 'foo'
|
10
|
-
version '0.0.1'
|
11
|
-
type 'test'
|
12
|
-
requires 'foo'
|
13
|
-
}
|
14
|
-
}
|
15
|
-
expect(items[0].requires).to be_instance_of(Array)
|
16
|
-
expect(items[0].requires[0]).to eq('foo')
|
17
|
-
end
|
18
|
-
|
19
|
-
it "handles multiple dependencies" do
|
20
|
-
items = parse_dsl {
|
21
|
-
package {
|
22
|
-
name 'foo'
|
23
|
-
version '0.0.1'
|
24
|
-
type 'test'
|
25
|
-
requires 'foo', 'bar'
|
26
|
-
requires 'baz'
|
27
|
-
}
|
28
|
-
}
|
29
|
-
expect(items[0].requires).to be_instance_of(Array)
|
30
|
-
expect(items[0].requires).to eq([ 'foo', 'bar', 'baz' ])
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "provides" do
|
35
|
-
it "handles a provides" do
|
36
|
-
items = parse_dsl {
|
37
|
-
package {
|
38
|
-
name 'foo'
|
39
|
-
version '0.0.1'
|
40
|
-
type 'test'
|
41
|
-
provides 'foo'
|
42
|
-
}
|
43
|
-
}
|
44
|
-
expect(items[0].provides).to be_instance_of(Array)
|
45
|
-
expect(items[0].provides[0]).to eq('foo')
|
46
|
-
end
|
47
|
-
|
48
|
-
it "handles multiple dependencies" do
|
49
|
-
items = parse_dsl {
|
50
|
-
package {
|
51
|
-
name 'foo'
|
52
|
-
version '0.0.1'
|
53
|
-
type 'test'
|
54
|
-
provides 'foo', 'bar'
|
55
|
-
provides 'baz'
|
56
|
-
}
|
57
|
-
}
|
58
|
-
expect(items[0].provides).to be_instance_of(Array)
|
59
|
-
expect(items[0].provides).to eq([ 'foo', 'bar', 'baz' ])
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
1
|
+
require './spec/dsl/context.rb'
|
2
|
+
describe Packager::DSL do
|
3
|
+
include_context :dsl
|
4
|
+
|
5
|
+
context "requires" do
|
6
|
+
it "handles a dependency" do
|
7
|
+
items = parse_dsl {
|
8
|
+
package {
|
9
|
+
name 'foo'
|
10
|
+
version '0.0.1'
|
11
|
+
type 'test'
|
12
|
+
requires 'foo'
|
13
|
+
}
|
14
|
+
}
|
15
|
+
expect(items[0].requires).to be_instance_of(Array)
|
16
|
+
expect(items[0].requires[0]).to eq('foo')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "handles multiple dependencies" do
|
20
|
+
items = parse_dsl {
|
21
|
+
package {
|
22
|
+
name 'foo'
|
23
|
+
version '0.0.1'
|
24
|
+
type 'test'
|
25
|
+
requires 'foo', 'bar'
|
26
|
+
requires 'baz'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
expect(items[0].requires).to be_instance_of(Array)
|
30
|
+
expect(items[0].requires).to eq([ 'foo', 'bar', 'baz' ])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "provides" do
|
35
|
+
it "handles a provides" do
|
36
|
+
items = parse_dsl {
|
37
|
+
package {
|
38
|
+
name 'foo'
|
39
|
+
version '0.0.1'
|
40
|
+
type 'test'
|
41
|
+
provides 'foo'
|
42
|
+
}
|
43
|
+
}
|
44
|
+
expect(items[0].provides).to be_instance_of(Array)
|
45
|
+
expect(items[0].provides[0]).to eq('foo')
|
46
|
+
end
|
47
|
+
|
48
|
+
it "handles multiple dependencies" do
|
49
|
+
items = parse_dsl {
|
50
|
+
package {
|
51
|
+
name 'foo'
|
52
|
+
version '0.0.1'
|
53
|
+
type 'test'
|
54
|
+
provides 'foo', 'bar'
|
55
|
+
provides 'baz'
|
56
|
+
}
|
57
|
+
}
|
58
|
+
expect(items[0].provides).to be_instance_of(Array)
|
59
|
+
expect(items[0].provides).to eq([ 'foo', 'bar', 'baz' ])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/spec/dsl/error_spec.rb
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
require './spec/dsl/context.rb'
|
2
|
-
describe Packager::DSL do
|
3
|
-
context "error handling" do
|
4
|
-
include_context :dsl
|
5
|
-
|
6
|
-
it "reject an empty package" do
|
7
|
-
expect {
|
8
|
-
parse_dsl { package {} }
|
9
|
-
}.to raise_error("Every package must have a name")
|
10
|
-
end
|
11
|
-
|
12
|
-
it "reject a package without a name" do
|
13
|
-
expect {
|
14
|
-
parse_dsl { package { version '0.0.1' } }
|
15
|
-
}.to raise_error("Every package must have a name")
|
16
|
-
end
|
17
|
-
|
18
|
-
context "for versions" do
|
19
|
-
it "reject a package without a version" do
|
20
|
-
expect {
|
21
|
-
parse_dsl { package { name 'foo' } }
|
22
|
-
}.to raise_error("Every package must have a version")
|
23
|
-
end
|
24
|
-
|
25
|
-
it "rejects a package with a bad version" do
|
26
|
-
expect {
|
27
|
-
parse_dsl {
|
28
|
-
package {
|
29
|
-
name 'foo'
|
30
|
-
version 'b'
|
31
|
-
}
|
32
|
-
}
|
33
|
-
}.to raise_error("'b' is not a legal version string")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
it "rejects a package without a type" do
|
38
|
-
expect {
|
39
|
-
parse_dsl {
|
40
|
-
package {
|
41
|
-
name 'foo'
|
42
|
-
version '0.0.1'
|
43
|
-
}
|
44
|
-
}
|
45
|
-
}.to raise_error("Every package must have a type")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
1
|
+
require './spec/dsl/context.rb'
|
2
|
+
describe Packager::DSL do
|
3
|
+
context "error handling" do
|
4
|
+
include_context :dsl
|
5
|
+
|
6
|
+
it "reject an empty package" do
|
7
|
+
expect {
|
8
|
+
parse_dsl { package {} }
|
9
|
+
}.to raise_error("Every package must have a name")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "reject a package without a name" do
|
13
|
+
expect {
|
14
|
+
parse_dsl { package { version '0.0.1' } }
|
15
|
+
}.to raise_error("Every package must have a name")
|
16
|
+
end
|
17
|
+
|
18
|
+
context "for versions" do
|
19
|
+
it "reject a package without a version" do
|
20
|
+
expect {
|
21
|
+
parse_dsl { package { name 'foo' } }
|
22
|
+
}.to raise_error("Every package must have a version")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "rejects a package with a bad version" do
|
26
|
+
expect {
|
27
|
+
parse_dsl {
|
28
|
+
package {
|
29
|
+
name 'foo'
|
30
|
+
version 'b'
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}.to raise_error("'b' is not a legal version string")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "rejects a package without a type" do
|
38
|
+
expect {
|
39
|
+
parse_dsl {
|
40
|
+
package {
|
41
|
+
name 'foo'
|
42
|
+
version '0.0.1'
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}.to raise_error("Every package must have a type")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/spec/dsl/files_spec.rb
CHANGED
@@ -1,46 +1,46 @@
|
|
1
|
-
require './spec/dsl/context.rb'
|
2
|
-
describe Packager::DSL do
|
3
|
-
context "files" do
|
4
|
-
include_context :dsl
|
5
|
-
|
6
|
-
it "handles one file" do
|
7
|
-
items = parse_dsl {
|
8
|
-
package {
|
9
|
-
name 'foo'
|
10
|
-
version '0.0.1'
|
11
|
-
type 'test'
|
12
|
-
file {
|
13
|
-
source 'foo'
|
14
|
-
dest 'bar'
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|
18
|
-
expect(items[0].files).to be_instance_of(Array)
|
19
|
-
expect(items[0].files[0].source).to eq('foo')
|
20
|
-
expect(items[0].files[0].dest).to eq('bar')
|
21
|
-
end
|
22
|
-
|
23
|
-
it "handles two files" do
|
24
|
-
items = parse_dsl {
|
25
|
-
package {
|
26
|
-
name 'foo'
|
27
|
-
version '0.0.1'
|
28
|
-
type 'test'
|
29
|
-
file {
|
30
|
-
source 'foo'
|
31
|
-
dest 'bar'
|
32
|
-
}
|
33
|
-
files {
|
34
|
-
source 'foo2'
|
35
|
-
dest 'bar2'
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
39
|
-
expect(items[0].files).to be_instance_of(Array)
|
40
|
-
expect(items[0].files[0].source).to eq('foo')
|
41
|
-
expect(items[0].files[0].dest).to eq('bar')
|
42
|
-
expect(items[0].files[1].source).to eq('foo2')
|
43
|
-
expect(items[0].files[1].dest).to eq('bar2')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
1
|
+
require './spec/dsl/context.rb'
|
2
|
+
describe Packager::DSL do
|
3
|
+
context "files" do
|
4
|
+
include_context :dsl
|
5
|
+
|
6
|
+
it "handles one file" do
|
7
|
+
items = parse_dsl {
|
8
|
+
package {
|
9
|
+
name 'foo'
|
10
|
+
version '0.0.1'
|
11
|
+
type 'test'
|
12
|
+
file {
|
13
|
+
source 'foo'
|
14
|
+
dest 'bar'
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
expect(items[0].files).to be_instance_of(Array)
|
19
|
+
expect(items[0].files[0].source).to eq('foo')
|
20
|
+
expect(items[0].files[0].dest).to eq('bar')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "handles two files" do
|
24
|
+
items = parse_dsl {
|
25
|
+
package {
|
26
|
+
name 'foo'
|
27
|
+
version '0.0.1'
|
28
|
+
type 'test'
|
29
|
+
file {
|
30
|
+
source 'foo'
|
31
|
+
dest 'bar'
|
32
|
+
}
|
33
|
+
files {
|
34
|
+
source 'foo2'
|
35
|
+
dest 'bar2'
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
expect(items[0].files).to be_instance_of(Array)
|
40
|
+
expect(items[0].files[0].source).to eq('foo')
|
41
|
+
expect(items[0].files[0].dest).to eq('bar')
|
42
|
+
expect(items[0].files[1].source).to eq('foo2')
|
43
|
+
expect(items[0].files[1].dest).to eq('bar2')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|