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.



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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/generamba/code_generation/code_module.rb', line 39

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)

  @create_logical_groups = rambafile[CREATE_LOGICAL_GROUPS_KEY] if rambafile[CREATE_LOGICAL_GROUPS_KEY]
  if create_logical_groups
      @project_file_root = Pathname.new(rambafile[PROJECT_FILE_PATH_KEY])
      @test_file_root = Pathname.new(rambafile[TEST_FILE_PATH_KEY])
  end
  
  @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]

  @test_unit_target = rambafile[TEST_UNIT_TARGET_KEY] if rambafile[TEST_UNIT_TARGET_KEY]
  @test_unit_path = Pathname.new(rambafile[TEST_UNIT_PATH_KEY]).join(@name) if rambafile[TEST_UNIT_PATH_KEY]
  @test_unit_testable_import = rambafile[TEST_UNIT_TESTABLE_IMPORT] if rambafile[TEST_UNIT_TESTABLE_IMPORT]

  @test_snapshot_target = rambafile[TEST_SNAPSHOT_TARGET_KEY] if rambafile[TEST_SNAPSHOT_TARGET_KEY]
  @test_snapshot_path = Pathname.new(rambafile[TEST_SNAPSHOT_PATH_KEY]) if rambafile[TEST_SNAPSHOT_PATH_KEY]
  @test_snapshot_testable_import = rambafile[TEST_SNAPSHOT_TESTABLE_IMPORT] if rambafile[TEST_SNAPSHOT_TESTABLE_IMPORT]

  # 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

#create_logical_groupsObject (readonly)

Returns the value of attribute create_logical_groups.



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

def create_logical_groups
  @create_logical_groups
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_file_rootObject (readonly)

Returns the value of attribute project_file_root.



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

def project_file_root
  @project_file_root
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_file_rootObject (readonly)

Returns the value of attribute test_file_root.



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

def test_file_root
  @test_file_root
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_snapshot_pathObject (readonly)

Returns the value of attribute test_snapshot_path.



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

def test_snapshot_path
  @test_snapshot_path
end

#test_snapshot_targetObject (readonly)

Returns the value of attribute test_snapshot_target.



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

def test_snapshot_target
  @test_snapshot_target
end

#test_snapshot_testable_importObject (readonly)

Returns the value of attribute test_snapshot_testable_import.



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

def test_snapshot_testable_import
  @test_snapshot_testable_import
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

#test_unit_pathObject (readonly)

Returns the value of attribute test_unit_path.



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

def test_unit_path
  @test_unit_path
end

#test_unit_targetObject (readonly)

Returns the value of attribute test_unit_target.



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

def test_unit_target
  @test_unit_target
end

#test_unit_testable_importObject (readonly)

Returns the value of attribute test_unit_testable_import.



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

def test_unit_testable_import
  @test_unit_testable_import
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