class Pod::PlaygroundGenerator
Constants
- TEMPLATE_DIR
- TEMPLATE_NAME
Public Class Methods
dir_for_platform(platform)
click to toggle source
# File lib/cocoapods-playgrounds/generate.rb, line 41 def self.dir_for_platform(platform) platform = :macos if major_version == 8 && platform.to_sym == :osx Dir.foreach(template_dir) do |file| return (template_dir + file) if platform_name(file) == platform end end
major_version()
click to toggle source
# File lib/cocoapods-playgrounds/generate.rb, line 33 def self.major_version `xcodebuild -version`.split("\n").first.split(' ')[1].split('.').first.to_i end
new(platform)
click to toggle source
# File lib/cocoapods-playgrounds/generate.rb, line 9 def initialize(platform) @template = self.class.dir_for_platform(platform) raise "Could not find template for #{platform}" if @template.nil? @template += TEMPLATE_NAME end
platform_name(file)
click to toggle source
# File lib/cocoapods-playgrounds/generate.rb, line 37 def self.platform_name(file) file.downcase.sub(' ', '').to_sym end
platforms()
click to toggle source
# File lib/cocoapods-playgrounds/generate.rb, line 20 def self.platforms Dir.entries(template_dir).map do |file| next if file.start_with?('.') next unless (template_dir + file).directory? platform_name(file) end.compact end
template_dir()
click to toggle source
# File lib/cocoapods-playgrounds/generate.rb, line 28 def self.template_dir xcode = Pathname.new(`xcode-select -p`.strip) xcode + TEMPLATE_DIR end
Public Instance Methods
generate(name)
click to toggle source
# File lib/cocoapods-playgrounds/generate.rb, line 15 def generate(name) FileUtils.cp_r(@template, "#{name}.playground") Pathname.new("#{name}.playground") end