Skip to content

Commit

Permalink
rubocop changes
Browse files Browse the repository at this point in the history
  • Loading branch information
leikind committed Jul 15, 2015
1 parent e0bc392 commit 77502b4
Show file tree
Hide file tree
Showing 36 changed files with 1,063 additions and 756 deletions.
521 changes: 521 additions & 0 deletions .rubocop.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
source 'https://rubygems.org'

gemspec
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require 'rubygems'
require 'bundler'
require 'bundler/gem_tasks'
Expand All @@ -16,7 +17,7 @@ RSpec::Core::RakeTask.new(:spec)
require 'rubocop/rake_task'
desc 'Run RuboCop on the lib directory'
RuboCop::RakeTask.new(:rubocop) do |task|
task.patterns = ['lib/**/*.rb']
task.patterns = ['lib/**/*.rb']
# don't abort rake on failure
task.fail_on_error = false
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# encoding: utf-8
module WiceGrid #:nodoc:
module Generators #:nodoc:

class AddMigrationForSerializedQueriesGenerator < Rails::Generators::Base #:nodoc:

include Rails::Generators::Migration

desc 'Add a migration which creates a table for serialized queries'

source_root File.expand_path('../templates', __FILE__)

def self.next_migration_number(path)
Time.now.utc.strftime("%Y%m%d%H%M%S")
def self.next_migration_number(_path)
Time.now.utc.strftime('%Y%m%d%H%M%S')
end

def create_model_file
migration_template "create_wice_grid_serialized_queries.rb", "db/migrate/create_wice_grid_serialized_queries.rb"
migration_template 'create_wice_grid_serialized_queries.rb', 'db/migrate/create_wice_grid_serialized_queries.rb'
end
end

end
end
4 changes: 2 additions & 2 deletions lib/generators/wice_grid/install_generator.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# encoding: utf-8
module WiceGrid #:nodoc:
module Generators #:nodoc:
class InstallGenerator < Rails::Generators::Base #:nodoc:

desc 'Copy WiceGrid wice_grid_config.rb to config/initializers, ' +
desc 'Copy WiceGrid wice_grid_config.rb to config/initializers, ' \
'wice_grid.yml to config/locales/, and wice_grid.scss to assets/stylesheets'

source_root File.expand_path('../templates', __FILE__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
class CreateWiceGridSerializedQueries < ::ActiveRecord::Migration #:nodoc:
def change #:nodoc:
create_table :wice_grid_serialized_queries do |t|
Expand Down
29 changes: 9 additions & 20 deletions lib/generators/wice_grid/templates/wice_grid_config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
if defined?(Wice::Defaults)

# Default number of rows to show per page.
Expand Down Expand Up @@ -33,7 +34,6 @@
# Default CSV field separator
Wice::Defaults::CSV_FIELD_SEPARATOR = ','


# The strategy when to show the filter.
# * <tt>:when_filtered</tt> - when the table is the result of filtering
# * <tt>:always</tt> - show the filter always
Expand All @@ -43,12 +43,10 @@
# A boolean value specifying if a change in a filter triggers reloading of the grid.
Wice::Defaults::AUTO_RELOAD = false


# SQL operator used for matching strings in string filters.
Wice::Defaults::STRING_MATCHING_OPERATOR = 'LIKE'
# STRING_MATCHING_OPERATOR = 'ILIKE' # Use this for Postgresql case-insensitive matching.


# Defining one string matching operator globally for the whole application turns is not enough
# when you connect to two databases one of which is MySQL and the other is Postgresql.
# If the key for an adapter is missing it will fall back to Wice::Defaults::STRING_MATCHING_OPERATOR
Expand All @@ -57,15 +55,12 @@
'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter' => 'ILIKE'
}



# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Advanced Filters #

# Switch of the negation checkbox in all text filters
Wice::Defaults::NEGATION_IN_STRING_FILTERS = false


# Each WiceGrid filter column is defined in two classes, one used for rendering the filter, the other
# for generating query conditions. All these columns are in lib/wice/columns/*.rb .
# File lib/wice/columns/column_processor_index.rb lists all predefined processors.
Expand All @@ -88,7 +83,6 @@
# Wice::Columns::ViewColumn, the second should be a name of conditions generator class inherited from
# Wice::Columns::ConditionsGeneratorColumn .


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Showing All Records #

Expand All @@ -107,15 +101,13 @@
# set to nil to skip the check
Wice::Defaults::SWITCH_BACK_TO_PAGINATION_FROM = nil


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Saving Queries #

# ActiveRecord model to store queries. Read the documentation for details
# QUERY_STORE_MODEL = 'WiceGridSerializedQuery'
Wice::Defaults::QUERY_STORE_MODEL = 'WiceGridSerializedQuery'


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Here go settings related to the calendar helpers #

Expand All @@ -128,47 +120,44 @@

# Format of the datetime displayed.
# If you change the format, make sure to check if +DATETIME_PARSER+ can still parse this string.
Wice::Defaults::DATETIME_FORMAT = "%Y-%m-%d %H:%M"
Wice::Defaults::DATETIME_FORMAT = '%Y-%m-%d %H:%M'

# Format of the date displayed.
# If you change the format, make sure to check if +DATE_PARSER+ can still parse this string.
Wice::Defaults::DATE_FORMAT = "%Y-%m-%d"
Wice::Defaults::DATE_FORMAT = '%Y-%m-%d'

# Format of the date displayed in jQuery's Datepicker
# If you change the format, make sure to check if +DATE_PARSER+ can still parse this string.
Wice::Defaults::DATE_FORMAT_JQUERY = "yy-mm-dd"

Wice::Defaults::DATE_FORMAT_JQUERY = 'yy-mm-dd'

# Format of the date displayed in Bootstrap's Datepicker
# If you change the format, make sure to check if +DATE_PARSER+ can still parse this string.
Wice::Defaults::DATE_FORMAT_BOOTSTRAP = "yyyy-mm-dd"

Wice::Defaults::DATE_FORMAT_BOOTSTRAP = 'yyyy-mm-dd'

# With Calendar helpers enabled the parameter sent is the string displayed. This lambda will be given a date string in the
# format defined by +DATETIME_FORMAT+ and must generate a DateTime object.
# In many cases <tt>Time.zone.parse</tt> is enough, for instance, <tt>%Y-%m-%d</tt>. If you change the format, make sure to check this code
# and modify it if needed.
Wice::Defaults::DATETIME_PARSER = lambda{|datetime_string|
Wice::Defaults::DATETIME_PARSER = lambda do|datetime_string|
if datetime_string.blank?
nil
elsif Time.zone
Time.zone.parse(datetime_string)
else
Time.parse(datetime_string)
end
}
end

# The range of years to display in jQuery Datepicker.
# It can always be changed dynamically with the following javascript:
# $( ".hasDatepicker" ).datepicker( "option", "yearRange", "2000:2042" );
Wice::Defaults::DATEPICKER_YEAR_RANGE = (from = Date.current.year - 10).to_s + ':' + (from + 15).to_s


# With Calendar helpers enabled the parameter sent is the string displayed. This lambda will be given a date string in the
# format defined by +DATETIME+ and must generate a Date object.
# In many cases <tt>Date.parse</tt> is enough, for instance, <tt>%Y-%m-%d</tt>. If you change the format, make sure to check this code
# and modify it if needed.
Wice::Defaults::DATE_PARSER = lambda{|date_string|
Wice::Defaults::DATE_PARSER = lambda do|date_string|
if date_string.blank?
nil
else
Expand All @@ -178,7 +167,7 @@
nil
end
end
}
end

# The name of the page method (should correspond to Kaminari.config.page_method_name)
Wice::Defaults::PAGE_METHOD_NAME = :page
Expand Down
14 changes: 3 additions & 11 deletions lib/wice/active_record_column_wrapper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# encoding: utf-8
module Wice

# to be mixed in into ActiveRecord::ConnectionAdapters::Column
module WiceGridExtentionToActiveRecordColumn #:nodoc:
attr_accessor :model
end



class ActiveRecordColumnWrapper #:nodoc:
def initialize(column, all_filter_params, main_table, table_alias, custom_filter_active, filter_type) #:nodoc:
@column = column
Expand All @@ -15,7 +13,6 @@ def initialize(column, all_filter_params, main_table, table_alias, custom_filter
all_filter_params, main_table, table_alias, custom_filter_active
end


def wg_initialize_request_parameters #:nodoc:
@request_params = nil
return if @all_filter_params.nil?
Expand Down Expand Up @@ -60,7 +57,7 @@ def wg_initialize_request_parameters #:nodoc:
end
end

return wg_generate_conditions, current_parameter_name
[wg_generate_conditions, current_parameter_name]
end

def wg_generate_conditions #:nodoc:
Expand Down Expand Up @@ -92,13 +89,8 @@ def model #:nodoc:
@column.model
end


def alias_or_table_name(table_alias) #:nodoc:
table_alias || @column.model.table_name
end


end


end
end
Loading

0 comments on commit 77502b4

Please sign in to comment.