Permalink
Browse files

[Specs] bump the coverage

  • Loading branch information...
1 parent 8c6ecc9 commit d0a0058a08d1303a56100109176f57a3f4a957b8 @fabiopelosin fabiopelosin committed Mar 18, 2013
View
@@ -113,6 +113,7 @@ namespace :spec do
end
task :all do
+ ENV['GENERATE_COVERAGE'] = 'true'
sh "bundle exec bacon #{specs('**')}"
end
@@ -144,7 +145,7 @@ namespace :spec do
puts e.message
puts
puts e.backtrace.reject { |l| !l.include?(Dir.pwd) || l.include?('/Rakefile')}
- clean = FALSE
+ FALSE
end
end
@@ -4,16 +4,16 @@ module Pod
#
module CoreUI
- class << self
- def puts(message)
- STDOUT.puts message
- end
-
- def warn(message)
- STDERR.puts message
- end
+ def self.puts(message)
+ STDOUT.puts message
+ end
+ def self.warn(message)
+ STDERR.puts message
end
+
+ #-------------------------------------------------------------------------#
+
end
end
@@ -209,7 +209,7 @@ def merge(other)
def to_s
version = ''
if external?
- version << external_source_description
+ version << external_source_description(external_source)
elsif head?
version << 'HEAD'
elsif @version_requirements != Requirement.default
@@ -271,8 +271,7 @@ def inspect
#
# @return [String] the description of the external source.
#
- def external_source_description
- source = external_source
+ def external_source_description(source)
if source.key?(:git)
desc = "`#{source[:git]}`"
desc << ", commit `#{source[:commit]}`" if source[:commit]
@@ -39,10 +39,9 @@ def initialize(hash)
#
def self.from_file(path)
return nil unless path.exist?
- begin
- hash = YAML.load(File.open(path))
- rescue Exception => e
- raise StandardError, "Podfile.lock syntax error: #{e.inspect}"
+ hash = YAML.load(File.open(path))
+ unless hash && hash.is_a?(Hash)
+ raise Informative, "Invalid Lockfile in `#{path}`"
end
lockfile = Lockfile.new(hash)
lockfile.defined_in_file = path
@@ -59,12 +58,6 @@ def ==(other)
other && self.to_hash == other.to_hash
end
- # @return [String] a string representation suitable for UI output.
- #
- def to_s
- "Podfile.lock"
- end
-
# @return [String] a string representation suitable for debugging.
#
def inspect
@@ -95,8 +88,8 @@ def pod_names
def version(pod_name)
version = pod_versions[pod_name]
return version if version
- pod_name = pod_versions.keys.find { |name| Specification.root_name(name) == pod_name }
- pod_versions[pod_name]
+ root_name = pod_versions.keys.find { |name| Specification.root_name(name) == pod_name }
+ pod_versions[root_name]
end
# Returns the checksum for the given Pod.
@@ -146,14 +139,10 @@ def dependency_to_lock_pod_named(name)
dep = dependencies.find { |d| d.name == name || d.root_name == name }
version = version(name)
- unless dep
+ unless dep && version
raise StandardError, "Attempt to lock the `#{name}` Pod without an known dependency."
end
- unless version
- raise StandardError, "Attempt to lock the `#{name}` Pod without an known version."
- end
-
locked_dependency = dep.dup
locked_dependency.specific_version = version
locked_dependency
@@ -272,7 +261,7 @@ def write_to_disk(path)
self.defined_in_file = path
end
- # @return [Hash{String=>Array,Hash,String}] a hash reppresentation of the
+ # @return [Hash{String=>Array,Hash,String}] a hash representation of the
# Lockfile.
#
# @example Output
@@ -339,7 +328,7 @@ class << self
#
def generate(podfile, specs)
hash = {
- 'PODS' => generate_pods_data(podfile, specs),
+ 'PODS' => generate_pods_data(specs),
'DEPENDENCIES' => generate_dependencies_data(podfile),
'EXTERNAL SOURCES' => generate_external_sources_data(podfile),
'SPEC CHECKSUMS' => generate_checksums(specs),
@@ -369,7 +358,7 @@ def generate(podfile, specs)
# "monkey (1.0.8)" ]
#
#
- def generate_pods_data(podfile, specs)
+ def generate_pods_data(specs)
pod_and_deps = specs.map do |spec|
[spec.to_s, spec.all_dependencies.map(&:to_s).sort]
end.uniq
@@ -165,7 +165,7 @@ def self.string_name(symbolic_name)
case symbolic_name
when :ios then 'iOS'
when :osx then 'OS X'
- else symbolic_name end
+ else symbolic_name.to_s end
end
end
end
@@ -210,7 +210,7 @@ def to_yaml
def self.from_file(path)
path = Pathname.new(path)
unless path.exist?
- raise StandardError, "No Podfile exists at path `#{path}`."
+ raise Informative, "No Podfile exists at path `#{path}`."
end
string = File.open(path, 'r:utf-8') { |f| f.read }
# Work around for Rubinius incomplete encoding in 1.9 mode
@@ -224,7 +224,7 @@ def self.from_file(path)
when '.yaml', '.cocoapods'
Podfile.from_yaml(string, path)
else
- raise StandardError, "Unsupported Podfile format `#{path}`."
+ raise Informative, "Unsupported Podfile format `#{path}`."
end
end
@@ -332,15 +332,20 @@ def get_hash_value(key)
#
attr_accessor :current_target_definition
+ public
+
+ # @!group Deprecations
#-------------------------------------------------------------------------#
# @deprecated Deprecated in favour of the more succinct {#pod}. Remove for
# CocoaPods 1.0.
#
def dependency(name = nil, *requirements, &block)
- warn "[DEPRECATED] `dependency' is deprecated (use `pod')"
+ CoreUI.warn "[DEPRECATED] `dependency' is deprecated (use `pod')"
pod(name, *requirements, &block)
end
+ #-------------------------------------------------------------------------#
+
end
end
@@ -217,7 +217,7 @@ def podspec(options = nil)
#
def target(name, options = {})
if options && !options.keys.all? { |key| [:exclusive].include?(key) }
- raise StandardError, "Unsupported options `#{options}` for target `#{name}`"
+ raise Informative, "Unsupported options `#{options}` for target `#{name}`"
end
parent = current_target_definition
@@ -264,10 +264,8 @@ def target(name, options = {})
# @return [void]
#
def platform(name, target = nil)
-
# Support for deprecated options parameter
target = target[:deployment_target] if target.is_a?(Hash)
-
current_target_definition.set_platform(name, target)
end
@@ -105,11 +105,7 @@ def label
end
end
- # @return [String] A string representation suitable for UI.
- #
- def to_s
- "`#{label}` target definition"
- end
+ alias :to_s :label
# @return [String] A string representation suitable for debug.
#
@@ -115,15 +115,15 @@ def all_specs
specs = pods.map do |name|
begin
versions(name).map { |version| specification(name, version) }
- rescue DSLError => e
+ rescue
CoreUI.warn "Skipping `#{name}` because the podspec contains errors."
next
end
end
specs.flatten.compact
end
- #---------------------------------------------------------------------------#
+ #-------------------------------------------------------------------------#
# @!group Searching the source
@@ -168,7 +168,7 @@ def search_by_name(query, full_text_search = false)
end.compact
end
- #---------------------------------------------------------------------------#
+ #-------------------------------------------------------------------------#
# @!group Representations
@@ -179,7 +179,6 @@ def search_by_name(query, full_text_search = false)
def to_hash
hash = {}
all_specs.each do |spec|
- print '.'
hash[spec.name] ||= {}
hash[spec.name][spec.version.version] = spec.to_hash
end
@@ -266,6 +265,8 @@ def search(dependency)
#
# @raise If no source including the set can be found.
#
+ # @todo Clients should raise not this method.
+ #
# @see Source#search_by_name
#
def search_by_name(query, full_text_search = false)
@@ -299,6 +300,9 @@ def dirs
[]
end
end
+
+ #-----------------------------------------------------------------------#
+
end
end
end
@@ -105,13 +105,13 @@ def lint
end
# TODO: this check cannot be performed before a merge.
- def check_spec_path
- expected = "#{spec.name}/#{spec.version}/#{spec.name}.podspec"
- relative_path = spec_path.relative_path_from(source.repo).to_s
- unless relative_path == expected
- error "Incorrect path, the path is `#{relative_path}` and should be `#{expected}`."
- end
- end
+ # def check_spec_path
+ # expected = "#{spec.name}/#{spec.version}/#{spec.name}.podspec"
+ # relative_path = spec_path.relative_path_from(source.repo).to_s
+ # unless relative_path == expected
+ # error "Incorrect path, the path is `#{relative_path}` and should be `#{expected}`."
+ # end
+ # end
def check_spec_source_change
return unless spec
@@ -131,7 +131,7 @@ def check_if_untagged_version_is_acceptable
return if !spec.source[:git] || spec.source[:tag]
# Allow to fix a 0.0.1 podspec
- if !related_specifications.any? { |s| s.version == '0.0.1' }
+ if related_specifications && !related_specifications.any? { |s| s.version == '0.0.1' }
error "There is already versioned specifications so " \
"untagged versions cannot be added."
elsif spec.version != Version.new('0.0.1')
@@ -102,7 +102,13 @@ def hash
# clients.
#
def to_s
- "#{name} (#{version})"
+ if name && version.version != ""
+ "#{name} (#{version})"
+ elsif name
+ name
+ else
+ "No-name"
+ end
end
# @return [String] A string suitable for debugging.
@@ -527,19 +533,19 @@ def defined_in_file
def self.from_file(path, subspec_name = nil)
path = Pathname.new(path)
unless path.exist?
- raise StandardError, "No podspec exists at path `#{path}`."
+ raise Informative, "No podspec exists at path `#{path}`."
end
case path.extname
when '.podspec'
spec = ::Pod._eval_podspec(path)
unless spec.is_a?(Specification)
- raise StandardError, "Invalid podspec file at path `#{path}`."
+ raise Informative, "Invalid podspec file at path `#{path}`."
end
when '.yaml'
spec = Specification.from_yaml(path.read)
else
- raise StandardError, "Unsupported specification format `#{path.extname}`."
+ raise Informative, "Unsupported specification format `#{path.extname}`."
end
spec.defined_in_file = path
@@ -25,18 +25,18 @@ def singleton_method_added(method)
end
elsif method == :header_mappings
- raise StandardError, "[#{to_s}] The use of the `header_mappings` hook has been deprecated."
+ raise Informative, "[#{to_s}] The use of the `header_mappings` hook has been deprecated."
end
end
def clean_paths=(value)
- raise StandardError, "[#{to_s}] Clean paths are deprecated. CocoaPods now " \
+ raise Informative, "[#{to_s}] Clean paths are deprecated. CocoaPods now " \
"cleans unused files by default. Use preserver paths if needed."
end
[ :part_of_dependency=, :part_of=, :exclude_header_search_paths= ].each do |method|
define_method method do |value|
- raise StandardError, "[#{to_s}] Attribute `#{method.to_s[0..-2]}` has been deprecated."
+ raise Informative, "[#{to_s}] Attribute `#{method.to_s[0..-2]}` has been deprecated."
end
end
@@ -35,8 +35,8 @@ def version
@set.versions.first
end
- # @return [Array<Version>] all the versions available sorted
- # ascendingly.
+ # @return [Array<Version>] all the versions available ascending
+ # order.
#
def versions
@set.versions.sort.reverse
Oops, something went wrong.

0 comments on commit d0a0058

Please sign in to comment.