rdm 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +69 -1
- data/bin/rdm +102 -42
- data/example/.rdm/templates/configs/<%=config_path%> +2 -0
- data/example/.rdm/templates/configs/<%=role_config_path%> +2 -0
- data/example/Rdm.packages +8 -3
- data/example/domain/core/spec/core/one_more_spec.rb +5 -0
- data/example/domain/core/spec/core/sample_service_spec.rb +5 -0
- data/example/infrastructure/repository/Package.rb +1 -1
- data/example/infrastructure/repository/spec/example_spec.rb +5 -0
- data/example/infrastructure/repository/spec/spec_helper.rb +7 -0
- data/example/server/spec/server_spec.rb +5 -0
- data/example/server/spec/spec_helper.rb +7 -0
- data/example/{.runignore → tests/.runignore} +0 -0
- data/example/tests/diff_run +1 -30
- data/example/tests/run +1 -39
- data/lib/rdm.rb +2 -1
- data/lib/rdm/cli/dependencies_controller.rb +2 -0
- data/lib/rdm/cli/diff_spec_runner.rb +42 -0
- data/lib/rdm/errors.rb +3 -0
- data/lib/rdm/gen/config.rb +1 -3
- data/lib/rdm/gen/init.rb +13 -7
- data/lib/rdm/gen/package.rb +6 -6
- data/lib/rdm/handlers/dependencies_handler.rb +14 -9
- data/lib/rdm/handlers/diff_package_handler.rb +2 -1
- data/lib/rdm/handlers/template_handler.rb +2 -2
- data/lib/rdm/settings.rb +0 -1
- data/lib/rdm/source_modifier.rb +69 -0
- data/lib/rdm/spec_runner.rb +5 -2
- data/lib/rdm/spec_runner/command_generator.rb +3 -2
- data/lib/rdm/spec_runner/runner.rb +18 -8
- data/lib/rdm/templates/init/bin/console +1 -1
- data/lib/rdm/templates/init/{.runignore → tests/.runignore} +0 -0
- data/lib/rdm/templates/init/tests/diff_run +1 -33
- data/lib/rdm/templates/init/tests/run +1 -39
- data/lib/rdm/version.rb +1 -1
- data/spec/helpers/example_project_helper.rb +0 -185
- data/spec/rdm/cli/diff_spec_runner_spec.rb +55 -0
- data/spec/rdm/cli/init_spec.rb +0 -2
- data/spec/rdm/gen/init_spec.rb +9 -1
- data/spec/rdm/handlers/dependencies_handler_spec.rb +27 -0
- data/spec/rdm/source_parser_spec.rb +1 -2
- data/spec/rdm/spec_runner/runner_spec.rb +61 -3
- metadata +14 -9
- data/lib/rdm/source_composer.rb +0 -38
- data/spec/rdm/cli/diff_package_spec.rb +0 -5
- data/spec/rdm/source_composer_spec.rb +0 -76
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd2b98cd1a4c0604e5b22d4681bc8dd0ab957025
|
4
|
+
data.tar.gz: bc64b5cd0850ea5a639a3d2cb9312b487f0c9afa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 867ac2bf5b101620c1c0606d939ff92d3b5bc941908943b979613ab103fab111cebae5feb85511fa8ca943f5b3ba9245cc1242fe9835be2de55fe73a6e943d27
|
7
|
+
data.tar.gz: ee2208aacb31e87c3c9c82617df99caf040fa817ef9a8aca9fd87717db5a02d1ccb851fe369b91fe71b7fc4df3f73c9df5fb14fe35b962b19d8ab7283a1bbe4c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -92,7 +92,75 @@ require 'rdm'
|
|
92
92
|
Rdm.init(File.expand_path("../../", __FILE__), :test)
|
93
93
|
```
|
94
94
|
|
95
|
+
### Templates and generators
|
96
|
+
Rdm has a set of generators using which you can make the creation of template structures automatic.
|
97
|
+
By default upon project initialization two generators are available: new package generator gen.package and configuration files generator gen.config.
|
98
|
+
|
99
|
+
**Syntax of the generator is the following:**
|
100
|
+
```ruby
|
101
|
+
rdm gen.package #{PACKAGE_NAME} --path #{PATH/TO/PACKAGE}
|
102
|
+
rdm gen.config #{CONFIG_NAME}
|
103
|
+
```
|
104
|
+
To create new package “repository” and place it in the “infrastructure/repository” folder in your app you should type the following command: `rdm gen.package repository --path infrastructure/repository`
|
105
|
+
You can also change the standard package generator or add custom templates to your project. All available templates are in the **".rdm/templates/:template_name"** folder of your project. The syntax to launch any template generator is the following:
|
106
|
+
```ruby
|
107
|
+
rdm gen.template #{TEMPLATE_NAME} --path #{PATH/TO/TEMPLATE}
|
108
|
+
```
|
109
|
+
This way if you want to create a structure using “repository” template in the “infrastructure/storage” folder of your app you should type the following command: `rdm gen.template repository --path infrastructure/storage`
|
110
|
+
|
111
|
+
When copying the template you can use any variables and helpers methods. In order to get unknown variables that are contained in the templates, the Rdm will show the dialogue window requesting to type in their values. A previously defined variable is "package_subdir_name", it’s value is set in Rdm.packages file. To enter variables to templates a common erb syntax is used:
|
112
|
+
```ruby
|
113
|
+
require '<%=name%>_repository'
|
114
|
+
```
|
115
|
+
```ruby
|
116
|
+
class <%= package_name %>
|
117
|
+
def initialize
|
118
|
+
end
|
119
|
+
end
|
120
|
+
```
|
121
|
+
You can add helpers methods yourself to the **.rdm/helpers/render_helper.rb** and they will be available to use in the templates.
|
122
|
+
```ruby
|
123
|
+
# .rdm/helpers/render_helper.rb
|
124
|
+
module Rdm
|
125
|
+
module RenderHelper
|
126
|
+
def camelize(string, uppercase_first_letter = true)
|
127
|
+
# some staff
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
```
|
132
|
+
```ruby
|
133
|
+
# .rdm/templates/custom_template
|
134
|
+
class <%= capitalize(package_name) %>
|
135
|
+
def initialize
|
136
|
+
end
|
137
|
+
end
|
138
|
+
```
|
139
|
+
|
140
|
+
### Package compiler
|
141
|
+
Rdm lets you make any package compliance easier, using only dependencies needed for it. Command syntax is the following:
|
142
|
+
```ruby
|
143
|
+
rdm compile.package #{PACKAGE_NAME} --path #{PATH/TO/COMPILED/PACKAGE}
|
144
|
+
```
|
145
|
+
By default the path value is **‘tmp/:package_name’**, where *:package_name* is changed to the name of the package. This way if you want to comply a ‘web’ package with all it’s dependencies in the '~/dev/web' directory type the following command: `rdm compile.package web --path '~/dev/web'`
|
146
|
+
|
147
|
+
### Diff manager
|
148
|
+
If you have VCS Git on your projects you can use it to get the list of packages that have undergone any changes. The command syntax is the following:
|
149
|
+
```ruby
|
150
|
+
rdm git.diff #{REVISION}
|
151
|
+
```
|
152
|
+
This way if you want to get a list of packages that have undergone changes compared to the development branch from the master branch, type this command: `rdm git.diff development`
|
153
|
+
|
154
|
+
### Dependencies manager
|
155
|
+
Rdm lets you to create a dependency tree for your packages. Syntax for the command is the following:
|
156
|
+
```ruby
|
157
|
+
rdm gen.deps #{PACKAGE_NAME}
|
158
|
+
```
|
159
|
+
This way if you want to display recursive list of dependencies for the ‘server’ package type in the following:
|
160
|
+
`rdm gen.deps server`
|
161
|
+
Values listed in the parentheses to the right of the package contain information on groups that have this package in them.
|
162
|
+
|
95
163
|
|
96
164
|
## Examples
|
97
165
|
|
98
|
-
- [small dummy application](/example)
|
166
|
+
- [small dummy application](/example)
|
data/bin/rdm
CHANGED
@@ -17,21 +17,23 @@ class RdmCliRunner
|
|
17
17
|
program :description, 'Ruby Dependencies Manager'
|
18
18
|
|
19
19
|
command :init do |c|
|
20
|
-
c.syntax
|
21
|
-
c.description = 'generates project scaffold in
|
22
|
-
c.summary
|
23
|
-
c.example
|
24
|
-
c.example
|
25
|
-
c.example
|
26
|
-
c.example
|
27
|
-
c.option
|
28
|
-
c.option
|
29
|
-
c.option
|
20
|
+
c.syntax = 'rdm init PATH, [options]'
|
21
|
+
c.description = 'generates project scaffold in passed directory'
|
22
|
+
c.summary = '> ' + c.description
|
23
|
+
c.example 'generate scaffold with minitest', 'rdm init --test=minitest'
|
24
|
+
c.example 'generate scaffold with rspec', 'rdm init --test=rspec'
|
25
|
+
c.example 'generate scaffold with irb', 'rdm init --console=irb'
|
26
|
+
c.example 'generate scaffold with pry', 'rdm init --console=pry'
|
27
|
+
c.option '--test FRAMEWORK', TESTFRAMEWORKS, "select test framework: #{TESTFRAMEWORKS.join(", ")}"
|
28
|
+
c.option '--console CONSOLE', CONSOLES, "select console: #{CONSOLES.join(", ")}"
|
29
|
+
c.option '--current_path [ROOT_DIR]', String, 'Path for the root folder'
|
30
|
+
|
30
31
|
c.action do |args, options|
|
32
|
+
init_dir = (args.first || `pwd`.strip)
|
31
33
|
defaults = {
|
32
34
|
test: "rspec",
|
33
35
|
console: "irb",
|
34
|
-
current_path:
|
36
|
+
current_path: init_dir
|
35
37
|
}
|
36
38
|
options_hash = options.__hash__
|
37
39
|
options_hash.delete(:trace)
|
@@ -42,18 +44,19 @@ class RdmCliRunner
|
|
42
44
|
end
|
43
45
|
|
44
46
|
command :"gen.package" do |c|
|
45
|
-
c.syntax
|
47
|
+
c.syntax = 'rdm gen.package PACKAGE_NAME [options]'
|
46
48
|
c.description = 'generates a package scaffold in specified folder'
|
47
|
-
c.summary
|
48
|
-
c.example
|
49
|
-
|
50
|
-
c.example
|
51
|
-
|
52
|
-
c.example
|
53
|
-
|
54
|
-
c.example
|
55
|
-
c.option
|
56
|
-
c.option
|
49
|
+
c.summary = '> ' + c.description
|
50
|
+
c.example 'generate commands package',
|
51
|
+
'rdm gen.package commands --path core/application/commands'
|
52
|
+
c.example 'generate pack/age package',
|
53
|
+
'rdm gen.package pack/age --path subsystems/package'
|
54
|
+
c.example 'generate events package within /some/other/path folder',
|
55
|
+
'rdm gen.package events --path core/domain/events --current_path /some/other/path'
|
56
|
+
c.example 'generate auth package without tests', 'rdm gen.package auth --path subsystems/auth'
|
57
|
+
c.option '--path [RELATIVE_PATH]', String, 'Path for the package'
|
58
|
+
c.option '--current_path [ROOT_DIR]', String, 'Path for the root folder'
|
59
|
+
|
57
60
|
c.action do |args, options|
|
58
61
|
package_name = (args.first || "")
|
59
62
|
defaults = {
|
@@ -73,8 +76,9 @@ class RdmCliRunner
|
|
73
76
|
c.syntax = 'rdm git.diff REVISION'
|
74
77
|
c.description = 'show list of modified packages from git revision'
|
75
78
|
c.summary = '> ' + c.description
|
76
|
-
c.example
|
77
|
-
|
79
|
+
c.example 'show list of modified packages from master',
|
80
|
+
'rdm git.diff master'
|
81
|
+
|
78
82
|
c.action do |args, options|
|
79
83
|
revision = (args.first || "HEAD")
|
80
84
|
options = {
|
@@ -86,12 +90,13 @@ class RdmCliRunner
|
|
86
90
|
end
|
87
91
|
|
88
92
|
command :"compile.package" do |c|
|
89
|
-
c.syntax
|
93
|
+
c.syntax = 'rdm compile.package PACKAGE_NAME [options]'
|
90
94
|
c.description = 'copy specified package and its dependencies to some folder'
|
91
|
-
c.summary
|
92
|
-
c.example
|
93
|
-
|
94
|
-
c.option
|
95
|
+
c.summary = '> ' + c.description
|
96
|
+
c.example 'compilation of "commands" package to /tmp/commands dir',
|
97
|
+
'rdm compile.package commands --path /tmp/commands'
|
98
|
+
c.option '--path [COMPILE_PATH]', String, 'Path for compiled package'
|
99
|
+
|
95
100
|
c.action do |args, options|
|
96
101
|
package_name = (args.first || "")
|
97
102
|
opts = {
|
@@ -104,13 +109,14 @@ class RdmCliRunner
|
|
104
109
|
end
|
105
110
|
|
106
111
|
command :"gen.template" do |c|
|
107
|
-
c.syntax
|
112
|
+
c.syntax = 'rdm gen.template TEMPLATE_NAME [options]'
|
108
113
|
c.description = 'generates template from ROOT/.rdm/templates folder with specified variables'
|
109
|
-
c.summary
|
110
|
-
c.example
|
111
|
-
|
112
|
-
c.option
|
113
|
-
c.option
|
114
|
+
c.summary = '> ' + c.description
|
115
|
+
c.example 'creating new repository, mapper and dao files',
|
116
|
+
'rdm gen.template repository --path infrastructure/storage'
|
117
|
+
c.option '--path [DESTINATION_PATH]', String, 'Location of generated folders'
|
118
|
+
c.option '--OPTION_NAME [OPTION_VALUE]', String, 'Local variables for template handler'
|
119
|
+
|
114
120
|
c.action do |args, options|
|
115
121
|
options_hash = options.__hash__
|
116
122
|
options_hash.delete(:trace)
|
@@ -127,10 +133,10 @@ class RdmCliRunner
|
|
127
133
|
end
|
128
134
|
|
129
135
|
command :"gen.deps" do |c|
|
130
|
-
c.syntax
|
136
|
+
c.syntax = 'rdm gen.deps PACKAGE_NAME'
|
131
137
|
c.description = 'puts list of recursive dependencies for specified package'
|
132
|
-
c.summary
|
133
|
-
c.example
|
138
|
+
c.summary = '> ' + c.description
|
139
|
+
c.example 'show dependencies for `commands` package', 'rdm gen.deps commands'
|
134
140
|
|
135
141
|
c.action do |args, options|
|
136
142
|
package_name = args.first || ""
|
@@ -143,11 +149,11 @@ class RdmCliRunner
|
|
143
149
|
end
|
144
150
|
|
145
151
|
command :"gen.config" do |c|
|
146
|
-
c.syntax
|
152
|
+
c.syntax = 'rdm gen.config CONFIG_NAME --CONFIG_KEY=CONFIG_VALUE'
|
147
153
|
c.description = 'generate config file with passed arguments'
|
148
|
-
c.summary
|
149
|
-
c.example
|
150
|
-
|
154
|
+
c.summary = '> ' + c.description
|
155
|
+
c.example 'generate config `mailing_system` with `host: localhost`',
|
156
|
+
'rdm gen.config mailing_system --host=localhost'
|
151
157
|
|
152
158
|
c.action do |args, options|
|
153
159
|
config_name = args.first || ""
|
@@ -161,6 +167,60 @@ class RdmCliRunner
|
|
161
167
|
)
|
162
168
|
end
|
163
169
|
end
|
170
|
+
|
171
|
+
command :"rspec.run" do |c|
|
172
|
+
c.syntax = 'rdm rspec.run PACKAGE_NAME SPEC_MATCHER'
|
173
|
+
c.description = 'run tests for specified package and spec file matcher'
|
174
|
+
c.summary = '> ' + c.description
|
175
|
+
|
176
|
+
c.example 'run tests for all packages',
|
177
|
+
'rdm rspec.run'
|
178
|
+
c.example 'run tests for `mailing_system` package',
|
179
|
+
'rdm rspec.run mailing_system'
|
180
|
+
c.example 'run tests for `mailing_system` package and files, matches `events` string',
|
181
|
+
'rdm rspec.run mailing_system events'
|
182
|
+
|
183
|
+
c.action do |args, options|
|
184
|
+
package_name = args[0]
|
185
|
+
spec_matcher = args[1]
|
186
|
+
|
187
|
+
ENV['RUBY_ENV'] = 'test'
|
188
|
+
|
189
|
+
Rdm.root(`pwd`.chomp)
|
190
|
+
Rdm::SpecRunner.run(
|
191
|
+
package: package_name,
|
192
|
+
spec_matcher: spec_matcher,
|
193
|
+
path: `pwd`.chomp,
|
194
|
+
skip_ignored_packages: true,
|
195
|
+
show_missing_packages: true
|
196
|
+
)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
command :"rspec.diff_run" do |c|
|
201
|
+
c.syntax = 'rdm rspec.diff_run REVISION'
|
202
|
+
c.description = 'run tests for modified packages from specified git revision'
|
203
|
+
c.summary = '> ' + c.description
|
204
|
+
|
205
|
+
c.example 'run tests for packages modified from HEAD',
|
206
|
+
'rdm rspec.diff_run'
|
207
|
+
c.example 'run tests for packages modified from commit by hash',
|
208
|
+
'rdm rspec.diff_run a7rrey'
|
209
|
+
c.example 'run tests for packages modified from specified branch',
|
210
|
+
'rdm rspec.diff_run master'
|
211
|
+
|
212
|
+
c.action do |args, options|
|
213
|
+
revision = args[0]
|
214
|
+
|
215
|
+
ENV['RUBY_ENV'] = 'test'
|
216
|
+
Rdm.root(`pwd`.chomp)
|
217
|
+
|
218
|
+
Rdm::CLI::DiffSpecRunner.run(
|
219
|
+
revision: revision,
|
220
|
+
path: `pwd`.chomp
|
221
|
+
)
|
222
|
+
end
|
223
|
+
end
|
164
224
|
|
165
225
|
run!
|
166
226
|
end
|
data/example/Rdm.packages
CHANGED
File without changes
|
data/example/tests/diff_run
CHANGED
@@ -1,32 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
require 'rdm'
|
5
|
-
|
6
|
-
REVISION = ARGV.clone.first
|
7
|
-
PATH = File.expand_path(__FILE__)
|
8
|
-
|
9
|
-
begin
|
10
|
-
changed_packages = Rdm::Handlers::DiffPackageHandler.handle(
|
11
|
-
path: PATH,
|
12
|
-
revision: REVISION
|
13
|
-
)
|
14
|
-
|
15
|
-
puts "Tests for the following packages will run:"
|
16
|
-
puts changed_packages
|
17
|
-
|
18
|
-
changed_packages.each do |package|
|
19
|
-
Rdm::SpecRunner.run(
|
20
|
-
package: package,
|
21
|
-
path: PATH,
|
22
|
-
show_missing_packages: false
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
rescue Rdm::Errors::GitRepositoryNotInitialized
|
28
|
-
puts "Git repository is not initialized. Use `git init .`"
|
29
|
-
exit(1)
|
30
|
-
end
|
31
|
-
|
32
|
-
|
3
|
+
system("bundle exec rdm rspec.diff_run #{ARGV.join(' ')}", out: STDOUT, err: :out)
|
data/example/tests/run
CHANGED
@@ -1,41 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
## $ TEST_RUN=1 tests/run
|
5
|
-
|
6
|
-
## # run application tests:
|
7
|
-
## $ tests/run
|
8
|
-
|
9
|
-
## # run package tests:
|
10
|
-
## $ tests/run commands
|
11
|
-
|
12
|
-
## # run spec in a package:
|
13
|
-
## $ tests/run commands some_spec.rb
|
14
|
-
|
15
|
-
ENV['RUBY_ENV'] = 'test'
|
16
|
-
require 'rdm'
|
17
|
-
|
18
|
-
Rdm.root(__FILE__)
|
19
|
-
|
20
|
-
if ENV['TEST_RUN']
|
21
|
-
require 'minitest/autorun'
|
22
|
-
describe Rdm::SpecRunner::Runner do
|
23
|
-
before do
|
24
|
-
@runner = Rdm::SpecRunner::Runner.new({})
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'works ' do
|
28
|
-
it 'assert true' do
|
29
|
-
assert 2 == 2
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
else
|
34
|
-
Rdm::SpecRunner.run(
|
35
|
-
package: ARGV.clone.first,
|
36
|
-
spec_matcher: ARGV.clone[1],
|
37
|
-
path: File.expand_path(__FILE__),
|
38
|
-
skip_ignored_packages: true,
|
39
|
-
show_missing_packages: true
|
40
|
-
)
|
41
|
-
end
|
3
|
+
system("bundle exec rdm rspec.run #{ARGV.join(' ')}", out: STDOUT, err: :out)
|