Kill trailing whitespace in ruby files

This commit is contained in:
小太
2013-03-19 23:10:10 +11:00
parent c107f96cec
commit cba839ba76
319 changed files with 2710 additions and 2710 deletions

View File

@@ -4,18 +4,18 @@ module Danbooru
module Paginator
module ActiveRecordExtension
extend ActiveSupport::Concern
module ClassMethods
def paginate(page, options = {})
@paginator_options = options
if use_sequential_paginator?(page)
paginate_sequential(page)
else
paginate_numbered(page)
end
end
def use_sequential_paginator?(page)
page =~ /[ab]\d+/i
end
@@ -32,11 +32,11 @@ module Danbooru
def paginate_sequential_before(before_id = nil)
c = limit(records_per_page)
if before_id.to_i > 0
c = c.where("id < ?", before_id.to_i)
end
c.reorder("id desc").tap do |obj|
obj.extend(SequentialCollectionExtension)
obj.sequential_paginator_mode = :before
@@ -49,14 +49,14 @@ module Danbooru
obj.sequential_paginator_mode = :after
end
end
def paginate_numbered(page)
page = [page.to_i, 1].max
if page > Danbooru.config.max_numbered_pages
raise ::Danbooru::Paginator::PaginationError.new("You cannot go beyond page #{Danbooru.config.max_numbered_pages}. Please narrow your search terms.")
end
limit(records_per_page).offset((page - 1) * records_per_page).tap do |obj|
obj.extend(NumberedCollectionExtension)
if records_per_page > 0
@@ -67,11 +67,11 @@ module Danbooru
obj.current_page = page
end
end
def records_per_page
option_for(:limit).to_i
end
# When paginating large tables, we want to avoid doing an expensive count query
# when the result won't even be used. So when calling paginate you can pass in
# an optional :search_count key which points to the search params. If these params
@@ -86,7 +86,7 @@ module Danbooru
limit = 1000
end
limit
when :count
if @paginator_options.has_key?(:search_count) && @paginator_options[:search_count].blank?
1_000_000
@@ -95,14 +95,14 @@ module Danbooru
else
nil
end
end
end
# taken from kaminari (https://github.com/amatsuda/kaminari)
def total_count
return option_for(:count) if option_for(:count)
c = except(:offset, :limit, :order)
c = c.reorder(nil)
c = c.count

View File

@@ -2,11 +2,11 @@ module Danbooru
module Paginator
module NumberedCollectionExtension
attr_accessor :current_page, :total_pages
def is_first_page?
current_page == 1
end
def is_last_page?
current_page >= total_pages
end

View File

@@ -2,15 +2,15 @@ module Danbooru
module Paginator
module SequentialCollectionExtension
attr_accessor :sequential_paginator_mode
def is_first_page?
size == 0
end
def is_last_page?
size == 0
end
def to_a
if sequential_paginator_mode == :before
super

View File

@@ -7,28 +7,28 @@ module Danbooru
# wider than it is tall
geometry = "#{Danbooru.config.small_image_width}x#{Danbooru.config.small_image_width}>"
end
image.change_geometry(geometry) do |new_width, new_height, img|
img.resize!(new_width, new_height)
width = new_width
height = new_height
end
image = flatten(image, width, height)
image.write(write_path) do
self.quality = resize_quality
end
image.destroy!
FileUtils.chmod(0664, write_path)
end
def flatten(image, width, height)
if image.alpha?
# since jpeg can't represent transparency, we need to create an image list,
# put a white image on the bottom, then flatten it.
list = Magick::ImageList.new
list.new_image(width, height) do
self.background_color = "#FFFFFF"

View File

@@ -659,7 +659,7 @@ module FileOperations
def ruby(*args)
command config('rubyprog'), *args
end
def make(task = nil)
command(*[config('makeprog'), task].compact)
end
@@ -722,7 +722,7 @@ module HookScriptAPI
def srcdirectory?(path)
File.dir?(srcfile(path))
end
def srcfile?(path)
File.file?(srcfile(path))
end
@@ -826,7 +826,7 @@ class ToplevelInstaller
__send__ "exec_#{task}"
end
end
def run_metaconfigs
@config.load_script "#{@ardir}/metaconfig"
end
@@ -1404,7 +1404,7 @@ class Installer
end
# picked up many entries from cvs-1.11.1/src/ignore.c
JUNK_FILES = %w(
JUNK_FILES = %w(
core RCSLOG tags TAGS .make.state
.nse_depinfo #* .#* cvslog.* ,* .del-* *.olb
*~ *.old *.bak *.BAK *.orig *.rej _$* *$

View File

@@ -3,9 +3,9 @@ require './test/test_helper.rb'
class TestImageSize < Test::Unit::TestCase
def setup
@files = ['4_1_2.gif', '2-4-7.png', 'tokyo_tower.jpg', 'bmp.bmp',
'ppm.ppm', 'pgm.pgm', 'pbm.pbm',
'cursor.xbm', 'tiff.tiff', 'test.xpm',
@files = ['4_1_2.gif', '2-4-7.png', 'tokyo_tower.jpg', 'bmp.bmp',
'ppm.ppm', 'pgm.pgm', 'pbm.pbm',
'cursor.xbm', 'tiff.tiff', 'test.xpm',
'tower_e.gif.psd', 'detect.swf']
@results = [
['GIF' ,668,481],