rdm 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec7392add4bff744020f08554065f66d2b1c2155
4
- data.tar.gz: 39ac10317b4c8ae71816e6844ec922b06025a74c
3
+ metadata.gz: 396c2803b01c338a4c6297bc2f2a5df629d96a9b
4
+ data.tar.gz: 45f399f0dd90357c6754fc9c35562b7fc3375b45
5
5
  SHA512:
6
- metadata.gz: 705e6d22a68e2c9e5c2499bc197885bcb624f02777ba0601647cee6e93a034afb6c3c91dbef73da21ff5381d5e4f4d103f423193eaf6490c0fc0113badca3c21
7
- data.tar.gz: 1a00c19c72dcdc189d84f9e1ac11412963bc04b7e4df69d3a6f1393bce683d9ae269180f35db35917bab16e1f6708f3778fe8f3bccff80dcaae91970fd1da638
6
+ metadata.gz: f65d094c45b7e596bf7bd7950e6a3fa8c167171db762e4e060080f5907c9ad47b4ed0c820951e7f11bac00266634b302b16673e4fc11d246065064c17957f9ab
7
+ data.tar.gz: f584ad64900d94cc77e4596245ff006d5a1560f8d77cb2076de5199798bc20e59ea88c911a4f8c2234abdcb44968eded70a4d592e85e51c74b0378689e872b3c
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
3
+ # - 2.2.2
4
4
  - 2.3.0
5
5
  - 2.4.0
6
+ - 2.4.1
6
7
 
7
8
  before_install:
8
9
  - gem update --system
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rdm (0.4.1)
4
+ rdm (0.4.2)
5
5
  activesupport
6
6
  commander (~> 4.4)
7
7
 
@@ -25,7 +25,7 @@ GEM
25
25
  diff-lcs (1.3)
26
26
  docile (1.1.5)
27
27
  highline (1.7.8)
28
- i18n (0.8.4)
28
+ i18n (0.8.6)
29
29
  json (2.0.3)
30
30
  minitest (5.10.2)
31
31
  parser (2.3.3.1)
data/bin/rdm CHANGED
@@ -33,7 +33,10 @@ class RdmCliRunner
33
33
  console: "irb",
34
34
  current_path: `pwd`.strip
35
35
  }
36
- options_with_defaults = defaults.merge!(options.__hash__)
36
+ options_hash = options.__hash__
37
+ options_hash.delete(:trace)
38
+
39
+ options_with_defaults = defaults.merge!(options_hash)
37
40
  Rdm::CLI::Init.run(options_with_defaults)
38
41
  end
39
42
  end
@@ -58,7 +61,10 @@ class RdmCliRunner
58
61
  package_name: package_name,
59
62
  path: package_name.downcase.gsub(/\s+/, '_')
60
63
  }
61
- options_with_defaults = defaults.merge!(options.__hash__)
64
+ options_hash = options.__hash__
65
+ options_hash.delete(:trace)
66
+
67
+ options_with_defaults = defaults.merge!(options_hash)
62
68
  Rdm::CLI::GenPackage.run(options_with_defaults)
63
69
  end
64
70
  end
@@ -106,10 +112,13 @@ class RdmCliRunner
106
112
  c.option '--path [DESTINATION_PATH]', String, 'Location of generated folders'
107
113
  c.option '--OPTION_NAME [OPTION_VALUE]', String, 'Local variables for template handler'
108
114
  c.action do |args, options|
109
- options_hash = options.__hash__
115
+ options_hash = options.__hash__
116
+ options_hash.delete(:trace)
117
+
118
+ template_name = args.first || ""
110
119
 
111
120
  Rdm::CLI::TemplateGenerator.run(
112
- template_name: (args.first || ""),
121
+ template_name: template_name,
113
122
  current_path: `pwd`.chomp,
114
123
  local_path: options_hash.delete(:path),
115
124
  locals: options_hash
@@ -133,6 +142,26 @@ class RdmCliRunner
133
142
  end
134
143
  end
135
144
 
145
+ command :"gen.config" do |c|
146
+ c.syntax = 'rdm gen.config CONFIG_NAME --CONFIG_KEY=CONFIG_VALUE'
147
+ c.description = 'generate config file with passed arguments'
148
+ c.summary = '> ' + c.description
149
+ c.example 'generate config `mailing_system` with `host: localhost`',
150
+ 'rdm gen.config mailing_system --host=localhost'
151
+
152
+ c.action do |args, options|
153
+ config_name = args.first || ""
154
+ options_hash = options.__hash__
155
+ options_hash.delete(:trace)
156
+
157
+ Rdm::CLI::Config.run(
158
+ config_name: config_name,
159
+ current_path: `pwd`.chomp,
160
+ config_data: options_hash
161
+ )
162
+ end
163
+ end
164
+
136
165
  run!
137
166
  end
138
167
  end
@@ -0,0 +1,4 @@
1
+ # type in packages, they will be ignored upon the start of the specs
2
+ # for example:
3
+ # entities
4
+ # repository
@@ -1 +1,2 @@
1
- app_name: "Sample app"
1
+ app:
2
+ name: "Sample app"
@@ -1 +1,2 @@
1
- app_name: "Sample app (Production)"
1
+ app:
2
+ name: "Sample app (Production)"
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV['RUBY_ENV'] = 'test'
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
+
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ## # run own tests:
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
+ runignore_path = File.expand_path(File.join(File.dirname(Rdm.root(__FILE__)), '.runignore'))
19
+ skipped_packages = File.open(runignore_path).each_line.inject([]) { |all, line| all.push(line.chomp!) }
20
+
21
+ if ENV['TEST_RUN']
22
+ require 'minitest/autorun'
23
+ describe Rdm::SpecRunner::Runner do
24
+ before do
25
+ @runner = Rdm::SpecRunner::Runner.new({})
26
+ end
27
+
28
+ describe 'works ' do
29
+ it 'assert true' do
30
+ assert 2 == 2
31
+ end
32
+ end
33
+ end
34
+ else
35
+ Rdm::SpecRunner.run(
36
+ package: ARGV.clone.first,
37
+ spec_matcher: ARGV.clone.last,
38
+ path: File.expand_path(__FILE__),
39
+ skipped_packages: skipped_packages,
40
+ show_missing_packages: true
41
+ )
42
+ end
data/lib/rdm.rb CHANGED
@@ -15,6 +15,7 @@ module Rdm
15
15
  require 'rdm/cli/diff_package'
16
16
  require 'rdm/cli/template_generator'
17
17
  require 'rdm/cli/dependencies_controller'
18
+ require 'rdm/cli/config'
18
19
 
19
20
  # Runtime part
20
21
  require 'rdm/config'
@@ -27,10 +28,12 @@ module Rdm
27
28
  require 'rdm/settings'
28
29
  require 'rdm/source'
29
30
  require 'rdm/source_parser'
31
+ require 'rdm/source_composer'
30
32
  require 'rdm/source_locator'
31
33
  require 'rdm/git/diff_manager'
32
34
  require 'rdm/git/diff_command'
33
35
  require 'rdm/git/repository_locator'
36
+ require 'rdm/config_locals'
34
37
 
35
38
  # Package part
36
39
  require 'rdm/packages/compiler_service'
@@ -39,6 +42,7 @@ module Rdm
39
42
  # Handlers part
40
43
  require 'rdm/gen/package'
41
44
  require 'rdm/gen/init'
45
+ require 'rdm/gen/config'
42
46
  require 'rdm/handlers/diff_package_handler'
43
47
  require 'rdm/handlers/template_handler'
44
48
  require 'rdm/handlers/dependencies_handler'
@@ -0,0 +1,31 @@
1
+ class Rdm::CLI::Config
2
+ def self.run(current_path:, config_name:, config_data: {}, stdout: $stdout)
3
+ Rdm::CLI::Config.new(current_path, config_name, config_data, stdout).run
4
+ end
5
+
6
+ def initialize(current_path, config_name, config_data, stdout)
7
+ @current_path = current_path
8
+ @config_name = config_name
9
+ @config_data = config_data
10
+ @stdout = stdout
11
+ end
12
+
13
+ def run
14
+ generated_files = Rdm::Gen::Config.generate(
15
+ current_path: @current_path,
16
+ config_name: @config_name,
17
+ config_data: @config_data
18
+ )
19
+
20
+ puts "Following files were generated:"
21
+ puts generated_files
22
+ rescue Errno::ENOENT => e
23
+ @stdout.puts "Error occurred. Possible reasons:\n #{Rdm::SOURCE_FILENAME} not found. Please run on directory containing #{Rdm::SOURCE_FILENAME} \n#{e.inspect}"
24
+ rescue NoMethodError => e
25
+ @stdout.puts e.message
26
+ rescue Rdm::Errors::SourceFileDoesNotExist => e
27
+ @stdout.puts "Rdm.packages was not found. Run 'rdm init' to create it"
28
+ rescue Rdm::Errors::ConfigExists => e
29
+ @stdout.puts "Config :#{e.message} already exists! Use other name"
30
+ end
31
+ end
@@ -0,0 +1,11 @@
1
+ class Rdm::ConfigLocals
2
+ def initialize(locals = {})
3
+ @locals = locals
4
+ end
5
+
6
+ def to_s
7
+ @locals
8
+ .map {|key, value| "#{key}: #{value}"}
9
+ .join("\n")
10
+ end
11
+ end
@@ -0,0 +1,61 @@
1
+ class Rdm::Gen::Config
2
+ TEMPLATE_NAME = 'configs'
3
+
4
+ def self.generate(config_name:, current_path:, config_data: {})
5
+ Rdm::Gen::Config.new(config_name, current_path, config_data = {}).generate
6
+ end
7
+
8
+ def initialize(config_name, current_path, config_data)
9
+ @current_path = current_path
10
+ @config_name = config_name
11
+ @source = get_source
12
+
13
+ @config_locals = Rdm::ConfigLocals.new(config_data)
14
+ end
15
+
16
+ def generate
17
+ @source.config(@config_name)
18
+
19
+ @locals = {
20
+ config_name: @config_name,
21
+ config_locals: @config_locals,
22
+ config_path: config_path(@config_name),
23
+ role_config_path: role_config_path(@config_name)
24
+ }
25
+
26
+ generated_files = Rdm::Handlers::TemplateHandler.generate(
27
+ current_path: @current_path,
28
+ locals: @locals,
29
+ template_name: TEMPLATE_NAME,
30
+ local_path: './'
31
+ )
32
+
33
+ Rdm::SourceComposer.run(@source)
34
+
35
+ generated_files
36
+ end
37
+
38
+ private
39
+
40
+ def get_source
41
+ @source ||= Rdm::SourceParser.read_and_init_source(Rdm::SourceLocator.locate(@current_path))
42
+ end
43
+
44
+ def config_path(config_name)
45
+ Rdm.settings.read_setting(
46
+ :config_path,
47
+ vars: {
48
+ config_name: config_name
49
+ }
50
+ )
51
+ end
52
+
53
+ def role_config_path(config_name)
54
+ Rdm.settings.read_setting(
55
+ :role_config_path,
56
+ vars: {
57
+ config_name: config_name
58
+ }
59
+ )
60
+ end
61
+ end
@@ -17,14 +17,17 @@ module Rdm
17
17
  @package_name = package_name
18
18
  @local_path = local_path
19
19
  @locals = locals
20
+ @source = get_source
20
21
  end
21
22
 
22
23
  def create
23
- raise Rdm::Errors::PackageDirExists.new(@local_path) if Dir.exist?(File.join(source.root_path, @local_path))
24
- raise Rdm::Errors::PackageNameNotSpecified if @package_name.nil? || @package_name.empty?
25
- raise Rdm::Errors::PackageExists if source.packages.keys.include?(@package_name)
24
+ @source.package(@local_path)
26
25
 
27
- File.open(File.join(source.root_path, Rdm::SOURCE_FILENAME), 'a+') {|f| f.write("\npackage '#{@local_path}'")}
26
+ raise Rdm::Errors::PackageDirExists.new(@local_path) if Dir.exist?(File.join(@source.root_path, @local_path))
27
+ raise Rdm::Errors::PackageNameNotSpecified if @package_name.nil? || @package_name.empty?
28
+ raise Rdm::Errors::PackageExists if @source.packages.keys.include?(@package_name)
29
+
30
+ Rdm::SourceComposer.run(@source)
28
31
 
29
32
  Rdm::Handlers::TemplateHandler.generate(
30
33
  template_name: TEMPLATE_NAME,
@@ -34,7 +37,7 @@ module Rdm
34
37
  )
35
38
  end
36
39
 
37
- def source
40
+ def get_source
38
41
  @source ||= Rdm::SourceParser.read_and_init_source(Rdm::SourceLocator.locate(@current_path))
39
42
  end
40
43
  end
@@ -79,7 +79,7 @@ module Rdm
79
79
  template_files_list.map! do |path|
80
80
  rendered_abs_path = Rdm::Templates::TemplateRenderer.handle(get_destination_path(path), @locals)
81
81
  rendered_rel_path = Pathname.new(rendered_abs_path).relative_path_from Pathname.new(project_path)
82
-
82
+
83
83
  if File.file?(rendered_abs_path) && File.exists?(rendered_abs_path)
84
84
  @stdout.puts "Warning! #{rendered_rel_path} already exists. Skipping file creation..."
85
85
  next
@@ -89,12 +89,11 @@ module Rdm
89
89
  FileUtils.mkdir_p rendered_abs_path
90
90
  next
91
91
  end
92
-
92
+
93
93
  rendered_file_content = handle_file_content?(path) ?
94
94
  Rdm::Templates::TemplateRenderer.handle(File.read(path), @locals) :
95
95
  File.read(path)
96
96
 
97
-
98
97
  FileUtils.mkdir_p(File.dirname(rendered_abs_path))
99
98
  File.open(rendered_abs_path, 'w') { |f| f.write rendered_file_content }
100
99
 
@@ -1,4 +1,6 @@
1
1
  class Rdm::Settings
2
+ attr_reader :settings
3
+
2
4
  SETTING_KEYS = [
3
5
  :role, :package_subdir_name, :configs_dir, :config_path, :role_config_path,
4
6
  :silence_missing_package_file, :silence_missing_package, :compile_path,
@@ -24,13 +26,14 @@ class Rdm::Settings
24
26
  ])
25
27
  compile_add_files([
26
28
  'Gemfile',
27
- 'Gemfile.lock',
29
+ 'Gemfile.lock'
28
30
  ])
29
31
  compile_path('/tmp/rdm/:package_name')
30
32
  end
31
33
 
32
34
  SETTING_KEYS.each do |key|
33
35
  define_method(key) do |value = nil, &block|
36
+ # debugger if key == :compile_ignore_files
34
37
  fetch_setting key, value, &block
35
38
  end
36
39
  end
@@ -39,7 +42,8 @@ class Rdm::Settings
39
42
  if value.nil? && !block_given?
40
43
  read_setting(key)
41
44
  else
42
- write_setting(key, value || block)
45
+ write_value = value.nil? ? block : value
46
+ write_setting(key, write_value)
43
47
  end
44
48
  end
45
49
 
@@ -16,7 +16,10 @@ class Rdm::Source
16
16
  # Add config to list of known configs
17
17
  # @param config_name [String] Config name
18
18
  def config(config_name)
19
- @config_names << config_name.to_s
19
+ config_name = config_name.to_s
20
+ raise Rdm::Errors::ConfigExists, config_name if @config_names.include?(config_name)
21
+
22
+ @config_names << config_name
20
23
  end
21
24
 
22
25
  # Add package to list of known packages
@@ -0,0 +1,38 @@
1
+ class Rdm::SourceComposer
2
+ def self.run(source)
3
+ Rdm::SourceComposer.new(source).run
4
+ end
5
+
6
+ def initialize(source)
7
+ @source = source
8
+ @content = []
9
+ end
10
+
11
+ def run
12
+ @content.push "setup do"
13
+ Rdm.settings.settings.each do |setting, value|
14
+ @content.push " #{setting} #{format_value(value)}"
15
+ end
16
+ @content.push "end"
17
+
18
+ @content.push "\n"
19
+
20
+ @source.config_names.each do |config, _|
21
+ @content.push "config :#{config}"
22
+ end
23
+
24
+ @content.push "\n"
25
+
26
+ @source.package_paths.each do |package, _|
27
+ @content.push "package \"#{package}\""
28
+ end
29
+
30
+ File.open(Rdm.root(@source.root_path), 'w') {|f| f.puts @content}
31
+ end
32
+
33
+ def format_value(value)
34
+ return "\"#{value}\"" if value.is_a?(String)
35
+
36
+ value.to_s
37
+ end
38
+ end
@@ -1,5 +1,17 @@
1
1
  module Rdm::SpecRunner
2
- def self.run(path: nil, package: nil, spec_matcher: nil)
3
- Rdm::SpecRunner::Runner.new(path: path, package: package, spec_matcher: spec_matcher).run
2
+ def self.run(
3
+ path: nil,
4
+ package: nil,
5
+ spec_matcher: nil,
6
+ show_missing_packages: nil,
7
+ skipped_packages: []
8
+ )
9
+ Rdm::SpecRunner::Runner.new(
10
+ path: path,
11
+ package: package,
12
+ spec_matcher: spec_matcher,
13
+ show_missing_packages: show_missing_packages,
14
+ skipped_packages: skipped_packages
15
+ ).run
4
16
  end
5
17
  end
@@ -1,20 +1,28 @@
1
1
  class Rdm::SpecRunner::Runner
2
- attr_accessor :skipped_packages
2
+ attr_accessor :no_specs_packages
3
3
  attr_accessor :prepared_command_params
4
4
  attr_accessor :command
5
5
 
6
- def initialize(package: nil, spec_matcher: nil, path: nil)
7
- @package = package,
8
- @spec_matcher = spec_matcher.to_s
9
- @skipped_packages = []
10
- @path = path
11
- @run_all = @package.nil?
6
+ def initialize(
7
+ package: nil,
8
+ spec_matcher: nil,
9
+ path: nil,
10
+ show_missing_packages: nil,
11
+ skipped_packages: []
12
+ )
13
+ @package = package,
14
+ @spec_matcher = spec_matcher.to_s
15
+ @no_specs_packages = []
16
+ @skipped_packages = skipped_packages
17
+ @path = path
18
+ @run_all = @package.nil?
19
+ @show_missing_packages = show_missing_packages
12
20
  end
13
21
 
14
22
  def run
15
23
  prepare!
16
24
  check_input_params!
17
- display_missing_specs
25
+ display_missing_specs if @show_missing_packages
18
26
  execute_command
19
27
  end
20
28
 
@@ -44,7 +52,7 @@ class Rdm::SpecRunner::Runner
44
52
  )
45
53
  end
46
54
 
47
- if skipped_packages.include?(@package_name)
55
+ if no_specs_packages.include?(@package_name)
48
56
  exit_with_message(
49
57
  view.no_specs_for_package(@package_name)
50
58
  )
@@ -60,10 +68,10 @@ class Rdm::SpecRunner::Runner
60
68
 
61
69
  def prepare!
62
70
  prepared_command_params = []
63
- skipped_packages = []
71
+ no_specs_packages = []
64
72
  command = nil
65
73
  prepare_command_params
66
- prepare_skipped_packages
74
+ prepare_no_specs_packages
67
75
  prepare_command
68
76
  end
69
77
 
@@ -77,10 +85,10 @@ class Rdm::SpecRunner::Runner
77
85
  end
78
86
  end
79
87
 
80
- def prepare_skipped_packages
88
+ def prepare_no_specs_packages
81
89
  prepared_command_params
82
90
  .select { |cp| cp.spec_count == 0 }
83
- .map { |cp| skipped_packages << cp.package_name }
91
+ .map { |cp| no_specs_packages << cp.package_name }
84
92
  end
85
93
 
86
94
  def prepare_command
@@ -101,17 +109,24 @@ class Rdm::SpecRunner::Runner
101
109
  end
102
110
 
103
111
  def prepare_command_for_packages(packages_command_params)
104
- packages_command_params.select do |cmd_params|
105
- cmd_params.spec_count > 0
106
- end.sort_by do |cmd_params|
107
- - cmd_params.spec_count
108
- end.map(&:command).join(' && ')
112
+ packages_command_params
113
+ .select { |cmd_params| cmd_params.spec_count > 0 }
114
+ .reject { |cmd_params| @skipped_packages.include?(cmd_params.package_name) }
115
+ .sort_by { |cmd_params| - cmd_params.spec_count }
116
+ .map(&:command)
117
+ .join(' && ')
109
118
  end
110
119
 
111
120
  def display_missing_specs
112
- unless skipped_packages.empty?
113
- print_message view.missing_specs_message(skipped_packages)
121
+ unless no_specs_packages.empty?
122
+ print_message view.missing_specs_message(no_specs_packages)
114
123
  end
124
+
125
+ unless @skipped_packages.empty?
126
+ print_message view.skipping_specs_message(@skipped_packages)
127
+ end
128
+
129
+ print_message view.specs_header_message
115
130
  end
116
131
 
117
132
  def execute_command
@@ -11,7 +11,15 @@ class Rdm::SpecRunner::View
11
11
  end
12
12
 
13
13
  def missing_specs_message(skipped_packages)
14
- "NO SPECS FOUND FOR PACKAGES: \n#{skipped_packages.map { |x| " - #{x}" }.join("\n")}\n\n**** SPECS *****: "
14
+ "NO SPECS FOUND FOR PACKAGES: \n#{skipped_packages.map { |x| " - #{x}" }.join("\n")}\n\n"
15
+ end
16
+
17
+ def skipping_specs_message(skipped_packages)
18
+ "FOLLOWING PACKAGES WERE SKIPPED BY .runignore FILE: \n#{skipped_packages.map { |x| " - #{x}" }.join("\n")}\n\n"
19
+ end
20
+
21
+ def specs_header_message
22
+ "**** SPECS *****"
15
23
  end
16
24
 
17
25
  def no_specs_for_package(package_name)
@@ -0,0 +1,2 @@
1
+ <%=config_name%>:
2
+ <%=config_locals%>
@@ -0,0 +1,2 @@
1
+ <%=config_name%>:
2
+ <%=config_locals%>
@@ -0,0 +1,4 @@
1
+ # type in packages, they will be ignored upon the start of the specs
2
+ # for example:
3
+ # entities
4
+ # repository
@@ -1 +1,3 @@
1
- RUBY_ENV=development
1
+ RUBY_ENV=development
2
+
3
+ APP_NAME=Application
@@ -1 +1,3 @@
1
- RUBY_ENV=production
1
+ RUBY_ENV=production
2
+
3
+ APP_NAME=Application
@@ -1 +1,3 @@
1
- RUBY_ENV=test
1
+ RUBY_ENV=test
2
+
3
+ APP_NAME=Application
@@ -12,14 +12,17 @@ begin
12
12
  revision: REVISION
13
13
  )
14
14
 
15
- puts "No changed packages found!" if changed_packages.count == 0
15
+ puts "Tests for the following packages will run:"
16
+ puts changed_packages
16
17
 
17
18
  changed_packages.each do |package|
18
19
  Rdm::SpecRunner.run(
19
- package: package,
20
- path: PATH
20
+ package: package,
21
+ path: PATH,
22
+ show_missing_packages: false
21
23
  )
22
24
  end
25
+
23
26
 
24
27
  rescue Rdm::Errors::GitRepositoryNotInitialized
25
28
  puts "Git repository is not initialized. Use `git init .`"
@@ -15,6 +15,9 @@
15
15
  ENV['RUBY_ENV'] = 'test'
16
16
  require 'rdm'
17
17
 
18
+ runignore_path = File.expand_path(File.join(File.dirname(Rdm.root(__FILE__)), '.runignore'))
19
+ skipped_packages = File.open(runignore_path).each_line.inject([]) { |all, line| all.push(line.chomp!) }
20
+
18
21
  if ENV['TEST_RUN']
19
22
  require 'minitest/autorun'
20
23
  describe Rdm::SpecRunner::Runner do
@@ -30,8 +33,10 @@ if ENV['TEST_RUN']
30
33
  end
31
34
  else
32
35
  Rdm::SpecRunner.run(
33
- package: ARGV.clone.first,
34
- spec_matcher: ARGV.clone.last,
35
- path: File.expand_path(__FILE__)
36
+ package: ARGV.clone.first,
37
+ spec_matcher: ARGV.clone.last,
38
+ path: File.expand_path(__FILE__),
39
+ skipped_packages: skipped_packages,
40
+ show_missing_packages: true
36
41
  )
37
42
  end
@@ -1,3 +1,3 @@
1
1
  module Rdm
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = '0.4.2'.freeze
3
3
  end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rdm::Gen::Config do
4
+ include ExampleProjectHelper
5
+
6
+ subject { described_class }
7
+
8
+ describe "::generate" do
9
+ before { initialize_example_project }
10
+ after { reset_example_project }
11
+
12
+ context "sample config" do
13
+ before do
14
+ subject.generate(
15
+ config_name: 'mailing_system',
16
+ current_path: example_project_path
17
+ )
18
+ end
19
+
20
+ it "generates sample config" do
21
+ FileUtils.cd(example_project_path) do
22
+ ensure_exists("configs/mailing_system/default.yml")
23
+ end
24
+ end
25
+
26
+ it "add config line to Rdm.packages" do
27
+ ensure_content(rdm_source_file, 'config :mailing_system')
28
+ end
29
+ end
30
+ end
31
+ end
@@ -54,7 +54,7 @@ describe Rdm::Gen::Package do
54
54
  )
55
55
 
56
56
  FileUtils.cd(example_project_path) do
57
- ensure_content("Rdm.packages", "package 'domain/some'")
57
+ ensure_content("Rdm.packages", 'package "domain/some"')
58
58
  end
59
59
  end
60
60
  end
@@ -34,6 +34,8 @@ describe Rdm do
34
34
  end
35
35
 
36
36
  context "root=" do
37
+ after { Rdm.root = nil }
38
+
37
39
  it "sets root" do
38
40
  Rdm.root = "/some/path"
39
41
  expect(Rdm.root).to eq("/some/path")
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rdm::SourceComposer do
4
+ include ExampleProjectHelper
5
+
6
+ subject { described_class }
7
+
8
+ before { initialize_example_project }
9
+ after { reset_example_project }
10
+
11
+ describe '::run' do
12
+ context 'setup block' do
13
+ before do
14
+ @rdm_source = Rdm::SourceParser.read_and_init_source(rdm_source_file)
15
+ described_class.run(@rdm_source)
16
+ end
17
+
18
+ it "composes with explicit options" do
19
+ ensure_content(rdm_source_file, 'role "production"')
20
+ ensure_content(rdm_source_file, 'env_file_name "production"')
21
+ ensure_content(rdm_source_file, 'env_files_dir "env_files"')
22
+ ensure_content(rdm_source_file, 'config_path ":configs_dir/:config_name/default.yml"')
23
+ ensure_content(rdm_source_file, 'role_config_path ":configs_dir/:config_name/:role.yml"')
24
+ ensure_content(rdm_source_file, 'package_subdir_name "package"')
25
+ ensure_content(rdm_source_file, 'compile_path "/tmp/rdm/:package_name"')
26
+ end
27
+
28
+ it "composes with default options" do
29
+ ensure_content(rdm_source_file, 'silence_missing_package false')
30
+ ensure_content(rdm_source_file, 'silence_missing_package_file true') # From 'spec_helper' settings, should be false
31
+ expect(
32
+ File.read(rdm_source_file)
33
+ ).to include('compile_ignore_files [".gitignore", ".byebug_history", ".irbrc", ".rspec", "*_spec.rb", "*.log"]')
34
+ expect(
35
+ File.read(rdm_source_file)
36
+ ).to include('compile_add_files ["Gemfile", "Gemfile.lock"]')
37
+ end
38
+ end
39
+
40
+ context 'configs' do
41
+ before do
42
+ @rdm_source = Rdm::SourceParser.read_and_init_source(rdm_source_file)
43
+ @rdm_source.config(:mailing_system)
44
+ described_class.run(@rdm_source)
45
+ end
46
+
47
+ it "composes with old configs" do
48
+ ensure_content(rdm_source_file, 'config :database')
49
+ ensure_content(rdm_source_file, 'config :app')
50
+ end
51
+
52
+ it "composes with new configs" do
53
+ ensure_content(rdm_source_file, 'config :mailing_system')
54
+ end
55
+ end
56
+
57
+ context 'packages' do
58
+ before do
59
+ @rdm_source = Rdm::SourceParser.read_and_init_source(rdm_source_file)
60
+ @rdm_source.package('mailing_system')
61
+ described_class.run(@rdm_source)
62
+ end
63
+
64
+ it "composes with old configs" do
65
+ ensure_content(rdm_source_file, 'package "server"')
66
+ ensure_content(rdm_source_file, 'package "domain/core"')
67
+ ensure_content(rdm_source_file, 'package "infrastructure/repository"')
68
+ ensure_content(rdm_source_file, 'package "application/web"')
69
+ end
70
+
71
+ it "composes with new configs" do
72
+ ensure_content(rdm_source_file, 'package "mailing_system"')
73
+ end
74
+ end
75
+ end
76
+ end
@@ -1,4 +1,10 @@
1
1
  require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter "/spec/"
4
+ add_filter "/.direnv/"
5
+ add_filter "/rdm/templates"
6
+ end
7
+
2
8
  require 'rdm'
3
9
  require 'byebug'
4
10
  require 'fileutils'
@@ -6,16 +12,18 @@ require 'fileutils'
6
12
  require_relative 'helpers/example_project_helper'
7
13
  require_relative 'helpers/git_commands_helper'
8
14
 
9
- SimpleCov.start do
10
- add_filter "/spec/"
11
- add_filter "/.direnv/"
12
- add_filter "/rdm/templates"
13
- end
14
15
  if ENV['CI']=='true'
15
16
  require 'codecov'
16
17
  SimpleCov.formatter = SimpleCov::Formatter::Codecov
17
18
  end
18
19
 
20
+ # setup GIT so specs for GIT run properly on Travis
21
+ if ENV['CI'] == 'true'
22
+ %x{ git config --global user.email "travisci@example.com" }
23
+ %x{ git config --global user.name "TravisCI Developer" }
24
+ end
25
+
26
+
19
27
  Rdm.setup do
20
28
  silence_missing_package_file true
21
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Droid Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-11 00:00:00.000000000 Z
11
+ date: 2017-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -141,6 +141,7 @@ files:
141
141
  - example/.rdm/templates/repository/mapper/<%=name%>_mapper.rb
142
142
  - example/.rdm/templates/repository/repository/<%=name%>_repository.rb
143
143
  - example/.rdm/templates/repository/views/users.html.erb
144
+ - example/.runignore
144
145
  - example/Gemfile
145
146
  - example/Gemfile.lock
146
147
  - example/Makefile
@@ -170,15 +171,18 @@ files:
170
171
  - example/tests/run
171
172
  - lib/rdm.rb
172
173
  - lib/rdm/cli/compile_package.rb
174
+ - lib/rdm/cli/config.rb
173
175
  - lib/rdm/cli/dependencies_controller.rb
174
176
  - lib/rdm/cli/diff_package.rb
175
177
  - lib/rdm/cli/gen_package.rb
176
178
  - lib/rdm/cli/init.rb
177
179
  - lib/rdm/cli/template_generator.rb
178
180
  - lib/rdm/config.rb
181
+ - lib/rdm/config_locals.rb
179
182
  - lib/rdm/config_manager.rb
180
183
  - lib/rdm/config_scope.rb
181
184
  - lib/rdm/errors.rb
185
+ - lib/rdm/gen/config.rb
182
186
  - lib/rdm/gen/init.rb
183
187
  - lib/rdm/gen/package.rb
184
188
  - lib/rdm/git/diff_command.rb
@@ -195,6 +199,7 @@ files:
195
199
  - lib/rdm/packages/locator.rb
196
200
  - lib/rdm/settings.rb
197
201
  - lib/rdm/source.rb
202
+ - lib/rdm/source_composer.rb
198
203
  - lib/rdm/source_locator.rb
199
204
  - lib/rdm/source_parser.rb
200
205
  - lib/rdm/spec_runner.rb
@@ -203,7 +208,10 @@ files:
203
208
  - lib/rdm/spec_runner/package_fetcher.rb
204
209
  - lib/rdm/spec_runner/runner.rb
205
210
  - lib/rdm/spec_runner/view.rb
211
+ - lib/rdm/templates/configs/<%=config_path%>
212
+ - lib/rdm/templates/configs/<%=role_config_path%>
206
213
  - lib/rdm/templates/init/.rdm/helpers/render_helper.rb
214
+ - lib/rdm/templates/init/.runignore
207
215
  - lib/rdm/templates/init/Gemfile
208
216
  - lib/rdm/templates/init/Rdm.packages
209
217
  - lib/rdm/templates/init/Readme.md
@@ -239,6 +247,7 @@ files:
239
247
  - spec/rdm/cli/gen_package_spec.rb
240
248
  - spec/rdm/cli/init_spec.rb
241
249
  - spec/rdm/config_manager_spec.rb
250
+ - spec/rdm/gen/config_spec.rb
242
251
  - spec/rdm/gen/init_spec.rb
243
252
  - spec/rdm/gen/package_spec.rb
244
253
  - spec/rdm/git/diff_manager_spec.rb
@@ -253,6 +262,7 @@ files:
253
262
  - spec/rdm/package_parser_spec.rb
254
263
  - spec/rdm/rdm_spec.rb
255
264
  - spec/rdm/settings_spec.rb
265
+ - spec/rdm/source_composer_spec.rb
256
266
  - spec/rdm/source_locator_spec.rb
257
267
  - spec/rdm/source_parser_spec.rb
258
268
  - spec/rdm/spec_runner/runner_spec.rb
@@ -295,6 +305,7 @@ test_files:
295
305
  - spec/rdm/cli/gen_package_spec.rb
296
306
  - spec/rdm/cli/init_spec.rb
297
307
  - spec/rdm/config_manager_spec.rb
308
+ - spec/rdm/gen/config_spec.rb
298
309
  - spec/rdm/gen/init_spec.rb
299
310
  - spec/rdm/gen/package_spec.rb
300
311
  - spec/rdm/git/diff_manager_spec.rb
@@ -309,6 +320,7 @@ test_files:
309
320
  - spec/rdm/package_parser_spec.rb
310
321
  - spec/rdm/rdm_spec.rb
311
322
  - spec/rdm/settings_spec.rb
323
+ - spec/rdm/source_composer_spec.rb
312
324
  - spec/rdm/source_locator_spec.rb
313
325
  - spec/rdm/source_parser_spec.rb
314
326
  - spec/rdm/spec_runner/runner_spec.rb