Skip to content

Commit

Permalink
Merge 7738d01 into ac88e64
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopelosin committed Aug 2, 2013
2 parents ac88e64 + 7738d01 commit 53da7c1
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 3 deletions.
34 changes: 34 additions & 0 deletions lib/cocoapods-core/specification/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,34 @@ module DSL
:container => Array,
}

#------------------#

# @!method prepare_command=(command)
#
# A bash script that will be executed after the Pod is downloaded. This
# command can be used to create, delete and modify any file downloaded
# and will be ran before any paths for other file attributes of the
# specification are collected.
#
# This command is executed before the Pod is cleaned and before the
# Pods project is created.
#
# @example
#
# spec.prepare_command = 'ruby build_files.rb'
#
# @example
#
# spec.prepare_command = <<-CMD
# sed -i 's/MyNameSpacedHeader/Header/g' ./**/*.h
# sed -i 's/MyNameOtherSpacedHeader/OtherHeader/g' ./**/*.h
# CMD
#
# @param [String] command
# the prepare command of the pod.
#
root_attribute :prepare_command

#-----------------------------------------------------------------------#

# @!group Platform
Expand Down Expand Up @@ -985,6 +1013,9 @@ def dependency(*args)
# end
#
def pre_install(&block)
CoreUI.warn "The pre install hook of the specification DSL has been " \
"deprecated, use the `resource_bundles` or the `prepare_command` " \
"attributes."
@pre_install_callback = block
end

Expand Down Expand Up @@ -1012,6 +1043,9 @@ def pre_install(&block)
# end
#
def post_install(&block)
CoreUI.warn "The post install hook of the specification DSL has been " \
"deprecated, use the `resource_bundles` or the `prepare_command` " \
"attributes."
@post_install_callback = block
end

Expand Down
13 changes: 13 additions & 0 deletions lib/cocoapods-core/specification/linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def perform_all_specs_ananlysis
validate_file_patterns
check_tmp_arc_not_nil
check_if_spec_is_empty
check_install_hooks
@consumer = nil
end
end
Expand Down Expand Up @@ -301,6 +302,18 @@ def check_if_spec_is_empty
end
end

# Check the hooks
#
def check_install_hooks
warning "The pre install hook of the specification DSL has been " \
"deprecated, use the `resource_bundles` or the `prepare_command` " \
"attributes." unless consumer.spec.pre_install_callback.nil?

warning "The post install hook of the specification DSL has been " \
"deprecated, use the `resource_bundles` or the `prepare_command` " \
"attributes." unless consumer.spec.post_install_callback.nil?
end

#-----------------------------------------------------------------------#

# !@group Result Helpers
Expand Down
4 changes: 4 additions & 0 deletions lib/cocoapods-core/specification/root_attribute_accessors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def screenshots
[*value]
end

def prepare_command
attributes_hash["prepare_command"]
end

#-----------------------------------------------------------------------#

private
Expand Down
4 changes: 4 additions & 0 deletions spec/specification/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ module Pod
@spec.attributes_hash["description"].should == 'text'
end

it "allows to specify a prepare command" do
@spec.prepare_command = "ruby build_files.rb"
@spec.attributes_hash["prepare_command"].should == "ruby build_files.rb"
end
end

#-----------------------------------------------------------------------------#
Expand Down
21 changes: 18 additions & 3 deletions spec/specification/linter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,28 @@ def message_should_include(*values)
message.should.include('spec is empty')
end

it "requires that the require_arc value is specified until the switch to a true default" do
consumer = Specification::Consumer
consumer.any_instance.stubs(:requires_arc).returns(nil)
xit "requires that the require_arc value is specified until the switch to a true default" do
# TODO the default value is invalidating this test
consumer = @spec.consumer(:ios)
@spec.requires_arc = nil
@linter.lint
message = @linter.results.first.message
message.should.include('`requires_arc` should be specified')
end

it "checks if the pre install hook has been defined" do
@spec.pre_install do; end
@linter.lint
message = @linter.results.first.message
message.should.match /pre install hook.*deprecated/
end

it "checks if the post install hook has been defined" do
@spec.post_install do; end
@linter.lint
message = @linter.results.first.message
message.should.match /post install hook.*deprecated/
end
end

end
Expand Down
5 changes: 5 additions & 0 deletions spec/specification/root_attribute_accessors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,10 @@ module Pod
@spec.screenshots.should == ['www.example.com/img1.png']
end

it "returns the prepare_command" do
@spec.prepare_command = 'ruby prepare_script.rb'
@spec.prepare_command.should == 'ruby prepare_script.rb'
end

end
end

0 comments on commit 53da7c1

Please sign in to comment.