diff --git a/lib/generamba/code_generation/code_module.rb b/lib/generamba/code_generation/code_module.rb index b9b8bc0..2f19d76 100644 --- a/lib/generamba/code_generation/code_module.rb +++ b/lib/generamba/code_generation/code_module.rb @@ -1,5 +1,7 @@ module Generamba + SLASH_REGEX = /^\/|\/$/ + # Represents currently generating code module class CodeModule attr_reader :name, @@ -58,16 +60,38 @@ def initialize(name, description, rambafile, options) @project_targets = options[:module_targets].split(',') if options[:module_targets] @test_targets = options[:test_targets].split(',') if options[:test_targets] - @module_file_path = Pathname.new(options[:module_file_path]).join(@name) if options[:module_file_path] - @module_group_path = Pathname.new(options[:module_group_path]).join(@name) if options[:module_group_path] - @test_file_path = Pathname.new(options[:test_file_path]).join(@name) if options[:test_file_path] - @test_group_path = Pathname.new(options[:test_group_path]).join(@name) if options[:test_group_path] + if options[:module_file_path] + @module_file_path = options[:module_file_path].gsub(SLASH_REGEX, '') + @module_file_path = Pathname.new(@module_file_path).join(@name) if @module_file_path + end + + if options[:module_group_path] + @module_group_path = options[:module_group_path].gsub(SLASH_REGEX, '') + @module_group_path = Pathname.new(@module_group_path).join(@name) if @module_group_path + end + + if options[:test_file_path] + @test_file_path = options[:test_file_path].gsub(SLASH_REGEX, '') + @test_file_path = Pathname.new(@test_file_path).join(@name) if @test_file_path + end + + if options[:test_group_path] + @test_group_path = options[:test_group_path].gsub(SLASH_REGEX, '') + @test_group_path = Pathname.new(@test_group_path).join(@name) if @test_group_path + end # The priority is given to `module_path` and 'test_path' options - @module_file_path = Pathname.new(options[:module_path]).join(@name) if options[:module_path] - @module_group_path = Pathname.new(options[:module_path]).join(@name) if options[:module_path] - @test_file_path = Pathname.new(options[:test_path]).join(@name) if options[:test_path] - @test_group_path = Pathname.new(options[:test_path]).join(@name) if options[:test_path] + if options[:module_path] + @module_path = options[:module_path].gsub(SLASH_REGEX, '') + @module_file_path = Pathname.new(@module_path).join(@name) + @module_group_path = Pathname.new(@module_path).join(@name) + end + + if options[:test_path] + @test_path = options[:test_path].gsub(SLASH_REGEX, '') + @test_file_path = Pathname.new(@test_path).join(@name) + @test_group_path = Pathname.new(@test_path).join(@name) + end @podfile_path = rambafile[PODFILE_PATH_KEY] if rambafile[PODFILE_PATH_KEY] != nil @cartfile_path = rambafile[CARTFILE_PATH_KEY] if rambafile[CARTFILE_PATH_KEY] != nil