diff --git a/lib/cocoapods-core/specification/dsl.rb b/lib/cocoapods-core/specification/dsl.rb index a6c218f87..fb04e4165 100644 --- a/lib/cocoapods-core/specification/dsl.rb +++ b/lib/cocoapods-core/specification/dsl.rb @@ -300,6 +300,33 @@ 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 other attributes from the specification. + # + # 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 @@ -985,6 +1012,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 @@ -1012,6 +1042,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 diff --git a/lib/cocoapods-core/specification/linter.rb b/lib/cocoapods-core/specification/linter.rb index f578185aa..9e9f39796 100644 --- a/lib/cocoapods-core/specification/linter.rb +++ b/lib/cocoapods-core/specification/linter.rb @@ -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 @@ -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 diff --git a/lib/cocoapods-core/specification/root_attribute_accessors.rb b/lib/cocoapods-core/specification/root_attribute_accessors.rb index a42003b94..5201eb78e 100644 --- a/lib/cocoapods-core/specification/root_attribute_accessors.rb +++ b/lib/cocoapods-core/specification/root_attribute_accessors.rb @@ -118,6 +118,10 @@ def screenshots [*value] end + def prepare_command + attributes_hash["prepare_command"] + end + #-----------------------------------------------------------------------# private diff --git a/spec/specification/dsl_spec.rb b/spec/specification/dsl_spec.rb index c1675dabd..ecc5eff52 100644 --- a/spec/specification/dsl_spec.rb +++ b/spec/specification/dsl_spec.rb @@ -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 #-----------------------------------------------------------------------------# diff --git a/spec/specification/linter_spec.rb b/spec/specification/linter_spec.rb index bc4265cd6..bdcb13433 100644 --- a/spec/specification/linter_spec.rb +++ b/spec/specification/linter_spec.rb @@ -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 diff --git a/spec/specification/root_attribute_accessors_spec.rb b/spec/specification/root_attribute_accessors_spec.rb index 36847ec7a..c9aae9fbf 100644 --- a/spec/specification/root_attribute_accessors_spec.rb +++ b/spec/specification/root_attribute_accessors_spec.rb @@ -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