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