rdm 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/Gemfile.lock +80 -0
- data/bin/rdm +78 -10
- data/example/.rdm/helpers/render_helper.rb +12 -0
- data/example/.rdm/templates/package/.gitignore +1 -0
- data/example/.rdm/templates/package/.rspec +2 -0
- data/example/.rdm/templates/package/<%=package_subdir_name%>/<%=package_name%>.rb +3 -0
- data/example/.rdm/templates/package/<%=package_subdir_name%>/<%=package_name%>/.gitkeep +0 -0
- data/{lib/rdm/templates/package/package.rb.erb → example/.rdm/templates/package/Package.rb} +0 -0
- data/{lib/rdm/templates/package/bin/console_irb → example/.rdm/templates/package/bin/console} +0 -0
- data/example/.rdm/templates/package/spec/spec_helper.rb +10 -0
- data/example/.rdm/templates/repository/dao/<%=name%>_dao.rb +4 -0
- data/example/.rdm/templates/repository/mapper/<%=name%>_mapper.rb +2 -0
- data/example/.rdm/templates/repository/repository/<%=name%>_repository.rb +2 -0
- data/example/.rdm/templates/repository/views/users.html.erb +2 -0
- data/example/Gemfile.lock +50 -0
- data/example/Rdm.packages +1 -0
- data/example/tests/diff_run +0 -0
- data/example/tests/run +0 -0
- data/lib/rdm.rb +40 -8
- data/lib/rdm/cli/compile_package.rb +56 -0
- data/lib/rdm/cli/dependencies_controller.rb +30 -0
- data/lib/rdm/cli/diff_package.rb +21 -0
- data/lib/rdm/cli/gen_package.rb +24 -32
- data/lib/rdm/cli/init.rb +20 -27
- data/lib/rdm/cli/template_generator.rb +38 -0
- data/lib/rdm/errors.rb +37 -0
- data/lib/rdm/gen/init.rb +29 -44
- data/lib/rdm/gen/package.rb +24 -78
- data/lib/rdm/git/diff_command.rb +13 -0
- data/lib/rdm/git/diff_manager.rb +30 -0
- data/lib/rdm/git/repository_locator.rb +23 -0
- data/lib/rdm/handlers/dependencies_handler.rb +110 -0
- data/lib/rdm/handlers/diff_package_handler.rb +48 -0
- data/lib/rdm/handlers/template_handler.rb +118 -0
- data/lib/rdm/helpers/path_helper.rb +15 -0
- data/lib/rdm/package.rb +6 -0
- data/lib/rdm/package_importer.rb +1 -1
- data/lib/rdm/packages/compiler_service.rb +78 -0
- data/lib/rdm/packages/locator.rb +28 -0
- data/lib/rdm/settings.rb +14 -1
- data/lib/rdm/spec_runner.rb +5 -0
- data/lib/rdm/spec_runner/command_generator.rb +28 -0
- data/lib/rdm/spec_runner/command_params.rb +3 -0
- data/lib/rdm/spec_runner/package_fetcher.rb +13 -0
- data/lib/rdm/spec_runner/runner.rb +122 -0
- data/lib/rdm/spec_runner/view.rb +20 -0
- data/lib/rdm/templates/init/.rdm/helpers/render_helper.rb +12 -0
- data/lib/rdm/templates/init/{Gemfile.erb → Gemfile} +0 -0
- data/lib/rdm/templates/init/{Rdm.packages.erb → Rdm.packages} +0 -0
- data/lib/rdm/templates/init/{Readme.md.erb → Readme.md} +0 -0
- data/lib/rdm/templates/init/tests/diff_run +29 -0
- data/lib/rdm/templates/init/tests/run +7 -210
- data/lib/rdm/templates/package/<%=package_subdir_name%>/<%=package_name%>.rb +3 -0
- data/lib/rdm/templates/package/<%=package_subdir_name%>/<%=package_name%>/.gitkeep +0 -0
- data/lib/rdm/templates/package/Package.rb +8 -0
- data/lib/rdm/templates/package/bin/console +16 -0
- data/lib/rdm/templates/template_detector.rb +32 -0
- data/lib/rdm/templates/template_renderer.rb +49 -0
- data/lib/rdm/utils/file_utils.rb +20 -0
- data/lib/rdm/utils/render_util.rb +24 -0
- data/lib/rdm/utils/string_utils.rb +16 -0
- data/lib/rdm/version.rb +1 -1
- data/rdm.gemspec +1 -1
- data/spec/helpers/example_project_helper.rb +217 -0
- data/spec/helpers/git_commands_helper.rb +13 -0
- data/spec/rdm/cli/compile_package_spec.rb +114 -0
- data/spec/rdm/cli/dependencies_controller_spec.rb +50 -0
- data/spec/rdm/cli/diff_package_spec.rb +5 -0
- data/spec/rdm/cli/gen_package_spec.rb +60 -86
- data/spec/rdm/cli/init_spec.rb +53 -70
- data/spec/rdm/gen/init_spec.rb +21 -38
- data/spec/rdm/gen/package_spec.rb +70 -51
- data/spec/rdm/git/diff_manager_spec.rb +81 -0
- data/spec/rdm/git/repository_locator_spec.rb +31 -0
- data/spec/rdm/handlers/dependencies_handler_spec.rb +84 -0
- data/spec/rdm/handlers/diff_package_handler_spec.rb +78 -0
- data/spec/rdm/handlers/template_handler_spec.rb +94 -0
- data/spec/rdm/helpers/path_helper_spec.rb +52 -0
- data/spec/rdm/package/compiler_service_spec.rb +124 -0
- data/spec/rdm/package/locator_spec.rb +31 -0
- data/spec/rdm/rdm_spec.rb +2 -2
- data/spec/rdm/spec_runner/runner_spec.rb +12 -0
- data/spec/rdm/templates/template_detector_spec.rb +39 -0
- data/spec/rdm/templates/template_renderer_spec.rb +42 -0
- data/spec/spec_helper.rb +31 -25
- metadata +84 -17
- data/lib/rdm/gen/concerns/template_handling.rb +0 -81
- data/lib/rdm/support/colorize.rb +0 -106
- data/lib/rdm/support/render.rb +0 -17
- data/lib/rdm/support/template.rb +0 -30
- data/lib/rdm/templates/package/main_module_file.rb.erb +0 -3
- data/spec/rdm/support/colorize_spec.rb +0 -24
- data/spec/rdm/support/template_spec.rb +0 -20
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rdm::CLI::DependenciesController do
|
4
|
+
include ExampleProjectHelper
|
5
|
+
|
6
|
+
subject { described_class }
|
7
|
+
|
8
|
+
before { initialize_example_project }
|
9
|
+
after { reset_example_project }
|
10
|
+
|
11
|
+
let(:stdout) { SpecLogger.new }
|
12
|
+
|
13
|
+
context ":run" do
|
14
|
+
it "returns array of dependencies names" do
|
15
|
+
subject.run(
|
16
|
+
package_name: 'web',
|
17
|
+
project_path: example_project_path,
|
18
|
+
stdout: stdout
|
19
|
+
)
|
20
|
+
|
21
|
+
expect(stdout.output).to include(
|
22
|
+
[
|
23
|
+
"web",
|
24
|
+
"└── core",
|
25
|
+
" └── repository"
|
26
|
+
]
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns no dependencies message" do
|
31
|
+
subject.run(
|
32
|
+
package_name: 'repository',
|
33
|
+
project_path: example_project_path,
|
34
|
+
stdout: stdout
|
35
|
+
)
|
36
|
+
|
37
|
+
expect(stdout.output).to include("Package `repository` has no dependencies")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "show error message if package_name not specified" do
|
41
|
+
subject.run(
|
42
|
+
package_name: '',
|
43
|
+
project_path: example_project_path,
|
44
|
+
stdout: stdout
|
45
|
+
)
|
46
|
+
|
47
|
+
expect(stdout.output).to include("Type package name, ex: rdm gen.deps repository")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,45 +1,25 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Rdm::CLI::GenPackage do
|
4
|
-
include
|
4
|
+
include ExampleProjectHelper
|
5
5
|
|
6
|
-
|
7
|
-
Rdm::Gen::Package.disable_logger!
|
8
|
-
end
|
6
|
+
subject { described_class }
|
9
7
|
|
10
|
-
|
11
|
-
Rdm::Gen::Init.generate(
|
12
|
-
current_dir: empty_project_dir
|
13
|
-
)
|
14
|
-
end
|
8
|
+
let(:stdout) { SpecLogger.new }
|
15
9
|
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
def ensure_content(file, content)
|
21
|
-
expect(File.read(file)).to match(content)
|
22
|
-
end
|
10
|
+
before { initialize_example_project }
|
11
|
+
after { reset_example_project }
|
23
12
|
|
24
13
|
context "run" do
|
25
|
-
before :all do
|
26
|
-
fresh_project
|
27
|
-
end
|
28
|
-
|
29
|
-
after :all do
|
30
|
-
clean_tmp
|
31
|
-
end
|
32
|
-
|
33
14
|
it "generates package" do
|
34
|
-
|
15
|
+
subject.run(
|
35
16
|
package_name: "database",
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
Rdm::CLI::GenPackage.run(opts)
|
17
|
+
current_path: example_project_path,
|
18
|
+
local_path: "infrastructure/database",
|
19
|
+
stdout: stdout
|
20
|
+
)
|
41
21
|
|
42
|
-
FileUtils.cd(
|
22
|
+
FileUtils.cd(example_project_path) do
|
43
23
|
ensure_exists("infrastructure/database/Package.rb")
|
44
24
|
ensure_exists("infrastructure/database/package/database.rb")
|
45
25
|
ensure_exists("infrastructure/database/package/database/")
|
@@ -50,79 +30,73 @@ describe Rdm::CLI::GenPackage do
|
|
50
30
|
ensure_content("infrastructure/database/package/database.rb", "module Database\n\nend\n")
|
51
31
|
end
|
52
32
|
end
|
53
|
-
end
|
54
33
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
34
|
+
it "has logged useful output" do
|
35
|
+
subject.run(
|
36
|
+
package_name: "database",
|
37
|
+
current_path: example_project_path,
|
38
|
+
local_path: "infrastructure/database",
|
39
|
+
stdout: stdout
|
40
|
+
)
|
59
41
|
|
60
|
-
|
61
|
-
clean_tmp
|
42
|
+
expect(stdout.output).to include("Generated: infrastructure/database/Package.rb")
|
62
43
|
end
|
44
|
+
end
|
63
45
|
|
46
|
+
context "run with errors" do
|
64
47
|
it "fails when in wrong directory" do
|
65
|
-
|
48
|
+
subject.run(
|
66
49
|
package_name: "database",
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
expect
|
73
|
-
Rdm::CLI::GenPackage.run(opts)
|
74
|
-
}.to output(/Rdm.packages\ not\ found/).to_stdout
|
50
|
+
current_path: File.dirname(example_project_path),
|
51
|
+
local_path: "infrastructure/database",
|
52
|
+
stdout: stdout
|
53
|
+
)
|
54
|
+
|
55
|
+
expect(stdout.output).to include("Rdm.packages was not found. Run 'rdm init' to create it")
|
75
56
|
end
|
76
57
|
|
77
58
|
it "fails when package already created" do
|
78
|
-
|
79
|
-
|
59
|
+
subject.run(
|
60
|
+
package_name: "database",
|
61
|
+
current_path: example_project_path,
|
62
|
+
local_path: "infrastructure/database",
|
63
|
+
stdout: stdout
|
64
|
+
)
|
65
|
+
|
66
|
+
subject.run(
|
80
67
|
package_name: "database",
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
expect{
|
88
|
-
Rdm::CLI::GenPackage.run(opts)
|
89
|
-
}.to output(Regexp.new("Error. Directory infrastructure/database exists. Package was not generated")).to_stdout
|
90
|
-
clean_tmp
|
68
|
+
current_path: example_project_path,
|
69
|
+
local_path: "infrastructure/database",
|
70
|
+
stdout: stdout
|
71
|
+
)
|
72
|
+
expect(stdout.output).to include("Error. Directory infrastructure/database exists. Package was not generated")
|
91
73
|
end
|
92
74
|
|
93
75
|
it "fails when package already created" do
|
94
|
-
|
95
|
-
opts = {
|
76
|
+
subject.run(
|
96
77
|
package_name: "database",
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
78
|
+
current_path: example_project_path,
|
79
|
+
local_path: "infrastructure/database",
|
80
|
+
stdout: stdout
|
81
|
+
)
|
82
|
+
|
83
|
+
subject.run(
|
84
|
+
package_name: "database",
|
85
|
+
current_path: example_project_path,
|
86
|
+
local_path: "database",
|
87
|
+
stdout: stdout
|
88
|
+
)
|
89
|
+
expect(stdout.output).to include("Error. Package already exist. Package was not generated")
|
109
90
|
end
|
110
91
|
|
111
92
|
it "fails when empty package given" do
|
112
|
-
|
113
|
-
opts = {
|
93
|
+
subject.run(
|
114
94
|
package_name: "",
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
expect{
|
121
|
-
Rdm::CLI::GenPackage.run(opts)
|
122
|
-
}.to output(Regexp.new("Package name was not specified!")).to_stdout
|
123
|
-
rescue SystemExit
|
124
|
-
clean_tmp
|
125
|
-
end
|
95
|
+
current_path: example_project_path,
|
96
|
+
local_path: "infrastructure/database",
|
97
|
+
stdout: stdout
|
98
|
+
)
|
99
|
+
expect(stdout.output).to include("Package name was not specified!")
|
126
100
|
end
|
127
101
|
end
|
128
102
|
|
data/spec/rdm/cli/init_spec.rb
CHANGED
@@ -1,97 +1,80 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Rdm::CLI::Init do
|
4
|
-
include
|
4
|
+
include ExampleProjectHelper
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
end
|
6
|
+
subject { described_class }
|
7
|
+
let(:stdout) { SpecLogger.new }
|
9
8
|
|
10
|
-
def ensure_exists(file)
|
11
|
-
expect(File.exists?(file)).to be true
|
12
|
-
end
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
end
|
10
|
+
before { initialize_example_project(skip_rdm_init: true) }
|
11
|
+
after { reset_example_project }
|
17
12
|
|
18
13
|
context "run" do
|
19
|
-
before :all do
|
20
|
-
fresh_empty_project
|
21
|
-
end
|
22
|
-
|
23
|
-
after :all do
|
24
|
-
clean_tmp
|
25
|
-
end
|
26
|
-
|
27
14
|
it "generates package" do
|
28
|
-
|
29
|
-
|
30
|
-
console:
|
31
|
-
test:
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
FileUtils.cd(
|
15
|
+
subject.run(
|
16
|
+
current_path: example_project_path,
|
17
|
+
console: "irb",
|
18
|
+
test: "rspec",
|
19
|
+
stdout: stdout
|
20
|
+
)
|
21
|
+
|
22
|
+
FileUtils.cd(example_project_path) do
|
36
23
|
ensure_exists("Rdm.packages")
|
37
24
|
ensure_exists("Gemfile")
|
38
25
|
ensure_exists("Readme.md")
|
39
26
|
ensure_exists("tests/run")
|
27
|
+
ensure_exists("tests/diff_run")
|
40
28
|
end
|
41
29
|
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "run with errors" do
|
45
|
-
before :all do
|
46
|
-
clean_tmp
|
47
|
-
end
|
48
30
|
|
49
|
-
|
50
|
-
|
31
|
+
it "output list of generated files" do
|
32
|
+
subject.run(
|
33
|
+
current_path: example_project_path,
|
34
|
+
console: "irb",
|
35
|
+
test: "rspec",
|
36
|
+
stdout: stdout
|
37
|
+
)
|
38
|
+
expect(stdout.output).to include('Generated: Rdm.packages')
|
51
39
|
end
|
40
|
+
end
|
52
41
|
|
42
|
+
context "run with errors" do
|
53
43
|
it "fails when in wrong directory" do
|
54
|
-
|
55
|
-
|
56
|
-
console:
|
57
|
-
test:
|
58
|
-
|
59
|
-
|
60
|
-
expect
|
61
|
-
Rdm::CLI::Init.run(opts)
|
62
|
-
}.to output(Regexp.new("Please run on empty directory")).to_stdout
|
44
|
+
subject.run(
|
45
|
+
current_path: example_project_path + "/not-there",
|
46
|
+
console: "irb",
|
47
|
+
test: "rspec",
|
48
|
+
stdout: stdout
|
49
|
+
)
|
50
|
+
expect(stdout.output).to include("/tmp/example/not-there doesn't exist. Initialize new rdm project with existing directory")
|
63
51
|
end
|
64
52
|
|
65
53
|
it "fails when project already initialized" do
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
54
|
+
subject.run(
|
55
|
+
current_path: example_project_path,
|
56
|
+
console: "irb",
|
57
|
+
test: "rspec",
|
58
|
+
stdout: stdout
|
59
|
+
)
|
60
|
+
|
61
|
+
subject.run(
|
62
|
+
current_path: example_project_path,
|
63
|
+
console: "irb",
|
64
|
+
test: "rspec",
|
65
|
+
stdout: stdout
|
66
|
+
)
|
67
|
+
expect(stdout.output).to include("Error. Project was already initialized")
|
78
68
|
end
|
79
69
|
|
80
|
-
it "fails with wrong
|
81
|
-
|
82
|
-
|
83
|
-
console:
|
84
|
-
test:
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
begin
|
89
|
-
a = 1
|
90
|
-
Rdm::CLI::Init.run(opts)
|
91
|
-
a = 2
|
92
|
-
rescue SystemExit
|
93
|
-
expect(a).to eq(1)
|
94
|
-
end
|
70
|
+
it "fails with wrong current_path and exits" do
|
71
|
+
subject.run(
|
72
|
+
current_path: "",
|
73
|
+
console: "irb",
|
74
|
+
test: "rspec",
|
75
|
+
stdout: stdout
|
76
|
+
)
|
77
|
+
expect(stdout.output).to include("Error. Project folder not specified. Type path to rdm project, ex: 'rdm init .'")
|
95
78
|
end
|
96
79
|
end
|
97
80
|
end
|
data/spec/rdm/gen/init_spec.rb
CHANGED
@@ -1,35 +1,18 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Rdm::Gen::Init do
|
4
|
-
include
|
4
|
+
include ExampleProjectHelper
|
5
5
|
|
6
|
-
|
7
|
-
Rdm::Gen::Init.generate(
|
8
|
-
current_dir: empty_project_dir
|
9
|
-
)
|
10
|
-
end
|
11
|
-
|
12
|
-
def ensure_exists(file)
|
13
|
-
expect(File.exists?(file)).to be true
|
14
|
-
end
|
6
|
+
subject { described_class }
|
15
7
|
|
16
|
-
|
17
|
-
|
18
|
-
end
|
8
|
+
before { initialize_example_project(skip_rdm_init: true) }
|
9
|
+
after { reset_example_project }
|
19
10
|
|
20
11
|
context "sample project" do
|
21
|
-
before :all do
|
22
|
-
Rdm::Gen::Init.disable_logger!
|
23
|
-
fresh_empty_project
|
24
|
-
generate_project!
|
25
|
-
end
|
26
|
-
|
27
|
-
after :all do
|
28
|
-
clean_tmp
|
29
|
-
end
|
30
|
-
|
31
12
|
it "has generated correct files" do
|
32
|
-
|
13
|
+
subject.generate(current_path: example_project_path)
|
14
|
+
|
15
|
+
FileUtils.cd(example_project_path) do
|
33
16
|
ensure_exists("Rdm.packages")
|
34
17
|
ensure_exists("Gemfile")
|
35
18
|
ensure_exists("Readme.md")
|
@@ -37,26 +20,26 @@ describe Rdm::Gen::Init do
|
|
37
20
|
end
|
38
21
|
end
|
39
22
|
|
40
|
-
it "has
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
23
|
+
it "has generated package templates" do
|
24
|
+
subject.generate(current_path: example_project_path)
|
25
|
+
|
26
|
+
FileUtils.cd(example_project_path) do
|
27
|
+
ensure_exists(".rdm/templates/package/Package.rb")
|
28
|
+
ensure_exists(".rdm/templates/package/<%=package_subdir_name%>/<%=package_name%>.rb")
|
29
|
+
ensure_exists(".rdm/templates/package/.rspec")
|
30
|
+
ensure_exists(".rdm/templates/package/.gitignore")
|
31
|
+
ensure_exists(".rdm/templates/package/spec/spec_helper.rb")
|
32
|
+
ensure_exists(".rdm/templates/package/bin/console")
|
33
|
+
end
|
47
34
|
end
|
48
35
|
end
|
49
36
|
|
50
37
|
context "prevents double execution" do
|
51
|
-
after :all do
|
52
|
-
clean_tmp
|
53
|
-
end
|
54
|
-
|
55
38
|
it "raises on second project generation" do
|
56
|
-
|
57
|
-
|
39
|
+
subject.generate(current_path: example_project_path)
|
40
|
+
|
58
41
|
expect {
|
59
|
-
|
42
|
+
subject.generate(current_path: example_project_path)
|
60
43
|
}.to raise_error(Rdm::Errors::ProjectAlreadyInitialized)
|
61
44
|
end
|
62
45
|
end
|