diff --git a/CHANGELOG.md b/CHANGELOG.md index 86b91a294..e850b0987 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ [Joshua Kalpin][Kapin] [#50](https://github.com/CocoaPods/Core/pull/50) +* Added `deprecated` and `deprecated_in_favor_of` attributes to Specification + DSL. + [Paul Young](https://github.com/paulyoung) + [#87](https://github.com/CocoaPods/Core/pull/87) + ## 0.31.1 ##### Enhancements diff --git a/lib/cocoapods-core/specification/dsl.rb b/lib/cocoapods-core/specification/dsl.rb index a7d1f2ca1..7837ba7ee 100644 --- a/lib/cocoapods-core/specification/dsl.rb +++ b/lib/cocoapods-core/specification/dsl.rb @@ -405,6 +405,38 @@ module DSL # root_attribute :prepare_command + #------------------# + + # @!method deprecated=(flag) + # + # Whether the library has been deprecated. + # + # @example + # + # spec.deprecated = true + # + # @param [Bool] flag + # whether the library has been deprecated. + # + root_attribute :deprecated, { + :types => [TrueClass, FalseClass], + :default_value => false, + } + + # @!method deprecated_in_favor_of=(deprecated_in_favor_of) + # + # The name of the Pod that this one has been deprecated in favor of. + # + # @example + # + # spec.deprecated_in_favor_of = 'NewMoreAwesomePod' + # + # @param [String] deprecated_in_favor_of + # the name of the Pod that this one has been deprecated in + # favor of. + # + root_attribute :deprecated_in_favor_of + #-----------------------------------------------------------------------# # @!group Platform diff --git a/lib/cocoapods-core/specification/root_attribute_accessors.rb b/lib/cocoapods-core/specification/root_attribute_accessors.rb index c381e55cb..4a52f889f 100644 --- a/lib/cocoapods-core/specification/root_attribute_accessors.rb +++ b/lib/cocoapods-core/specification/root_attribute_accessors.rb @@ -147,6 +147,19 @@ def prepare_command command.strip_heredoc.chomp if command end + # @return [Bool] Whether the Pod has been deprecated. + # + def deprecated + attributes_hash["deprecated"] + end + + # @return [String] The name of the Pod that this one has been + # deprecated in favor of. + # + def deprecated_in_favor_of + attributes_hash["deprecated_in_favor_of"] + end + #---------------------------------------------------------------------# private diff --git a/spec/specification/dsl_spec.rb b/spec/specification/dsl_spec.rb index ed73d66af..934a6130f 100644 --- a/spec/specification/dsl_spec.rb +++ b/spec/specification/dsl_spec.rb @@ -76,6 +76,16 @@ module Pod @spec.prepare_command = "ruby build_files.rb" @spec.attributes_hash["prepare_command"].should == "ruby build_files.rb" end + + it "allows to specify whether the Pod has been deprecated" do + @spec.deprecated = true + @spec.attributes_hash["deprecated"].should == true + end + + it "allows to specify the name of the Pod that this one has been deprecated in favor of" do + @spec.deprecated_in_favor_of = 'NewMoreAwesomePod' + @spec.attributes_hash["deprecated_in_favor_of"].should == 'NewMoreAwesomePod' + end end #-----------------------------------------------------------------------------# diff --git a/spec/specification/root_attribute_accessors_spec.rb b/spec/specification/root_attribute_accessors_spec.rb index 82bc960ab..351ac93ca 100644 --- a/spec/specification/root_attribute_accessors_spec.rb +++ b/spec/specification/root_attribute_accessors_spec.rb @@ -135,5 +135,15 @@ module Pod @spec.prepare_command.should == 'ruby prepare_script.rb' end + it "returns whether the Pod has been deprecated" do + @spec.deprecated = true + @spec.deprecated.should == true + end + + it "returns the name of the Pod that this one has been deprecated in favor of" do + @spec.deprecated_in_favor_of = 'NewMoreAwesomePod' + @spec.deprecated_in_favor_of.should == 'NewMoreAwesomePod' + end + end end