Commit e52bca45 authored by Fabio Pelosin's avatar Fabio Pelosin

Merge branch '0.17' into LocalPod-refactor

* 0.17:
  Added help display tests. added lint test for nonexistent specs. Removed cat tests in favor of which tests
  Removed Gemfile.lock
  GitIgnore Gemfile.lock
  Modified gitmodules to ignore the SSToolKit submodule when it's marked as dirty
  Fixed tests for which
  Adding which tests
  Edited editor behavior and errors
  Fixed no input
  Added pod spec which and edit, edited cat
  Updated example podspec comment

Conflicts:
	Gemfile.lock
parents 78bff53d b40494e6
...@@ -22,3 +22,5 @@ spec/fixtures/vcr ...@@ -22,3 +22,5 @@ spec/fixtures/vcr
.yardoc .yardoc
/doc /doc
.rbx/ .rbx/
Gemfile.lock
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
[submodule "spec/fixtures/integration/sstoolkit"] [submodule "spec/fixtures/integration/sstoolkit"]
path = spec/fixtures/integration/sstoolkit path = spec/fixtures/integration/sstoolkit
url = https://github.com/samsoffes/sstoolkit.git url = https://github.com/samsoffes/sstoolkit.git
ignore = dirty
[submodule "spec/fixtures/spec-repos/master"] [submodule "spec/fixtures/spec-repos/master"]
path = spec/fixtures/spec-repos/master path = spec/fixtures/spec-repos/master
url = https://github.com/CocoaPods/Specs.git url = https://github.com/CocoaPods/Specs.git
......
GIT
remote: git://github.com/CocoaPods/Core.git
revision: 72bb4fd0e0df8a9dd731ca3885ef4203967acce1
specs:
cocoapods-core (0.17.0.alpha)
activesupport (~> 3.2.6)
faraday (~> 0.8.1)
octokit (~> 1.7)
rake (~> 0.9.4)
GIT
remote: git://github.com/CocoaPods/Xcodeproj.git
revision: 39b060359900d5d319f8e42e50d641ef58bf7825
specs:
xcodeproj (0.4.1)
activesupport (~> 3.2.6)
colored (~> 1.2)
GIT
remote: git://github.com/CocoaPods/cocoapods-downloader
revision: f5fc744975f89be09bce4775ed255c0f7b8eee33
specs:
cocoapods-downloader (0.1.0)
GIT
remote: https://github.com/alloy/kicker.git
revision: 6430787ebf8b9305acc2d2f89ae5cf01d2cd5488
branch: 3.0.0
specs:
kicker (3.0.0pre1)
listen
terminal-notifier
PATH
remote: .
specs:
cocoapods (0.0.0)
activesupport (~> 3.2.6)
claide (~> 0.1)
cocoapods-core
colored (~> 1.2)
escape (~> 0.0.4)
faraday (~> 0.8.1)
json (~> 1.7.3)
octokit (~> 1.7)
open4 (~> 1.3.0)
rake (~> 0.9.4)
xcodeproj (~> 0.4.1)
GEM
remote: http://rubygems.org/
specs:
activesupport (3.2.11)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.3.2)
awesome_print (1.1.0)
bacon (1.2.0)
claide (0.2.0)
coderay (1.0.8)
colored (1.2)
escape (0.0.4)
faraday (0.8.4)
multipart-post (~> 1.1)
faraday_middleware (0.9.0)
faraday (>= 0.7.4, < 0.9)
github-markup (0.7.5)
hashie (1.2.0)
i18n (0.6.1)
json (1.7.6)
listen (0.7.2)
metaclass (0.0.1)
method_source (0.8.1)
mocha (0.11.4)
metaclass (~> 0.0.1)
mocha-on-bacon (0.2.1)
mocha (>= 0.9.8)
multi_json (1.5.0)
multipart-post (1.1.5)
netrc (0.7.7)
octokit (1.22.0)
addressable (~> 2.2)
faraday (~> 0.8)
faraday_middleware (~> 0.9)
hashie (~> 1.2)
multi_json (~> 1.3)
netrc (~> 0.7.7)
open4 (1.3.0)
posix-spawn (0.3.6)
pry (0.9.11.1)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
pygments.rb (0.3.7)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rake (0.9.6)
rb-fsevent (0.9.3)
redcarpet (2.2.2)
slop (3.4.3)
terminal-notifier (1.4.2)
yajl-ruby (1.1.0)
yard (0.8.3)
PLATFORMS
ruby
DEPENDENCIES
awesome_print
bacon
cocoapods!
cocoapods-core!
cocoapods-downloader!
github-markup
kicker!
mocha (~> 0.11.4)
mocha-on-bacon
pry
pygments.rb
rake
rb-fsevent
redcarpet
xcodeproj!
yard
...@@ -19,7 +19,7 @@ Pod::Spec.new do |s| ...@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
s.homepage = "http://EXAMPLE/Example.podspec" s.homepage = "http://EXAMPLE/Example.podspec"
# Specify the license type. CocoaPods detects automatically the license file if it is named # Specify the license type. CocoaPods detects automatically the license file if it is named
# `LICEN{C,S}E*.*', however if the name is different, specify it. # 'LICENCE*.*' or 'LICENSE*.*', however if the name is different, specify it.
s.license = 'MIT (example)' s.license = 'MIT (example)'
# s.license = { :type => 'MIT (example)', :file => 'FILE_LICENSE' } # s.license = { :type => 'MIT (example)', :file => 'FILE_LICENSE' }
# #
......
...@@ -78,7 +78,7 @@ module Pod ...@@ -78,7 +78,7 @@ module Pod
@quick = argv.flag?('quick') @quick = argv.flag?('quick')
@local = argv.flag?('local') @local = argv.flag?('local')
@only_errors = argv.flag?('only-errors') @only_errors = argv.flag?('only-errors')
@clean = argv.flag?('clean', true) @clean = argv.flag?('clean', true)
@podspecs_paths = argv.arguments! @podspecs_paths = argv.arguments!
super super
end end
...@@ -115,65 +115,237 @@ module Pod ...@@ -115,65 +115,237 @@ module Pod
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
class Cat < Spec class Which < Spec
self.summary = 'Prints a spec file' self.summary = 'Prints the path of the given spec.'
self.description = <<-DESC self.description = <<-DESC
Prints `NAME.podspec` to standard output. Prints the path of 'NAME.podspec'
DESC DESC
self.arguments = '[ NAME.podspec ]' self.arguments = '[ NAME ]'
def self.options
[["--show-all", "Print all versions of the given podspec"]].concat(super)
end
def initialize(argv) def initialize(argv)
@name = argv.shift_argument @show_all = argv.flag?('show-all')
@spec = argv.shift_argument
@spec = @spec.gsub('.podspec', '') unless @spec.nil?
super super
end end
def validate! def validate!
super super
help! "A pod name is required." unless @name help! "A podspec name is required." unless @spec
end end
def run def run
found_sets = SourcesManager.search_by_name(@name) UI.puts get_path_of_spec(@spec, @show_all)
raise Informative, "Unable to find a spec named `#{@name}'." if found_sets.count == 0 end
unless found_sets.count == 1 end
names = found_sets.map(&:name) * ', '
raise Informative, "More that one fitting spec found:\n #{names}" #-----------------------------------------------------------------------#
end
class Cat < Spec
self.summary = 'Prints a spec file.'
self.description = <<-DESC
Prints 'NAME.podspec' to standard output.
DESC
set = found_sets.first self.arguments = '[ NAME ]'
spec = best_spec_from_set(set)
file_name = spec.defined_in_file def self.options
UI.puts File.open(file_name).read [["--show-all", "Pick from all versions of the given podspec"]].concat(super)
end end
#--------------------------------------# def initialize(argv)
@show_all = argv.flag?('show-all')
@spec = argv.shift_argument
@spec = @spec.gsub('.podspec', '') unless @spec.nil?
super
end
# @return [Specification] the highest know specification of the given def validate!
# set. super
# help! "A podspec name is required." unless @spec
def best_spec_from_set(set) end
sources = set.sources
best_source = sources.first def run
best_version = best_source.versions(set.name).first filepath = if @show_all
sources.each do |source| specs = get_path_of_spec(@spec, @show_all).split(/\n/)
if source.versions(set.name).first > best_version index = choose_from_array(specs, "Which spec would you like to print [1-#{ specs.count }]? ")
best_source = source specs[index]
best_version = version else
end get_path_of_spec(@spec)
end end
best_spec = best_source.specification(set.name, best_version) UI.puts File.open(filepath).read
end end
end end
#-----------------------------------------------------------------------#
class Edit < Spec
self.summary = 'Edit a spec file.'
self.description = <<-DESC
Opens 'NAME.podspec' to be edited.
DESC
self.arguments = '[ NAME ]'
def self.options
[["--show-all", "Pick which spec to edit from all avaliable versions of the given podspec"]].concat(super)
end
def initialize(argv)
@show_all = argv.flag?('show-all')
@spec = argv.shift_argument
@spec = @spec.gsub('.podspec', '') unless @spec.nil?
super
end
def validate!
super
help! "A podspec name is required." unless @spec
end
def run
filepath = if @show_all
specs = get_path_of_spec(@spec, @show_all).split(/\n/)
index = choose_from_array(specs, "Which spec would you like to edit [1-#{ specs.count }]? ")
specs[index]
else
get_path_of_spec(@spec)
end
exec_editor(filepath.to_s) if File.exists? filepath
raise Informative, "#{ filepath } doesn't exist."
end
# Thank you homebrew
def which(cmd)
dir = ENV['PATH'].split(':').find { |p| File.executable? File.join(p, cmd) }
Pathname.new(File.join(dir, cmd)) unless dir.nil?
end
def which_editor
editor = ENV['EDITOR']
# If an editor wasn't set, try to pick a sane default
return editor unless editor.nil?
# Find Sublime Text 2
return 'subl' if which 'subl'
# Find Textmate
return 'mate' if which 'mate'
# Find # BBEdit / TextWrangler
return 'edit' if which 'edit'
# Default to vim
return 'vim' if which 'vim'
raise Informative, "Failed to open editor. Set your 'EDITOR' environment variable."
end
def exec_editor *args
return if args.to_s.empty?
safe_exec(which_editor, *args)
end
def safe_exec(cmd, *args)
# This buys us proper argument quoting and evaluation
# of environment variables in the cmd parameter.
exec "/bin/sh", "-i", "-c", cmd + ' "$@"', "--", *args
end
end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
# TODO some of the following methods can probably move to one of the subclasses. # TODO some of the following methods can probably move to one of the subclasses.
private private
# @return [Fixnum] the index of the chosen array item
#
def choose_from_array(array, message)
array.each_with_index do |item, index|
UI.puts "#{ index + 1 }: #{ item }"
end
print message
index = STDIN.gets.chomp.to_i - 1
if index < 0 || index > array.count
raise Informative, "#{ index + 1 } is invalid [1-#{ array.count }]"
else
index
end
end
# @return [Pathname] the absolute path or paths of the given podspec
#
def get_path_of_spec(spec, show_all = false)
pods = SourcesManager.search_by_name(spec)
unless pods.count == 1
names = pods.collect(&:name) * ', '
raise Informative, "More than one spec found for '#{ spec }':\n#{ names }"
end
unless show_all
best_spec, spec_source = spec_and_source_from_set(pods.first)
return pathname_from_spec(best_spec, spec_source)
end
return all_paths_from_set(pods.first)
end
# @return [Pathname] the absolute path of the given spec and source
#
def pathname_from_spec(spec, source)
Pathname.new("~/.cocoapods/#{ source }/#{ spec.name }/#{ spec.version }/#{ spec.name }.podspec").expand_path
end
# @return [String] of spec paths one on each line
#
def all_paths_from_set(set)
paths = ""
sources = set.sources
sources.each do |source|
versions = source.versions(set.name)
versions.each do |version|
spec = source.specification(set.name, version)
paths += "#{ pathname_from_spec(spec, source) }\n"
end
end
paths
end
# @return [Specification, Source] the highest known specification with it's source of the given
# set.
#
def spec_and_source_from_set(set)
sources = set.sources
best_source = sources.first
best_version = best_source.versions(set.name).first
sources.each do |source|
version = source.versions(set.name).first
if version > best_version
best_source = source
best_version = version
end
end
return best_source.specification(set.name, best_version), best_source
end
def podspecs_to_lint def podspecs_to_lint
@podspecs_to_lint ||= begin @podspecs_to_lint ||= begin
...@@ -288,7 +460,7 @@ Pod::Spec.new do |s| ...@@ -288,7 +460,7 @@ Pod::Spec.new do |s|
s.homepage = "#{data[:homepage]}" s.homepage = "#{data[:homepage]}"
# Specify the license type. CocoaPods detects automatically the license file if it is named # Specify the license type. CocoaPods detects automatically the license file if it is named
# `LICEN{C,S}E*.*', however if the name is different, specify it. # 'LICENCE*.*' or 'LICENSE*.*', however if the name is different, specify it.
s.license = 'MIT (example)' s.license = 'MIT (example)'
# s.license = { :type => 'MIT (example)', :file => 'FILE_LICENSE' } # s.license = { :type => 'MIT (example)', :file => 'FILE_LICENSE' }
# #
......
...@@ -12,6 +12,9 @@ module Pod ...@@ -12,6 +12,9 @@ module Pod
lambda { run_command('spec', 'NAME') }.should.raise CLAide::Help lambda { run_command('spec', 'NAME') }.should.raise CLAide::Help
lambda { run_command('spec', 'createa') }.should.raise CLAide::Help lambda { run_command('spec', 'createa') }.should.raise CLAide::Help
lambda { run_command('lint', 'agument1', '2') }.should.raise CLAide::Help lambda { run_command('lint', 'agument1', '2') }.should.raise CLAide::Help
lambda { run_command('spec', 'which') }.should.raise CLAide::Help
lambda { run_command('spec', 'cat') }.should.raise CLAide::Help
lambda { run_command('spec', 'edit') }.should.raise CLAide::Help
end end
end end
...@@ -103,6 +106,12 @@ module Pod ...@@ -103,6 +106,12 @@ module Pod
end end
end end
it "complains if it can't find a spec with the given name" do
Dir.chdir(temporary_directory) do
lambda { run_command('spec', 'lint', 'some_pod_that_doesnt_exist') }.should.raise Informative
end
end
it "lints the current working directory" do it "lints the current working directory" do
Dir.chdir(fixture('spec-repos') + 'master/JSONKit/1.4/') do Dir.chdir(fixture('spec-repos') + 'master/JSONKit/1.4/') do
cmd = command('spec', 'lint', '--quick', '--only-errors') cmd = command('spec', 'lint', '--quick', '--only-errors')
...@@ -143,27 +152,24 @@ module Pod ...@@ -143,27 +152,24 @@ module Pod
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
describe "cat subcommand" do describe "which subcommand" do
extend SpecHelper::TemporaryRepos it "errors if a given podspec doesn't exist" do
e = lambda { command('spec', 'which', 'some_pod_that_doesnt_exist').run }.should.raise Informative
it "complains it cant't find a spec to read" do e.message.should.match /Unable to find a pod with/
lambda { command('spec', 'cat', 'not-exissting-spec').run }.should.raise Informative end
it "prints the path of a given podspec" do
lambda { command('spec', 'which', 'AFNetworking').run }.should.not.raise
text = "AFNetworking.podspec"
UI.output.should.include text.gsub(/\n/, '')
end end
it "complains provided spec name is ambigious" do it "complains provided spec name is ambigious" do
e = lambda { command('spec', 'cat', 'AF').run }.should.raise Informative e = lambda { command('spec', 'cat', 'AF').run }.should.raise Informative
e.message.should.match /More that one/ e.message.should.match /More than one/
end
it "prints the spec on standard output" do
lambda { command('spec', 'cat', 'JRSwizzle').run }.should.not.raise
text = (fixture('spec-repos') + 'master/JRSwizzle/1.0/JRSwizzle.podspec').read
#output.gsub(/\n/,'').should.equsal text.gsub(/\n/,'')
UI.output.should.include text.gsub(/\n/,'')
end end
end end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment