cocoapods-try 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59846a9b4b264d248b3179fbd131845ad5e8c105
4
- data.tar.gz: fd0b200c55f3009cb0f4bd9d06d29122d0e8decb
3
+ metadata.gz: c6852926d0e2280157a7d754c29ded139c053e96
4
+ data.tar.gz: d374de7456ab6faae9787a99f29beee01191d0ec
5
5
  SHA512:
6
- metadata.gz: c453c8f582e5680eadb629a994fae354718f7ecffa39ca9054a9f6aa30aa2ad690ffceb2af0bd6c4b466bea5e2ef61312f5d73b7eec6136cd7d0d9896f970ef9
7
- data.tar.gz: 4aeb31d49f8005375f06b8826e0641ce94169e401bd33a8f9656a6f0dadfd832ba3cd10aba095c3b44364f325b4f55674278da1922d7df82ff0b4b2a633a2c65
6
+ metadata.gz: 6c8fd308506bf958b5c0bddee407b45346b89e33737aceac8eeea750d3345fd83ae9b7fa038171c00defff0bf3d0a1469e3126192252a49e45ad9f744416e39b
7
+ data.tar.gz: 6eb9e69bef6993e259d41a6c043f61a8bb1ce1573da09f7e07d2a34364aae98e964541019d61b138bc95c9bcedaf169fc5fa11a369030f63e4676535d600a18e
data/.rubocop.yml ADDED
@@ -0,0 +1,51 @@
1
+ HashSyntax:
2
+ EnforcedStyle: hash_rockets
3
+
4
+ StringLiterals:
5
+ Enabled: false
6
+ EnforcedStyle: double_quotes
7
+
8
+ SignalException:
9
+ EnforcedStyle: only_raise
10
+
11
+ ConstantName:
12
+ Enabled: false
13
+
14
+ IfUnlessModifier:
15
+ Enabled: false
16
+
17
+ EmptyLinesAroundBody:
18
+ Enabled: false
19
+
20
+ AsciiComments:
21
+ Enabled: false
22
+
23
+ Proc:
24
+ Enabled: false
25
+
26
+ BracesAroundHashParameters:
27
+ Enabled: false
28
+
29
+ Encoding:
30
+ Enabled: false
31
+
32
+ TrailingComma:
33
+ EnforcedStyleForMultiline: comma
34
+
35
+ FileName:
36
+ Enabled: false
37
+
38
+ #------------------------------------------------------------------------------
39
+ # Needs fixing
40
+ #------------------------------------------------------------------------------
41
+
42
+ ClassLength:
43
+ Max: 200
44
+
45
+ MethodLength:
46
+ Max: 18
47
+
48
+ LineLength:
49
+ Enabled: false
50
+
51
+
data/.travis.yml CHANGED
@@ -1,11 +1,10 @@
1
1
  language: objective-c
2
2
  env:
3
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 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
5
- - RVM_RUBY_VERSION=1.8.7-p358 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
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
6
  before_install:
7
7
  - curl http://curl.haxx.se/ca/cacert.pem -o /usr/local/share/cacert.pem
8
- - sh -c 'if [ "$RVM_RUBY_VERSION" != "system" ]; then rvm install $RVM_RUBY_VERSION --without-tcl --without-tk; fi'
9
8
  - source ~/.rvm/scripts/rvm && rvm use $RVM_RUBY_VERSION
10
- install: eval $RUBY_VERSION_SPECIFIC && bundle install --path ./travis_bundle_dir
11
- script: bundle exec rake specs
9
+ install: eval $RUBY_VERSION_SPECIFIC && rake bootstrap[use_bundle_dir]
10
+ script: bundle exec rake spec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
1
  # Cocoapods::Try Changelog
2
2
 
3
- ## Master
3
+ ## 0.2.0
4
+
5
+ ### Enhancements
6
+
7
+ * Added support for the specification of an URL instead of the name of a Pod.
8
+ [David Grandinetti](https://github.com/dbgrandi)
9
+ [Fabio Pelosin](https://github.com/irrationalfab)
10
+
11
+ ## 0.1.2
12
+
13
+ ### Enhancements
14
+
15
+ * Prefer workspaces over projects.
16
+ [Kyle Fuller](https://github.com/kylef)
17
+
18
+ * Open workspaces if available.
19
+ [Kyle Fuller](https://github.com/kylef)
20
+
21
+ ### Fixes
22
+
23
+ * Don't consider workspaces in bundles.
24
+ [Eloy Durán](https://github.com/alloy)
25
+
26
+ * Typo fixes.
27
+ [Mark Townsend](https://github.com/markltownsend)
28
+
29
+ ## 0.1.0
30
+
31
+ * Initial implementation.
32
+ [Fabio Pelosin](https://github.com/fabiopelosin)
data/Gemfile CHANGED
@@ -6,7 +6,8 @@ group :development do
6
6
  gem 'cocoapods'
7
7
  gem 'bacon'
8
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'
9
+ gem 'prettybacon'
10
+ if RUBY_VERSION >= '1.9.3'
11
+ gem 'rubocop'
12
+ end
12
13
  end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 CocoaPods Dev Team
1
+ Copyright (c) 2013 Fabio Pelosin
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,15 +1,18 @@
1
1
  # Cocoapods try
2
2
 
3
- [![Build Status](https://travis-ci.org/CocoaPods/cocoapods-try.png?branch=master)](https://travis-ci.org/CocoaPods/cocoapods-try)
3
+ [![Build Status](https://travis-ci.org/CocoaPods/cocoapods-try.svg?branch=master)](https://travis-ci.org/CocoaPods/cocoapods-try)
4
+ [![Code Climate](https://img.shields.io/codeclimate/github/CocoaPods/cocoapods-try.svg)](https://codeclimate.com/github/CocoaPods/cocoapods-try)
4
5
 
5
6
  CocoaPods plugin which allows to quickly try the demo project of a Pod.
6
7
 
7
- ## Installation
8
-
9
- $ git clone THIS_REPO_URL
10
- $ cd THIS_REPO
11
- $ rake install
8
+ ![](http://i.imgur.com/xxWNUrg.gif)
12
9
 
13
10
  ## Usage
14
11
 
15
12
  $ pod try POD_NAME
13
+
14
+ ## Installation
15
+
16
+ $ gem install cocoapods-try
17
+
18
+
data/Rakefile CHANGED
@@ -1,12 +1,45 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- def specs(dir)
4
- FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
3
+ task :default => "spec"
4
+
5
+ # Bootstrap
6
+ #-----------------------------------------------------------------------------#
7
+
8
+ task :bootstrap, :use_bundle_dir? do |t, args|
9
+ if args[:use_bundle_dir?]
10
+ sh "bundle install --path ./travis_bundle_dir"
11
+ else
12
+ sh "bundle install"
13
+ end
5
14
  end
6
15
 
16
+ # Spec
17
+ #-----------------------------------------------------------------------------#
18
+
7
19
  desc "Runs all the specs"
8
- task :specs do
20
+ task :spec do
21
+ start_time = Time.now
9
22
  sh "bundle exec bacon #{specs('**')}"
23
+ duration = Time.now - start_time
24
+ puts "Tests completed in #{duration}s"
25
+ Rake::Task["rubocop"].invoke
10
26
  end
11
27
 
12
- task :default => :specs
28
+ def specs(dir)
29
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
30
+ end
31
+
32
+ # Rubocop
33
+ #-----------------------------------------------------------------------------#
34
+
35
+ desc 'Checks code style'
36
+ task :rubocop do
37
+ if RUBY_VERSION >= '1.9.3'
38
+ require 'rubocop'
39
+ cli = Rubocop::CLI.new
40
+ result = cli.run(FileList['{spec,lib}/**/*.rb'])
41
+ abort('RuboCop failed!') unless result == 0
42
+ else
43
+ puts "[!] Ruby > 1.9 is required to run style checks"
44
+ end
45
+ end
@@ -6,7 +6,7 @@ require 'cocoapods_try.rb'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "cocoapods-try"
8
8
  spec.version = CocoapodsTry::VERSION
9
- spec.authors = ["CocoaPods Dev Team"]
9
+ spec.authors = ["Fabio Pelosin"]
10
10
  spec.summary = %q{CocoaPods plugin which allows to quickly try the demo project of a Pod.}
11
11
  spec.homepage = "https://github.com/cocoapods/cocoapods-try"
12
12
  spec.license = "MIT"
data/lib/cocoapods_try.rb CHANGED
@@ -1,3 +1,6 @@
1
+
2
+ # The namespace of the Cocoapods try plugin.
3
+ #
1
4
  module CocoapodsTry
2
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
3
6
  end
@@ -1,3 +1,6 @@
1
+
2
+ # The CocoaPods namespace
3
+ #
1
4
  module Pod
2
5
  class Command
3
6
 
@@ -7,10 +10,12 @@ module Pod
7
10
  self.summary = "Try a Pod!"
8
11
 
9
12
  self.description = <<-DESC
10
- Donwloads the Pod with the given NAME and opens its project.
13
+ Downloads the Pod with the given NAME (or Git URL), install its
14
+ depedencies if needed and opens its demo project. If a Git URL is
15
+ provided the head of the repo is used.
11
16
  DESC
12
17
 
13
- self.arguments = 'NAME'
18
+ self.arguments = 'NAME_OR_URL'
14
19
 
15
20
  def initialize(argv)
16
21
  @name = argv.shift_argument
@@ -19,14 +24,21 @@ module Pod
19
24
 
20
25
  def validate!
21
26
  super
22
- help! "A Pod name is required." unless @name
27
+ help! "A Pod name or URL is required." unless @name
23
28
  end
24
29
 
25
30
  def run
26
- spec = spec_with_name(@name)
27
- update_specs_repos
31
+ sandbox = Sandbox.new(TRY_TMP_DIR)
32
+ if git_url?(@name)
33
+ spec = spec_with_url(@name)
34
+ sandbox.store_pre_downloaded_pod(spec.name)
35
+ else
36
+ update_specs_repos
37
+ spec = spec_with_name(@name)
38
+ end
39
+
28
40
  UI.title "Trying #{spec.name}" do
29
- pod_dir = install_pod(spec, TRY_TMP_DIR)
41
+ pod_dir = install_pod(spec, sandbox)
30
42
  proj = pick_demo_project(pod_dir)
31
43
  file = install_podfile(proj)
32
44
  if file
@@ -63,6 +75,28 @@ module Pod
63
75
  end
64
76
  end
65
77
 
78
+ # Returns the specification found in the given Git repository URL by
79
+ # downloading the repository.
80
+ #
81
+ # @param [String] url
82
+ # The URL for the pod Git repository.
83
+ #
84
+ # @return [Specification] The specification.
85
+ #
86
+ def spec_with_url(url)
87
+ name = url.split('/').last
88
+ name = name.chomp(".git") if name.end_with?(".git")
89
+
90
+ target_dir = TRY_TMP_DIR + name
91
+ target_dir.rmtree if target_dir.exist?
92
+
93
+ downloader = Pod::Downloader.for_target(target_dir, { :git => url })
94
+ downloader.download
95
+
96
+ spec_file = target_dir + "#{name}.podspec"
97
+ Pod::Specification.from_file(spec_file)
98
+ end
99
+
66
100
  # Installs the specification in the given directory.
67
101
  #
68
102
  # @param [Specification] The specification of the Pod.
@@ -71,16 +105,17 @@ module Pod
71
105
  #
72
106
  # @return [Pathname] The path where the Pod was installed
73
107
  #
74
- def install_pod(spec, dir)
75
- sandbox = Sandbox.new(dir)
108
+ def install_pod(spec, sandbox)
76
109
  specs = { :ios => spec, :osx => spec }
77
110
  installer = Installer::PodSourceInstaller.new(sandbox, specs)
78
111
  installer.aggressive_cache = config.aggressive_cache?
79
112
  installer.install!
80
- TRY_TMP_DIR + spec.name
113
+ sandbox.root + spec.name
81
114
  end
82
115
 
83
- # Picks a project suitable for the demo purposes in the given directory.
116
+ # Picks a project or workspace suitable for the demo purposes in the
117
+ # given directory.
118
+ #
84
119
  # To decide the project simple heuristics are used according to the name,
85
120
  # if no project is found this method raises and `Informative` otherwise
86
121
  # if more than one project is found the choice is presented to the user.
@@ -91,30 +126,29 @@ module Pod
91
126
  # @return [String] The path of the project.
92
127
  #
93
128
  def pick_demo_project(dir)
94
- glob_match = Dir.glob("#{dir}/**/*.xcodeproj")
95
- glob_match = glob_match.reject { |p| p.include?('Pods.xcodeproj') }
96
- if glob_match.count == 0
129
+ projs = projects_in_dir(dir)
130
+ if projs.count == 0
97
131
  raise Informative, "Unable to find any project in the source files" \
98
- "of the Pod: `#{dir}`"
99
- elsif glob_match.count == 1
100
- glob_match.first
101
- elsif (selection = filter_array(glob_match, "demo")).count == 1
102
- selection.first
103
- elsif (selection = filter_array(glob_match, "example")).count == 1
104
- selection.first
132
+ " of the Pod: `#{dir}`"
133
+ elsif projs.count == 1
134
+ projs.first
135
+ elsif (workspaces = projs.grep(/(demo|example).*\.xcworkspace$/i)).count == 1
136
+ workspaces.first
137
+ elsif (projects = projs.grep(/demo|example/i)).count == 1
138
+ projects.first
105
139
  else
106
140
  message = "Which project would you like to open"
107
- selection_array = glob_match.map do |p|
141
+ selection_array = projs.map do |p|
108
142
  Pathname.new(p).relative_path_from(dir).to_s
109
143
  end
110
144
  index = choose_from_array(selection_array, message)
111
- glob_match[index]
145
+ projs[index]
112
146
  end
113
147
  end
114
148
 
115
- # Performs a CocoaPods installation for the given project if Podfile is found.
116
- # Shells out to avoid issues with the config of the process running the
117
- # try command.
149
+ # Performs a CocoaPods installation for the given project if Podfile is
150
+ # found. Shells out to avoid issues with the config of the process
151
+ # running the try command.
118
152
  #
119
153
  # @return [String] proj
120
154
  # The path of the project.
@@ -125,11 +159,18 @@ module Pod
125
159
  def install_podfile(proj)
126
160
  return unless proj
127
161
  dirname = Pathname.new(proj).dirname
128
- podfile = dirname + 'Podfile'
129
- if podfile.exist?
162
+ podfile_path = dirname + 'Podfile'
163
+ if podfile_path.exist?
130
164
  Dir.chdir(dirname) do
131
165
  perform_cocoapods_installation
132
- proj.chomp(File.extname(proj.to_s)) + '.xcworkspace'
166
+
167
+ podfile = Pod::Podfile.from_file(podfile_path)
168
+
169
+ if podfile.workspace_path
170
+ File.expand_path(podfile.workspace_path)
171
+ else
172
+ proj.chomp(File.extname(proj.to_s)) + '.xcworkspace'
173
+ end
133
174
  end
134
175
  else
135
176
  proj
@@ -163,21 +204,6 @@ module Pod
163
204
  `open "#{path}"`
164
205
  end
165
206
 
166
- # Selects the entries in the given array which includes the given string
167
- # (case insensitive check).
168
- #
169
- # @param [Array] array
170
- # The array to filter.
171
- #
172
- # @param [String] string
173
- # The string that should be used to filter the array.
174
- #
175
- # @return [Array] The selection.
176
- #
177
- def filter_array(array, string)
178
- array.select { |p| p.downcase.include?(string.downcase) }
179
- end
180
-
181
207
  # Presents a choice among the elements of an array to the user.
182
208
  #
183
209
  # @param [Array<#to_s>] array
@@ -211,6 +237,32 @@ module Pod
211
237
  UI.puts `pod install`
212
238
  end
213
239
 
240
+ # @return [Bool] Wether the given string is the name of a Pod or an URL
241
+ # for a Git repo.
242
+ #
243
+ def git_url?(name)
244
+ prefixes = ['https://', 'http://']
245
+ if prefixes.any? { |prefix| name.start_with?(prefix) }
246
+ true
247
+ else
248
+ false
249
+ end
250
+ end
251
+
252
+ # @return [Array<String>] The list of the workspaces and projects in a
253
+ # given directory excluding The Pods project and the projects
254
+ # that have a sister workspace.
255
+ #
256
+ def projects_in_dir(dir)
257
+ glob_match = Dir.glob("#{dir}/**/*.xc{odeproj,workspace}")
258
+ glob_match = glob_match.reject do |p|
259
+ next true if p.include?('Pods.xcodeproj')
260
+ next true if p.end_with?('.xcodeproj/project.xcworkspace')
261
+ sister_workspace = p.chomp(File.extname(p.to_s)) + '.xcworkspace'
262
+ p.end_with?('.xcodeproj') && glob_match.include?(sister_workspace)
263
+ end
264
+ end
265
+
214
266
  #-------------------------------------------------------------------#
215
267
 
216
268
  end
@@ -1,31 +1,50 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
+ # The CocoaPods namespace
4
+ #
3
5
  module Pod
4
6
  describe Command::Try do
5
7
 
6
8
  #-------------------------------------------------------------------------#
7
9
 
8
- describe "CLAide" do
10
+ describe "Try" do
9
11
  it "registers it self" do
10
- Command.parse(%w{ try }).should.be.instance_of Command::Try
12
+ Command.parse(%w(try)).should.be.instance_of Command::Try
11
13
  end
12
14
 
13
15
  it "presents the help if no name is provided" do
14
16
  command = Pod::Command.parse(['try'])
15
17
  should.raise CLAide::Help do
16
18
  command.validate!
17
- end.message.should.match /A Pod name is required/
19
+ end.message.should.match(/A Pod name or URL is required/)
18
20
  end
19
21
 
20
- it "runs" do
22
+ it "allows the user to try the Pod with the given name" do
21
23
  Config.instance.skip_repo_update = false
22
- command = Pod::Command.parse(['try', 'ARAnalytics'])
24
+ command = Pod::Command.parse(%w(try ARAnalytics))
23
25
  Installer::PodSourceInstaller.any_instance.expects(:install!)
24
26
  command.expects(:update_specs_repos)
25
27
  command.expects(:pick_demo_project).returns("/tmp/Proj.xcodeproj")
26
28
  command.expects(:open_project).with('/tmp/Proj.xcodeproj')
27
29
  command.run
28
30
  end
31
+
32
+ it "allows the user to try the Pod with the given Git URL" do
33
+ require 'cocoapods-downloader/git'
34
+ Pod::Downloader::GitHub.any_instance.expects(:download)
35
+ spec_file = '/tmp/CocoaPods/Try/ARAnalytics/ARAnalytics.podspec'
36
+ stub_spec = stub(:name => 'ARAnalytics')
37
+ Pod::Specification.stubs(:from_file).with(Pathname(spec_file)).returns(stub_spec)
38
+
39
+ Config.instance.skip_repo_update = false
40
+ command = Pod::Command.parse(['try', 'https://github.com/orta/ARAnalytics.git'])
41
+ Installer::PodSourceInstaller.any_instance.expects(:install!)
42
+ command.expects(:update_specs_repos).never
43
+ command.expects(:pick_demo_project).returns("/tmp/Proj.xcodeproj")
44
+ command.expects(:open_project).with('/tmp/Proj.xcodeproj')
45
+ command.run
46
+ end
47
+
29
48
  end
30
49
 
31
50
  #-------------------------------------------------------------------------#
@@ -41,11 +60,27 @@ module Pod
41
60
  spec.name.should == "ARAnalytics"
42
61
  end
43
62
 
63
+ describe "#spec_at_url" do
64
+
65
+ it "returns a spec for an https git repo" do
66
+ require 'cocoapods-downloader/git'
67
+ Pod::Downloader::GitHub.any_instance.expects(:download)
68
+ spec_file = '/tmp/CocoaPods/Try/ARAnalytics/ARAnalytics.podspec'
69
+ stub_spec = stub
70
+ Pod::Specification.stubs(:from_file).with(Pathname(spec_file)).returns(stub_spec)
71
+ spec = @sut.spec_with_url('https://github.com/orta/ARAnalytics.git')
72
+ spec.should == stub_spec
73
+ end
74
+
75
+ end
76
+
44
77
  it "installs the pod" do
45
78
  Installer::PodSourceInstaller.any_instance.expects(:install!)
46
79
  spec = stub(:name => 'ARAnalytics')
47
- path = @sut.install_pod(spec, '/tmp/CocoaPods/Try')
48
- path.should == Pathname.new("/tmp/CocoaPods/Try/ARAnalytics")
80
+ sandbox_root = Pathname.new('/tmp/CocoaPods/Try')
81
+ sandbox = Sandbox.new(sandbox_root)
82
+ path = @sut.install_pod(spec, sandbox)
83
+ path.should == sandbox.root + "ARAnalytics"
49
84
  end
50
85
 
51
86
  describe "#pick_demo_project" do
@@ -53,35 +88,35 @@ module Pod
53
88
  projects = []
54
89
  Dir.stubs(:glob).returns(projects)
55
90
  should.raise Informative do
56
- @sut.pick_demo_project(stub())
57
- end.message.should.match /Unable to find any project/
91
+ @sut.pick_demo_project(stub)
92
+ end.message.should.match(/Unable to find any project/)
58
93
  end
59
94
 
60
95
  it "picks a demo project" do
61
96
  projects = ['Demo.xcodeproj']
62
97
  Dir.stubs(:glob).returns(projects)
63
- path = @sut.pick_demo_project(stub())
98
+ path = @sut.pick_demo_project(stub)
64
99
  path.should == "Demo.xcodeproj"
65
100
  end
66
101
 
67
102
  it "is not case sensitive" do
68
103
  projects = ['demo.xcodeproj']
69
104
  Dir.stubs(:glob).returns(projects)
70
- path = @sut.pick_demo_project(stub())
105
+ path = @sut.pick_demo_project(stub)
71
106
  path.should == "demo.xcodeproj"
72
107
  end
73
108
 
74
109
  it "considers also projects named example" do
75
110
  projects = ['Example.xcodeproj']
76
111
  Dir.stubs(:glob).returns(projects)
77
- path = @sut.pick_demo_project(stub())
112
+ path = @sut.pick_demo_project(stub)
78
113
  path.should == "Example.xcodeproj"
79
114
  end
80
115
 
81
116
  it "returns the project if only one is found" do
82
117
  projects = ['Lib.xcodeproj']
83
118
  Dir.stubs(:glob).returns(projects)
84
- path = @sut.pick_demo_project(stub())
119
+ path = @sut.pick_demo_project(stub)
85
120
  path.should == "Lib.xcodeproj"
86
121
  end
87
122
 
@@ -89,9 +124,27 @@ module Pod
89
124
  projects = ['Lib_1.xcodeproj', 'Lib_2.xcodeproj']
90
125
  Dir.stubs(:glob).returns(projects)
91
126
  @sut.stubs(:choose_from_array).returns(0)
92
- path = @sut.pick_demo_project(stub(:cleanpath=>''))
127
+ path = @sut.pick_demo_project(stub(:cleanpath => ''))
93
128
  path.should == "Lib_1.xcodeproj"
94
129
  end
130
+
131
+ it "should prefer demo or example workspaces" do
132
+ Dir.stubs(:glob).returns(['Project Demo.xcodeproj', 'Project Demo.xcworkspace'])
133
+ path = @sut.pick_demo_project(stub(:cleanpath => ''))
134
+ path.should == 'Project Demo.xcworkspace'
135
+ end
136
+
137
+ it "should not show workspaces inside a project" do
138
+ Dir.stubs(:glob).returns(['Project Demo.xcodeproj', 'Project Demo.xcodeproj/project.xcworkspace'])
139
+ path = @sut.pick_demo_project(stub(:cleanpath => ''))
140
+ path.should == 'Project Demo.xcodeproj'
141
+ end
142
+
143
+ it "should prefer workspaces over projects with the same name" do
144
+ Dir.stubs(:glob).returns(['Project Demo.xcodeproj', 'Project Demo.xcworkspace'])
145
+ path = @sut.pick_demo_project(stub(:cleanpath => ''))
146
+ path.should == 'Project Demo.xcworkspace'
147
+ end
95
148
  end
96
149
 
97
150
  describe "#install_podfile" do
@@ -102,10 +155,19 @@ module Pod
102
155
  path.should == proj
103
156
  end
104
157
 
105
- it "performs an installation and returns the path of the Podfile" do
158
+ it "performs an installation and returns the path of the workspace" do
106
159
  Pathname.any_instance.stubs(:exist?).returns(true)
107
160
  proj = "/tmp/Project.xcodeproj"
108
161
  @sut.expects(:perform_cocoapods_installation)
162
+ Podfile.stubs(:from_file).returns(stub(:workspace_path => "/tmp/Project.xcworkspace"))
163
+ path = @sut.install_podfile(proj)
164
+ path.should == "/tmp/Project.xcworkspace"
165
+ end
166
+
167
+ it "returns the default workspace if one is not set" do
168
+ Pathname.any_instance.stubs(:exist?).returns(true)
169
+ proj = "/tmp/Project.xcodeproj"
170
+ Podfile.stubs(:from_file).returns(stub(:workspace_path => nil))
109
171
  path = @sut.install_podfile(proj)
110
172
  path.should == "/tmp/Project.xcworkspace"
111
173
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'pathname'
2
2
  ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
- $:.unshift((ROOT + 'lib').to_s)
4
- $:.unshift((ROOT + 'spec').to_s)
3
+ $LOAD_PATH.unshift((ROOT + 'lib').to_s)
4
+ $LOAD_PATH.unshift((ROOT + 'spec').to_s)
5
5
 
6
6
  require 'bundler/setup'
7
7
  require 'bacon'
@@ -13,6 +13,8 @@ require 'cocoapods_plugin'
13
13
 
14
14
  #-----------------------------------------------------------------------------#
15
15
 
16
+ # The CocoaPods namespace
17
+ #
16
18
  module Pod
17
19
 
18
20
  # Disable the wrapping so the output is deterministic in the tests.
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-try
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - CocoaPods Dev Team
7
+ - Fabio Pelosin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-02 00:00:00.000000000 Z
11
+ date: 2014-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description:
@@ -44,14 +44,15 @@ executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
- - .gitignore
48
- - .travis.yml
47
+ - ".gitignore"
48
+ - ".rubocop.yml"
49
+ - ".travis.yml"
49
50
  - CHANGELOG.md
50
51
  - Gemfile
51
52
  - LICENSE
52
53
  - README.md
53
54
  - Rakefile
54
- - cocoapods-docs.gemspec
55
+ - cocoapods-try.gemspec
55
56
  - lib/cocoapods_plugin.rb
56
57
  - lib/cocoapods_try.rb
57
58
  - lib/pod/command/try.rb
@@ -67,20 +68,21 @@ require_paths:
67
68
  - lib
68
69
  required_ruby_version: !ruby/object:Gem::Requirement
69
70
  requirements:
70
- - - '>='
71
+ - - ">="
71
72
  - !ruby/object:Gem::Version
72
73
  version: '0'
73
74
  required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  requirements:
75
- - - '>='
76
+ - - ">="
76
77
  - !ruby/object:Gem::Version
77
78
  version: '0'
78
79
  requirements: []
79
80
  rubyforge_project:
80
- rubygems_version: 2.0.3
81
+ rubygems_version: 2.2.2
81
82
  signing_key:
82
83
  specification_version: 4
83
84
  summary: CocoaPods plugin which allows to quickly try the demo project of a Pod.
84
85
  test_files:
85
86
  - spec/command/try_spec.rb
86
87
  - spec/spec_helper.rb
88
+ has_rdoc: