Commit a68044eb authored by Fabio Pelosin's avatar Fabio Pelosin

Merge branch 'lib-subcommand'

* lib-subcommand:
  Add Pod lib command #850
parents 4dc9be62 3f8fccf7
...@@ -8,17 +8,18 @@ module Pod ...@@ -8,17 +8,18 @@ module Pod
class Command < CLAide::Command class Command < CLAide::Command
require 'cocoapods/command/help'
require 'cocoapods/command/inter_process_communication'
require 'cocoapods/command/lib'
require 'cocoapods/command/list' require 'cocoapods/command/list'
require 'cocoapods/command/outdated' require 'cocoapods/command/outdated'
require 'cocoapods/command/podfile_info'
require 'cocoapods/command/project' require 'cocoapods/command/project'
require 'cocoapods/command/push' require 'cocoapods/command/push'
require 'cocoapods/command/repo' require 'cocoapods/command/repo'
require 'cocoapods/command/search' require 'cocoapods/command/search'
require 'cocoapods/command/setup' require 'cocoapods/command/setup'
require 'cocoapods/command/spec' require 'cocoapods/command/spec'
require 'cocoapods/command/help'
require 'cocoapods/command/inter_process_communication'
require 'cocoapods/command/podfile_info'
self.abstract_command = true self.abstract_command = true
self.default_subcommand = 'install' self.default_subcommand = 'install'
......
module Pod
class Command
class Lib < Command
self.abstract_command = true
self.summary = 'Develop pods'
#-----------------------------------------------------------------------#
class Create < Lib
self.summary = 'Creates a new Pod'
self.description = <<-DESC
Creates a new Pod with the given name from the template in the working directory.
DESC
self.arguments = '[NAME]'
def initialize(argv)
@name = argv.shift_argument
super
end
def validate!
super
help! "A name for the Pod is required." unless @name
end
def run
clone_template
configure_template
print_info
end
private
#----------------------------------------#
# !@group Private helpers
extend Executable
executable :git
executable :ruby
TEMPLATE_REPO = "/Users/fabio/Projects/CP/pod-template"
TEMPLATE_INFO_URL = "/Users/fabio/Projects/CP/pod-template"
# Clones the template from the remote in the working directory using
# the name of the Pod.
#
# @return [void]
#
def clone_template
UI.section("Creating `#{@name}` Pod") do
git!"clone '#{TEMPLATE_REPO}' #{@name}"
end
end
# Runs the template configuration utilities.
#
# @return [void]
#
def configure_template
UI.section("Configuring template") do
Dir.chdir(@name) do
ruby! "_CONFIGURE.rb #{@name}"
end
end
end
# Runs the template configuration utilities.
#
# @return [void]
#
def print_info
UI.puts "\nTo learn more about the template see `#{TEMPLATE_INFO_URL}`."
end
end
#-----------------------------------------------------------------------#
class Lint < Lib
self.summary = 'Validates a Pod'
self.description = <<-DESC
Validates the Pod using the files in the working directory.
DESC
def self.options
[ ["--quick", "Lint skips checks that would require to download and build the spec"],
["--only-errors", "Lint validates even if warnings are present"],
["--no-clean", "Lint leaves the build directory intact for inspection"] ].concat(super)
end
def initialize(argv)
@quick = argv.flag?('quick')
@only_errors = argv.flag?('only-errors')
@clean = argv.flag?('clean', true)
super
end
def validate!
super
end
def run
UI.puts
validator = Validator.new(podspec_to_lint)
validator.local = true
validator.quick = @quick
validator.no_clean = !@clean
validator.only_errors = @only_errors
validator.validate
if validator.validated?
UI.puts "#{validator.spec.name} passed validation.".green
else
raise Informative, "#{validator.spec.name} did not pass validation."
end
unless @clean
UI.puts "Pods project available at `#{validator.validation_dir}/Pods/Pods.xcodeproj` for inspection."
UI.puts
end
end
private
#----------------------------------------#
# !@group Private helpers
# @return [Pathname] The path of the podspec found in the current
# working directory.
#
# @raise If no podspec is found.
# @raise If multiple podspecs are found.
#
def podspec_to_lint
podspecs = Pathname.glob(Pathname.pwd + '*.podspec{.yaml,}')
raise Informative, "Unable to find a podspec in the working directory" if podspecs.count.zero?
raise Informative, "Multiple podspecs detected in the working directory" if podspecs.count > 1
podspecs.first
end
end
#-----------------------------------------------------------------------#
end
end
end
module Pod module Pod
class Command class Command
class Search < Command class Search < Command
self.summary = 'Search pods' self.summary = 'Searches for pods'
self.description = <<-DESC self.description = <<-DESC
Searches for pods, ignoring case, whose name matches `QUERY'. If the Searches for pods, ignoring case, whose name matches `QUERY'. If the
......
...@@ -60,14 +60,12 @@ module Pod ...@@ -60,14 +60,12 @@ module Pod
def self.options def self.options
[ ["--quick", "Lint skips checks that would require to download and build the spec"], [ ["--quick", "Lint skips checks that would require to download and build the spec"],
["--local", "Lint a podspec against the local files contained in its directory"],
["--only-errors", "Lint validates even if warnings are present"], ["--only-errors", "Lint validates even if warnings are present"],
["--no-clean", "Lint leaves the build directory intact for inspection"] ].concat(super) ["--no-clean", "Lint leaves the build directory intact for inspection"] ].concat(super)
end end
def initialize(argv) def initialize(argv)
@quick = argv.flag?('quick') @quick = argv.flag?('quick')
@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!
...@@ -80,7 +78,6 @@ module Pod ...@@ -80,7 +78,6 @@ module Pod
podspecs_to_lint.each do |podspec| podspecs_to_lint.each do |podspec|
validator = Validator.new(podspec) validator = Validator.new(podspec)
validator.quick = @quick validator.quick = @quick
validator.local = @local
validator.no_clean = !@clean validator.no_clean = !@clean
validator.only_errors = @only_errors validator.only_errors = @only_errors
validator.validate validator.validate
......
...@@ -308,7 +308,7 @@ module Pod ...@@ -308,7 +308,7 @@ module Pod
podfile = Pod::Podfile.new do podfile = Pod::Podfile.new do
platform(platform_name, deployment_target) platform(platform_name, deployment_target)
if (local) if (local)
pod name, :local => podspec.dirname.to_s pod name, :path => podspec.dirname.to_s
else else
pod name, :podspec => podspec.to_s pod name, :podspec => podspec.to_s
end end
......
# Acknowledgements
This application makes use of the following third party libraries:
## Reachability
Copyright (c) 2011, Tony Million.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Generated by CocoaPods - http://cocoapods.org
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>FooterText</key>
<string>This application makes use of the following third party libraries:</string>
<key>Title</key>
<string>Acknowledgements</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Copyright (c) 2011, Tony Million.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</string>
<key>Title</key>
<string>Reachability</string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
<dict>
<key>FooterText</key>
<string>Generated by CocoaPods - http://cocoapods.org</string>
<key>Title</key>
<string></string>
<key>Type</key>
<string>PSGroupSpecifier</string>
</dict>
</array>
<key>StringsTable</key>
<string>Acknowledgements</string>
<key>Title</key>
<string>Acknowledgements</string>
</dict>
</plist>
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