Skip to content

Commit

Permalink
Merge 554127d into 26f43e2
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiopelosin committed Oct 30, 2013
2 parents 26f43e2 + 554127d commit b485e6e
Show file tree
Hide file tree
Showing 34 changed files with 698 additions and 343 deletions.
125 changes: 125 additions & 0 deletions .tailor
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
require 'rake/file_list'

#------------------------------------------------------------------------------
# Horizontal Whitespace
#------------------------------------------------------------------------------
# allow_hard_tabs True to let hard tabs be considered a single space.
# Default: false
#
# allow_trailing_line_spaces
# True to skip detecting extra spaces at the ends of
# lines.
# Default: false
#
# indentation_spaces The number of spaces to consider a proper indent.
# Default: 2
#
# max_line_length The maximum number of characters in a line before
# tailor complains.
# Default: 80
# spaces_after_comma Number of spaces to expect after a comma.
# Default: 1
#
# spaces_before_comma Number of spaces to expect before a comma.
# Default: 0
#
# spaces_after_lbrace The number of spaces to expect after an lbrace ('{').
# Default: 1
#
# spaces_before_lbrace The number of spaces to expect before an lbrace ('{').
# Default: 1
#
# spaces_before_rbrace The number of spaces to expect before an rbrace ('}').
# Default: 1
#
# spaces_in_empty_braces The number of spaces to expect between braces when
# there's nothing in the braces (i.e. {}).
# Default: 0
#
# spaces_after_lbracket The number of spaces to expect after an
# lbracket ('[').
# Default: 0
#
# spaces_before_rbracket The number of spaces to expect before an
# rbracket (']').
# Default: 0
#
# spaces_after_lparen The number of spaces to expect after an
# lparen ('(').
# Default: 0
#
# spaces_before_rparen The number of spaces to expect before an
# rbracket (')').
# Default: 0
#
#------------------------------------------------------------------------------
# Naming
#------------------------------------------------------------------------------
# allow_camel_case_methods
# Setting to true skips detection of camel-case method
# names (i.e. def myMethod).
# Default: false
#
# allow_screaming_snake_case_classes
# Setting to true skips detection of screaming
# snake-case class names (i.e. My_Class).
# Default: false
#
#------------------------------------------------------------------------------
# Vertical Whitespace
#------------------------------------------------------------------------------
# max_code_lines_in_class The number of lines of code in a class to allow before
# tailor will warn you.
# Default: 300
#
# max_code_lines_in_method
# The number of lines of code in a method to allow
# before tailor will warn you.
# Default: 30
#
# trailing_newlines The number of newlines that should be at the end of
# the file.
# Default: 1
#
Tailor.config do |config|
config.formatters "text"

config.file_set 'lib/cocoapods-core/specification/dsl/attribute.rb', :dsl do |style|
style.spaces_before_rbrace 1, level: :off
style.spaces_before_lbrace 1, level: :off
style.spaces_before_rbracket 1, level: :off
end

excluded = [
"lib/cocoapods-core/specification/dsl/attribute.rb",
"lib/cocoapods-core/vendor/*.rb",
"lib/cocoapods-core/specification/dsl/deprecations.rb", # Bug with indentation check
]
file_list = Rake::FileList['lib/**/*.rb']
excluded.each { |file| file_list.exclude(file) }
files = file_list.to_a

config.file_set(files) do |style|
style.allow_camel_case_methods false, level: :error
style.allow_hard_tabs false, level: :error
style.allow_screaming_snake_case_classes false, level: :error
style.allow_trailing_line_spaces false, level: :error
style.allow_invalid_ruby false, level: :warn
style.indentation_spaces 2, level: :error
style.max_code_lines_in_class 300, level: :error
style.max_code_lines_in_method 30, level: :error
style.max_line_length 80, level: :error
style.spaces_after_comma 1, level: :off
style.spaces_after_conditional 1, level: :error
style.spaces_after_lbrace 1, level: :error
style.spaces_after_lbracket 0, level: :error
style.spaces_after_lparen 0, level: :error
style.spaces_before_comma 0, level: :error
style.spaces_before_lbrace 1, level: :error
style.spaces_before_rbrace 1, level: :error
style.spaces_before_rbracket 0, level: :error
style.spaces_before_rparen 0, level: :error
style.spaces_in_empty_braces 0, level: :error
style.trailing_newlines 1, level: :error
end
end
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ source "http://rubygems.org"

gemspec

# Ruby 1.8.7
gem "mime-types", "< 2.0"

group :development do
gem 'coveralls', :require => false
gem "mocha", "~> 0.11.4"
gem "bacon"
gem "mocha-on-bacon"
gem "rake"
gem 'prettybacon', :git => 'https://github.com/irrationalfab/PrettyBacon.git', :branch => 'master'
gem 'tailor'
end

group :debugging do
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ GEM
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
log_switch (0.4.0)
metaclass (0.0.1)
method_source (0.8.2)
mime-types (1.25)
Expand Down Expand Up @@ -78,8 +79,13 @@ GEM
simplecov-html (~> 0.7.1)
simplecov-html (0.7.1)
slop (3.4.6)
tailor (1.3.1)
log_switch (>= 0.3.0)
term-ansicolor (>= 1.0.5)
text-table (>= 1.2.2)
term-ansicolor (1.2.2)
tins (~> 0.8)
text-table (1.2.3)
thor (0.18.1)
tins (0.12.0)
yajl-ruby (1.1.0)
Expand All @@ -95,6 +101,7 @@ DEPENDENCIES
coveralls
github-markup
kicker!
mime-types (< 2.0)
mocha (~> 0.11.4)
mocha-on-bacon
prettybacon!
Expand All @@ -103,4 +110,5 @@ DEPENDENCIES
rake
rb-fsevent
redcarpet
tailor
yard
14 changes: 13 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ namespace :spec do
task :all do
ENV['GENERATE_COVERAGE'] = 'true'
sh "bundle exec bacon #{specs('**')}"
puts "Checking code style..."
Rake::Task["tailor"].invoke
end

desc "Checks that the gem is campable of loading all the specs of the master repo."
desc "Checks that the gem is capable of loading all the specs of the master repo."
task :repo do
puts "Checking compatibility with master repo"
require 'pathname'
Expand Down Expand Up @@ -193,4 +195,14 @@ end
desc "Run all specs"
task :spec => 'spec:all'

if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('1.9.3')
require 'tailor/rake_task'
Tailor::RakeTask.new
else
desc "Check style"
task :tailor do
puts "[!] Ruby > 1.9 is required to run style checks"
end
end

task :default => :spec
2 changes: 0 additions & 2 deletions lib/cocoapods-core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,3 @@ class Informative < PlainInformative; end
Spec = Specification

end


1 change: 0 additions & 1 deletion lib/cocoapods-core/core_ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ def self.warn(message)

end
end

15 changes: 10 additions & 5 deletions lib/cocoapods-core/dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@ def initialize(name = nil, *requirements)
if requirements.last.is_a?(Hash)
@external_source = requirements.pop
unless requirements.empty?
raise Informative, "A dependency with an external source may not specify version requirements (#{name})."
raise Informative, "A dependency with an external source may not " \
"specify version requirements (#{name})."
end

elsif requirements.last == :head
@head = true
requirements.pop
unless requirements.empty?
raise Informative, "A `:head` dependency may not specify version requirements (#{name})."
raise Informative, "A `:head` dependency may not specify version " \
"requirements (#{name})."
end
end

Expand All @@ -103,8 +105,11 @@ def initialize(name = nil, *requirements)
# be better to add something like Version#display_string.
#
def requirement
return Requirement.new(Version.new(specific_version.version)) if specific_version
@requirement
if specific_version
Requirement.new(Version.new(specific_version.version))
else
@requirement
end
end

# @return [Bool] whether the dependency points to a subspec.
Expand Down Expand Up @@ -329,7 +334,7 @@ def self.from_string(string)
#
def inspect
"<#{self.class} name=#{self.name} requirements=#{requirement.to_s} " \
"external_source=#{external_source||'nil'}>"
"external_source=#{external_source||'nil'}>"
end

#--------------------------------------#
Expand Down
22 changes: 13 additions & 9 deletions lib/cocoapods-core/lockfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def pod_names
def version(pod_name)
version = pod_versions[pod_name]
return version if version
root_name = pod_versions.keys.find { |name| Specification.root_name(name) == pod_name }
root_name = pod_versions.keys.find do |name|
Specification.root_name(name) == pod_name
end
pod_versions[root_name]
end

Expand Down Expand Up @@ -140,7 +142,8 @@ def dependency_to_lock_pod_named(name)
version = version(name)

unless dep && version
raise StandardError, "Attempt to lock the `#{name}` Pod without an known dependency."
raise StandardError, "Attempt to lock the `#{name}` Pod without an " \
"known dependency."
end

locked_dependency = dep.dup
Expand Down Expand Up @@ -229,17 +232,19 @@ def checksum_data
#
def detect_changes_with_podfile(podfile)
result = {}
[ :added, :changed, :removed, :unchanged ].each { |k| result[k] = [] }
[:added, :changed, :removed, :unchanged].each { |k| result[k] = [] }

installed_deps = dependencies.map { |d| dependency_to_lock_pod_named(d.name) }
installed_deps = dependencies.map do |dep|
dependency_to_lock_pod_named(dep.name)
end
all_dep_names = (dependencies + podfile.dependencies).map(&:name).uniq
all_dep_names.each do |name|
installed_dep = installed_deps.find { |d| d.name == name }
podfile_dep = podfile.dependencies.find { |d| d.name == name }

if installed_dep.nil? then key = :added
elsif podfile_dep.nil? then key = :removed
elsif podfile_dep.compatible?(installed_dep ) then key = :unchanged
elsif podfile_dep.compatible?(installed_dep) then key = :unchanged
else key = :changed
end
result[key] << name
Expand All @@ -262,7 +267,7 @@ def detect_changes_with_podfile(podfile)
#
def write_to_disk(path)
path.dirname.mkpath unless path.dirname.exist?
File.open(path, 'w') {|f| f.write(to_yaml) }
File.open(path, 'w') { |f| f.write(to_yaml) }
self.defined_in_file = path
end

Expand Down Expand Up @@ -391,7 +396,7 @@ def generate_pods_data(specs)
# @return [Array] the generated data.
#
def generate_dependencies_data(podfile)
podfile.dependencies.map{ |d| d.to_s }.sort
podfile.dependencies.map { |d| d.to_s }.sort
end

# Generates the information of the external sources.
Expand All @@ -409,7 +414,7 @@ def generate_dependencies_data(podfile)
#
def generate_external_sources_data(podfile)
deps = podfile.dependencies.select(&:external?)
deps = deps.sort { |d, other| d.name <=> other.name}
deps = deps.sort { |d, other| d.name <=> other.name }
sources = {}
deps.each { |d| sources[d.root_name] = d.external_source }
sources
Expand Down Expand Up @@ -437,4 +442,3 @@ def generate_checksums(specs)
end
end
end

10 changes: 7 additions & 3 deletions lib/cocoapods-core/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def ==(other)
def supports?(other)
other = Platform.new(other)
if other.deployment_target && deployment_target
(other.name == name) && (other.deployment_target <= deployment_target)
(other.name == name) && (other.deployment_target <= deployment_target)
else
other.name == name
end
Expand All @@ -119,7 +119,7 @@ def to_s
#
def inspect
"#<#{self.class.name} name=#{name.inspect} " \
"deployment_target=#{deployment_target.inspect}>"
"deployment_target=#{deployment_target.inspect}>"
end

# @return [Symbol] a symbol representing the name of the platform.
Expand Down Expand Up @@ -150,7 +150,11 @@ def <=> other
# iOS.
#
def requires_legacy_ios_archs?
(name == :ios) && deployment_target && (deployment_target < Version.new("4.3"))
if name == :ios
deployment_target && (deployment_target < Version.new("4.3"))
else
false
end
end

# Converts the symbolic name of a platform to a string name suitable to be
Expand Down
Loading

0 comments on commit b485e6e

Please sign in to comment.