@@ -31,15 +31,29 @@ def raw_versions
3131 end . compact
3232 end
3333
34- def podspecs
35- Pathname . glob ( repo . join ( '*.podspec' ) )
34+ def process_podspec ( path , output_path )
35+ spec = Specification . from_file ( path )
36+ File . open ( output_path , 'w' ) { |f | f . write ( spec . to_pretty_json ) }
37+ output_path
38+ end
39+
40+ def preload_podspecs_at_version ( version )
41+ version_dir = repo . join ( '.git' , '.specs' , version . to_s )
42+ if version_dir . exist?
43+ Pathname . glob ( version_dir . join ( '*' ) )
44+ else
45+ repo_git ( [ 'checkout' , version . to_s ] )
46+ version_dir . mkpath
47+ Pathname . glob ( repo . join ( '*.podspec' ) ) . map do |podspec_path |
48+ name = podspec_path . basename ( '.podspec' )
49+ process_podspec ( podspec_path , version_dir . join ( "#{ name } .podspec.json" ) )
50+ end . compact
51+ end
3652 end
3753
3854 def spec_paths
3955 raw_versions . map do |version |
40- podspecs . map do |podspec |
41- specification_path ( podspec . basename ( '.podspec' ) , version )
42- end . compact
56+ preload_podspecs_at_version ( version )
4357 end . flatten
4458 end
4559
@@ -52,10 +66,9 @@ def spec_paths
5266 #
5367 #
5468 def pods
55- pods = spec_paths . map do |spec_path |
69+ spec_paths . map do |spec_path |
5670 spec_path . basename ( '.podspec.json' ) . to_s
57- end
58- Set . new ( pods ) . sort
71+ end . flatten . uniq . sort
5972 end
6073
6174 # @return [Array<Version>] all the available versions for the Pod, sorted
@@ -75,16 +88,6 @@ def versions(name)
7588 end . compact . sort . reverse
7689 end
7790
78- # @return [Specification] the specification for a given version of Pod.
79- #
80- # @param @see specification_path
81- #
82- def specification ( name , version )
83- repo_git ( [ 'checkout' , version ] )
84-
85- Specification . from_file ( specification_path ( name , version ) )
86- end
87-
8891 # Returns the path of the specification with the given name and version.
8992 #
9093 # @param [String] name
@@ -99,17 +102,13 @@ def specification_path(name, version)
99102 raise ArgumentError , 'No name' unless name
100103 raise ArgumentError , 'No version' unless version
101104
102- path = repo . join ( '.git' , '.specs' , name , version . to_s )
105+ preload_podspecs_at_version ( version )
103106
104- unless path . join ( "#{ name } .podspec.json" ) . exist?
105- repo_git ( [ 'checkout' , version ] )
106- return unless repo . join ( "#{ name } .podspec" ) . exist?
107+ path = repo . join ( '.git' , '.specs' , version . to_s , "#{ name } .podspec.json" )
107108
108- spec = Specification . from_file ( repo . join ( "#{ name } .podspec" ) )
109- path . mkpath
110- File . open ( path . join ( "#{ name } .podspec.json" ) , 'w' ) { |f | f . write ( spec . to_pretty_json ) }
111- end
112- path . join ( "#{ name } .podspec.json" )
109+ return nil unless path . exist?
110+
111+ path
113112 end
114113
115114 # @return [Array<Specification>] all the specifications contained by the
0 commit comments