From 58c07c87c19dc8946926f71b25d2203d383ac347 Mon Sep 17 00:00:00 2001 From: Dan Kubb Date: Sun, 25 May 2008 16:14:41 -0700 Subject: [PATCH] Whitespace cleanup with "sake strip" (from dm-dev sake tasks) --- Rakefile | 2 +- lib/data_mapper/associations/one_to_many.rb | 22 ++++++------- lib/data_mapper/identity_map.rb | 4 +-- lib/data_mapper/logger.rb | 2 +- lib/data_mapper/repository.rb | 2 +- lib/data_mapper/resource.rb | 2 +- lib/data_mapper/support/string.rb | 2 +- lib/data_mapper/types/discriminator.rb | 10 +++--- spec/integration/resource_spec.rb | 10 +++--- spec/unit/hook_spec.rb | 36 ++++++++++----------- spec/unit/property_spec.rb | 2 +- spec/unit/repository_spec.rb | 2 +- spec/unit/support/object_spec.rb | 2 +- 13 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Rakefile b/Rakefile index af6cf351..479a7326 100755 --- a/Rakefile +++ b/Rakefile @@ -224,4 +224,4 @@ namespace :ci do end #task :ci => %w[ ci:spec ci:doc ci:saikuro install ci:publish ] # yard-related tasks do not work yet -task :ci => %w[ ci:spec ci:saikuro install ] \ No newline at end of file +task :ci => %w[ ci:spec ci:saikuro install ] diff --git a/lib/data_mapper/associations/one_to_many.rb b/lib/data_mapper/associations/one_to_many.rb index 24e3a2f3..0df56092 100644 --- a/lib/data_mapper/associations/one_to_many.rb +++ b/lib/data_mapper/associations/one_to_many.rb @@ -11,8 +11,8 @@ def one_to_many(name, options = {}) raise ArgumentError, "+name+ should be a Symbol (or Hash for +through+ support), but was #{name.class}", caller unless Symbol === name || Hash === name raise ArgumentError, "+options+ should be a Hash, but was #{options.class}", caller unless Hash === options - relationship = - relationships(repository.name)[name] = + relationship = + relationships(repository.name)[name] = if options.include?(:through) RelationshipChain.new(:child_model_name => options.fetch(:class_name, DataMapper::Inflection.classify(name)), :parent_model_name => self.name, @@ -22,7 +22,7 @@ def one_to_many(name, options = {}) :parent_key => options[:parent_key], :child_key => options[:child_key]) else - relationships(repository.name)[name] = + relationships(repository.name)[name] = Relationship.new( DataMapper::Inflection.underscore(self.name.split('::').last).to_sym, repository.name, @@ -31,7 +31,7 @@ def one_to_many(name, options = {}) options ) end - + class_eval <<-EOS, __FILE__, __LINE__ def #{name}(options={}) options.empty? ? #{name}_association : #{name}_association.all(options) @@ -81,7 +81,7 @@ def unshift(*resources) def <<(resource) # - # The order here is of the essence. + # The order here is of the essence. # # self.append_resource used to be called before children.<<, which created weird errors # where the resource was appended in the db before it was appended onto the @children @@ -128,7 +128,7 @@ def all(options={}) def first(options={}) options.empty? ? children.first : @relationship.get_children(@parent_resource,options,:first) end - + def reload! @dirty_children = [] @children = nil @@ -153,17 +153,17 @@ def children def ensure_mutable raise ImmutableAssociationError, "You can not modify this assocation" if RelationshipChain === @relationship end - + def add_default_association_values(resources) resources.each do |resource| conditions = @relationship.query.reject { |key, value| key == :order } conditions.each do |key, value| resource.send("#{key}=", value) if key.class != DataMapper::Query::Operator && resource.send("#{key}") == nil - end + end end - resources - end - + resources + end + def remove_resource(resource) ensure_mutable begin diff --git a/lib/data_mapper/identity_map.rb b/lib/data_mapper/identity_map.rb index 07be5e2b..1df7c4b4 100644 --- a/lib/data_mapper/identity_map.rb +++ b/lib/data_mapper/identity_map.rb @@ -40,11 +40,11 @@ def initialize(second_level_cache = nil) Hash.new end end - + def cache @cache end - + def method_missing(method, *args, &block) cache.__send__(method, *args, &block) end diff --git a/lib/data_mapper/logger.rb b/lib/data_mapper/logger.rb index 9116392d..b4476a6e 100644 --- a/lib/data_mapper/logger.rb +++ b/lib/data_mapper/logger.rb @@ -149,7 +149,7 @@ def close end # Appends a string and log level to logger's buffer. - + # @note # Note that the string is discarded if the string's log level less than the # logger's log level. diff --git a/lib/data_mapper/repository.rb b/lib/data_mapper/repository.rb index be7841fc..f73c1c30 100755 --- a/lib/data_mapper/repository.rb +++ b/lib/data_mapper/repository.rb @@ -18,7 +18,7 @@ def self.default_name end attr_reader :name, :adapter, :type_map - + def identity_map_get(model, key) identity_map(model)[key] end diff --git a/lib/data_mapper/resource.rb b/lib/data_mapper/resource.rb index 0f9beab1..36698750 100644 --- a/lib/data_mapper/resource.rb +++ b/lib/data_mapper/resource.rb @@ -208,7 +208,7 @@ def reload self end alias reload! reload - + def reload_attributes(*attributes) @collection.reload(:fields => attributes) self diff --git a/lib/data_mapper/support/string.rb b/lib/data_mapper/support/string.rb index eb2b959a..ccbbd1d0 100644 --- a/lib/data_mapper/support/string.rb +++ b/lib/data_mapper/support/string.rb @@ -9,7 +9,7 @@ def self.translations end # Matches any whitespace (including newline) and replaces with a single space - # + # # @example # < (model.inheritance_class_names << model.name)) - + end end # class Discriminator end # module Types -end # module DataMapper \ No newline at end of file +end # module DataMapper diff --git a/spec/integration/resource_spec.rb b/spec/integration/resource_spec.rb index 55fe4a62..e5abf52d 100644 --- a/spec/integration/resource_spec.rb +++ b/spec/integration/resource_spec.rb @@ -133,7 +133,7 @@ class Psycho < Maniac; end class Geek < Male property :awkward, Boolean, :default => true end - + Geek.auto_migrate!(ADAPTER) repository(ADAPTER) do @@ -146,7 +146,7 @@ class Geek < Male Maniac.create!(:name => 'William') Psycho.create!(:name => 'Norman') end - + class Flanimal include DataMapper::Resource property :id, Integer, :serial => true @@ -156,11 +156,11 @@ class Flanimal end class Sprog < Flanimal; end - + Flanimal.auto_migrate!(ADAPTER) - + end - + it "should test bug ticket #302" do repository(ADAPTER) do Sprog.create(:name => 'Marty') diff --git a/spec/unit/hook_spec.rb b/spec/unit/hook_spec.rb index 19b4da1c..d4cc8d88 100644 --- a/spec/unit/hook_spec.rb +++ b/spec/unit/hook_spec.rb @@ -54,7 +54,7 @@ def a_hook it 'should run an advice block for class methods when the class is inherited' do @inherited_class = Class.new(@class) - + @class.before_class_method :a_class_method do hi_dad! end @@ -75,10 +75,10 @@ def a_hook inst.a_method end - + it 'should run an advice block when the class is inherited' do @inherited_class = Class.new(@class) - + @class.before :a_method do hi_dad! end @@ -481,11 +481,11 @@ class CaptHook @@ruler_of_all_neverland = false @@clocks_bashed = 0 - + def self.ruler_of_all_neverland? @@ruler_of_all_neverland end - + def self.conquer_neverland @@ruler_of_all_neverland = true end @@ -493,11 +493,11 @@ def self.conquer_neverland def self.bash_clock @@clocks_bashed += 1 end - + def self.clocks_bashed @@clocks_bashed end - + def self.walk_the_plank! true end @@ -511,25 +511,25 @@ def throw_halt end end - + it "should catch :halt from a before instance hook and abort the advised method" do CaptHook.before :get_eaten_by_croc, :throw_halt capt_hook = CaptHook.new - lambda { - capt_hook.get_eaten_by_croc + lambda { + capt_hook.get_eaten_by_croc capt_hook.should_not be_eaten }.should_not throw_symbol(:halt) end - + it "should catch :halt from an after instance hook and cease the advice" do CaptHook.after :get_eaten_by_croc, :throw_halt capt_hook = CaptHook.new - lambda { + lambda { capt_hook.get_eaten_by_croc capt_hook.should be_eaten }.should_not throw_symbol(:halt) end - + it "should catch :halt from a before class method hook and abort advised method" do CaptHook.before_class_method :conquer_neverland, :throw_halt lambda { @@ -538,21 +538,21 @@ def throw_halt }.should_not throw_symbol(:halt) end - + it "should catch :halt from an after class method hook and abort the rest of the advice" do CaptHook.after_class_method :bash_clock, :throw_halt lambda { CaptHook.bash_clock CaptHook.clocks_bashed.should == 1 }.should_not throw_symbol(:halt) - + end - + after do # Thus perished James Hook CaptHook.walk_the_plank! end end - - + + end diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index b2e5572d..ba44e859 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -32,7 +32,7 @@ class Tomato property.primitive.should == String end - + it "should not have key that is lazy" do property = DataMapper::Property.new(Zoo, :id, DataMapper::Types::Text, { :key => true }) property.lazy?.should == false diff --git a/spec/unit/repository_spec.rb b/spec/unit/repository_spec.rb index 5ebb1b5b..428f8ac9 100644 --- a/spec/unit/repository_spec.rb +++ b/spec/unit/repository_spec.rb @@ -58,7 +58,7 @@ class Grain @repository.should respond_to(:save) @repository.should respond_to(:destroy) end - + it "should be reused in inner scope" do DataMapper.repository(:default) do |outer_repos| DataMapper.repository(:default) do |inner_repos| diff --git a/spec/unit/support/object_spec.rb b/spec/unit/support/object_spec.rb index 25c70c08..5d673d36 100644 --- a/spec/unit/support/object_spec.rb +++ b/spec/unit/support/object_spec.rb @@ -5,7 +5,7 @@ it "should be able to get a recursive constant" do find_const('DataMapper::Resource').should == DataMapper::Resource end - + it "should ignore get Constants from the Kernel namespace correctly" do find_const('::DataMapper::Resource').should == ::DataMapper::Resource end