Class: Generamba::CodeModule

Inherits:
Object
  • Object
show all
Defined in:
lib/generamba/code_generation/code_module.rb

Overview

Represents currently generating code module

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, rambafile, options) ⇒ CodeModule

Returns a new instance of CodeModule.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/generamba/code_generation/code_module.rb', line 30

def initialize(name, rambafile, options)
  # Base initialization
  @name = name
  @description = options[:description] ? options[:description] : "#{name} module"
  @author = rambafile[AUTHOR_NAME_KEY] ? rambafile[AUTHOR_NAME_KEY] : UserPreferences.obtain_username
  @company = rambafile[COMPANY_KEY]
  @year = Time.now.year.to_s

  @prefix = rambafile[PROJECT_PREFIX_KEY]
  @project_name = rambafile[PROJECT_NAME_KEY]

  @product_module_name = rambafile[PRODUCT_MODULE_NAME_KEY]
  @product_module_name = @project_name.gsub(C99IDENTIFIER, '_') if !@product_module_name && @project_name

  @xcodeproj_path = rambafile[XCODEPROJ_PATH_KEY]

  setup_file_and_group_paths(rambafile[PROJECT_FILE_PATH_KEY], rambafile[PROJECT_GROUP_PATH_KEY], PATH_TYPE_PROJECT)
  setup_file_and_group_paths(rambafile[TEST_FILE_PATH_KEY], rambafile[TEST_GROUP_PATH_KEY], PATH_TYPE_TEST)

  @project_targets = [rambafile[PROJECT_TARGET_KEY]] if rambafile[PROJECT_TARGET_KEY]
  @project_targets = rambafile[PROJECT_TARGETS_KEY] if rambafile[PROJECT_TARGETS_KEY]

  @test_targets = [rambafile[TEST_TARGET_KEY]] if rambafile[TEST_TARGET_KEY]
  @test_targets = rambafile[TEST_TARGETS_KEY] if rambafile[TEST_TARGETS_KEY]

  # Custom parameters
  @custom_parameters = options[:custom_parameters]

  # Options adaptation
  @author = options[:author] if options[:author]
  @project_targets = options[:project_targets].split(',') if options[:project_targets]
  @test_targets = options[:test_targets].split(',') if options[:test_targets]
  
  setup_file_and_group_paths(options[:project_file_path], options[:project_group_path], PATH_TYPE_PROJECT)
  setup_file_and_group_paths(options[:test_file_path], options[:test_group_path], PATH_TYPE_TEST)

  # The priority is given to `module_path` and 'test_path' options
  setup_file_and_group_paths(options[:module_path], options[:module_path], PATH_TYPE_PROJECT)
  setup_file_and_group_paths(options[:test_path], options[:test_path], PATH_TYPE_TEST)

  @podfile_path = rambafile[PODFILE_PATH_KEY] if rambafile[PODFILE_PATH_KEY]
  @cartfile_path = rambafile[CARTFILE_PATH_KEY] if rambafile[CARTFILE_PATH_KEY]
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def author
  @author
end

#cartfile_pathObject (readonly)

Returns the value of attribute cartfile_path.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def cartfile_path
  @cartfile_path
end

#companyObject (readonly)

Returns the value of attribute company.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def company
  @company
end

#custom_parametersObject (readonly)

Returns the value of attribute custom_parameters.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def custom_parameters
  @custom_parameters
end

#descriptionObject (readonly)

Returns the value of attribute description.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def name
  @name
end

#podfile_pathObject (readonly)

Returns the value of attribute podfile_path.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def podfile_path
  @podfile_path
end

#prefixObject (readonly)

Returns the value of attribute prefix.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def prefix
  @prefix
end

#product_module_nameObject (readonly)

Returns the value of attribute product_module_name.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def product_module_name
  @product_module_name
end

#project_file_pathObject (readonly)

Returns the value of attribute project_file_path.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def project_file_path
  @project_file_path
end

#project_group_pathObject (readonly)

Returns the value of attribute project_group_path.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def project_group_path
  @project_group_path
end

#project_nameObject (readonly)

Returns the value of attribute project_name.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def project_name
  @project_name
end

#project_targetsObject (readonly)

Returns the value of attribute project_targets.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def project_targets
  @project_targets
end

#test_file_pathObject (readonly)

Returns the value of attribute test_file_path.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def test_file_path
  @test_file_path
end

#test_group_pathObject (readonly)

Returns the value of attribute test_group_path.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def test_group_path
  @test_group_path
end

#test_targetsObject (readonly)

Returns the value of attribute test_targets.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def test_targets
  @test_targets
end

#xcodeproj_pathObject (readonly)

Returns the value of attribute xcodeproj_path.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def xcodeproj_path
  @xcodeproj_path
end

#yearObject (readonly)

Returns the value of attribute year.



11
12
13
# File 'lib/generamba/code_generation/code_module.rb', line 11

def year
  @year
end