tetra 0.43.0 → 0.44.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/.rubocop.yml +1 -1
  2. data/README.md +2 -2
  3. data/SPECIAL_CASES.md +8 -8
  4. data/integration-tests/build-commons.sh +5 -6
  5. data/lib/template/gitignore +1 -1
  6. data/lib/template/{output → packages}/CONTENTS +0 -0
  7. data/lib/template/packages/kit/CONTENTS +3 -0
  8. data/lib/tetra.rb +14 -14
  9. data/lib/tetra/commands/generate_all.rb +7 -11
  10. data/lib/tetra/commands/{generate_package_archive.rb → generate_archive.rb} +3 -3
  11. data/lib/tetra/commands/{generate_kit_spec.rb → generate_kit.rb} +5 -2
  12. data/lib/tetra/commands/generate_script.rb +18 -0
  13. data/lib/tetra/commands/{generate_package_spec.rb → generate_spec.rb} +3 -3
  14. data/lib/tetra/git.rb +0 -8
  15. data/lib/tetra/main.rb +9 -15
  16. data/lib/tetra/packages/archivable.rb +26 -0
  17. data/lib/tetra/{package.rb → packages/built_package.rb} +11 -25
  18. data/lib/tetra/{glue_kit_item.rb → packages/glue_kit_item.rb} +14 -15
  19. data/lib/tetra/{jar_kit_item.rb → packages/jar_kit_item.rb} +13 -15
  20. data/lib/tetra/{kit.rb → packages/kit.rb} +0 -0
  21. data/lib/tetra/{maven_kit_item.rb → packages/maven_kit_item.rb} +13 -13
  22. data/lib/tetra/packages/scriptable.rb +48 -0
  23. data/lib/tetra/{spec_generator.rb → packages/speccable.rb} +12 -22
  24. data/lib/tetra/project.rb +19 -10
  25. data/lib/tetra/version.rb +1 -1
  26. data/spec/lib/archivable_spec.rb +36 -0
  27. data/spec/lib/{package_spec.rb → built_package_spec.rb} +4 -4
  28. data/spec/lib/git_spec.rb +0 -6
  29. data/spec/lib/glue_kit_item_spec.rb +1 -1
  30. data/spec/lib/maven_kit_item_spec.rb +2 -2
  31. data/spec/lib/project_spec.rb +8 -0
  32. data/spec/lib/{script_generator_spec.rb → scriptable_spec.rb} +8 -11
  33. data/spec/lib/{spec_generator_spec.rb → speccable.rb} +11 -20
  34. metadata +20 -20
  35. data/lib/tetra/archiver.rb +0 -31
  36. data/lib/tetra/commands/generate_kit_archive.rb +0 -18
  37. data/lib/tetra/commands/generate_package_script.rb +0 -18
  38. data/lib/tetra/script_generator.rb +0 -58
  39. data/spec/lib/archiver_spec.rb +0 -50
@@ -2,26 +2,17 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe Tetra::SpecGenerator do
5
+ describe Tetra::Speccable do
6
6
  include Tetra::Mockers
7
7
 
8
8
  # mock
9
- class SpecGeneratorTestClass
9
+ class SpeccableTestClass
10
10
  attr_accessor :world_property
11
11
 
12
- include Tetra::SpecGenerator
13
- attr_reader :project
14
- attr_reader :package_name
15
- attr_reader :spec_dir
16
- attr_reader :template_spec_name
12
+ include Tetra::Speccable
17
13
 
18
- def initialize(project)
14
+ def initialize
19
15
  @world_property = "World!"
20
-
21
- @project = project
22
- @package_name = "test-package"
23
- @spec_dir = "kit"
24
- @template_spec_name = "test.spec"
25
16
  end
26
17
  end
27
18
 
@@ -31,10 +22,10 @@ describe Tetra::SpecGenerator do
31
22
  @template_path = File.join(instance.template_path, "test.spec")
32
23
  File.open(@template_path, "w") { |io| io.puts "Hello <%= world_property %>\nintentionally blank line\n" }
33
24
 
34
- @destination_path = File.join("output", instance.package_name, "#{instance.package_name}.spec")
25
+ @destination_path = File.join("output", "test-package", "test-package.spec")
35
26
  end
36
27
 
37
- let(:instance) { SpecGeneratorTestClass.new(@project) }
28
+ let(:instance) { SpeccableTestClass.new }
38
29
 
39
30
  after(:each) do
40
31
  delete_mock_project
@@ -43,7 +34,7 @@ describe Tetra::SpecGenerator do
43
34
 
44
35
  describe "#to_spec" do
45
36
  it "generates a first version" do
46
- expect(instance.to_spec).to be_truthy
37
+ expect(instance._to_spec(@project, "test-package", "kit", "test.spec")).to be_truthy
47
38
 
48
39
  @project.from_directory do
49
40
  spec_lines = File.readlines(@destination_path)
@@ -52,7 +43,7 @@ describe Tetra::SpecGenerator do
52
43
  end
53
44
 
54
45
  it "generates a second version" do
55
- expect(instance.to_spec).to be_truthy
46
+ expect(instance._to_spec(@project, "test-package", "kit", "test.spec")).to be_truthy
56
47
 
57
48
  @project.from_directory do
58
49
  File.open(@destination_path, "a") do |io|
@@ -62,7 +53,7 @@ describe Tetra::SpecGenerator do
62
53
 
63
54
  instance.world_property = "Mario!"
64
55
 
65
- expect(instance.to_spec).to be_truthy
56
+ expect(instance._to_spec(@project, "test-package", "kit", "test.spec")).to be_truthy
66
57
 
67
58
  @project.from_directory do
68
59
  spec_lines = File.readlines(@destination_path)
@@ -73,7 +64,7 @@ describe Tetra::SpecGenerator do
73
64
  end
74
65
 
75
66
  it "generates a conflicting version" do
76
- expect(instance.to_spec).to be_truthy
67
+ expect(instance._to_spec(@project, "test-package", "kit", "test.spec")).to be_truthy
77
68
 
78
69
  @project.from_directory do
79
70
  spec_contents = File.read(@destination_path)
@@ -86,7 +77,7 @@ describe Tetra::SpecGenerator do
86
77
 
87
78
  instance.world_property = "Mario!"
88
79
 
89
- expect(instance.to_spec).to be_truthy
80
+ expect(instance._to_spec(@project, "test-package", "kit", "test.spec")).to be_truthy
90
81
 
91
82
  @project.from_directory do
92
83
  spec_lines = File.readlines(@destination_path)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tetra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.43.0
4
+ version: 0.44.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-14 00:00:00.000000000 Z
12
+ date: 2014-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -167,23 +167,22 @@ files:
167
167
  - lib/template/kit/jars/CONTENTS
168
168
  - lib/template/kit/m2/settings.xml
169
169
  - lib/template/kit_item.spec
170
- - lib/template/output/CONTENTS
171
170
  - lib/template/package.spec
171
+ - lib/template/packages/CONTENTS
172
+ - lib/template/packages/kit/CONTENTS
172
173
  - lib/template/src/CONTENTS
173
174
  - lib/tetra.rb
174
175
  - lib/tetra/ant_runner.rb
175
- - lib/tetra/archiver.rb
176
176
  - lib/tetra/commands/ant.rb
177
177
  - lib/tetra/commands/base.rb
178
178
  - lib/tetra/commands/download_maven_source_jars.rb
179
179
  - lib/tetra/commands/dry_run.rb
180
180
  - lib/tetra/commands/finish.rb
181
181
  - lib/tetra/commands/generate_all.rb
182
- - lib/tetra/commands/generate_kit_archive.rb
183
- - lib/tetra/commands/generate_kit_spec.rb
184
- - lib/tetra/commands/generate_package_archive.rb
185
- - lib/tetra/commands/generate_package_script.rb
186
- - lib/tetra/commands/generate_package_spec.rb
182
+ - lib/tetra/commands/generate_archive.rb
183
+ - lib/tetra/commands/generate_kit.rb
184
+ - lib/tetra/commands/generate_script.rb
185
+ - lib/tetra/commands/generate_spec.rb
187
186
  - lib/tetra/commands/get_pom.rb
188
187
  - lib/tetra/commands/get_source.rb
189
188
  - lib/tetra/commands/init.rb
@@ -191,23 +190,24 @@ files:
191
190
  - lib/tetra/commands/move_jars_to_kit.rb
192
191
  - lib/tetra/commands/mvn.rb
193
192
  - lib/tetra/git.rb
194
- - lib/tetra/glue_kit_item.rb
195
- - lib/tetra/jar_kit_item.rb
196
- - lib/tetra/kit.rb
197
193
  - lib/tetra/kit_checker.rb
198
194
  - lib/tetra/kit_runner.rb
199
195
  - lib/tetra/logger.rb
200
196
  - lib/tetra/main.rb
201
- - lib/tetra/maven_kit_item.rb
202
197
  - lib/tetra/maven_runner.rb
203
198
  - lib/tetra/maven_website.rb
204
- - lib/tetra/package.rb
199
+ - lib/tetra/packages/archivable.rb
200
+ - lib/tetra/packages/built_package.rb
201
+ - lib/tetra/packages/glue_kit_item.rb
202
+ - lib/tetra/packages/jar_kit_item.rb
203
+ - lib/tetra/packages/kit.rb
204
+ - lib/tetra/packages/maven_kit_item.rb
205
+ - lib/tetra/packages/scriptable.rb
206
+ - lib/tetra/packages/speccable.rb
205
207
  - lib/tetra/pom.rb
206
208
  - lib/tetra/pom_getter.rb
207
209
  - lib/tetra/project.rb
208
- - lib/tetra/script_generator.rb
209
210
  - lib/tetra/source_getter.rb
210
- - lib/tetra/spec_generator.rb
211
211
  - lib/tetra/version.rb
212
212
  - lib/tetra/version_matcher.rb
213
213
  - spec/data/ant-super-simple-code/build.xml
@@ -227,7 +227,8 @@ files:
227
227
  - spec/data/struts-apps/pom.xml
228
228
  - spec/data/tomcat/pom.xml
229
229
  - spec/lib/ant_runner_spec.rb
230
- - spec/lib/archiver_spec.rb
230
+ - spec/lib/archivable_spec.rb
231
+ - spec/lib/built_package_spec.rb
231
232
  - spec/lib/git_spec.rb
232
233
  - spec/lib/glue_kit_item_spec.rb
233
234
  - spec/lib/kit_checker_spec.rb
@@ -235,13 +236,12 @@ files:
235
236
  - spec/lib/maven_kit_item_spec.rb
236
237
  - spec/lib/maven_runner_spec.rb
237
238
  - spec/lib/maven_website_spec.rb
238
- - spec/lib/package_spec.rb
239
239
  - spec/lib/pom_getter_spec.rb
240
240
  - spec/lib/pom_spec.rb
241
241
  - spec/lib/project_spec.rb
242
- - spec/lib/script_generator_spec.rb
242
+ - spec/lib/scriptable_spec.rb
243
243
  - spec/lib/source_getter_spec.rb
244
- - spec/lib/spec_generator_spec.rb
244
+ - spec/lib/speccable.rb
245
245
  - spec/lib/version_matcher_spec.rb
246
246
  - spec/spec_helper.rb
247
247
  - spec/support/kit_runner_examples.rb
@@ -1,31 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module Tetra
4
- # implements a to_archive method
5
- module Archiver
6
- include Logging
7
- # expected attributes:
8
- # project (Tetra::Project)
9
- # package_name (string)
10
- # source_dir (string)
11
- # source_paths ([string])
12
- # destination_dir (string)
13
-
14
- # generates an archive and returns its name
15
- # this will archive source_paths starting from source_dir in
16
- # destination_dir + package_name + extension
17
- def to_archive
18
- full_destination_dir = File.join(project.full_path, "output", destination_dir)
19
- FileUtils.mkdir_p(full_destination_dir)
20
-
21
- project.from_directory(source_dir) do
22
- destination_path = File.join(full_destination_dir, "#{package_name}.tar.xz")
23
- log.debug "creating #{destination_path}"
24
-
25
- `tar -cJf #{destination_path} #{source_paths.join(" ")}`
26
-
27
- destination_path
28
- end
29
- end
30
- end
31
- end
@@ -1,18 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module Tetra
4
- # tetra generate-kit-archive
5
- class GenerateKitArchiveCommand < Tetra::BaseCommand
6
- def execute
7
- checking_exceptions do
8
- project = Tetra::Project.new(".")
9
- ensure_dry_running(false, project) do
10
- Tetra::Kit.new(project).items.each do |item|
11
- result_path = item.to_archive
12
- print_generation_result(project, result_path)
13
- end
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,18 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module Tetra
4
- # tetra generate-package-script
5
- class GeneratePackageScriptCommand < Tetra::BaseCommand
6
- def execute
7
- checking_exceptions do
8
- project = Tetra::Project.new(".")
9
- ensure_dry_running(false, project) do
10
- history_file = File.join(Dir.home, ".bash_history")
11
- result_path, conflict_count = Tetra::ScriptGenerator.new(project, history_file)
12
- .generate_build_script
13
- print_generation_result(project, result_path, conflict_count)
14
- end
15
- end
16
- end
17
- end
18
- end
@@ -1,58 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module Tetra
4
- # generates build scripts from bash_history
5
- class ScriptGenerator
6
- include Logging
7
-
8
- def initialize(project, history_path)
9
- @project = project
10
- @ant_runner = Tetra::AntRunner.new(project)
11
- @maven_runner = Tetra::MavenRunner.new(project)
12
- @history_path = history_path
13
- end
14
-
15
- def generate_build_script
16
- @project.from_directory do
17
- history_lines = File.readlines(@history_path).map { |e| e.strip }
18
- relevant_lines =
19
- history_lines
20
- .reverse
21
- .take_while { |e| e.match(/tetra +dry-run/).nil? }
22
- .reverse
23
- .take_while { |e| e.match(/tetra +finish/).nil? }
24
- .select { |e| e.match(/^#/).nil? }
25
-
26
- script_lines = [
27
- "#!/bin/bash",
28
- "set -xe",
29
- "PROJECT_PREFIX=`readlink -e .`",
30
- "cd #{@project.latest_dry_run_directory}"
31
- ] +
32
- relevant_lines.map do |line|
33
- if line =~ /tetra +mvn/
34
- line.gsub(/tetra +mvn/, "#{@maven_runner.get_maven_commandline("$PROJECT_PREFIX", ["-o"])}")
35
- elsif line =~ /tetra +ant/
36
- line.gsub(/tetra +ant/, "#{@ant_runner.get_ant_commandline("$PROJECT_PREFIX")}")
37
- else
38
- line
39
- end
40
- end
41
-
42
- new_content = script_lines.join("\n") + "\n"
43
-
44
- result_path = File.join("src", "build.sh")
45
- conflict_count = @project.merge_new_content(new_content, result_path, "Build script generated",
46
- "generate_build_script")
47
-
48
- output_dir = File.join("output", @project.name)
49
- FileUtils.mkdir_p(output_dir)
50
-
51
- destination_script_path = File.join(output_dir, "build.sh")
52
- FileUtils.symlink(File.expand_path(result_path), destination_script_path, force: true)
53
-
54
- [destination_script_path, conflict_count]
55
- end
56
- end
57
- end
58
- end
@@ -1,50 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require "spec_helper"
4
-
5
- describe Tetra::Archiver do
6
- include Tetra::Mockers
7
-
8
- # mock
9
- class TestArchiverClass
10
- include Tetra::Archiver
11
-
12
- attr_reader :project
13
- attr_reader :package_name
14
- attr_reader :source_dir
15
- attr_reader :source_paths
16
- attr_reader :destination_dir
17
-
18
- def initialize(project)
19
- @project = project
20
- @package_name = "test-package"
21
- @source_dir = "kit"
22
- @source_paths = ["*"]
23
- @destination_dir = "test-package"
24
- end
25
- end
26
-
27
- before(:each) do
28
- create_mock_project
29
- end
30
-
31
- let(:instance) { TestArchiverClass.new(@project) }
32
-
33
- after(:each) do
34
- delete_mock_project
35
- end
36
-
37
- describe "#to_archive" do
38
- it "generates an archive" do
39
- @project.from_directory("kit") do
40
- FileUtils.touch("kit_test")
41
- end
42
-
43
- instance.to_archive
44
-
45
- @project.from_directory do
46
- expect(`tar -Jtf output/test-package/test-package.tar.xz`.split).to include("kit_test")
47
- end
48
- end
49
- end
50
- end