armg 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/README.md +36 -0
- data/lib/armg/mysql_geometry.rb +10 -2
- data/lib/armg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87b091745ad8e4956f0fe1d82c5550d6c700feeb34541fef66e96309f3bcf09c
|
4
|
+
data.tar.gz: 0a045f637a8914a492cf93579f85399a6510183e23425ea152e864a81d9f8d8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e448dc89ea4e86c696a06a7e16ea09634a729347592ddfe0372ee9dd18dbda6f243f5313f05b2f84872171c84585c69def8207cf4a8aa6f0d2b0ab9006a5a2ca
|
7
|
+
data.tar.gz: 9f426744830c050aa10152aa062232dc1bf9758b819c768b600f582c07ae3099acbb4413d43f2180c1b1a76593636192c6d06817770540922aef14abb895b845
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -113,6 +113,42 @@ bundle exec appraisal ar51 rake
|
|
113
113
|
# ARMG_TEST_MYSQL_PORT=10057 ARMG_TEST_MYSQL_ENGINE=InnoDB bundle exec appraisal ar51 rake
|
114
114
|
```
|
115
115
|
|
116
|
+
## Using with [Ridgepole](https://github.com/winebarrel/ridgepole)
|
117
|
+
|
118
|
+
You need to extend the TableDefinition class.
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
# ridgepole-geo.rb
|
122
|
+
module Ridgepole
|
123
|
+
class DSLParser
|
124
|
+
class TableDefinition
|
125
|
+
def geometry(*args)
|
126
|
+
options = args.extract_options!
|
127
|
+
column_names = args
|
128
|
+
column_names.each { |name| column(name, :geometry, options) }
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
135
|
+
```sh
|
136
|
+
$ ridgepole -c 'mysql2://root@127.0.0.1:10057/armg_test' -r armg -e > Schemafile
|
137
|
+
|
138
|
+
$ cat Schemafile
|
139
|
+
# Export Schema
|
140
|
+
create_table "geoms", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
141
|
+
t.geometry "location", null: false
|
142
|
+
t.string "name"
|
143
|
+
t.index ["location"], name: "idx_location", length: 32, type: :spatial
|
144
|
+
t.index ["name"], name: "idx_name", length: 10
|
145
|
+
end
|
146
|
+
|
147
|
+
$ ridgepole -c 'mysql2://root@127.0.0.1:10057/armg_test' -r armg,ridgepole-geo -a
|
148
|
+
Apply `Schemafile`
|
149
|
+
No change
|
150
|
+
```
|
151
|
+
|
116
152
|
## Related links
|
117
153
|
|
118
154
|
* [rgeo/rgeo: Geospatial data library for Ruby](https://github.com/rgeo/rgeo)
|
data/lib/armg/mysql_geometry.rb
CHANGED
@@ -6,9 +6,16 @@ module Armg
|
|
6
6
|
:geometry
|
7
7
|
end
|
8
8
|
|
9
|
+
def binary?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
9
13
|
def deserialize(value)
|
10
|
-
|
14
|
+
case value
|
15
|
+
when ::String
|
11
16
|
Armg.deserializer.deserialize(value)
|
17
|
+
when ActiveModel::Type::Binary::Data
|
18
|
+
Armg.deserializer.deserialize(value.to_s)
|
12
19
|
else
|
13
20
|
value
|
14
21
|
end
|
@@ -18,7 +25,8 @@ module Armg
|
|
18
25
|
if value.nil?
|
19
26
|
nil
|
20
27
|
else
|
21
|
-
Armg.serializer.serialize(value)
|
28
|
+
value = Armg.serializer.serialize(value)
|
29
|
+
ActiveModel::Type::Binary::Data.new(value)
|
22
30
|
end
|
23
31
|
end
|
24
32
|
end
|
data/lib/armg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: armg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|