This commit is contained in:
Loic Nageleisen 2017-03-01 09:34:43 +01:00
parent 2155aa8d43
commit 619837da62
3 changed files with 52 additions and 5 deletions

32
.rubocop.yml Normal file
View file

@ -0,0 +1,32 @@
inherit_from: .rubocop_todo.yml
Metrics/LineLength:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Style/Documentation:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
Metrics/ModuleLength:
Enabled: false
Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: comma
Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma
Style/NestedParenthesizedCalls:
Enabled: false
Style/BracesAroundHashParameters:
Exclude:
- 'test/test_*.rb'
Style/IndentArray:
EnforcedStyle: consistent

15
.rubocop_todo.yml Normal file
View file

@ -0,0 +1,15 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-02-28 19:06:39 +0100 using RuboCop version 0.47.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: prefer_alias, prefer_alias_method
Style/Alias:
Exclude:
- 'test/helper.rb'

View file

@ -105,7 +105,7 @@ module Rebel::SQL
end end
def update(table_name, set: nil, where: nil, inner: nil, left: nil, right: nil) def update(table_name, set: nil, where: nil, inner: nil, left: nil, right: nil)
fail ArgumentError if set.nil? raise ArgumentError if set.nil?
<<-SQL <<-SQL
UPDATE #{Rebel::SQL.name(table_name)} UPDATE #{Rebel::SQL.name(table_name)}
@ -180,9 +180,9 @@ module Rebel::SQL
case v case v
when Raw then v when Raw then v
when String then raw "'#{v.tr("'", "''")}'" when String then raw "'#{v.tr("'", "''")}'"
when Fixnum, Bignum, Integer then raw v.to_s when Integer then raw v.to_s
when nil then raw 'NULL' when nil then raw 'NULL'
else fail NotImplementedError, v.inspect else raise NotImplementedError, v.inspect
end end
end end
@ -218,7 +218,7 @@ module Rebel::SQL
case e case e
when Array then clause_term(e[0], e[1]) when Array then clause_term(e[0], e[1])
when Raw, String then e when Raw, String then e
else fail NotImplementedError, e.class else raise NotImplementedError, e.class
end end
end.join(' AND ') end.join(' AND ')
end end
@ -226,7 +226,7 @@ module Rebel::SQL
def where?(clause) def where?(clause)
return "WHERE #{clause}" if clause.is_a?(Raw) || clause.is_a?(String) return "WHERE #{clause}" if clause.is_a?(Raw) || clause.is_a?(String)
(clause && clause.any?) ? "WHERE #{Rebel::SQL.and_clause(clause)}" : nil clause && clause.any? ? "WHERE #{Rebel::SQL.and_clause(clause)}" : nil
end end
def inner?(join) def inner?(join)