Class: Configuration

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

Defined Under Namespace

Classes: UserConfig

Constant Summary collapse

@@user_config =
UserConfig.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shell) ⇒ Configuration

Returns a new instance of Configuration.



20
21
22
23
24
# File 'lib/configuration.rb', line 20

def initialize(shell)
  @shell = shell
  initialize_cartfile_resolved
  initialize_cartrcfile
end

Instance Attribute Details

#carthage_resolved_dependenciesObject (readonly)

Returns the value of attribute carthage_resolved_dependencies.



14
15
16
# File 'lib/configuration.rb', line 14

def carthage_resolved_dependencies
  @carthage_resolved_dependencies
end

#server_uriObject (readonly)

Returns the value of attribute server_uri.



14
15
16
# File 'lib/configuration.rb', line 14

def server_uri
  @server_uri
end

Class Method Details

.new_with_defaultsObject



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

def self.new_with_defaults
  Configuration.new(ShellWrapper.new)
end

.setup {|@@user_config| ... } ⇒ Object

Yields:

  • (@@user_config)


10
11
12
# File 'lib/configuration.rb', line 10

def self.setup
  yield(@@user_config)
end

Instance Method Details

#all_framework_namesObject



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

def all_framework_names
  version_files.flat_map { |vf| vf.framework_names }.uniq.sort
end

#ensure_shell_commandsObject

Ensure, that these lazy properties are loaded before kicking off async code.



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

def ensure_shell_commands
  xcodebuild_version
  swift_version
end

#swift_versionObject



45
46
47
48
49
50
51
52
# File 'lib/configuration.rb', line 45

def swift_version
  if @swift_version.nil?
    swift_raw_version = @shell.swift_version
    @swift_version = swift_raw_version[/Apple Swift version (.*) \(/, 1]
    raise AppError.new, "Could not parse swift version from '#{raw_swift_version}'" if @swift_version.nil?
  end
  @swift_version
end

#to_sObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/configuration.rb', line 54

def to_s
  <<~EOS
    Xcodebuild: #{xcodebuild_version}
    ---
    Swift: #{swift_version}
    ---
    Server: #{@server_uri.to_s}
    ---
    Cartfile.resolved:
    #{@carthage_resolved_dependencies.join("\n")}
    ---
    Local Build Frameworks:
    #{framework_names_with_platforms.join("\n")}
  EOS
end

#xcodebuild_versionObject



36
37
38
39
40
41
42
43
# File 'lib/configuration.rb', line 36

def xcodebuild_version
  if @xcodebuild_version.nil?
    xcodebuild_raw_version = @shell.xcodebuild_version
    @xcodebuild_version = xcodebuild_raw_version[/Build version (.*)$/, 1]
    raise AppError.new, "Could not parse build version from '#{xcodebuild_raw_version}'" if @xcodebuild_version.nil?
  end
  @xcodebuild_version
end