Skip to content

Commit

Permalink
update 2.0.3 (#8)
Browse files Browse the repository at this point in the history
* Version 2.0.3

* Update version history [ci skip]

* fix regex for parsing spacial column types

This fixes:
1. ruby warning: `warning: character class has duplicated range: /[geography,geometry]\((.*)\)$/`
2. wrongly matches of any type for which the name ends with any of the characters: g, e, o, r, a, p, h, y, m, t

* Add tests for #259

* remove a debug comment

* Adding more syntax highlighting

for easier scannability!

* Remove unnecessary .rb from require

* Fix requires

* Autoload AbstractAdapter to avoid circular require warnings

* Remove unnecessary ::

* Use require instead of load

* Remove unnecessary require

* Load byebug on ruby 2.4

* Improve module include

* Autoload AbstractAdapter to avoid warnings

* Referencing AbstractAdapter in a void context causes void context
warning, so use `module` to define context
* Requiring "active_record/connection_adapters/abstract_adapter" causes
circular require warning

* Simplify loading railtie

* Remove requires

* Less ::

* Version 2.0.3
  • Loading branch information
stadia authored Dec 12, 2017
1 parent 2e75606 commit ae8e5a6
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 105 deletions.
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
inherit_from: .rubocop_todo.yml

Style/AlignParameters:
Layout/AlignParameters:
Enabled: false

Style/MultilineOperationIndentation:
Layout/MultilineOperationIndentation:
Enabled: false

Style/SignalException:
Expand Down
214 changes: 131 additions & 83 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,178 +1,226 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2015-12-20 14:08:37 -0700 using RuboCop version 0.35.1.
# on 2017-12-12 10:59:52 +0900 using RuboCop version 0.51.0.
# 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: 3
# Cop supports --auto-correct.
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
# Include: **/Gemfile, **/gems.rb
Bundler/OrderedGems:
Enabled: false
Exclude:
- 'Gemfile'

# Offense count: 3
Lint/HandleExceptions:
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: Include, TreatCommentsAsGroupSeparators.
# Include: **/*.gemspec
Gemspec/OrderedDependencies:
Exclude:
- 'activerecord-mysql2rgeo-adapter.gemspec'

# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Exclude:
- 'lib/active_record/connection_adapters/mysql2rgeo/arel_tosql.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb'
- 'test/basic_test.rb'
- 'test/ddl_test.rb'
- 'test/nested_class_test.rb'
- 'test/spatial_queries_test.rb'
- 'test/tasks_test.rb'
- 'test/test_helper.rb'
- 'test/spatial_types_test.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
Lint/UnusedMethodArgument:
# Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Lint/EndAlignment:
Exclude:
- 'lib/active_record/connection_adapters/mysql2rgeo/arel_tosql.rb'

# Offense count: 5
Lint/HandleExceptions:
Exclude:
- 'test/spatial_types_test.rb'
- 'test/tasks_test.rb'
- 'test/test_helper.rb'

# Offense count: 3
Lint/RescueWithoutErrorClass:
Exclude:
- 'lib/active_record/type/spatial.rb'

# Offense count: 2
Lint/UselessAssignment:
Exclude:
- 'lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb'

# Offense count: 31
Metrics/AbcSize:
Max: 56
Max: 54

# Offense count: 4
# Offense count: 3
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 282
Max: 244

# Offense count: 2
# Offense count: 3
Metrics/CyclomaticComplexity:
Max: 9
Max: 12

# Offense count: 96
# Configuration parameters: AllowURI, URISchemes.
# Offense count: 72
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 143
Max: 176

# Offense count: 24
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 24
Max: 29

# Offense count: 3
# Offense count: 2
# Configuration parameters: CountKeywordArgs.
Metrics/ParameterLists:
Max: 8

# Offense count: 2
# Offense count: 4
Metrics/PerceivedComplexity:
Max: 10
Max: 12

# Offense count: 1
Naming/AccessorMethodName:
Exclude:
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb'

# Offense count: 1
Naming/ConstantName:
Exclude:
- 'lib/active_record/connection_adapters/mysql2rgeo/arel_tosql.rb'

# Offense count: 1
Style/AccessorMethodName:
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'lib/activerecord-mysql2rgeo-adapter.rb'

# Offense count: 2
# Configuration parameters: SupportedStyles.
# SupportedStyles: snake_case, camelCase
Naming/MethodName:
EnforcedStyle: snake_case

# Offense count: 2
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
# NameWhitelist: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
Exclude:
- 'spec/**/*'
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb'

# Offense count: 1
Security/Eval:
Exclude:
- 'test/spatial_types_test.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: prefer_alias, prefer_alias_method
Style/Alias:
Exclude:
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb'

# Offense count: 2
Style/CaseEquality:
Exclude:
- 'lib/active_record/type/spatial.rb'

# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'test/test_helper.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Keywords.
# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW
Style/CommentAnnotation:
Exclude:
- 'lib/active_record/type/spatial.rb'

# Offense count: 1
Style/ConstantName:
Exclude:
- 'lib/active_record/connection_adapters/mysql2rgeo/arel_tosql.rb'

# Offense count: 7
# Configuration parameters: Exclude.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/active_record/connection_adapters/mysql2rgeo/column_methods.rb'
- 'lib/active_record/type/spatial.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_expressions.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/version.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo_adapter.rb'

# Offense count: 7
Style/DoubleNegation:
Exclude:
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb'

# Offense count: 32
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Style/ExtraSpacing:
Exclude:
- 'lib/active_record/connection_adapters/mysql2rgeo/arel_tosql.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/create_connection.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb'
- 'test/basic_test.rb'
- 'test/ddl_test.rb'
- 'test/nested_class_test.rb'
- 'test/spatial_queries_test.rb'
- 'test/tasks_test.rb'

# Offense count: 1
# Configuration parameters: Exclude.
Style/FileName:
Exclude:
- 'lib/activerecord-mysql2rgeo-adapter.rb'

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/FirstParameterIndentation:
Exclude:
- 'activerecord-mysql2rgeo-adapter.gemspec'

# Offense count: 2
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/active_record/connection_adapters/mysql2rgeo/create_connection.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb'

# Offense count: 3
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Exclude:
- 'lib/active_record/type/spatial.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb'

# Offense count: 2
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MethodName:
Enabled: false
# Offense count: 1
Style/MultipleComparison:
Exclude:
- 'lib/active_record/type/spatial.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
EnforcedStyle: comparison
Exclude:
- 'spec/**/*'
- 'lib/active_record/connection_adapters/mysql2rgeo_adapter.rb'

# Offense count: 1
# Cop supports --auto-correct.
Style/ParallelAssignment:
Exclude:
- 'lib/active_record/type/spatial.rb'

# Offense count: 5
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
Style/PredicateName:
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_column.rb'
- 'Rakefile'
- 'lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb'

# Offense count: 5
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
Style/TrivialAccessors:
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'lib/active_record/connection_adapters/mysql2rgeo/schema_statements.rb'
- 'lib/active_record/connection_adapters/mysql2rgeo/spatial_table_definition.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: MinSize, SupportedStyles.
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: brackets
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ gem "mysql2", "~> 0.4.4", platform: :ruby
gem "jdbc-mysql", platform: :jruby
gem "activerecord-jdbc-adapter", "~> 5.0.pre1", platform: :jruby
gem "ffi-geos", platform: :jruby
gem "byebug", platform: :mri_23
gem "byebug", platform: :mri_24
8 changes: 8 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### 2.0.3 / 2017-11-09

* Improve requires, fix warnings #268
* Improve readme #264
* Fix Travis #261
* Remove comment #260
* Fix regex for parsing spacial column types #259

### 2.0.2 / 2017-11-08

* Fix activerecord gem dependency
Expand Down
2 changes: 1 addition & 1 deletion activerecord-mysql2rgeo-adapter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = ">= 2.2.2"

spec.add_dependency "activerecord", "~> 5.1"
spec.add_dependency "rgeo-activerecord", "< 5.1.1"
spec.add_dependency "rgeo-activerecord", "~> 5.1"

spec.add_development_dependency "rake", "~> 12.0"
spec.add_development_dependency "minitest", "~> 5.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ def new_column(*args)
end

def type_to_sql(type, limit: nil, precision: nil, scale: nil, unsigned: nil, **) # :nodoc:
if (info = spatial_column_constructor(type.to_sym))
if (info = RGeo::ActiveRecord.geometric_type_from_name(type.to_s.delete("_")))
type = limit[:type] || type if limit.is_a?(::Hash)
type = 'geometry' if type.to_s.eql? 'spatial'
type = :geometry if type.eql? :spatial
type = type.to_s.delete("_").upcase
end
super
end

def spatial_column_constructor(name)
RGeo::ActiveRecord::DEFAULT_SPATIAL_COLUMN_CONSTRUCTORS[name]
end

# override
def native_database_types
# Add spatial types
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module ActiveRecord
module ConnectionAdapters
module Mysql2Rgeo
VERSION = "2.0.2".freeze
VERSION = "2.0.3".freeze
end
end
end
Loading

0 comments on commit ae8e5a6

Please sign in to comment.