Skip to content

Commit

Permalink
[XCScheme] Added YARD Documentation
Browse files Browse the repository at this point in the history
(+ fix access to private methods from specs)
  • Loading branch information
AliSoftware committed Jul 28, 2015
1 parent da8a19c commit e638f0c
Show file tree
Hide file tree
Showing 13 changed files with 278 additions and 19 deletions.
36 changes: 36 additions & 0 deletions lib/xcodeproj/scheme.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,60 +76,96 @@ def configure_with_targets(runnable_target, test_target)

# @!group Access Action nodes

# @return [XCScheme::BuildAction]
# The Build Action associated with this scheme
#
def build_action
@build_action ||= BuildAction.new(@scheme.elements['BuildAction'])
end

# @param [XCScheme::BuildAction] action
# The Build Action to associate to this scheme
#
def build_action=(action)
@scheme.delete_element('BuildAction')
@scheme.add_element(action.xml_element)
@build_action = action
end

# @return [XCScheme::TestAction]
# The Test Action associated with this scheme
#
def test_action
@test_action ||= TestAction.new(@scheme.elements['TestAction'])
end

# @param [XCScheme::TestAction] action
# The Test Action to associate to this scheme
#
def test_action=(action)
@scheme.delete_element('TestAction')
@scheme.add_element(action.xml_element)
@test_action = action
end

# @return [XCScheme::LaunchAction]
# The Launch Action associated with this scheme
#
def launch_action
@launch_action ||= LaunchAction.new(@scheme.elements['LaunchAction'])
end

# @param [XCScheme::LaunchAction] action
# The Launch Action to associate to this scheme
#
def launch_action=(action)
@scheme.delete_element('LaunchAction')
@scheme.add_element(action.xml_element)
@launch_action = action
end

# @return [XCScheme::ProfileAction]
# The Profile Action associated with this scheme
#
def profile_action
@profile_action ||= ProfileAction.new(@scheme.elements['ProfileAction'])
end

# @param [XCScheme::ProfileAction] action
# The Profile Action to associate to this scheme
#
def profile_action=(action)
@scheme.delete_element('ProfileAction')
@scheme.add_element(action.xml_element)
@profile_action = action
end

# @return [XCScheme::AnalyzeAction]
# The Analyze Action associated with this scheme
#
def analyze_action
@analyze_action ||= AnalyzeAction.new(@scheme.elements['AnalyzeAction'])
end

# @param [XCScheme::AnalyzeAction] action
# The Analyze Action to associate to this scheme
#
def analyze_action=(action)
@scheme.delete_element('AnalyzeAction')
@scheme.add_element(action.xml_element)
@analyze_action = action
end

# @return [XCScheme::ArchiveAction]
# The Archive Action associated with this scheme
#
def archive_action
@archive_action ||= ArchiveAction.new(@scheme.elements['ArchiveAction'])
end

# @param [XCScheme::ArchiveAction] action
# The Archive Action to associate to this scheme
#
def archive_action=(action)
@scheme.delete_element('ArchiveAction')
@scheme.add_element(action.xml_element)
Expand Down
11 changes: 11 additions & 0 deletions lib/xcodeproj/scheme/abstract_scheme_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@

module Xcodeproj
class XCScheme
# This abstract class aims to be the base class for every XxxAction class
# that have a #build_configuration attribute
#
class AbstractSchemeAction < XMLElementWrapper
# @return [String]
# The build configuration associated with this action
# (usually either 'Debug' or 'Release')
#
def build_configuration
@xml_element.attributes['buildConfiguration']
end

# @param [String] config_name
# The build configuration to associate with this action
# (usually either 'Debug' or 'Release')
#
def build_configuration=(config_name)
@xml_element.attributes['buildConfiguration'] = config_name
end
Expand Down
6 changes: 6 additions & 0 deletions lib/xcodeproj/scheme/analyze_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

module Xcodeproj
class XCScheme
# This class wraps the AnalyzeAction node of a .xcscheme XML file
#
class AnalyzeAction < AbstractSchemeAction
# @param [REXML::Element] node
# The 'AnalyzeAction' XML node that this object will wrap.
# If nil, will create a default XML node to use.
#
def initialize(node = nil)
create_xml_element_with_fallback(node, 'AnalyzeAction') do
self.build_configuration = 'Debug'
Expand Down
25 changes: 25 additions & 0 deletions lib/xcodeproj/scheme/archive_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,51 @@

module Xcodeproj
class XCScheme
# This class wraps the ArchiveAction node of a .xcscheme XML file
#
class ArchiveAction < AbstractSchemeAction
# @param [REXML::Element] node
# The 'ArchiveAction' XML node that this object will wrap.
# If nil, will create a default XML node to use.
#
def initialize(node = nil)
create_xml_element_with_fallback(node, 'ArchiveAction') do
self.build_configuration = 'Release'
self.reveal_archive_in_organizer = true
end
end

# @return [Bool]
# Whether the Archive will be revealed in Xcode's Organizer
# after it's done building.
#
def reveal_archive_in_organizer?
string_to_bool(@xml_element.attributes['revealArchiveInOrganizer'])
end

# @param [Bool] flag
# Set whether the Archive will be revealed in Xcode's Organizer
# after it's done building.
#
def reveal_archive_in_organizer=(flag)
@xml_element.attributes['revealArchiveInOrganizer'] = bool_to_string(flag)
end

# @return [String]
# The custom name to give to the archive.
# If nil, the generated archive will have the same name as the one
# set in the associated target's Build Settings for the built product.
#
def custom_archive_name
@xml_element.attributes['customArchiveName']
end

# @param [String] name
# Set the custom name to use for the built archive
# If nil, the customization of the archive name will be removed and
# the generated archive will have the same name as the one set in the
# associated target's Build Settings for the build product.
#
def custom_archive_name=(name)
if name
@xml_element.attributes['customArchiveName'] = name
Expand Down
56 changes: 54 additions & 2 deletions lib/xcodeproj/scheme/build_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,54 @@

module Xcodeproj
class XCScheme
# Scheme action for "Build"
# This class wraps the BuildAction node of a .xcscheme XML file
#
# Note: It's not a AbstractSchemeAction like the others because it is
# a special case of action (with no build_configuration, etc)
#
class BuildAction < XMLElementWrapper
# @param [REXML::Element] node
# The 'BuildAction' XML node that this object will wrap.
# If nil, will create a default XML node to use.
#
def initialize(node = nil)
create_xml_element_with_fallback(node, 'BuildAction') do
self.parallelize_buildables = true
self.build_implicit_dependencies = true
end
end

# @return [Bool]
# Whether or not to build the various targets in parallel
#
def parallelize_buildables?
string_to_bool(@xml_element.attributes['parallelizeBuildables'])
end

# @param [Bool] flag
# Set whether or not to build the various targets in parallel
#
def parallelize_buildables=(flag)
@xml_element.attributes['parallelizeBuildables'] = bool_to_string(flag)
end

# @return [Bool]
# Whether or not to detect and build implicit dependencies for each target
#
def build_implicit_dependencies?
string_to_bool(@xml_element.attributes['buildImplicitDependencies'])
end

# @param [Bool] flag
# Whether or not to detect and build implicit dependencies for each target
#
def build_implicit_dependencies=(flag)
@xml_element.attributes['buildImplicitDependencies'] = bool_to_string(flag)
end

# [Array<BuildAction::Entry>]
# @return [Array<BuildAction::Entry>]
# The list of BuildActionEntry nodes associated with this Build Action.
# Each entry represent a target to build and tells for which action it's needed to be built.
#
def entries
@xml_element.elements['BuildActionEntries'].get_elements('BuildActionEntry').map do |entry_node|
Expand All @@ -40,6 +58,7 @@ def entries
end

# @param [BuildAction::Entry] entry
# The BuildActionEntry to add to the list of targets to build for the various actions
#
def add_entry(entry)
entries = @xml_element.elements['BuildActionEntries'] || @xml_element.add_element('BuildActionEntries')
Expand Down Expand Up @@ -75,47 +94,79 @@ def initialize(target_or_node = nil)
end
end

# @return [Bool]
# Whether or not to build this target when building for Testing
#
def build_for_testing?
string_to_bool(@xml_element.attributes['buildForTesting'])
end

# @param [Bool]
# Set whether or not to build this target when building for Testing
#
def build_for_testing=(flag)
@xml_element.attributes['buildForTesting'] = bool_to_string(flag)
end

# @return [Bool]
# Whether or not to build this target when building for Running
#
def build_for_running?
string_to_bool(@xml_element.attributes['buildForRunning'])
end

# @param [Bool]
# Set whether or not to build this target when building for Running
#
def build_for_running=(flag)
@xml_element.attributes['buildForRunning'] = bool_to_string(flag)
end

# @return [Bool]
# Whether or not to build this target when building for Profiling
#
def build_for_profiling?
string_to_bool(@xml_element.attributes['buildForProfiling'])
end

# @param [Bool]
# Set whether or not to build this target when building for Profiling
#
def build_for_profiling=(flag)
@xml_element.attributes['buildForProfiling'] = bool_to_string(flag)
end

# @return [Bool]
# Whether or not to build this target when building for Archiving
#
def build_for_archiving?
string_to_bool(@xml_element.attributes['buildForArchiving'])
end

# @param [Bool]
# Set whether or not to build this target when building for Archiving
#
def build_for_archiving=(flag)
@xml_element.attributes['buildForArchiving'] = bool_to_string(flag)
end

# @return [Bool]
# Whether or not to build this target when building for Analyzing
#
def build_for_analyzing?
string_to_bool(@xml_element.attributes['buildForAnalyzing'])
end

# @param [Bool]
# Set whether or not to build this target when building for Analyzing
#
def build_for_analyzing=(flag)
@xml_element.attributes['buildForAnalyzing'] = bool_to_string(flag)
end

# @return [Array<BuildableReference>]
# The list of BuildableReferences this entry will build.
# (The list usually contains only one element)
#
def buildable_references
@xml_element.get_elements('BuildableReference').map do |node|
Expand All @@ -124,6 +175,7 @@ def buildable_references
end

# @param [BuildableReference] ref
# The BuildableReference to add to the list of targets this entry will build
#
def add_buildable_reference(ref)
@xml_element.add_element(ref.xml_element)
Expand Down
13 changes: 13 additions & 0 deletions lib/xcodeproj/scheme/buildable_product_runnable.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
module Xcodeproj
class XCScheme
# This class wraps the BuildableProductRunnable node of a .xcscheme XML file
#
# A BuildableProductRunnable is a product that is both buildable
# (it contains a BuildableReference) and runnable (it can be launched and debugged)
#
class BuildableProductRunnable < XMLElementWrapper
# @param [Xcodeproj::Project::Object::AbstractTarget, REXML::Element] target_or_node
# Either the Xcode target to reference,
Expand All @@ -16,21 +21,29 @@ def initialize(target_or_node = nil, runnable_debugging_mode = nil)
end
end

# @return [String]
# The Runnable debugging mode (usually either empty or equal to '0')
#
def runnable_debugging_mode
@xml_element.attributes['runnableDebuggingMode']
end

# @param [String] value
# Set the runnable debugging mode of this buildable product runnable
#
def runnable_debugging_mode=(value)
@xml_element.attributes['runnableDebuggingMode'] = value.to_s
end

# @return [BuildableReference]
# The Buildable Reference this Buildable Product Runnable is gonna build and run
#
def buildable_reference
@buildable_reference ||= BuildableReference.new @xml_element.elements['BuildableReference']
end

# @param [BuildableReference] ref
# Set the Buildable Reference this Buildable Product Runnable is gonna build and run
#
def buildable_reference=(ref)
@xml_element.delete_element('BuildableReference')
Expand Down
Loading

0 comments on commit e638f0c

Please sign in to comment.