Skip to content

Commit

Permalink
Whitespace cleanup with "sake strip" (from dm-dev sake tasks)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Kubb committed May 25, 2008
1 parent f767849 commit 58c07c8
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -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 ]
task :ci => %w[ ci:spec ci:saikuro install ]
22 changes: 11 additions & 11 deletions lib/data_mapper/associations/one_to_many.rb
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/data_mapper/identity_map.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/data_mapper/logger.rb
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/data_mapper/repository.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/data_mapper/resource.rb
Expand Up @@ -208,7 +208,7 @@ def reload
self
end
alias reload! reload

def reload_attributes(*attributes)
@collection.reload(:fields => attributes)
self
Expand Down
2 changes: 1 addition & 1 deletion lib/data_mapper/support/string.rb
Expand Up @@ -9,7 +9,7 @@ def self.translations
end

# Matches any whitespace (including newline) and replaces with a single space
#
#
# @example
# <<QUERY.compress_lines
# SELECT name
Expand Down
10 changes: 5 additions & 5 deletions lib/data_mapper/types/discriminator.rb
Expand Up @@ -6,23 +6,23 @@ class Discriminator < DataMapper::Type

def self.bind(property)
model = property.model

model.class_eval <<-EOS
def self.inheritance_class_names
@inheritance_class_names ||= []
end
after_class_method :inherited, :propagate_inheritance_class_name
def self.propagate_inheritance_class_name(target)
inheritance_class_names << target.name
superclass.send(:propagate_inheritance_class_name,target) if superclass.respond_to?(:propagate_inheritance_class_name)
end
EOS

model.send(:scope_stack) << DataMapper::Query.new(property.repository, model, property.name => (model.inheritance_class_names << model.name))

end
end # class Discriminator
end # module Types
end # module DataMapper
end # module DataMapper
10 changes: 5 additions & 5 deletions spec/integration/resource_spec.rb
Expand Up @@ -133,7 +133,7 @@ class Psycho < Maniac; end
class Geek < Male
property :awkward, Boolean, :default => true
end

Geek.auto_migrate!(ADAPTER)

repository(ADAPTER) do
Expand All @@ -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
Expand All @@ -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')
Expand Down
36 changes: 18 additions & 18 deletions spec/unit/hook_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -481,23 +481,23 @@ 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

def self.bash_clock
@@clocks_bashed += 1
end

def self.clocks_bashed
@@clocks_bashed
end

def self.walk_the_plank!
true
end
Expand All @@ -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 {
Expand All @@ -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
2 changes: 1 addition & 1 deletion spec/unit/property_spec.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/repository_spec.rb
Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/support/object_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 58c07c8

Please sign in to comment.