Skip to content

Commit

Permalink
Merge pull request #124 from rambler-ios/feature/task-99
Browse files Browse the repository at this point in the history
Fixed bug #99
  • Loading branch information
etolstoy authored Jul 21, 2016
2 parents 0c73804 + c80f595 commit 0cafe28
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions lib/generamba/code_generation/code_module.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Generamba

SLASH_REGEX = /^\/|\/$/

# Represents currently generating code module
class CodeModule
attr_reader :name,
Expand Down Expand Up @@ -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)
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)
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)
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)
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
Expand Down

0 comments on commit 0cafe28

Please sign in to comment.