cocoapods-try-release-fix 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: be63bdbd27501b3ec5239201329a3916bcd87a31
4
+ data.tar.gz: 2404c5104caea42299e952f070faae0e33f84253
5
+ SHA512:
6
+ metadata.gz: ef5a78d733eaed67ca95fe191cfce2338a85530e5c8e1519c91ad3e491976b3eb0555c47da64a83d3f34a61dbb08fd7cb005351674626afec685d976791377fd
7
+ data.tar.gz: f4dd2d870c5480896b9ed2902449cff05786b24ada8281fe1bb8a541689fbf70814c971061931497067517d33296f060ea3337662c8308bcbebc6ffa920d83df
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: objective-c
2
+ env:
3
+ # This is what 10.8.x comes with and we want to support that.
4
+ - RVM_RUBY_VERSION=system NOEXEC_DISABLE=1 RUBY_VERSION_SPECIFIC='sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2' SSL_CERT_FILE=/usr/local/share/cacert.pem GIT_AUTHOR_NAME=CocoaPods GIT_AUTHOR_EMAIL=cocoapods@example.com PYTHONPATH=/usr/local/lib/python2.7/site-packages
5
+ - RVM_RUBY_VERSION=2.0.0-p247 NOEXEC_DISABLE=1 RUBY_VERSION_SPECIFIC='sudo gem install bundler --no-ri --no-rdoc' GIT_AUTHOR_NAME=CocoaPods GIT_AUTHOR_EMAIL=cocoapods@example.com PYTHONPATH=/usr/local/lib/python2.7/site-packages
6
+ before_install:
7
+ - curl http://curl.haxx.se/ca/cacert.pem -o /usr/local/share/cacert.pem
8
+ - source ~/.rvm/scripts/rvm && rvm use $RVM_RUBY_VERSION
9
+ install: eval $RUBY_VERSION_SPECIFIC && rake bootstrap[use_bundle_dir]
10
+ script: bundle exec rake spec:ci
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # Cocoapods::Try Changelog
2
+
3
+ ## Master
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'cocoapods'
7
+ gem 'bacon'
8
+ gem 'mocha-on-bacon'
9
+ gem 'mocha', '~> 0.11.4'
10
+ gem 'rake'
11
+ gem 'prettybacon', :git => 'https://github.com/irrationalfab/PrettyBacon.git', :branch => 'master'
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Fabio Pelosin
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,17 @@
1
+ # Cocoapods try
2
+
3
+ [![Build Status](https://travis-ci.org/CocoaPods/cocoapods-try.png?branch=master)](https://travis-ci.org/CocoaPods/cocoapods-try)
4
+
5
+ CocoaPods plugin which allows to quickly try the demo project of a Pod.
6
+
7
+ ![](http://i.imgur.com/xxWNUrg.gif)
8
+
9
+ ## Usage
10
+
11
+ $ pod try POD_NAME
12
+
13
+ ## Installation
14
+
15
+ $ gem install cocoapods-try
16
+
17
+
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ task :bootstrap, :use_bundle_dir? do |t, args|
8
+ if args[:use_bundle_dir?]
9
+ sh "bundle install --path ./travis_bundle_dir"
10
+ else
11
+ sh "bundle install"
12
+ end
13
+ end
14
+
15
+ namespace :spec do
16
+ desc "Runs all the specs"
17
+ task :ci do
18
+ sh "bundle exec bacon #{specs('**')}"
19
+ end
20
+ end
21
+
22
+ task :default => "spec:ci"
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods_try.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cocoapods-try"
8
+ spec.version = CocoapodsTry::VERSION
9
+ spec.authors = ["Fabio Pelosin"]
10
+ spec.summary = %q{CocoaPods plugin which allows to quickly try the demo project of a Pod.}
11
+ spec.homepage = "https://github.com/cocoapods/cocoapods-try"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "rake"
21
+ end
@@ -0,0 +1 @@
1
+ require 'pod/command/try'
@@ -0,0 +1,3 @@
1
+ module CocoapodsTry
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,208 @@
1
+ module Pod
2
+ class Command
3
+
4
+ # The pod try command.
5
+ #
6
+ class Try < Command
7
+ self.summary = "Try a Pod!"
8
+
9
+ self.description = <<-DESC
10
+ Donwloads the Pod with the given NAME and opens its project.
11
+ DESC
12
+
13
+ self.arguments = 'NAME'
14
+
15
+ def initialize(argv)
16
+ @name = argv.shift_argument
17
+ super
18
+ end
19
+
20
+ def validate!
21
+ super
22
+ help! "A Pod name is required." unless @name
23
+ end
24
+
25
+ def run
26
+ spec = spec_with_name(@name)
27
+ update_specs_repos
28
+ UI.title "Trying #{spec.name}" do
29
+ pod_dir = install_pod(spec, TRY_TMP_DIR)
30
+ proj = pick_demo_project(pod_dir)
31
+ file = install_podfile(proj)
32
+ if file
33
+ open_project(file)
34
+ else
35
+ UI.puts "Unable to locate a project for #{spec.name}"
36
+ end
37
+ end
38
+ end
39
+
40
+ public
41
+
42
+ # Helpers
43
+ #-----------------------------------------------------------------------#
44
+
45
+ # @return [Pathname]
46
+ #
47
+ TRY_TMP_DIR = Pathname.new('/tmp/CocoaPods/Try')
48
+
49
+ # Returns the specification of the last version of the Pod with the given
50
+ # name.
51
+ #
52
+ # @param [String] name
53
+ # The name of the pod.
54
+ #
55
+ # @return [Specification] The specification.
56
+ #
57
+ def spec_with_name(name)
58
+ set = SourcesManager.search(Dependency.new(name))
59
+ if set
60
+ set.specification.root
61
+ else
62
+ raise Informative, "Unable to find a specification for `#{name}`"
63
+ end
64
+ end
65
+
66
+ # Installs the specification in the given directory.
67
+ #
68
+ # @param [Specification] The specification of the Pod.
69
+ # @param [Pathname] The directory of the sandbox where to install the
70
+ # Pod.
71
+ #
72
+ # @return [Pathname] The path where the Pod was installed
73
+ #
74
+ def install_pod(spec, dir)
75
+ sandbox = Sandbox.new(dir)
76
+ specs = { :ios => spec, :osx => spec }
77
+ installer = Installer::PodSourceInstaller.new(sandbox, specs)
78
+ installer.aggressive_cache = config.aggressive_cache?
79
+ installer.install!
80
+ TRY_TMP_DIR + spec.name
81
+ end
82
+
83
+ # Picks a project or workspace suitable for the demo purposes in the
84
+ # given directory.
85
+ #
86
+ # To decide the project simple heuristics are used according to the name,
87
+ # if no project is found this method raises and `Informative` otherwise
88
+ # if more than one project is found the choice is presented to the user.
89
+ #
90
+ # @param [#to_s] dir
91
+ # The path where to look for projects.
92
+ #
93
+ # @return [String] The path of the project.
94
+ #
95
+ def pick_demo_project(dir)
96
+ glob_match = Dir.glob("#{dir}/**/*.xc{odeproj,workspace}")
97
+ glob_match = glob_match.reject { |p| p.include?('Pods.xcodeproj') }
98
+
99
+ if glob_match.count == 0
100
+ raise Informative, "Unable to find any project in the source files" \
101
+ "of the Pod: `#{dir}`"
102
+ elsif glob_match.count == 1
103
+ glob_match.first
104
+ elsif (workspaces = glob_match.grep(/(demo|example).*\.xcworkspace$/i)).count == 1
105
+ workspaces.first
106
+ elsif (projects = glob_match.grep(/demo|example/i)).count == 1
107
+ projects.first
108
+ else
109
+ message = "Which project would you like to open"
110
+ selection_array = glob_match.map do |p|
111
+ Pathname.new(p).relative_path_from(dir).to_s
112
+ end
113
+ index = choose_from_array(selection_array, message)
114
+ glob_match[index]
115
+ end
116
+ end
117
+
118
+ # Performs a CocoaPods installation for the given project if Podfile is found.
119
+ # Shells out to avoid issues with the config of the process running the
120
+ # try command.
121
+ #
122
+ # @return [String] proj
123
+ # The path of the project.
124
+ #
125
+ # @return [String] The path of the file to open, in other words the
126
+ # workspace of the installation or the given project.
127
+ #
128
+ def install_podfile(proj)
129
+ return unless proj
130
+ dirname = Pathname.new(proj).dirname
131
+ podfile_path = dirname + 'Podfile'
132
+ if podfile_path.exist?
133
+ Dir.chdir(dirname) do
134
+ perform_cocoapods_installation
135
+
136
+ podfile = Pod::Podfile.from_file(podfile_path)
137
+ File.expand_path(podfile.workspace_path)
138
+ end
139
+ else
140
+ proj
141
+ end
142
+ end
143
+
144
+ public
145
+
146
+ # Private Helpers
147
+ #-----------------------------------------------------------------------#
148
+
149
+ # @return [void] Updates the specs repo unless disabled by the config.
150
+ #
151
+ def update_specs_repos
152
+ unless config.skip_repo_update?
153
+ UI.section 'Updating spec repositories' do
154
+ SourcesManager.update
155
+ end
156
+ end
157
+ end
158
+
159
+ # Opens the project at the given path.
160
+ #
161
+ # @return [String] path
162
+ # The path of the project.
163
+ #
164
+ # @return [void]
165
+ #
166
+ def open_project(path)
167
+ UI.puts "Opening '#{path}'"
168
+ `open "#{path}"`
169
+ end
170
+
171
+ # Presents a choice among the elements of an array to the user.
172
+ #
173
+ # @param [Array<#to_s>] array
174
+ # The list of the elements among which the user should make his
175
+ # choice.
176
+ #
177
+ # @param [String] message
178
+ # The message to display to the user.
179
+ #
180
+ # @return [Fixnum] The index of the chosen array item.
181
+ #
182
+ # @todo This method was duplicated from the spec subcommands
183
+ #
184
+ def choose_from_array(array, message)
185
+ array.each_with_index do |item, index|
186
+ UI.puts "#{ index + 1 }: #{ item }"
187
+ end
188
+ UI.puts "#{message} [1-#{array.count}]?"
189
+ index = STDIN.gets.chomp.to_i - 1
190
+ if index < 0 || index > array.count
191
+ raise Informative, "#{ index + 1 } is invalid [1-#{array.count}]"
192
+ else
193
+ index
194
+ end
195
+ end
196
+
197
+ # @return [void] Performs a CocoaPods installation in the working
198
+ # directory.
199
+ #
200
+ def perform_cocoapods_installation
201
+ UI.puts `pod install`
202
+ end
203
+
204
+ #-------------------------------------------------------------------#
205
+
206
+ end
207
+ end
208
+ end
@@ -0,0 +1,125 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ module Pod
4
+ describe Command::Try do
5
+
6
+ #-------------------------------------------------------------------------#
7
+
8
+ describe "CLAide" do
9
+ it "registers it self" do
10
+ Command.parse(%w{ try }).should.be.instance_of Command::Try
11
+ end
12
+
13
+ it "presents the help if no name is provided" do
14
+ command = Pod::Command.parse(['try'])
15
+ should.raise CLAide::Help do
16
+ command.validate!
17
+ end.message.should.match /A Pod name is required/
18
+ end
19
+
20
+ it "runs" do
21
+ Config.instance.skip_repo_update = false
22
+ command = Pod::Command.parse(['try', 'ARAnalytics'])
23
+ Installer::PodSourceInstaller.any_instance.expects(:install!)
24
+ command.expects(:update_specs_repos)
25
+ command.expects(:pick_demo_project).returns("/tmp/Proj.xcodeproj")
26
+ command.expects(:open_project).with('/tmp/Proj.xcodeproj')
27
+ command.run
28
+ end
29
+ end
30
+
31
+ #-------------------------------------------------------------------------#
32
+
33
+ describe "Helpers" do
34
+
35
+ before do
36
+ @sut = Pod::Command.parse(['try'])
37
+ end
38
+
39
+ it "returns the spec with the given name" do
40
+ spec = @sut.spec_with_name('ARAnalytics')
41
+ spec.name.should == "ARAnalytics"
42
+ end
43
+
44
+ it "installs the pod" do
45
+ Installer::PodSourceInstaller.any_instance.expects(:install!)
46
+ spec = stub(:name => 'ARAnalytics')
47
+ path = @sut.install_pod(spec, '/tmp/CocoaPods/Try')
48
+ path.should == Pathname.new("/tmp/CocoaPods/Try/ARAnalytics")
49
+ end
50
+
51
+ describe "#pick_demo_project" do
52
+ it "raises if no demo project could be found" do
53
+ projects = []
54
+ Dir.stubs(:glob).returns(projects)
55
+ should.raise Informative do
56
+ @sut.pick_demo_project(stub())
57
+ end.message.should.match /Unable to find any project/
58
+ end
59
+
60
+ it "picks a demo project" do
61
+ projects = ['Demo.xcodeproj']
62
+ Dir.stubs(:glob).returns(projects)
63
+ path = @sut.pick_demo_project(stub())
64
+ path.should == "Demo.xcodeproj"
65
+ end
66
+
67
+ it "is not case sensitive" do
68
+ projects = ['demo.xcodeproj']
69
+ Dir.stubs(:glob).returns(projects)
70
+ path = @sut.pick_demo_project(stub())
71
+ path.should == "demo.xcodeproj"
72
+ end
73
+
74
+ it "considers also projects named example" do
75
+ projects = ['Example.xcodeproj']
76
+ Dir.stubs(:glob).returns(projects)
77
+ path = @sut.pick_demo_project(stub())
78
+ path.should == "Example.xcodeproj"
79
+ end
80
+
81
+ it "returns the project if only one is found" do
82
+ projects = ['Lib.xcodeproj']
83
+ Dir.stubs(:glob).returns(projects)
84
+ path = @sut.pick_demo_project(stub())
85
+ path.should == "Lib.xcodeproj"
86
+ end
87
+
88
+ it "asks the user which project would like to open if not a single suitable one is found" do
89
+ projects = ['Lib_1.xcodeproj', 'Lib_2.xcodeproj']
90
+ Dir.stubs(:glob).returns(projects)
91
+ @sut.stubs(:choose_from_array).returns(0)
92
+ path = @sut.pick_demo_project(stub(:cleanpath=>''))
93
+ path.should == "Lib_1.xcodeproj"
94
+ end
95
+
96
+ it "should prefer demo or example workspaces" do
97
+ Dir.stubs(:glob).returns(['Project Demo.xcodeproj', 'Project Demo.xcworkspace'])
98
+ path = @sut.pick_demo_project(stub(:cleanpath => ''))
99
+ path.should == 'Project Demo.xcworkspace'
100
+ end
101
+ end
102
+
103
+ describe "#install_podfile" do
104
+ it "returns the original project if no Podfile could be found" do
105
+ Pathname.any_instance.stubs(:exist?).returns(false)
106
+ proj = "/tmp/Project.xcodeproj"
107
+ path = @sut.install_podfile(proj)
108
+ path.should == proj
109
+ end
110
+
111
+ it "performs an installation and returns the path of the workspace" do
112
+ Pathname.any_instance.stubs(:exist?).returns(true)
113
+ proj = "/tmp/Project.xcodeproj"
114
+ @sut.expects(:perform_cocoapods_installation)
115
+ Podfile.stubs(:from_file).returns(stub(:workspace_path => "/tmp/Project.xcworkspace"))
116
+ path = @sut.install_podfile(proj)
117
+ path.should == "/tmp/Project.xcworkspace"
118
+ end
119
+ end
120
+ end
121
+
122
+ #-------------------------------------------------------------------------#
123
+
124
+ end
125
+ end
@@ -0,0 +1,47 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'bacon'
8
+ require 'mocha-on-bacon'
9
+ require 'pretty_bacon'
10
+ require 'cocoapods'
11
+
12
+ require 'cocoapods_plugin'
13
+
14
+ #-----------------------------------------------------------------------------#
15
+
16
+ module Pod
17
+
18
+ # Disable the wrapping so the output is deterministic in the tests.
19
+ #
20
+ UI.disable_wrap = true
21
+
22
+ # Redirects the messages to an internal store.
23
+ #
24
+ module UI
25
+ @output = ''
26
+ @warnings = ''
27
+
28
+ class << self
29
+ attr_accessor :output
30
+ attr_accessor :warnings
31
+
32
+ def puts(message = '')
33
+ @output << "#{message}\n"
34
+ end
35
+
36
+ def warn(message = '', actions = [])
37
+ @warnings << "#{message}\n"
38
+ end
39
+
40
+ def print(message)
41
+ @output << message
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-try-release-fix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Fabio Pelosin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-25 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
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - .gitignore
48
+ - .travis.yml
49
+ - CHANGELOG.md
50
+ - Gemfile
51
+ - LICENSE
52
+ - README.md
53
+ - Rakefile
54
+ - cocoapods-try.gemspec
55
+ - lib/cocoapods_plugin.rb
56
+ - lib/cocoapods_try.rb
57
+ - lib/pod/command/try.rb
58
+ - spec/command/try_spec.rb
59
+ - spec/spec_helper.rb
60
+ homepage: https://github.com/cocoapods/cocoapods-try
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.0.3
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: CocoaPods plugin which allows to quickly try the demo project of a Pod.
84
+ test_files:
85
+ - spec/command/try_spec.rb
86
+ - spec/spec_helper.rb
87
+ has_rdoc: