Skip to content

Commit

Permalink
rubocop fix Style/AlignParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinKo committed Apr 8, 2015
1 parent f30e9f0 commit b7fac7e
Show file tree
Hide file tree
Showing 21 changed files with 157 additions and 141 deletions.
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ Rails/Validation:
Style/AccessorMethodName:
Enabled: false

# Offense count: 46
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/AlignParameters:
Enabled: false

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Expand Down
36 changes: 20 additions & 16 deletions app/controllers/exports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
class ExportsController < ApplicationController

def show
# Generate a Tempfile for the download
csv = Tempfile.new "export", encoding: 'utf-8'
#export_type = ''
# Generate a Tempfile for the download
csv = Tempfile.new "export", encoding: 'utf-8'
#export_type = ''

#if params && params[:kind_of_article] == 'seller_line_item_groups'
# LineItemGroupExporter.export(csv, current_user, params)
# export_type = 'purchase'
#else
#
# ArticleExporter.export(csv, current_user, params[:kind_of_article])
# export_type = 'article'
#end
ArticleExporter.export(csv, current_user, params[:kind_of_article])
#if params && params[:kind_of_article] == 'seller_line_item_groups'
# LineItemGroupExporter.export(csv, current_user, params)
# export_type = 'purchase'
#else
#
# ArticleExporter.export(csv, current_user, params[:kind_of_article])
# export_type = 'article'
#end
ArticleExporter.export(csv, current_user, params[:kind_of_article])

respond_to do |format|
format.csv { send_file csv.path,
{ type: 'text/csv; charset=utf-8' , filename: "Fairmondo_export_#{Time.now.strftime("%Y-%d-%m %H:%M:%S")}.csv"} }
end
respond_to do |format|
format.csv do
send_file csv.path,
type: 'text/csv; charset=utf-8',
filename: "Fairmondo_export_"\
"#{Time.now.strftime("%Y-%d-%m %H:%M:%S")}.csv"
end
end
end
end
8 changes: 5 additions & 3 deletions app/controllers/library_elements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ def create
current_user.library_elements.build(params.for(LibraryElement).refine)
authorize @library_element
if @library_element.save
flash[:notice] = I18n.t('library_element.notice.success',
href: library_path(@library_element.library),
title: @library_element.library_name).html_safe
flash[:notice] =
I18n.t('library_element.notice.success',
href: library_path(@library_element.library),
title: @library_element.library_name
).html_safe
end

redirect_to :back
Expand Down
6 changes: 4 additions & 2 deletions app/controllers/mass_uploads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ def show
@erroneous_articles = @mass_upload.erroneous_articles.page(params[:erroneous_articles_page])

respond_with @mass_upload do |format|
format.csv { send_data ArticleExporter.export_erroneous_articles(@mass_upload.erroneous_articles),
{filename: "Fairmondo_export_errors_#{Time.now.strftime("%Y-%d-%m %H:%M:%S")}.csv"} }
format.csv do
send_data ArticleExporter.export_erroneous_articles(@mass_upload.erroneous_articles),
filename: "Fairmondo_export_errors_#{Time.now.strftime("%Y-%d-%m %H:%M:%S")}.csv"
end
end
end

Expand Down
5 changes: 3 additions & 2 deletions app/inputs/plain_radio_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ def choice_html(choice)
opts["data-select-toggle"] ||= css_class
end

template.content_tag(:label,
template.content_tag(
:label,
(builder.radio_button(input_name, choice_value(choice), opts.merge(choice_html_options(choice)).merge(:required => false)) << choice_label(choice)).html_safe,
label_html_options.merge(:for => choice_input_dom_id(choice), :class => nil)
label_html_options.merge(:for => choice_input_dom_id(choice), :class => nil)
)
end

Expand Down
6 changes: 3 additions & 3 deletions app/models/article/associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ module Article::Associations
has_many :mass_uploads, through: :mass_upload_articles

belongs_to :friendly_percent_organisation,
class_name: 'User', foreign_key: 'friendly_percent_organisation_id'
class_name: 'User', foreign_key: 'friendly_percent_organisation_id'
belongs_to :discount

# images

has_many :images, class_name: "ArticleImage", foreign_key: "imageable_id", autosave: true
has_many :thumbnails, -> { reorder('is_title DESC, id ASC').offset(1) },
class_name: "ArticleImage", foreign_key: "imageable_id"
class_name: "ArticleImage", foreign_key: "imageable_id"
has_one :title_image, -> { reorder('is_title DESC, id ASC') },
class_name: "ArticleImage", foreign_key: "imageable_id"
class_name: "ArticleImage", foreign_key: "imageable_id"

accepts_nested_attributes_for :images, allow_destroy: true

Expand Down
65 changes: 36 additions & 29 deletions app/models/images/article_image.rb
Original file line number Diff line number Diff line change
@@ -1,39 +1,46 @@
class ArticleImage < Image
extend STI
PROCESSING_IMAGE_URL = "pending.png"

has_attached_file :image,
styles: {
original: {geometry: "900>x600>", animated: false},
medium: {geometry: "520>x360>", animated: false},
thumb: {geometry: "280x200>", animated: false}
},
convert_options: {
medium: "-quality 75 -strip",
thumb: "-quality 75 -strip -background white -gravity center -extent 260x180"
},
default_url: "missing.png",
url: "/system/images/:id_partition/:style/:filename",
path: "public/system/images/:id_partition/:style/:filename"
PROCESSING_IMAGE_URL = 'pending.png'

process_in_background :image, :processing_image_url => PROCESSING_IMAGE_URL
has_attached_file(
:image,
styles: {
original: { geometry: '900>x600>', animated: false },
medium: { geometry: '520>x360>', animated: false },
thumb: { geometry: '280x200>', animated: false }
},
convert_options: {
medium: '-quality 75 -strip',
thumb: '-quality 75 -strip -background white -gravity center -extent 260x180'
},
default_url: 'missing.png',
url: '/system/images/:id_partition/:style/:filename',
path: 'public/system/images/:id_partition/:style/:filename'
)

validates_attachment_presence :image, :unless => :external_url
validates_attachment_content_type :image,:content_type => ['image/jpeg', 'image/png', 'image/gif']
validates_attachment_size :image, :in => 1..20.megabytes # the 1 means one byte, not one megabyte
process_in_background :image, processing_image_url: PROCESSING_IMAGE_URL

belongs_to :article, foreign_key: "imageable_id"
validates_attachment_presence :image, unless: :external_url
validates_attachment_content_type :image,
content_type: %w(
image/jpeg image/png image/gif
)
validates_attachment_size :image, in: 1..20.megabytes # the 1 means one byte, not one megabyte

def original_image_url_while_processing
Paperclip::Interpolations.interpolate ArticleImage.paperclip_definitions[:image][:url] , self.image, :original
end
belongs_to :article, foreign_key: 'imageable_id'

def url_or_original_while_processing style = :thumb
if image.processing?
original_image_url_while_processing
else
image.url(style)
end
end
def original_image_url_while_processing
Paperclip::Interpolations.interpolate(
ArticleImage.paperclip_definitions[:image][:url], self.image, :original
)
end

def url_or_original_while_processing style = :thumb
if image.processing?
original_image_url_while_processing
else
image.url(style)
end
end
end
18 changes: 10 additions & 8 deletions app/models/images/feedback_image.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
class FeedbackImage < Image
extend STI

has_attached_file :image,
has_attached_file(
:image,
styles: {
original: {geometry: "300>x300>", animated: false}
original: { geometry: '300>x300>', animated: false }
},
default_url: "/assets/missing.png",
url: "/system/images/:id_partition/:style/:filename",
path: "public/system/images/:id_partition/:style/:filename"
default_url: '/assets/missing.png',
url: '/system/images/:id_partition/:style/:filename',
path: 'public/system/images/:id_partition/:style/:filename'
)

belongs_to :feedback, foreign_key: "imageable_id"
belongs_to :feedback, foreign_key: 'imageable_id'

validates_attachment_presence :image, unless: :external_url
validates_attachment_content_type :image, content_type: ['image/jpeg', 'image/png']
validates_attachment_content_type :image,
content_type: %w(image/jpeg image/png)
validates_attachment_size :image, in: 0..2.megabytes

end
27 changes: 16 additions & 11 deletions app/models/images/user_image.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
class UserImage < Image
extend STI
has_attached_file :image,
has_attached_file(
:image,
styles: {
original: {geometry: "300>x300>", animated: false},
profile: {geometry: "300x300>", animated: false}
original: { geometry: '300>x300>', animated: false },
profile: { geometry: '300x300>', animated: false }
},
convert_options: { profile: "-quality 75 -strip -background white -gravity center -extent 300x300" },
default_url: "/assets/missing.png",
url: "/system/images/:id_partition/:style/:filename",
path: "public/system/images/:id_partition/:style/:filename",
convert_options: { profile: '-quality 75 -strip -background white -gravity center -extent 300x300' },
default_url: '/assets/missing.png',
url: '/system/images/:id_partition/:style/:filename',
path: 'public/system/images/:id_partition/:style/:filename',
only_process: [:profile]
)

belongs_to :user, foreign_key: "imageable_id"
belongs_to :user, foreign_key: 'imageable_id'

validates_attachment_presence :image, :unless => :external_url
validates_attachment_content_type :image,:content_type => ['image/jpeg', 'image/png', 'image/gif']
validates_attachment_size :image, :in => 1..20.megabytes # the 1 means one byte, not one megabyte
validates_attachment_presence :image, unless: :external_url
validates_attachment_content_type :image,
content_type: %w(
image/jpeg image/png image/gif
)
validates_attachment_size :image, in: 1..20.megabytes # the 1 means one byte, not one megabyte
end
14 changes: 7 additions & 7 deletions app/objects/abaci/business_transaction_abacus.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class BusinessTransactionAbacus

attr_reader :prices,
:by_payment,
:single_transports,
:unified_transport,
:total_retail_price,
:total_net_price,
:total_vat,
:line_item_group
:by_payment,
:single_transports,
:unified_transport,
:total_retail_price,
:total_net_price,
:total_vat,
:line_item_group

def self.calculate line_item_group
abacus = BusinessTransactionAbacus.new(line_item_group)
Expand Down
2 changes: 1 addition & 1 deletion app/validators/common_sense_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def validate_each(record, attribute, selected_payment)
def common_sense_check selected_payment, selected_transport
if (selected_payment == 'cash_on_delivery' && selected_transport == 'pickup') or (selected_payment == 'cash' && selected_transport != 'pickup')
I18n.t 'transaction.errors.combination_invalid',
selected_payment: I18n.t("enumerize.business_transaction.selected_payment.#{selected_payment}")
selected_payment: I18n.t("enumerize.business_transaction.selected_payment.#{selected_payment}")
elsif (selected_payment != 'paypal' && selected_transport == 'bike_courier')
I18n.t 'transaction.errors.bike_courier_requires_paypal'
end
Expand Down
2 changes: 1 addition & 1 deletion app/validators/size_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def add_error(record, attribute, msg_key, count)
end

msg = I18n.t("#{msg_key}_#{attribute}",
:default => default, :scope => ["errors.messages"], :count => count)
:default => default, :scope => ["errors.messages"], :count => count)

attrs = options[:add_errors_to] || [attribute]
attrs.each do |attr|
Expand Down
12 changes: 4 additions & 8 deletions lib/autoload/fairtastic/inputs/base/input_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ def input_step(step_key, options = {}, &block)
@input_step_with_errors = false
end

template.content_tag(:div,
step_heading_html(step_key, options) << template.content_tag(:div,block_content, :class => "Accordion-content" ) ,
:class => css, :id => "#{step_key}_step"
template.content_tag(
:div,
step_heading_html(step_key, options) << template.content_tag(:div,block_content, :class => "Accordion-content" ),
:class => css, :id => "#{step_key}_step"
)


end

private
Expand All @@ -67,8 +66,6 @@ def step_heading_html(step_key, options = {})
end
tooltip = optional_tooltip_html("#{step_key}_input_step", options)
template.content_tag(:a, template.content_tag(:i,"", :class => "icon-arrow") << prefix.html_safe << (localized_string(step_key, object, "input_steps") || "").html_safe << tooltip, :href => "##{step_key}_step" ,:class => "Accordion-header")


end

def optional_tooltip_html(method, options = {})
Expand All @@ -80,7 +77,6 @@ def optional_tooltip_html(method, options = {})
""
end
end

end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/autoload/sanitization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def create_html_safe_method_for_tiny_mce field, options
# TinyMCE contents are assumed to have HTML content and are now sanitized. So we can always give them the html_safe flag.
if options[:method] == 'tiny_mce'
define_method "#{ field }_with_html_safe",
Proc.new {
orig = send("#{ field }_without_html_safe")
orig.is_a?(String) ? orig.html_safe : orig
}
Proc.new {
orig = send("#{ field }_without_html_safe")
orig.is_a?(String) ? orig.html_safe : orig
}
define_method field, -> { read_attribute field } #no idea why this fix is needed
alias_method_chain field, :html_safe
end
Expand Down
19 changes: 11 additions & 8 deletions lib/tasks/assets.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ namespace :assets do
desc 'recreate sprite images and css'
task :resprite => :environment do
require 'sprite_factory'
SpriteFactory.report = true # output report during generation
SpriteFactory.library = :chunkypng # use simple chunkypng gem to handle .png sprite generation
SpriteFactory.layout = :packed
SpriteFactory.run!('app/assets/images/sprites' ,
:style => 'scss' ,
:selector => 'span.sprite_',
:cssurl => "image-url('$IMAGE')",
:output_style => "app/assets/stylesheets/sprites.scss" )

SpriteFactory.report = true # output report during generation
SpriteFactory.library = :chunkypng # use simple chunkypng gem to handle .png sprite generation
SpriteFactory.layout = :packed
SpriteFactory.run!(
'app/assets/images/sprites',
style: 'scss',
selector: 'span.sprite_',
cssurl: "image-url('$IMAGE')",
output_style: "app/assets/stylesheets/sprites.scss"
)
end
end
Loading

0 comments on commit b7fac7e

Please sign in to comment.