armg 0.7.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e7678ce25fd09f721c2f7c3f1bede00883e9452e
4
- data.tar.gz: a20939445411bc79a773ea58eb4f9880de239190
2
+ SHA256:
3
+ metadata.gz: 799e9abfae32c77cb45dcba9d047b1993c0bd89c1c7991e6638ca57fe08df00c
4
+ data.tar.gz: 78872a397ba74eb08968f3c6e7e9173976501563304ed582d925b93ce085f920
5
5
  SHA512:
6
- metadata.gz: 591c81f706ce898945a6a72df3b4b241570c532038b8ec3352e1e81c8d13287454cf639b51b6098b06aacc79deee809537c2629998b2786d9f786eb3bc713de4
7
- data.tar.gz: 40c3a68f7de8800ee49c3b66dfc9f3e2a03540812813308a9040c902e7ae644c682c0b491482adb2be6d28a6841575d99ad7cc495abe8b7de01235dcde204c20
6
+ metadata.gz: f938016e888bf2d30cebc445c414205ea9543932b9c33c89dd2c0af6b0c2522997caee1503434cd2c6c22b635eaa496bddb5bec0b80e6b78634128e5b868259f
7
+ data.tar.gz: 18d735ba55d6504f0d784ec1b0d65527abb65d3cbf3ac7813e5a8ac05da90f2d72bd21a6928c26f1b059a43bce439896c0bad363835420497ba1a714a61a1cd2
@@ -0,0 +1,63 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ ruby:
14
+ - 2.4
15
+ - 2.5
16
+ - 2.6
17
+ - 2.7
18
+ env:
19
+ - ARMG_TEST_MYSQL_PORT=10056 ARMG_TEST_MYSQL_ENGINE=MyISAM
20
+ - ARMG_TEST_MYSQL_PORT=10057 ARMG_TEST_MYSQL_ENGINE=MyISAM
21
+ - ARMG_TEST_MYSQL_PORT=10057 ARMG_TEST_MYSQL_ENGINE=InnoDB
22
+ gemfile:
23
+ - gemfiles/ar50.gemfile
24
+ - gemfiles/ar51.gemfile
25
+ - gemfiles/ar52.gemfile
26
+ - gemfiles/ar60.gemfile
27
+ - gemfiles/ar61.gemfile
28
+ exclude:
29
+ - ruby: 2.4
30
+ gemfile: gemfiles/ar60.gemfile
31
+ - ruby: 2.4
32
+ gemfile: gemfiles/ar61.gemfile
33
+
34
+ steps:
35
+ - uses: actions/checkout@v2
36
+ - uses: actions/setup-ruby@v1
37
+ with:
38
+ ruby-version: ${{ matrix.ruby }}
39
+ - uses: actions/cache@v2
40
+ with:
41
+ path: gemfiles/vendor/bundle
42
+ key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.gemfile }}-${{ hashFiles('ridgepole.gemspec', '**/Gemfile', '${{ matrix.gemfile }}') }}
43
+ restore-keys: |
44
+ ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ matrix.gemfile }}-
45
+
46
+ - name: Setup dependencies
47
+ run: |
48
+ for i in {1..60}; do docker-compose up -d && break; sleep 1; done
49
+
50
+ gem install bundler
51
+ bundle config path vendor/bundle
52
+ bundle install --jobs 4 --retry 3
53
+
54
+ # Wait until database servers start
55
+ function mysql_ping { mysqladmin -u root -h 127.0.0.1 -P $1 ping; }
56
+ for i in {1..60}; do mysql_ping 10056 && break; sleep 1; done
57
+ for i in {1..60}; do mysql_ping 10057 && break; sleep 1; done
58
+ env:
59
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
60
+
61
+ - run: ${{ matrix.env }} bundle exec rake
62
+ env:
63
+ BUNDLE_GEMFILE: ${{ matrix.gemfile }}
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  .rspec_status
13
13
 
14
14
  /gemfiles/*.lock
15
+ /test.rb
@@ -0,0 +1,27 @@
1
+ AllCops:
2
+ Exclude:
3
+ - gemfiles/**/*
4
+ - test.rb
5
+ TargetRubyVersion: 2.4
6
+ NewCops: enable
7
+ Bundler/OrderedGems:
8
+ Include:
9
+ - "Appraisals"
10
+ Layout/LineLength:
11
+ Enabled: false
12
+ Metrics/BlockLength:
13
+ Enabled: false
14
+ Naming/MethodParameterName:
15
+ Enabled: false
16
+ Style/AccessModifierDeclarations:
17
+ Enabled: false
18
+ Style/Documentation:
19
+ Enabled: false
20
+ Style/HashEachMethods:
21
+ Enabled: true
22
+ Style/HashTransformKeys:
23
+ Enabled: true
24
+ Style/HashTransformValues:
25
+ Enabled: true
26
+ Gemspec/RequiredRubyVersion:
27
+ Enabled: false
data/Appraisals CHANGED
@@ -1,7 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  appraise 'ar50' do
2
- gem 'activerecord', '~> 5.0'
4
+ gem 'activerecord', '~> 5.0.0'
3
5
  end
4
6
 
5
7
  appraise 'ar51' do
6
- gem 'activerecord', '~> 5.1'
8
+ gem 'activerecord', '~> 5.1.0'
9
+ end
10
+
11
+ appraise 'ar52' do
12
+ gem 'activerecord', '~> 5.2.0'
13
+ end
14
+
15
+ appraise 'ar60' do
16
+ gem 'activerecord', '~> 6.0.0'
17
+ end
18
+
19
+ appraise 'ar61' do
20
+ gem 'activerecord', '~> 6.1.0'
7
21
  end
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in armg.gemspec
data/README.md CHANGED
@@ -3,7 +3,8 @@
3
3
  Add MySQL geometry type to Active Record.
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/armg.svg)](https://badge.fury.io/rb/armg)
6
- [![Build Status](https://travis-ci.org/winebarrel/armg.svg?branch=master)](https://travis-ci.org/winebarrel/armg)
6
+ [![Build Status](https://github.com/winebarrel/armg/workflows/test/badge.svg?branch=master)](https://github.com/winebarrel/armg/actions)
7
+
7
8
 
8
9
  ## Installation
9
10
 
@@ -113,6 +114,47 @@ bundle exec appraisal ar51 rake
113
114
  # ARMG_TEST_MYSQL_PORT=10057 ARMG_TEST_MYSQL_ENGINE=InnoDB bundle exec appraisal ar51 rake
114
115
  ```
115
116
 
117
+ ## Using with [Ridgepole](https://github.com/winebarrel/ridgepole)
118
+
119
+ You need to extend the TableDefinition class.
120
+
121
+ ```ruby
122
+ # ridgepole-geo.rb
123
+ module TableDefinitionExtForGeometry
124
+ def geometry(*args)
125
+ options = args.extract_options!
126
+ column_names = args
127
+ column_names.each { |name| column(name, :geometry, options) }
128
+ end
129
+ end
130
+ Ridgepole::DSLParser::TableDefinition.prepend(TableDefinitionExtForGeometry)
131
+
132
+ module DiffExtForGeometry
133
+ def normalize_index_options!(opts)
134
+ super
135
+ opts.delete(:length) if opts[:type] == :spatial
136
+ end
137
+ end
138
+ Ridgepole::Diff.prepend(DiffExtForGeometry)
139
+ ```
140
+
141
+ ```sh
142
+ $ ridgepole -c 'mysql2://root@127.0.0.1:10057/armg_test' -r armg -e > Schemafile
143
+
144
+ $ cat Schemafile
145
+ # Export Schema
146
+ create_table "geoms", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
147
+ t.geometry "location", null: false
148
+ t.string "name"
149
+ t.index ["location"], name: "idx_location", length: 32, type: :spatial
150
+ t.index ["name"], name: "idx_name", length: 10
151
+ end
152
+
153
+ $ ridgepole -c 'mysql2://root@127.0.0.1:10057/armg_test' -r armg,ridgepole-geo -a
154
+ Apply `Schemafile`
155
+ No change
156
+ ```
157
+
116
158
  ## Related links
117
159
 
118
160
  * [rgeo/rgeo: Geospatial data library for Ruby](https://github.com/rgeo/rgeo)
data/Rakefile CHANGED
@@ -1,6 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
3
6
 
4
7
  RSpec::Core::RakeTask.new(:spec)
5
8
 
6
- task :default => :spec
9
+ RuboCop::RakeTask.new do |task|
10
+ task.options = %w[-c .rubocop.yml]
11
+ end
12
+
13
+ task default: %i[rubocop spec]
@@ -1,5 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'armg/version'
5
6
 
@@ -9,8 +10,8 @@ Gem::Specification.new do |spec|
9
10
  spec.authors = ['Genki Sugawara']
10
11
  spec.email = ['sugawara@cookpad.com']
11
12
 
12
- spec.summary = %q{Add MySQL geometry type to Active Record.}
13
- spec.description = %q{Add MySQL geometry type to Active Record.}
13
+ spec.summary = 'Add MySQL geometry type to Active Record.'
14
+ spec.description = 'Add MySQL geometry type to Active Record.'
14
15
  spec.homepage = 'https://github.com/winebarrel/armg'
15
16
  spec.license = 'MIT'
16
17
 
@@ -21,12 +22,16 @@ Gem::Specification.new do |spec|
21
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
23
  spec.require_paths = ['lib']
23
24
 
24
- spec.add_dependency 'activerecord', '~> 5'
25
+ spec.add_dependency 'activerecord', '>= 5', '< 7'
25
26
  spec.add_dependency 'rgeo'
27
+ spec.add_development_dependency 'appraisal', '>= 2.2.0'
26
28
  spec.add_development_dependency 'bundler'
29
+ spec.add_development_dependency 'erbh', '>= 0.1.2'
30
+ spec.add_development_dependency 'mysql2'
27
31
  spec.add_development_dependency 'rake'
28
32
  spec.add_development_dependency 'rspec', '~> 3.0'
29
- spec.add_development_dependency 'mysql2'
30
- spec.add_development_dependency 'rspec-match_fuzzy'
31
- spec.add_development_dependency 'appraisal', '>= 2.2.0'
33
+ spec.add_development_dependency 'rspec-match_ruby', '>= 0.1.3'
34
+ spec.add_development_dependency 'rubocop', '>= 1.7.0'
35
+ spec.add_development_dependency 'rubocop-rake'
36
+ spec.add_development_dependency 'rubocop-rspec'
32
37
  end
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "armg"
4
+ require 'bundler/setup'
5
+ require 'armg'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "armg"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,4 +1,4 @@
1
- version: '2'
1
+ version: "2"
2
2
  services:
3
3
  mysql56:
4
4
  ports:
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_RETRY: "1"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.0"
5
+ gem "activerecord", "~> 5.0.0"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.1"
5
+ gem "activerecord", "~> 5.1.0"
6
6
 
7
7
  gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 5.2.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 6.0.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 6.1.0"
6
+
7
+ gemspec path: "../"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/lazy_load_hooks'
2
4
  require 'rgeo'
3
5
  require 'armg/version'
@@ -1,18 +1,20 @@
1
- module Armg::AbstractMysqlAdapterExt
2
- def initialize_type_map(m)
3
- super
4
- m.register_type %r(^geometry)i, Armg::MysqlGeometry.new
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Armg
4
+ module AbstractMysqlAdapterExt
5
+ def initialize_type_map(m = type_map)
6
+ super
7
+ m.register_type(/^geometry/i, Armg::MysqlGeometry.new)
8
+ end
6
9
 
7
- def indexes(*args, &block)
8
- is = super
10
+ def indexes(*args, &block)
11
+ is = super
9
12
 
10
- is.each do |i|
11
- if i.type == :spatial
12
- i.lengths = nil
13
+ is.each do |i|
14
+ i.lengths = nil if i.type == :spatial && i.respond_to?(:lengths=)
13
15
  end
14
- end
15
16
 
16
- is
17
+ is
18
+ end
17
19
  end
18
20
  end
@@ -1,22 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Armg
2
4
  @deserializer = Armg::WkbDeserializer.new
3
5
  @serializer = Armg::WkbSerializer.new
4
6
 
5
7
  class << self
6
- def deserializer
7
- @deserializer
8
- end
9
-
10
- def deserializer=(v)
11
- @deserializer = v
12
- end
13
-
14
- def serializer
15
- @serializer
16
- end
17
-
18
- def serializer=(v)
19
- @serializer = v
20
- end
8
+ attr_accessor :deserializer, :serializer
21
9
  end
22
10
  end
@@ -1,21 +1,33 @@
1
- class Armg::MysqlGeometry < ActiveModel::Type::Value
2
- def type
3
- :geometry
4
- end
1
+ # frozen_string_literal: true
5
2
 
6
- def deserialize(value)
7
- if value.is_a?(::String)
8
- Armg.deserializer.deserialize(value)
9
- else
10
- value
3
+ module Armg
4
+ class MysqlGeometry < ActiveModel::Type::Value
5
+ def type
6
+ :geometry
7
+ end
8
+
9
+ def binary?
10
+ true
11
+ end
12
+
13
+ def deserialize(value)
14
+ case value
15
+ when ::String
16
+ Armg.deserializer.deserialize(value)
17
+ when ActiveModel::Type::Binary::Data
18
+ Armg.deserializer.deserialize(value.to_s)
19
+ else
20
+ value
21
+ end
11
22
  end
12
- end
13
23
 
14
- def serialize(value)
15
- if value.nil?
16
- nil
17
- else
18
- Armg.serializer.serialize(value)
24
+ def serialize(value)
25
+ if value.nil?
26
+ nil
27
+ else
28
+ value = Armg.serializer.serialize(value)
29
+ ActiveModel::Type::Binary::Data.new(value)
30
+ end
19
31
  end
20
32
  end
21
33
  end
@@ -1,5 +1,9 @@
1
- module Armg::TableDefinitionExt
2
- def geometry(*args, **options)
3
- args.each { |name| column(name, :geometry, options) }
1
+ # frozen_string_literal: true
2
+
3
+ module Armg
4
+ module TableDefinitionExt
5
+ def geometry(*args, **options)
6
+ args.each { |name| column(name, :geometry, **options) }
7
+ end
4
8
  end
5
9
  end
@@ -1,15 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # see https://dev.mysql.com/doc/refman/5.7/en/gis-data-formats.html
2
- module Armg::Utils
3
- def mysql_geometry_to_wkb(mysql_geometry)
4
- mysql_geometry = mysql_geometry.b
5
- srid = mysql_geometry.slice!(0..3)
6
- mysql_geometry[4] = "\x20"
7
- mysql_geometry.insert(5, srid)
8
- end
9
- module_function :mysql_geometry_to_wkb
4
+ module Armg
5
+ module Utils
6
+ def mysql_geometry_to_wkb(mysql_geometry)
7
+ mysql_geometry = mysql_geometry.b
8
+ srid = mysql_geometry.slice!(0..3)
9
+ mysql_geometry[4] = "\x20"
10
+ mysql_geometry.insert(5, srid)
11
+ end
12
+ module_function :mysql_geometry_to_wkb
10
13
 
11
- def pack_srid(srid)
12
- [srid].pack('L<')
14
+ def pack_srid(srid)
15
+ [srid].pack('L<')
16
+ end
17
+ module_function :pack_srid
13
18
  end
14
- module_function :pack_srid
15
19
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Armg
2
- VERSION = '0.7.0'
4
+ VERSION = '0.9.0'
3
5
  end
@@ -1,15 +1,19 @@
1
- class Armg::WkbDeserializer
2
- DEFAULT_OPTIONS = {
3
- support_ewkb: true,
4
- }
1
+ # frozen_string_literal: true
5
2
 
6
- def initialize(factory: nil, **options)
7
- options = DEFAULT_OPTIONS.merge(options)
8
- @wkb_parser = RGeo::WKRep::WKBParser.new(factory, options)
9
- end
3
+ module Armg
4
+ class WkbDeserializer
5
+ DEFAULT_OPTIONS = {
6
+ support_ewkb: true
7
+ }.freeze
8
+
9
+ def initialize(factory: nil, **options)
10
+ options = DEFAULT_OPTIONS.merge(options)
11
+ @wkb_parser = RGeo::WKRep::WKBParser.new(factory, options)
12
+ end
10
13
 
11
- def deserialize(mysql_geometry)
12
- wkb = Armg::Utils.mysql_geometry_to_wkb(mysql_geometry)
13
- @wkb_parser.parse(wkb)
14
+ def deserialize(mysql_geometry)
15
+ wkb = Armg::Utils.mysql_geometry_to_wkb(mysql_geometry)
16
+ @wkb_parser.parse(wkb)
17
+ end
14
18
  end
15
19
  end
@@ -1,16 +1,20 @@
1
- class Armg::WkbSerializer
2
- DEFAULT_OPTIONS = {
3
- type_format: :ewkb,
4
- little_endian: true,
5
- }
1
+ # frozen_string_literal: true
6
2
 
7
- def initialize(**options)
8
- options = DEFAULT_OPTIONS.merge(options)
9
- @wkb_generator = RGeo::WKRep::WKBGenerator.new(options)
10
- end
3
+ module Armg
4
+ class WkbSerializer
5
+ DEFAULT_OPTIONS = {
6
+ type_format: :ewkb,
7
+ little_endian: true
8
+ }.freeze
9
+
10
+ def initialize(**options)
11
+ options = DEFAULT_OPTIONS.merge(options)
12
+ @wkb_generator = RGeo::WKRep::WKBGenerator.new(options)
13
+ end
11
14
 
12
- def serialize(obj)
13
- srid = Armg::Utils.pack_srid(obj.srid)
14
- srid + @wkb_generator.generate(obj)
15
+ def serialize(obj)
16
+ srid = Armg::Utils.pack_srid(obj.srid)
17
+ srid + @wkb_generator.generate(obj)
18
+ end
15
19
  end
16
20
  end
@@ -1,23 +1,30 @@
1
- class Armg::WktDeserializer
2
- DEFAULT_WKB_PARSER_OPTIONS = {
3
- support_ewkb: true,
4
- }
1
+ # frozen_string_literal: true
5
2
 
6
- DEFAULT_WKT_GENERATOR_OPTIONS = {
7
- tag_format: :ewkt,
8
- #emit_ewkt_srid: true,
9
- }
3
+ module Armg
4
+ class WktDeserializer
5
+ DEFAULT_WKB_PARSER_OPTIONS = {
6
+ support_ewkb: true
7
+ }.freeze
10
8
 
11
- def initialize(factory: nil, wkb_parser_options: {}, wkt_generator_options: {})
12
- @wkb_parser = RGeo::WKRep::WKBParser.new(factory,
13
- DEFAULT_WKB_PARSER_OPTIONS.merge(wkb_parser_options))
14
- @wkt_generator = RGeo::WKRep::WKTGenerator.new(
15
- DEFAULT_WKT_GENERATOR_OPTIONS.merge(wkt_generator_options))
16
- end
9
+ DEFAULT_WKT_GENERATOR_OPTIONS = {
10
+ tag_format: :ewkt
11
+ # emit_ewkt_srid: true,
12
+ }.freeze
13
+
14
+ def initialize(factory: nil, wkb_parser_options: {}, wkt_generator_options: {})
15
+ @wkb_parser = RGeo::WKRep::WKBParser.new(
16
+ factory,
17
+ DEFAULT_WKB_PARSER_OPTIONS.merge(wkb_parser_options)
18
+ )
19
+ @wkt_generator = RGeo::WKRep::WKTGenerator.new(
20
+ DEFAULT_WKT_GENERATOR_OPTIONS.merge(wkt_generator_options)
21
+ )
22
+ end
17
23
 
18
- def deserialize(mysql_geometry)
19
- wkb = Armg::Utils.mysql_geometry_to_wkb(mysql_geometry)
20
- obj = @wkb_parser.parse(wkb)
21
- @wkt_generator.generate(obj)
24
+ def deserialize(mysql_geometry)
25
+ wkb = Armg::Utils.mysql_geometry_to_wkb(mysql_geometry)
26
+ obj = @wkb_parser.parse(wkb)
27
+ @wkt_generator.generate(obj)
28
+ end
22
29
  end
23
30
  end
@@ -1,23 +1,30 @@
1
- class Armg::WktSerializer
2
- DEFAULT_WKB_GENERATOR_OPTIONS = {
3
- type_format: :ewkb,
4
- little_endian: true,
5
- }
1
+ # frozen_string_literal: true
6
2
 
7
- DEFAULT_WKT_PARSER_OPTIONS = {
8
- support_ewkt: true
9
- }
3
+ module Armg
4
+ class WktSerializer
5
+ DEFAULT_WKB_GENERATOR_OPTIONS = {
6
+ type_format: :ewkb,
7
+ little_endian: true
8
+ }.freeze
10
9
 
11
- def initialize(factory: nil, wkb_generator_options: {}, wkt_parser_options: {})
12
- @wkb_generator = RGeo::WKRep::WKBGenerator.new(
13
- DEFAULT_WKB_GENERATOR_OPTIONS.merge(wkb_generator_options))
14
- @wkt_parser = RGeo::WKRep::WKTParser.new(factory,
15
- DEFAULT_WKT_PARSER_OPTIONS.merge(wkt_parser_options))
16
- end
10
+ DEFAULT_WKT_PARSER_OPTIONS = {
11
+ support_ewkt: true
12
+ }.freeze
13
+
14
+ def initialize(factory: nil, wkb_generator_options: {}, wkt_parser_options: {})
15
+ @wkb_generator = RGeo::WKRep::WKBGenerator.new(
16
+ DEFAULT_WKB_GENERATOR_OPTIONS.merge(wkb_generator_options)
17
+ )
18
+ @wkt_parser = RGeo::WKRep::WKTParser.new(
19
+ factory,
20
+ DEFAULT_WKT_PARSER_OPTIONS.merge(wkt_parser_options)
21
+ )
22
+ end
17
23
 
18
- def serialize(wkt)
19
- obj = @wkt_parser.parse(wkt)
20
- srid = Armg::Utils.pack_srid(obj.srid)
21
- srid + @wkb_generator.generate(obj)
24
+ def serialize(wkt)
25
+ obj = @wkt_parser.parse(wkt)
26
+ srid = Armg::Utils.pack_srid(obj.srid)
27
+ srid + @wkb_generator.generate(obj)
28
+ end
22
29
  end
23
30
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: armg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-13 00:00:00.000000000 Z
11
+ date: 2020-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '5'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '5'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rgeo
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +44,20 @@ dependencies:
38
44
  - - ">="
39
45
  - !ruby/object:Gem::Version
40
46
  version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: appraisal
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.2.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.2.0
41
61
  - !ruby/object:Gem::Dependency
42
62
  name: bundler
43
63
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +72,34 @@ dependencies:
52
72
  - - ">="
53
73
  - !ruby/object:Gem::Version
54
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: erbh
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 0.1.2
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 0.1.2
89
+ - !ruby/object:Gem::Dependency
90
+ name: mysql2
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
55
103
  - !ruby/object:Gem::Dependency
56
104
  name: rake
57
105
  requirement: !ruby/object:Gem::Requirement
@@ -81,21 +129,35 @@ dependencies:
81
129
  - !ruby/object:Gem::Version
82
130
  version: '3.0'
83
131
  - !ruby/object:Gem::Dependency
84
- name: mysql2
132
+ name: rspec-match_ruby
85
133
  requirement: !ruby/object:Gem::Requirement
86
134
  requirements:
87
135
  - - ">="
88
136
  - !ruby/object:Gem::Version
89
- version: '0'
137
+ version: 0.1.3
90
138
  type: :development
91
139
  prerelease: false
92
140
  version_requirements: !ruby/object:Gem::Requirement
93
141
  requirements:
94
142
  - - ">="
95
143
  - !ruby/object:Gem::Version
96
- version: '0'
144
+ version: 0.1.3
97
145
  - !ruby/object:Gem::Dependency
98
- name: rspec-match_fuzzy
146
+ name: rubocop
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: 1.7.0
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: 1.7.0
159
+ - !ruby/object:Gem::Dependency
160
+ name: rubocop-rake
99
161
  requirement: !ruby/object:Gem::Requirement
100
162
  requirements:
101
163
  - - ">="
@@ -109,19 +171,19 @@ dependencies:
109
171
  - !ruby/object:Gem::Version
110
172
  version: '0'
111
173
  - !ruby/object:Gem::Dependency
112
- name: appraisal
174
+ name: rubocop-rspec
113
175
  requirement: !ruby/object:Gem::Requirement
114
176
  requirements:
115
177
  - - ">="
116
178
  - !ruby/object:Gem::Version
117
- version: 2.2.0
179
+ version: '0'
118
180
  type: :development
119
181
  prerelease: false
120
182
  version_requirements: !ruby/object:Gem::Requirement
121
183
  requirements:
122
184
  - - ">="
123
185
  - !ruby/object:Gem::Version
124
- version: 2.2.0
186
+ version: '0'
125
187
  description: Add MySQL geometry type to Active Record.
126
188
  email:
127
189
  - sugawara@cookpad.com
@@ -129,9 +191,10 @@ executables: []
129
191
  extensions: []
130
192
  extra_rdoc_files: []
131
193
  files:
194
+ - ".github/workflows/test.yml"
132
195
  - ".gitignore"
133
196
  - ".rspec"
134
- - ".travis.yml"
197
+ - ".rubocop.yml"
135
198
  - Appraisals
136
199
  - Gemfile
137
200
  - LICENSE.txt
@@ -141,8 +204,12 @@ files:
141
204
  - bin/console
142
205
  - bin/setup
143
206
  - docker-compose.yml
207
+ - gemfiles/.bundle/config
144
208
  - gemfiles/ar50.gemfile
145
209
  - gemfiles/ar51.gemfile
210
+ - gemfiles/ar52.gemfile
211
+ - gemfiles/ar60.gemfile
212
+ - gemfiles/ar61.gemfile
146
213
  - lib/armg.rb
147
214
  - lib/armg/abstract_mysql_adapter_ext.rb
148
215
  - lib/armg/armg.rb
@@ -154,12 +221,11 @@ files:
154
221
  - lib/armg/wkb_serializer.rb
155
222
  - lib/armg/wkt_deserializer.rb
156
223
  - lib/armg/wkt_serializer.rb
157
- - test.rb
158
224
  homepage: https://github.com/winebarrel/armg
159
225
  licenses:
160
226
  - MIT
161
227
  metadata: {}
162
- post_install_message:
228
+ post_install_message:
163
229
  rdoc_options: []
164
230
  require_paths:
165
231
  - lib
@@ -174,9 +240,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
240
  - !ruby/object:Gem::Version
175
241
  version: '0'
176
242
  requirements: []
177
- rubyforge_project:
178
- rubygems_version: 2.5.2
179
- signing_key:
243
+ rubygems_version: 3.1.2
244
+ signing_key:
180
245
  specification_version: 4
181
246
  summary: Add MySQL geometry type to Active Record.
182
247
  test_files: []
@@ -1,30 +0,0 @@
1
- dist: trusty
2
- sudo: required
3
- group: edge
4
- services:
5
- - docker
6
- language: ruby
7
- rvm:
8
- - 2.2.7
9
- - 2.3.4
10
- - 2.4.1
11
- gemfile:
12
- - gemfiles/ar50.gemfile
13
- - gemfiles/ar51.gemfile
14
- before_install:
15
- - gem install bundler
16
- before_script:
17
- - sudo service mysql stop
18
- - docker-compose up -d
19
- - function mysql_ping { mysqladmin -u root -h 127.0.0.1 -P $1 ping; }
20
- - for i in {1..60}; do mysql_ping 10056 && break; sleep 1; done
21
- - for i in {1..60}; do mysql_ping 10057 && break; sleep 1; done
22
- cache:
23
- - bundler
24
- - apt
25
- env:
26
- - ARMG_TEST_MYSQL_PORT=10056 ARMG_TEST_MYSQL_ENGINE=MyISAM
27
- - ARMG_TEST_MYSQL_PORT=10057 ARMG_TEST_MYSQL_ENGINE=MyISAM
28
- - ARMG_TEST_MYSQL_PORT=10057 ARMG_TEST_MYSQL_ENGINE=InnoDB
29
- script:
30
- - bundle exec rake
data/test.rb DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'rgeo'
3
- a = "0101000000000000000000F03F000000000000F03F"
4
-
5
- factory = RGeo::Geographic.spherical_factory(:default_srid => 4326)
6
- parser = RGeo::WKRep::WKBParser.new(nil, support_ewkb: true, default_srid: 4326)
7
- point = parser.parse(a)
8
- p point.srid
9
-
10
- generator = RGeo::WKRep::WKTGenerator.new(tag_format: :ewkt) #, emit_ewkt_srid: true)
11
- p generator.generate(point)