Commit fbbb61c9 authored by Fabio Pelosin's avatar Fabio Pelosin

Improve support for JSON podspecs

Fixes https://github.com/CocoaPods/CocoaPods/issues/2157
parent 9fa6abf1
......@@ -2,6 +2,14 @@
To install or update CocoaPods see this [guide](http://docs.cocoapods.org/guides/installing_cocoapods.html).
## Master
##### Bug Fixes
* Fix `pod spec lint` for `json` podspecs.
[Fabio Pelosin][irrationalfab]
[#2157](https://github.com/CocoaPods/CocoaPods/issues/2157)
## 0.33.0
##### Breaking
......
......@@ -27,10 +27,10 @@ GIT
GIT
remote: https://github.com/CocoaPods/cocoapods-downloader.git
revision: 3075d0aa20246f99718cfe7ef22b4c7c4230dc95
revision: 6b2fbda4342ced96df16a55dfa907636dc366b53
branch: master
specs:
cocoapods-downloader (0.6.0)
cocoapods-downloader (0.6.1)
GIT
remote: https://github.com/CocoaPods/cocoapods-plugins.git
......@@ -68,9 +68,9 @@ PATH
specs:
cocoapods (0.33.0)
activesupport (>= 3.2.15, < 4)
claide (~> 0.6.0)
claide (~> 0.6.1)
cocoapods-core (= 0.33.0)
cocoapods-downloader (~> 0.6.0)
cocoapods-downloader (~> 0.6.1)
cocoapods-plugins (~> 0.2.0)
cocoapods-trunk (~> 0.1.0)
cocoapods-try (~> 0.3.0)
......
......@@ -30,7 +30,7 @@ s.files = Dir["lib/**/*.rb"] + %w{ bin/pod bin/sandbox-pod README.md LICENSE CHA
s.add_runtime_dependency 'cocoapods-core', "= #{Pod::VERSION}"
s.add_runtime_dependency 'claide', '~> 0.6.1'
s.add_runtime_dependency 'xcodeproj', '~> 0.17.0'
s.add_runtime_dependency 'cocoapods-downloader', '~> 0.6.0'
s.add_runtime_dependency 'cocoapods-downloader', '~> 0.6.1'
s.add_runtime_dependency 'cocoapods-plugins', '~> 0.2.0'
s.add_runtime_dependency 'cocoapods-try', '~> 0.3.0'
s.add_runtime_dependency 'cocoapods-trunk', '~> 0.1.0'
......
......@@ -126,17 +126,17 @@ module Pod
end
files << output_path
else if (pathname = Pathname.new(path)).directory?
files += Pathname.glob(pathname + '**/*.podspec')
raise Informative, "No specs found in the current directory." if files.empty?
else
files << (pathname = Pathname.new(path))
raise Informative, "Unable to find a spec named `#{path}'." unless pathname.exist? && path.include?('.podspec')
end
files += Pathname.glob(pathname + '**/*.podspec{.json,}')
raise Informative, "No specs found in the current directory." if files.empty?
else
files << (pathname = Pathname.new(path))
raise Informative, "Unable to find a spec named `#{path}'." unless pathname.exist? && path.include?('.podspec')
end
end
files
end
files
end
end
def podspecs_tmp_dir
Pathname.new(File.join(Pathname.new('/tmp').realpath, '/CocoaPods/Lint_podspec'))
......
......@@ -67,7 +67,8 @@ module Pod
# relative to the file system.
#
def normalized_podspec_path(declared_path)
if File.extname(declared_path) == '.podspec'
extension = File.extname(declared_path)
if extension == '.podspec' || extension == '.json'
path_with_ext = declared_path
else
path_with_ext = "#{declared_path}/#{name}.podspec"
......@@ -130,8 +131,8 @@ module Pod
#
# @return [void]
#
def store_podspec(sandbox, spec)
sandbox.store_podspec(name, spec, true)
def store_podspec(sandbox, spec, json = false)
sandbox.store_podspec(name, spec, true, json)
end
end
end
......
......@@ -11,8 +11,9 @@ module Pod
def fetch(sandbox)
title = "Fetching podspec for `#{name}` #{description}"
UI.titled_section(title, { :verbose_prefix => "-> " }) do
is_json = podspec_uri.split('.').last == 'json'
require 'open-uri'
open(podspec_uri) { |io| store_podspec(sandbox, io.read) }
open(podspec_uri) { |io| store_podspec(sandbox, io.read, is_json) }
end
end
......
......@@ -217,7 +217,16 @@ module Pod
#
def specification_path(name)
path = specifications_dir + "#{name}.podspec"
path.exist? ? path : nil
if path.exist?
path
else
path = specifications_dir + "#{name}.podspec.json"
if path.exist?
path
else
nil
end
end
end
# Stores a specification in the `Local Podspecs` folder.
......@@ -232,8 +241,9 @@ module Pod
# @todo Store all the specifications (including those not originating
# from external sources) so users can check them.
#
def store_podspec(name, podspec, external_source = false)
output_path = specifications_dir(external_source) + "#{name}.podspec"
def store_podspec(name, podspec, external_source = false, json = false)
file_name = json ? "#{name}.podspec.json" : "#{name}.podspec"
output_path = specifications_dir(external_source) + file_name
output_path.dirname.mkpath
if podspec.is_a?(String)
output_path.open('w') { |f| f.puts(podspec) }
......
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