Skip to content

Commit

Permalink
Merge pull request #45 from CocoaPods/Kapin-framework-linter-fix
Browse files Browse the repository at this point in the history
Add validation to frameworks to make sure they are only names
  • Loading branch information
kapin committed Dec 3, 2013
2 parents 2f028e0 + 0eab49f commit 691f3e9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/cocoapods-core/specification/linter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,30 @@ def _validate_description(d)
end
end

# Performs validations related to the `homepage` attribute.
#
def _validate_homepage(h)
if h =~ %r[http://EXAMPLE]
warning "The homepage has not been updated from default"
end
end

# Performs validations related to the `frameworks` attribute.
#
def _validate_frameworks(frameworks)
if frameworks_invalid?(frameworks)
error "A framework should only be specified by its name"
end
end

# Performs validations related to the `weak frameworks` attribute.
#
def _validate_weak_frameworks(frameworks)
if frameworks_invalid?(frameworks)
error "A weak framework should only be specified by its name"
end
end

# Performs validations related to the `license` attribute.
#
def _validate_license(l)
Expand Down Expand Up @@ -395,6 +413,17 @@ def check_install_hooks
end
end

# Returns whether the frameworks are valid
#
# @params frameworks [Array<String>]
# The frameworks to be validated
#
# @return [Boolean] true if a framework ends in `.framework`
#
def frameworks_invalid?(frameworks)
frameworks.any? { |framework| framework.end_with?('.framework') }
end

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

# !@group Result Helpers
Expand Down
12 changes: 12 additions & 0 deletions spec/specification/linter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,18 @@ def message_should_include(*values)
@spec.stubs(:source).returns({:git => 'www.banana-empire.git'})
message_should_include('sources', 'specify a tag.')
end

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

it "checks that frameworks do not end with a .framework extension" do
@spec.frameworks = %w{ AddressBook.framework QuartzCore.framework }
message_should_include('framework', 'name')
end

it "checks that weak frameworks do not end with a .framework extension" do
@spec.weak_frameworks = %w{ AddressBook.framework QuartzCore.framework }
message_should_include('weak framework', 'name')
end
end

#--------------------------------------#
Expand Down

0 comments on commit 691f3e9

Please sign in to comment.