Sha256: 7145664476343857e088809b4d7482d81b61df1607479e007a1b0401729cb8b0

Contents?: true

Size: 1.57 KB

Versions: 10

Compression:

Stored size: 1.57 KB

Contents

module Xcode
  module Configuration

    #
    # Within the a build settings there is a setting for the Targeted Device
    # Family which assigns particular numeric values to the platform types.
    # 
    # Instead of manipulating the numeric values, this will perform a conversion
    # return an array of symbols with the platforms like :iphone and :ipad.
    # 
    module TargetedDeviceFamily
      extend self
      
      #
      # @param [String] value convert the comma-delimited list of platforms
      # @return [Array<Symbol>] the platform names supported.
      #
      def open(value)
        value.to_s.split(",").map do |platform_number|
          platforms[platform_number]
        end
      end
    
      #
      # @param [String,Array<String>] value convert the array of platform names 
      # @return [String] the comma-delimited list of numeric values representing 
      #   the platforms.
      #
      def save(value)
        Array(value).map do |platform_name|
          platforms.map {|number,name| number if name.to_s == platform_name.to_s.downcase }
        end.flatten.compact.uniq.join(",")
      end
      
      #
      # @param [String] original is the current string value stored in the configuration
      #   that needs to be converted into an Array of names.
      # @param [String,Array<String>] value the new values to include in the device
      #   family.
      # 
      def append(original,value)
        save(open(original) + Array(value))
      end
    
      private
  
      def platforms
        { "1" => :iphone, "2" => :ipad }
      end
  
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
xcoder-0.1.18 lib/xcode/configurations/targeted_device_family_property.rb
xcoder-0.1.15 lib/xcode/configurations/targeted_device_family_property.rb
xcoder-0.1.14 lib/xcode/configurations/targeted_device_family_property.rb
xcoder-0.1.13 lib/xcode/configurations/targeted_device_family_property.rb
xcoder-0.1.12 lib/xcode/configurations/targeted_device_family_property.rb
xcoder-0.1.11 lib/xcode/configurations/targeted_device_family_property.rb
xcoder-0.1.10 lib/xcode/configurations/targeted_device_family_property.rb
xcoder-0.1.9 lib/xcode/configurations/targeted_device_family_property.rb
xcoder-0.1.8 lib/xcode/configurations/targeted_device_family_property.rb
xcoder-0.1.7 lib/xcode/configurations/targeted_device_family_property.rb