Class: GAConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/ga_configuration.rb

Overview

Author:

  • Vittorio Monaco

Constant Summary collapse

GAConfigurationScheme =
"scheme"
GAConfigurationWorkspace =
"workspace"
GAConfigurationTarget =
"target"
GAConfigurationSuffix =
"suffix"
GAConfigurationReporter =
"reporter"
GAConfigurationXctoolPath =
"xctool"
GAConfigurationProject =
"project"
GAConfigurationDefaultReporter =
"pretty"
GAConfigurationDefaultXctoolPath =
"xctool"
GAConfigurationDefaultSuffix =
"Test"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration = { GAConfigurationSuffix => "Test", GAConfigurationReporter => "pretty", GAConfigurationXctoolPath => "xctool" }) ⇒ GAConfiguration

Note:

by default the #suffix is implied as “Test”, the #reporter as “pretty” and the #xctool_path as “xctool”

Creates an instance with the given configuration, or uses a default one if not provided

Parameters:

  • configuration (GAConfiguration) (defaults to: { GAConfigurationSuffix => "Test", GAConfigurationReporter => "pretty", GAConfigurationXctoolPath => "xctool" })


86
87
88
89
90
91
92
93
94
# File 'lib/ga_configuration.rb', line 86

def initialize(configuration = { GAConfigurationSuffix => "Test", GAConfigurationReporter => "pretty", GAConfigurationXctoolPath => "xctool" })
  @scheme = configuration[GAConfigurationScheme]
  @workspace = configuration[GAConfigurationWorkspace]
  @target = configuration[GAConfigurationTarget]
  @suffix = configuration[GAConfigurationSuffix]
  @reporter = configuration[GAConfigurationReporter]
  @xctool_path = configuration[GAConfigurationXctoolPath]
  @project = configuration[GAConfigurationProject]
end

Class Method Details

.sampleGAConfiguration

Creates a sample GAConfiguration instance to instruct the user

Returns:

  • (GAConfiguration)

    an instance that should not be used apart from outputting on the console



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ga_configuration.rb', line 69

def self.sample
  sample = GAConfiguration.new({
    GAConfigurationWorkspace => 'MyProject',
    GAConfigurationScheme => 'MyProject-Dev',
    GAConfigurationTarget => 'MyProjectTests',
    GAConfigurationSuffix => GAConfigurationDefaultSuffix,
    GAConfigurationReporter => GAConfigurationDefaultReporter,
    GAConfigurationXctoolPath => GAConfigurationDefaultXctoolPath
  })
      
  return sample
end

Instance Method Details

#merge(other) ⇒ Object

Note:

nil values will not overwrite valid values of self

Merges two GAConfiguration instances

Parameters:

  • other (GAConfiguration)

    another instance of GAConfiguration you want to merge



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/ga_configuration.rb', line 100

def merge(other)
  @scheme = other.scheme unless other.scheme.nil?
  @workspace = other.workspace unless other.workspace.nil?
  @target = other.target unless other.target.nil?
  @suffix = other.suffix unless other.suffix.nil?
  @reporter = other.reporter unless other.reporter.nil?
  @xctool_path = other.xctool_path unless other.xctool_path.nil?
  @project = other.project unless other.project.nil?
  
  return self
end

#projectObject

Returns the configured xcode project, if not using workspaces.

Returns:

  • the configured xcode project, if not using workspaces



21
22
23
# File 'lib/ga_configuration.rb', line 21

def project
  @project
end

#reporterObject

Returns the configured xctool reporter.

Returns:

  • the configured xctool reporter



41
42
43
# File 'lib/ga_configuration.rb', line 41

def reporter
  @reporter
end

#schemeObject

Returns the configured xcode scheme.

Returns:

  • the configured xcode scheme



16
17
18
# File 'lib/ga_configuration.rb', line 16

def scheme
  @scheme
end

#suffixObject

Returns the configured suffix for tests files.

Returns:

  • the configured suffix for tests files



31
32
33
# File 'lib/ga_configuration.rb', line 31

def suffix
  @suffix
end

#targetObject

Returns the configured xcode tests target.

Returns:

  • the configured xcode tests target



36
37
38
# File 'lib/ga_configuration.rb', line 36

def target
  @target
end

#to_sObject

Prints the configuration instance



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ga_configuration.rb', line 52

def to_s
  hashForOutput = {
    GAConfigurationScheme => @scheme,
    GAConfigurationWorkspace => @workspace,
    GAConfigurationTarget => @target,
    GAConfigurationSuffix => @suffix,
    GAConfigurationReporter => @reporter,
    GAConfigurationXctoolPath => @xctool_path,
    GAConfigurationProject => @project
  }
  
  return hashForOutput.to_s
end

#workspaceObject

Returns the configured xcode workspace, if not using projects.

Returns:

  • the configured xcode workspace, if not using projects



26
27
28
# File 'lib/ga_configuration.rb', line 26

def workspace
  @workspace
end

#xctool_pathObject

Returns the configured xctool executable path.

Returns:

  • the configured xctool executable path



46
47
48
# File 'lib/ga_configuration.rb', line 46

def xctool_path
  @xctool_path
end