Commit 3744f691 authored by Eloy Duran's avatar Eloy Duran

+ partial installer spec

parent 1139295f
recipe :ruby
Ruby.runner_bin = 'macbacon'
process do |files|
specs = files.take_and_map do |file|
case file
when %r{lib/cocoa_pods/(.+?)\.rb$}
s = Dir.glob("spec/**/#{$1}_spec.rb")
s unless s.empty?
end
end
Ruby.run_tests(specs)
end
......@@ -21,3 +21,9 @@ module Pod
autoload :Pathname, 'pathname'
autoload :Executioner, 'executioner'
end
class Pathname
def glob(pattern = '')
Dir.glob((self + pattern).to_s).map { |f| Pathname.new(f) }
end
end
......@@ -4,12 +4,31 @@ module Pod
class Installer
include Config::Mixin
def initialize(top_level_specification)
@top_level_specification = top_level_specification
def initialize(specification)
@specification = specification
end
def dependent_specification_sets
@dependent_specifications_sets ||= Resolver.new(@top_level_specification).resolve
@dependent_specification_sets ||= Resolver.new(@specification).resolve
end
def build_specification_sets
dependent_specification_sets.reject(&:only_part_of_other_pod?)
end
def source_files
source_files = []
build_specification_sets.each do |set|
spec = set.specification
spec.read(:source_files).each do |pattern|
pattern = spec.pod_destroot + pattern
pattern = pattern + '*.{h,m,mm,c,cpp}' if pattern.directory?
pattern.glob.each do |file|
source_files << file.relative_path_from(config.project_pods_root)
end
end
end
source_files
end
def xcconfig
......@@ -27,7 +46,7 @@ module Pod
def install!
unless config.silent?
puts "Installing dependencies defined in: #{@top_level_specification.defined_in_file}"
puts "Installing dependencies defined in: #{@specification.defined_in_file}"
end
install_dependent_specifications!
generate_project
......@@ -45,21 +64,9 @@ module Pod
def generate_project
puts "==> Creating Pods project files" unless config.silent?
dependent_specification_sets.each do |set|
# In case the set is only part of other pods we don't need to build
# the pod itself.
next if set.only_part_of_other_pod?
spec = set.specification
spec.read(:source_files).each do |pattern|
pattern = spec.pod_destroot + pattern
pattern = pattern + '*.{h,m,mm,c,cpp}' if pattern.directory?
Dir.glob(pattern.to_s).each do |file|
file = Pathname.new(file)
file = file.relative_path_from(config.project_pods_root)
xproj.add_source_file(file)
end
end
xcconfig << spec.read(:xcconfig)
source_files.each { |file| xproj.add_source_file(file) }
build_specification_sets.each do |set|
xcconfig << set.specification.read(:xcconfig)
end
end
......
......@@ -104,11 +104,15 @@ module Pod
@dependencies.find { |d| d.name == name }
end
# Returns the specification for the pod that this pod's source is a part of.
def part_of_specification
def part_of_specification_set
if @part_of
Set.by_specification_name(@part_of.name).specification
Set.by_specification_name(@part_of.name)
end
end
# Returns the specification for the pod that this pod's source is a part of.
def part_of_specification
(set = part_of_specification_set) && set.specification
end
def pod_destroot
......
......@@ -2,14 +2,53 @@ require File.expand_path('../../spec_helper', __FILE__)
describe "Pod::Installer" do
before do
config.project_pods_root = fixture('integration')
fixture('spec-repos/master') # ensure the archive is unpacked
config.repos_dir = fixture('spec-repos')
@spec = Pod::Spec.new do
dependency 'JSONKit'
end
end
after do
config.project_pods_root = nil
config.repos_dir = SpecHelper.tmp_repos_path
end
it "adds all source files that should be included in the library to the xcode project" do
[
[
'ASIHTTPRequest',
['Classes'],
"{Classes,External/Reachability}/*.{h,m}"
],
[
'Reachability',
["External/Reachability/*.h", "External/Reachability/*.m"],
"External/Reachability/*.{h,m}"
],
[
'ASIWebPageRequest',
['**/ASIWebPageRequest.*'],
"{Classes,Classes/ASIWebPageRequest,External/Reachability}/*.{h,m}"
],
].each do |name, patterns, expected_pattern|
Pod::Source.reset!
Pod::Spec::Set.reset!
installer = Pod::Installer.new(Pod::Spec.new { dependency(name); source_files(*patterns) })
expected = (stubbed_destroot(installer) + expected_pattern).glob.map do |file|
file.relative_path_from(config.project_pods_root)
end
installer.source_files.size.should == expected.size
installer.source_files.sort.should == expected.sort
#installer.xproj.source_files.sort.should == expected.sort
end
end
def stubbed_destroot(installer)
set = installer.dependent_specification_sets.find { |s| s.name == 'ASIHTTPRequest' }
spec = set.specification
set.extend(Module.new { define_method(:specification) { spec }})
def spec.pod_destroot
config.project_pods_root + 'ASIHTTPRequest' # without name and version
end
spec.pod_destroot
end
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