cocoapods-playgrounds 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f2e5d3d15ca7b51b45357b3a5e9dbdb3de4075a2
4
+ data.tar.gz: eca58b67f5db94f42ac6381b30cc26ae00ac2e4c
5
+ SHA512:
6
+ metadata.gz: ef3cf3090ffec3e3a830bea62f01a7a4c19f47c1cd8a667f8fa08dc756bac459afb92e9da155f106a86a8940f5060258c820a8e4f33e03c32838fdfff1f2701a
7
+ data.tar.gz: 80f38e920f9a368b757c9c0df03351e420a57123e5e2bc86b1bfa857bcf34048b3c0df411fa95972aeb2c567276e3d4a8c96d89838ece3455a6571516b889049
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
data/.rubocop.yml ADDED
@@ -0,0 +1,24 @@
1
+ Metrics/LineLength:
2
+ Max: 130
3
+
4
+ Style/Documentation:
5
+ Exclude:
6
+ - 'spec/**/*'
7
+ - 'test/**/*'
8
+ - 'bin/playground'
9
+ - 'lib/cocoapods-playgrounds/generate.rb'
10
+ - 'lib/cocoapods-playgrounds/command/playgrounds.rb'
11
+
12
+ Style/FileName:
13
+ Exclude:
14
+ - 'lib/cocoapods-playgrounds.rb'
15
+
16
+ Lint/Void:
17
+ Exclude:
18
+ - 'spec/**/*'
19
+
20
+ Metrics/AbcSize:
21
+ Max: 20
22
+
23
+ Metrics/MethodLength:
24
+ Max: 20
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'cocoapods'
7
+
8
+ gem 'mocha'
9
+ gem 'bacon'
10
+ gem 'mocha-on-bacon'
11
+ gem 'prettybacon'
12
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,84 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-playgrounds (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (4.2.5.1)
10
+ i18n (~> 0.7)
11
+ json (~> 1.7, >= 1.7.7)
12
+ minitest (~> 5.1)
13
+ thread_safe (~> 0.3, >= 0.3.4)
14
+ tzinfo (~> 1.1)
15
+ bacon (1.2.0)
16
+ claide (0.9.1)
17
+ cocoapods (0.39.0)
18
+ activesupport (>= 4.0.2)
19
+ claide (~> 0.9.1)
20
+ cocoapods-core (= 0.39.0)
21
+ cocoapods-downloader (~> 0.9.3)
22
+ cocoapods-plugins (~> 0.4.2)
23
+ cocoapods-search (~> 0.1.0)
24
+ cocoapods-stats (~> 0.6.2)
25
+ cocoapods-trunk (~> 0.6.4)
26
+ cocoapods-try (~> 0.5.1)
27
+ colored (~> 1.2)
28
+ escape (~> 0.0.4)
29
+ molinillo (~> 0.4.0)
30
+ nap (~> 1.0)
31
+ xcodeproj (~> 0.28.2)
32
+ cocoapods-core (0.39.0)
33
+ activesupport (>= 4.0.2)
34
+ fuzzy_match (~> 2.0.4)
35
+ nap (~> 1.0)
36
+ cocoapods-downloader (0.9.3)
37
+ cocoapods-plugins (0.4.2)
38
+ nap
39
+ cocoapods-search (0.1.0)
40
+ cocoapods-stats (0.6.2)
41
+ cocoapods-trunk (0.6.4)
42
+ nap (>= 0.8, < 2.0)
43
+ netrc (= 0.7.8)
44
+ cocoapods-try (0.5.1)
45
+ colored (1.2)
46
+ escape (0.0.4)
47
+ fuzzy_match (2.0.4)
48
+ i18n (0.7.0)
49
+ json (1.8.3)
50
+ metaclass (0.0.4)
51
+ minitest (5.8.4)
52
+ mocha (1.1.0)
53
+ metaclass (~> 0.0.1)
54
+ mocha-on-bacon (0.2.2)
55
+ mocha (>= 0.13.0)
56
+ molinillo (0.4.2)
57
+ nap (1.1.0)
58
+ netrc (0.7.8)
59
+ prettybacon (0.0.2)
60
+ bacon (~> 1.2)
61
+ rake (10.5.0)
62
+ thread_safe (0.3.5)
63
+ tzinfo (1.2.2)
64
+ thread_safe (~> 0.1)
65
+ xcodeproj (0.28.2)
66
+ activesupport (>= 3)
67
+ claide (~> 0.9.1)
68
+ colored (~> 1.2)
69
+
70
+ PLATFORMS
71
+ ruby
72
+
73
+ DEPENDENCIES
74
+ bacon
75
+ bundler (~> 1.3)
76
+ cocoapods
77
+ cocoapods-playgrounds!
78
+ mocha
79
+ mocha-on-bacon
80
+ prettybacon
81
+ rake
82
+
83
+ BUNDLED WITH
84
+ 1.11.2
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Boris Bügling <boris@icculus.org>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # This Could Be Us But You Playing
2
+
3
+ Generates a Swift Playground for any Pod.
4
+
5
+ ## Usage
6
+
7
+ To generate a Playground from the commandline:
8
+
9
+ $ playground --platform=ios YOLO
10
+ $ open YOLO.playground
11
+
12
+ To generate a Playground for a specific Pod:
13
+
14
+ $ pod playgrounds Alamofire
15
+
16
+ ## Installation
17
+
18
+ $ gem install cocoapods-playgrounds
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task default: :specs
data/bin/playground ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if $PROGRAM_NAME == __FILE__
4
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
5
+ require 'rubygems'
6
+ require 'bundler/setup'
7
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
8
+ end
9
+
10
+ require 'claide'
11
+ require 'cocoapods-playgrounds/generate'
12
+ require 'cocoapods-playgrounds/gem_version'
13
+
14
+ class PlainInformative < StandardError
15
+ include CLAide::InformativeError
16
+ end
17
+
18
+ class Informative < PlainInformative
19
+ def message
20
+ "[!] #{super}".ansi.red
21
+ end
22
+ end
23
+
24
+ AVAILABLE = Pod::PlaygroundGenerator.platforms.join(', ')
25
+ DEFAULT = :osx
26
+
27
+ class Command < CLAide::Command
28
+ self.command = 'playground'
29
+ self.description = 'Generate Xcode Playgrounds'
30
+ self.version = CocoapodsPlaygrounds::VERSION
31
+
32
+ self.arguments = [CLAide::Argument.new('NAME', true)]
33
+
34
+ def self.options
35
+ [
36
+ ['--platform', "Platform to generate for (default: #{DEFAULT}, available: #{AVAILABLE})"]
37
+ ]
38
+ end
39
+
40
+ def initialize(argv)
41
+ @name = argv.shift_argument
42
+ @platform = argv.option('platform', DEFAULT).to_sym
43
+ super
44
+ end
45
+
46
+ def validate!
47
+ help! 'Please specify a name for your Playground' if @name.nil?
48
+ end
49
+
50
+ def run
51
+ generator = Pod::PlaygroundGenerator.new(@platform)
52
+ generator.generate(@name)
53
+ end
54
+ end
55
+
56
+ Command.run(ARGV)
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-playgrounds/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-playgrounds'
8
+ spec.version = CocoapodsPlaygrounds::VERSION
9
+ spec.authors = ['Boris Bügling']
10
+ spec.email = ['boris@icculus.org']
11
+ spec.summary = 'Generates a Swift Playground for any Pod.'
12
+ spec.homepage = 'https://github.com/EXAMPLE/cocoapods-playgrounds'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.3'
21
+ spec.add_development_dependency 'rake'
22
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-playgrounds/gem_version'
@@ -0,0 +1,2 @@
1
+ require 'cocoapods-playgrounds/generate'
2
+ require 'cocoapods-playgrounds/command/playgrounds'
@@ -0,0 +1,86 @@
1
+ module Pod
2
+ class Command
3
+ class Playgrounds < Command
4
+ self.summary = 'Generates a Swift Playground for any Pod.'
5
+
6
+ self.description = <<-DESC
7
+ Generates a Swift Playground for any Pod.
8
+ DESC
9
+
10
+ self.arguments = [CLAide::Argument.new('NAME', true)]
11
+
12
+ def initialize(argv)
13
+ @name = argv.shift_argument
14
+ @platform = :ios # TODO: Should be configurable
15
+ @deployment_target = '9.0' # TODO: Should be configurable
16
+ super
17
+ end
18
+
19
+ def validate!
20
+ super
21
+ help! 'A Pod name is required.' unless @name
22
+ end
23
+
24
+ def run
25
+ generate_project
26
+
27
+ Dir.chdir(target_dir) do
28
+ generate_podfile
29
+ Pod::Executable.execute_command('pod', ['install', '--no-repo-update'])
30
+ generator = Pod::PlaygroundGenerator.new(@platform)
31
+ path = generator.generate(@name)
32
+ File.open(path + 'Contents.swift', 'w') do |f|
33
+ f.write("//: Please build the scheme '#{target_name}' first\n")
34
+ f.write("import XCPlayground\n")
35
+ f.write("XCPlaygroundPage.currentPage.needsIndefiniteExecution = true\n\n")
36
+ f.write("import #{@name}\n\n")
37
+ end
38
+ end
39
+
40
+ `open #{workspace_path}`
41
+ end
42
+
43
+ private
44
+
45
+ def target_dir
46
+ Pathname.new(target_name)
47
+ end
48
+
49
+ def target_name
50
+ "#{@name}Playground"
51
+ end
52
+
53
+ def workspace_path
54
+ target_dir + "#{@name}.xcworkspace"
55
+ end
56
+
57
+ def generate_podfile
58
+ contents = "use_frameworks!\n\n"
59
+ contents << "target '#{target_name}' do\n"
60
+ contents << "pod '#{@name}'\n"
61
+ contents << "end\n"
62
+ File.open('Podfile', 'w') { |f| f.write(contents) }
63
+ end
64
+
65
+ def generate_project
66
+ `rm -fr #{target_dir}`
67
+ FileUtils.mkdir_p(target_dir)
68
+
69
+ project_path = "#{target_dir}/#{@name}.xcodeproj"
70
+ project = Xcodeproj::Project.new(project_path)
71
+
72
+ target = project.new_target(:framework,
73
+ target_name,
74
+ @platform,
75
+ @deployment_target)
76
+ target.build_configurations.each do |config|
77
+ config.build_settings['DEFINES_MODULE'] = 'NO'
78
+ end
79
+
80
+ # TODO: Should be at the root of the project
81
+ project.new_file("#{@name}.playground")
82
+ project.save
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsPlaygrounds
2
+ VERSION = '0.0.1'.freeze
3
+ end
@@ -0,0 +1,40 @@
1
+ module Pod
2
+ class PlaygroundGenerator
3
+ TEMPLATE_DIR = Pathname.new('Library/Xcode/Templates/File Templates/Source/Playground with Platform Choice.xctemplate')
4
+ TEMPLATE_NAME = Pathname.new('___FILEBASENAME___.playground')
5
+
6
+ def initialize(platform)
7
+ @template = self.class.dir_for_platform(platform)
8
+ fail "Could not find template for #{platform}" if @template.nil?
9
+ @template += TEMPLATE_NAME
10
+ end
11
+
12
+ def generate(name)
13
+ FileUtils.cp_r(@template, "#{name}.playground")
14
+ Pathname.new("#{name}.playground")
15
+ end
16
+
17
+ def self.platforms
18
+ Dir.entries(template_dir).map do |file|
19
+ next if file.start_with?('.')
20
+ next unless (template_dir + file).directory?
21
+ platform_name(file)
22
+ end.compact
23
+ end
24
+
25
+ def self.template_dir
26
+ xcode = Pathname.new(`xcode-select -p`.strip)
27
+ xcode + TEMPLATE_DIR
28
+ end
29
+
30
+ def self.platform_name(file)
31
+ file.downcase.sub(' ', '').to_sym
32
+ end
33
+
34
+ def self.dir_for_platform(platform)
35
+ Dir.foreach(template_dir) do |file|
36
+ return (template_dir + file) if platform_name(file) == platform
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-playgrounds/command'
@@ -0,0 +1,11 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Playgrounds do
5
+ describe 'CLAide' do
6
+ it 'registers it self' do
7
+ Command.parse(%w( playgrounds )).should.be.instance_of Command::Playgrounds
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,36 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe PlaygroundGenerator do
5
+ it 'can find the template directory' do
6
+ template_dir = PlaygroundGenerator.template_dir
7
+
8
+ template_dir.extname.should == '.xctemplate'
9
+ template_dir.exist?.should == true
10
+ end
11
+
12
+ it 'can list available platforms for Playgrounds' do
13
+ platforms = PlaygroundGenerator.platforms
14
+
15
+ platforms.should == [:ios, :osx, :tvos]
16
+ end
17
+
18
+ it 'returns nil if template for platform cannot be found' do
19
+ platform = PlaygroundGenerator.dir_for_platform(:watchos)
20
+
21
+ platform.should.nil?
22
+ end
23
+
24
+ it 'can find the template for OS X' do
25
+ platform = PlaygroundGenerator.dir_for_platform(:osx)
26
+
27
+ platform.to_s.end_with?('OS X').should == true
28
+ end
29
+
30
+ it 'can find the template for iOS' do
31
+ platform = PlaygroundGenerator.dir_for_platform(:ios)
32
+
33
+ platform.to_s.end_with?('iOS').should == true
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,49 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $LOAD_PATH.unshift((ROOT + 'lib').to_s)
4
+ $LOAD_PATH.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'bacon'
8
+ require 'mocha-on-bacon'
9
+ require 'pretty_bacon'
10
+ require 'pathname'
11
+ require 'cocoapods'
12
+
13
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
14
+
15
+ require 'cocoapods_plugin'
16
+
17
+ #-----------------------------------------------------------------------------#
18
+
19
+ module Pod
20
+ # Disable the wrapping so the output is deterministic in the tests.
21
+ #
22
+ UI.disable_wrap = true
23
+
24
+ # Redirects the messages to an internal store.
25
+ #
26
+ module UI
27
+ @output = ''
28
+ @warnings = ''
29
+
30
+ class << self
31
+ attr_accessor :output
32
+ attr_accessor :warnings
33
+
34
+ def puts(message = '')
35
+ @output << "#{message}\n"
36
+ end
37
+
38
+ def warn(message = '', _actions = [])
39
+ @warnings << "#{message}\n"
40
+ end
41
+
42
+ def print(message)
43
+ @output << message
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-playgrounds
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Boris Bügling
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - boris@icculus.org
44
+ executables:
45
+ - playground
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - .rubocop.yml
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bin/playground
57
+ - cocoapods-playgrounds.gemspec
58
+ - lib/cocoapods-playgrounds.rb
59
+ - lib/cocoapods-playgrounds/command.rb
60
+ - lib/cocoapods-playgrounds/command/playgrounds.rb
61
+ - lib/cocoapods-playgrounds/gem_version.rb
62
+ - lib/cocoapods-playgrounds/generate.rb
63
+ - lib/cocoapods_plugin.rb
64
+ - spec/command/playgrounds_spec.rb
65
+ - spec/generate_spec.rb
66
+ - spec/spec_helper.rb
67
+ homepage: https://github.com/EXAMPLE/cocoapods-playgrounds
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.0.14
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Generates a Swift Playground for any Pod.
91
+ test_files:
92
+ - spec/command/playgrounds_spec.rb
93
+ - spec/generate_spec.rb
94
+ - spec/spec_helper.rb
95
+ has_rdoc: