Class: RXCode::XCode::CommandLine

Inherits:
Object
  • Object
show all
Defined in:
lib/rxcode/tasks/ios_framework.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) {|_self| ... } ⇒ CommandLine

Returns a new instance of CommandLine.

Yields:

  • (_self)

Yield Parameters:



8
9
10
11
12
13
14
# File 'lib/rxcode/tasks/ios_framework.rb', line 8

def initialize(options = nil)
  if options
    options.each { |attr_name, attr_value| self.send("#{attr_name}=", attr_value) }
  end
  
  yield self if block_given?
end

Instance Attribute Details

#actionObject

ACTION =================================================================================================


18
19
20
# File 'lib/rxcode/tasks/ios_framework.rb', line 18

def action
  @action
end

#sdkObject

SDK ====================================================================================================


73
74
75
# File 'lib/rxcode/tasks/ios_framework.rb', line 73

def sdk
  @sdk
end

#targetObject

TARGET =================================================================================================


44
45
46
# File 'lib/rxcode/tasks/ios_framework.rb', line 44

def target
  @target || target_name
end

Instance Method Details

#action_argumentsObject



20
21
22
23
24
25
26
# File 'lib/rxcode/tasks/ios_framework.rb', line 20

def action_arguments
  if action
    [ action ]
  else
    []
  end
end

#commandObject



119
120
121
122
123
124
# File 'lib/rxcode/tasks/ios_framework.rb', line 119

def command
  command_args = command_line_arguments.join(' ')
  command_variables = command_environment.collect { |var_name, value| "#{var_name}='#{value}'" }.join(' ')
  
  "#{xcodebuild_binary} #{command_args} #{command_variables}"
end

#command_environmentObject



101
102
103
# File 'lib/rxcode/tasks/ios_framework.rb', line 101

def command_environment
  default_environment.merge(environment)
end

#command_line_argumentsObject



115
116
117
# File 'lib/rxcode/tasks/ios_framework.rb', line 115

def command_line_arguments
  project_arguments + target_arguments + configuration_arguments + sdk_arguments + action_arguments
end

#command_variablesObject



105
106
107
# File 'lib/rxcode/tasks/ios_framework.rb', line 105

def command_variables
  environment.collect { |var_name, value| "#{var_name}='#{value}'" }.join(' ')
end

#configurationObject

CONFIGURATION ==========================================================================================


63
64
65
# File 'lib/rxcode/tasks/ios_framework.rb', line 63

def configuration
  ENV['CONFIGURATION']
end

#configuration_argumentsObject



67
68
69
# File 'lib/rxcode/tasks/ios_framework.rb', line 67

def configuration_arguments
  [ '-configuration', configuration]
end

#default_environmentObject

ENVIRONMENT VARIABLES ==================================================================================


91
92
93
94
95
# File 'lib/rxcode/tasks/ios_framework.rb', line 91

def default_environment
  default_env = {}
  default_env['SYMROOT'] = symroot if symroot
  default_env
end

#dry_run?Boolean

Returns:

  • (Boolean)


126
127
128
# File 'lib/rxcode/tasks/ios_framework.rb', line 126

def dry_run?
  ENV['DRY_RUN'] =~ /^(1|yes|true)$/i
end

#environmentObject



97
98
99
# File 'lib/rxcode/tasks/ios_framework.rb', line 97

def environment
  @environment ||= {}
end

#project_argumentsObject



38
39
40
# File 'lib/rxcode/tasks/ios_framework.rb', line 38

def project_arguments
  [ '-project', project_file_path ]
end

#project_file_pathObject



34
35
36
# File 'lib/rxcode/tasks/ios_framework.rb', line 34

def project_file_path
  ENV['PROJECT_FILE_PATH'] || "#{project_name}.xcodeproj"
end

#project_nameObject

PROJECT ================================================================================================


30
31
32
# File 'lib/rxcode/tasks/ios_framework.rb', line 30

def project_name
  ENV['PROJECT_NAME']
end

#run(print_command = false) ⇒ Object



130
131
132
133
# File 'lib/rxcode/tasks/ios_framework.rb', line 130

def run(print_command = false)
  puts(command) if print_command
  system(command) unless dry_run?
end

#sdk_argumentsObject



75
76
77
78
79
80
81
# File 'lib/rxcode/tasks/ios_framework.rb', line 75

def sdk_arguments
  if sdk.nil?
    []
  else
    [ '-sdk', sdk ]
  end
end

#symrootObject

BUILD LOCATION =========================================================================================


85
86
87
# File 'lib/rxcode/tasks/ios_framework.rb', line 85

def symroot
  ENV['SYMROOT']
end

#target_argumentsObject



53
54
55
56
57
58
59
# File 'lib/rxcode/tasks/ios_framework.rb', line 53

def target_arguments
  if target
    [ "-target", "'#{target}'" ]
  else
    []
  end
end

#target_nameObject



49
50
51
# File 'lib/rxcode/tasks/ios_framework.rb', line 49

def target_name
  ENV['TARGET_NAME']
end

#xcodebuild_binaryObject

COMMAND ================================================================================================


111
112
113
# File 'lib/rxcode/tasks/ios_framework.rb', line 111

def xcodebuild_binary
  "xcodebuild"
end