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

@@ -1,12 +1,12 @@
module PostSets
class Artist < PostSets::Post
attr_reader :artist
def initialize(artist)
super(artist.name)
@artist = artist
end
def posts
::Post.tag_match(@artist.name).limit(10)
rescue ::Post::SearchError

View File

@@ -3,38 +3,38 @@ module PostSets
def has_wiki?
false
end
def wiki_page
nil
end
def has_artist?
false
end
def artist
nil
end
def is_single_tag?
false
end
def presenter
raise NotImplementedError
end
def arbitrary_sql_order_clause(ids, table_name)
if ids.empty?
return "#{table_name}.id desc"
end
conditions = []
ids.each_with_index do |x, n|
conditions << "when #{x} then #{n}"
end
"case #{table_name}.id " + conditions.join(" ") + " end"
end
end

View File

@@ -1,28 +1,28 @@
module PostSets
class Favorite < Base
attr_reader :user, :page, :favorites
def initialize(user_id, page = 1)
@user = ::User.find(user_id)
@favorites = ::Favorite.for_user(user.id).paginate(page).order("favorites.id desc")
end
def tag_array
@tag_array ||= ["fav:#{user.name}"]
end
def tag_string
tag_array.uniq.join(" ")
end
def humanized_tag_string
"fav:#{user.pretty_name}"
end
def posts
favorites.includes(:post).map(&:post)
end
def presenter
@presenter ||= ::PostSetPresenters::Favorite.new(self)
end

View File

@@ -3,26 +3,26 @@ module PostSets
module ActiveRecordExtension
attr_accessor :total_pages, :current_page
end
attr_reader :pool, :page
def initialize(pool, page = 1)
@pool = pool
@page = page
end
def offset
(current_page - 1) * limit
end
def limit
Danbooru.config.posts_per_page
end
def tag_array
["pool:#{pool.id}"]
end
def posts
@posts ||= begin
x = pool.posts(:offset => offset, :limit => limit)
@@ -32,27 +32,27 @@ module PostSets
x
end
end
def tag_string
tag_array.join("")
end
def humanized_tag_string
"pool:#{pool.pretty_name}"
end
def presenter
@presenter ||= PostSetPresenters::Pool.new(self)
end
def total_pages
(pool.post_count.to_f / limit).ceil
end
def size
posts.size
end
def current_page
[page.to_i, 1].max
end

View File

@@ -1,41 +1,41 @@
module PostSets
class Popular < Base
attr_reader :date, :scale
def initialize(date, scale)
@date = date.blank? ? Time.zone.now : Time.zone.parse(date)
@scale = scale
end
def posts
::Post.where("created_at between ? and ?", min_date.beginning_of_day, max_date.end_of_day).order("score desc").limit(limit)
end
def limit
25
end
def min_date
case scale
when "week"
date.beginning_of_week
when "month"
date.beginning_of_month
else
date
end
end
def max_date
case scale
when "week"
date.end_of_week
when "month"
date.end_of_month
else
date
end

View File

@@ -1,22 +1,22 @@
module PostSets
class Post < Base
attr_reader :tag_array, :page, :per_page
def initialize(tags, page = 1, per_page = nil)
@tag_array = Tag.scan_query(tags)
@page = page
@per_page = (per_page || Danbooru.config.posts_per_page).to_i
@per_page = 200 if @per_page > 200
end
def tag_string
@tag_string ||= tag_array.uniq.join(" ")
end
def humanized_tag_string
tag_array.slice(0, 25).join(" ").tr("_", " ")
end
def has_wiki?
tag_array.size == 1 && ::WikiPage.titled(tag_string).exists?
end
@@ -28,15 +28,15 @@ module PostSets
nil
end
end
def has_deleted?
CurrentUser.is_privileged? && tag_string !~ /status/ && ::Post.tag_match("#{tag_string} status:deleted").exists?
end
def has_explicit?
posts.any? {|x| x.rating == "e"}
end
def posts
if tag_array.size > 2 && !CurrentUser.is_privileged?
raise SearchError.new("Upgrade your account to search more than two tags at once")
@@ -45,50 +45,50 @@ module PostSets
if tag_array.any? {|x| x =~ /^source:.*\*.*pixiv/} && !CurrentUser.user.is_builder?
raise SearchError.new("Your search took too long to execute and was canceled")
end
@posts ||= begin
temp = ::Post.tag_match(tag_string).paginate(page, :count => ::Post.fast_count(tag_string), :limit => per_page)
temp.all
temp
end
end
def has_artist?
tag_array.any? && ::Artist.name_equals(tag_string).exists?
end
def artist
::Artist.name_matches(tag_string).first
end
def is_single_tag?
tag_array.size == 1
end
def is_empty_tag?
tag_array.size == 0
end
def is_pattern_search?
tag_string =~ /\*/
end
def current_page
[page.to_i, 1].max
end
def is_tag_subscription?
tag_subscription.present?
end
def tag_subscription
@tag_subscription ||= tag_array.select {|x| x =~ /^sub:/}.map {|x| x.sub(/^sub:/, "")}.first
end
def tag_subscription_tags
@tag_subscription_tags ||= TagSubscription.find_tags(tag_subscription)
end
def presenter
@presenter ||= ::PostSetPresenters::Post.new(self)
end

View File

@@ -1,7 +1,7 @@
module PostSets
class SearchError < Exception
end
class WikiPage < Post
def presenter
@presenter ||= ::PostSetPresenters::WikiPage.new(self)