Commit 44f594bf authored by Fabio Pelosin's avatar Fabio Pelosin

[Linter] Support for local option.

parent a79d0468
......@@ -5,12 +5,13 @@
###### Enhancements
- Pod `install` will update the specs repo only if needed.
[#533](https://github.com/CocoaPods/CocoaPods/issues/533)
- CocoaPods now searches for the highest version of a Pod on
all the repos.
- CocoaPods now searches for the highest version of a Pod on all the repos.
[#85](https://github.com/CocoaPods/CocoaPods/issues/85)
- Added a pre install hook to the Podfile and to root specifications.
[#486](https://github.com/CocoaPods/CocoaPods/issues/486)
- Support for `header_mappings_dir` attribute in subspecs.
- Added support for linting a Podspec using the files from its folder `pod spec
lint --local`
- Refactored UI.
- Added support for Podfiles named `Podfile.cocoapods` which allows to
associate an editor application in Mac OS X.
......
......@@ -6,6 +6,14 @@ module Pod
# TODO: Add check to ensure that attributes inherited by subspecs are not duplicated ?
attr_accessor :quick, :no_clean, :repo_path
# @return [Bool] Wether the lint should be performed against the root of
# the podspec instead to its original source. Uses the `:local` option
# of the Podfile.
#
attr_accessor :local
alias :local? :local
attr_reader :spec, :file
attr_reader :errors, :warnings, :notes
......@@ -116,9 +124,14 @@ module Pod
name = spec.name
podspec = file.realpath.to_s
platform = @platform
local = local?
podfile = Pod::Podfile.new do
platform(platform.to_sym, platform.deployment_target)
pod name, :podspec => podspec
if (local)
pod name, :local => '/Users/fabio/Desktop/RegexHighlightView'
else
pod name, :podspec => podspec
end
end
podfile
end
......
......@@ -20,6 +20,7 @@ module Pod
def self.options
[ ["--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"],
["--no-clean", "Lint leaves the build directory intact for inspection"] ].concat(super)
end
......@@ -32,9 +33,10 @@ module Pod
super if @name_or_url.nil?
super unless argv.empty?
elsif @action == 'lint'
@quick = argv.option('--quick')
@only_errors = argv.option('--only-errors')
@no_clean = argv.option('--no-clean')
@quick = argv.option('--quick')
@local = argv.option('--local')
@only_errors = argv.option('--only-errors')
@no_clean = argv.option('--no-clean')
@podspecs_paths = argv
else
super
......@@ -72,8 +74,9 @@ module Pod
UI.puts
invalid_count = 0
podspecs_to_lint.each do |podspec|
linter = Linter.new(podspec)
linter.quick = @quick
linter = Linter.new(podspec)
linter.quick = @quick
linter.local = @local
linter.no_clean = @no_clean
# Show immediatly which pod is being processed.
......
......@@ -231,7 +231,8 @@ module Pod
class LocalSource < AbstractExternalSource
def pod_spec_path
path = Pathname.new(@params[:local]).expand_path + "#{name}.podspec"
path = Pathname.new(@params[:local]).expand_path
path += "#{name}.podspec"# unless path.to_s.include?("#{name}.podspec")
raise Informative, "No podspec found for `#{name}' in `#{@params[:local]}'" unless path.exist?
path
end
......
......@@ -187,6 +187,27 @@ module Pod
# @!group Files
# @return [Pathname] Returns the relative path from the sandbox.
#
# @note If the two abosule paths don't share the same root directory an
# extra `../` is added to the result of {Pathname#relative_path_from}
#
# path = Pathname.new('/Users/dir')
# @sandbox
# #=> Pathname('/tmp/CocoaPods/Lint/Pods')
#
# p.relative_path_from(@sandbox
# #=> '../../../../Users/dir'
#
# relativize_from_sandbox(path)
# #=> '../../../../../Users/dir'
#
def relativize_from_sandbox(path)
result = path.relative_path_from(@sandbox.root)
result = Pathname.new('../') + result unless @sandbox.root.to_s.split('/')[1] == path.to_s.split('/')[1]
result
end
# @return [Array<Pathname>] The paths of the source files.
#
def source_files
......@@ -196,13 +217,13 @@ module Pod
# @return [Array<Pathname>] The *relative* paths of the source files.
#
def relative_source_files
source_files.map{ |p| p.relative_path_from(@sandbox.root) }
source_files.map{ |p| relativize_from_sandbox(p) }
end
def relative_source_files_by_spec
result = {}
source_files_by_spec.each do |spec, paths|
result[spec] = paths.map{ |p| p.relative_path_from(@sandbox.root) }
result[spec] = paths.map{ |p| relativize_from_sandbox(p) }
end
result
end
......@@ -230,7 +251,7 @@ module Pod
# @return [Array<Pathname>] The *relative* paths of the source files.
#
def relative_header_files
header_files.map{ |p| p.relative_path_from(@sandbox.root) }
header_files.map{ |p| relativize_from_sandbox(p) }
end
# @return [Hash{Specification => Array<Pathname>}] The paths of the header
......@@ -276,7 +297,7 @@ module Pod
# @return [Array<Pathname>] The *relative* paths of the resources.
#
def relative_resource_files
resource_files.map{ |p| p.relative_path_from(@sandbox.root) }
resource_files.map{ |p| relativize_from_sandbox(p) }
end
# @return [Pathname] The absolute path of the prefix header file
......@@ -390,7 +411,7 @@ module Pod
source_files_by_spec.each do | spec, files |
compiler_flags = spec.compiler_flags.strip
files.each do |file|
file = file.relative_path_from(@sandbox.root)
file = relativize_from_sandbox(file)
desc = Xcodeproj::Project::PBXNativeTarget::SourceFileDescription.new(file, compiler_flags, nil)
result << desc
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