lib/cocoapods-playgrounds/workspace.rb in cocoapods-playgrounds-1.0.0 vs lib/cocoapods-playgrounds/workspace.rb in cocoapods-playgrounds-1.1.0
- old
+ new
@@ -13,52 +13,57 @@
raise "Unsupported tool #{tool}" unless SUPPORTED_TOOLS.include?(tool)
@tool = tool
end
- def generate
+ def generate(install = true)
@cwd = Pathname.getwd
- `rm -fr #{target_dir}`
+ `rm -fr '#{target_dir}'`
FileUtils.mkdir_p(target_dir)
Dir.chdir(target_dir) do
- setup_project
+ setup_project(install)
generator = Pod::PlaygroundGenerator.new(@platform)
path = generator.generate(names.first)
generate_swift_code(path)
end
- `open #{workspace_path}`
+ `open #{workspace_path}` if install
end
private
- def setup_project
+ def setup_project(install = true)
case @tool
when :carthage then
generate_cartfile
Pod::Executable.execute_command('carthage', ['update', '--platform', @platform.to_s])
generate_project
copy_carthage_frameworks
when :cocoapods then
generate_podfile
generate_project
- Pod::Executable.execute_command('pod', ['install', '--no-repo-update'])
+ Pod::Executable.execute_command('pod', ['install', '--no-repo-update']) if install
end
end
def names
@names.map do |name|
- File.basename(name, '.podspec')
+ if !(@cwd + name).exist? && name.include?('/')
+ File.dirname(name)
+ else
+ File.basename(name, '.podspec')
+ end
end
end
def pods
names.zip(@names).map do |name, path|
- path = @cwd + path
+ abs_path = @cwd + path
+ name = path unless abs_path.exist? # support subspecs
requirement = "pod '#{name}'"
- requirement += ", :path => '#{path.dirname}'" if path.exist?
+ requirement += ", :path => '#{abs_path.dirname}'" if abs_path.exist?
requirement
end.join("\n")
end
def target_dir