tetra 0.40.0 → 0.41.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.
- data/.gitignore +1 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +48 -0
- data/MOTIVATION.md +9 -3
- data/README.md +5 -5
- data/SPECIAL_CASES.md +1 -3
- data/integration-tests/{commons.sh → build-commons.sh} +26 -6
- data/integration-tests/build-obs.sh +21 -0
- data/lib/template/kit_item.spec +53 -0
- data/lib/template/package.spec +4 -2
- data/lib/tetra.rb +5 -3
- data/lib/tetra/archiver.rb +23 -87
- data/lib/tetra/commands/generate_all.rb +13 -16
- data/lib/tetra/commands/generate_kit_archive.rb +4 -4
- data/lib/tetra/commands/generate_kit_spec.rb +4 -2
- data/lib/tetra/commands/generate_package_archive.rb +1 -1
- data/lib/tetra/commands/generate_package_spec.rb +2 -2
- data/lib/tetra/git.rb +19 -10
- data/lib/tetra/glue_kit_item.rb +42 -0
- data/lib/tetra/jar_kit_item.rb +45 -0
- data/lib/tetra/kit.rb +73 -0
- data/lib/tetra/maven_kit_item.rb +64 -0
- data/lib/tetra/package.rb +82 -0
- data/lib/tetra/project.rb +26 -22
- data/lib/tetra/spec_generator.rb +38 -42
- data/lib/tetra/version.rb +1 -1
- data/spec/lib/archiver_spec.rb +30 -86
- data/spec/lib/git_spec.rb +8 -8
- data/spec/lib/glue_kit_item_spec.rb +31 -0
- data/spec/lib/kit_spec.rb +67 -0
- data/spec/lib/maven_kit_item_spec.rb +74 -0
- data/spec/lib/package_spec.rb +78 -0
- data/spec/lib/project_spec.rb +1 -1
- data/spec/lib/spec_generator_spec.rb +59 -87
- metadata +15 -8
- data/lib/template/kit.spec +0 -64
- data/lib/tetra/kit_spec_adapter.rb +0 -28
- data/lib/tetra/package_spec_adapter.rb +0 -59
- data/lib/tetra/template_manager.rb +0 -33
- data/spec/lib/template_manager_spec.rb +0 -54
@@ -1,59 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Tetra
|
4
|
-
# encapsulates details of a package needed by the spec file
|
5
|
-
# retrieving them from other objects
|
6
|
-
class PackageSpecAdapter
|
7
|
-
attr_reader :name
|
8
|
-
attr_reader :version
|
9
|
-
attr_reader :license
|
10
|
-
attr_reader :summary
|
11
|
-
attr_reader :url
|
12
|
-
attr_reader :project_name
|
13
|
-
attr_reader :project_version
|
14
|
-
attr_reader :group_id
|
15
|
-
attr_reader :artifact_id
|
16
|
-
attr_reader :version
|
17
|
-
attr_reader :runtime_dependency_ids
|
18
|
-
attr_reader :description
|
19
|
-
attr_reader :outputs
|
20
|
-
|
21
|
-
def initialize(project, package_name, pom, filter)
|
22
|
-
@name = package_name
|
23
|
-
@version = pom.version
|
24
|
-
@license = (
|
25
|
-
if pom.license_name != ""
|
26
|
-
pom.license_name
|
27
|
-
else
|
28
|
-
"Apache-2.0"
|
29
|
-
end
|
30
|
-
)
|
31
|
-
@summary = cleanup_description(pom.description, 60)
|
32
|
-
@url = pom.url
|
33
|
-
@project_name = project.name
|
34
|
-
@project_version = project.version
|
35
|
-
@group_id = pom.group_id
|
36
|
-
@artifact_id = pom.artifact_id
|
37
|
-
@version = pom.version
|
38
|
-
@runtime_dependency_ids = pom.runtime_dependency_ids
|
39
|
-
@description = cleanup_description(pom.description, 1500)
|
40
|
-
|
41
|
-
@outputs = project.get_produced_files(package_name).select do |file|
|
42
|
-
File.fnmatch? filter, File.basename(file)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def public_binding
|
47
|
-
binding
|
48
|
-
end
|
49
|
-
|
50
|
-
def cleanup_description(raw, max_length)
|
51
|
-
raw
|
52
|
-
.gsub(/[\s]+/, " ")
|
53
|
-
.strip
|
54
|
-
.slice(0..max_length - 1)
|
55
|
-
.sub(/\s\w+$/, "")
|
56
|
-
.sub(/\.+$/, "")
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
module Tetra
|
4
|
-
# operates on files in template/
|
5
|
-
class TemplateManager
|
6
|
-
include Logging
|
7
|
-
|
8
|
-
attr_reader :template_path
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
@template_path = File.join(File.dirname(__FILE__), "..", "template")
|
12
|
-
end
|
13
|
-
|
14
|
-
# copies a template file in a directory
|
15
|
-
def copy(template_name, destination_dir)
|
16
|
-
FileUtils.cp_r(File.join(template_path, template_name), destination_dir)
|
17
|
-
end
|
18
|
-
|
19
|
-
# generates content from an ERB template and an object binding
|
20
|
-
# if destination_path is given, write it to that file, otherwise just
|
21
|
-
# return it
|
22
|
-
def generate(template_name, object_binding, destination_path = nil)
|
23
|
-
erb = ERB.new File.read(File.join(template_path, template_name)), nil, "<>"
|
24
|
-
new_content = erb.result(object_binding)
|
25
|
-
|
26
|
-
unless destination_path.nil?
|
27
|
-
File.open(destination_path, "w") { |io| io.write new_content }
|
28
|
-
end
|
29
|
-
|
30
|
-
new_content
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
describe Tetra::TemplateManager do
|
6
|
-
let(:template_manager) { Tetra::TemplateManager.new }
|
7
|
-
|
8
|
-
describe "#template_path" do
|
9
|
-
it "returns the pathname where all templates are stored" do
|
10
|
-
relative_path = template_manager.template_path
|
11
|
-
expected_path = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "template"))
|
12
|
-
expect(File.expand_path(relative_path)).to eq expected_path
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#copy" do
|
17
|
-
it "copies a file from template to another dir" do
|
18
|
-
destination = Tempfile.new("TemplateManager spec")
|
19
|
-
destination_path = destination.path
|
20
|
-
destination.unlink
|
21
|
-
|
22
|
-
template_manager.copy(File.join("src", "CONTENTS"), destination_path)
|
23
|
-
|
24
|
-
File.exist?(destination_path)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe "#generate" do
|
29
|
-
it "compiles a file from a template and a value objects file" do
|
30
|
-
template_path = File.join(template_manager.template_path, "test.erb")
|
31
|
-
File.open(template_path, "w") { |io| io.puts "Hello <%= world_property %>" }
|
32
|
-
|
33
|
-
destination = Tempfile.new("TemplateManager spec")
|
34
|
-
destination_path = destination.path
|
35
|
-
destination.unlink
|
36
|
-
|
37
|
-
# binding test class
|
38
|
-
class WorldClass
|
39
|
-
def world_property
|
40
|
-
"World!"
|
41
|
-
end
|
42
|
-
|
43
|
-
def public_binding
|
44
|
-
binding
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
template_manager.generate("test.erb", WorldClass.new.public_binding, destination_path)
|
49
|
-
File.unlink(template_path)
|
50
|
-
|
51
|
-
expect(File.read(destination_path)).to eq "Hello World!\n"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|