geo_scaffold 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -6
- data/lib/generators/geo_scaffold/{controller_generator.rb → scaffold_generator.rb} +13 -11
- data/lib/generators/geo_scaffold/templates/controller.rb +1 -1
- data/lib/generators/geo_scaffold/templates/helpers/helper.rb +14 -4
- data/lib/geo_scaffold/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b0e6a4be67267122c3266f9175d2b83d478a944d792181448b527c216f0cd97
|
4
|
+
data.tar.gz: 57d5986d1b771f127406907559307bf52532180740b9218a2cd9c4f06a7f6c1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0e976186f26f5f9e035fb82da3019a3235cc04a8a4bf18ea83719c76a2950151d1aab8b3d05796a0d08332f454200f688474ff703bf5af9f6f6ea483b8c54b1
|
7
|
+
data.tar.gz: 8946a732884faac5ed0bfd739f78e1f29a01745a7952c7fb53439464839007506fdc0eb6ebe98cf43b9cae615714120aff5d6319ff00a9de678afebc63ef8198
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,22 +24,23 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
|
27
|
+
Use GeoScaffold generator to create model, view and controller files.
|
28
|
+
You need to add `name` and coordinates(`lat` and `lng`) as columns.
|
28
29
|
|
29
30
|
```
|
30
|
-
% bin/rails g
|
31
|
+
% bin/rails g geo_scaffold:scaffold <resource name> name:string lat:float lng:float
|
31
32
|
```
|
32
33
|
|
33
|
-
|
34
|
+
You may add attachment column like `photo` and it will be handled as an image.
|
34
35
|
|
35
36
|
```
|
36
|
-
% bin/rails
|
37
|
+
% bin/rails g geo_scaffold:scaffold <resource name> name:string photo:attachment lat:float lng:float
|
37
38
|
```
|
38
39
|
|
39
|
-
|
40
|
+
Run the migration.
|
40
41
|
|
41
42
|
```
|
42
|
-
% bin/rails
|
43
|
+
% bin/rails db:migrate
|
43
44
|
```
|
44
45
|
|
45
46
|
## Development
|
@@ -2,7 +2,7 @@ require 'generators/geo_scaffold/generator_helpers'
|
|
2
2
|
|
3
3
|
module GeoScaffold
|
4
4
|
module Generators
|
5
|
-
class
|
5
|
+
class ScaffoldGenerator < Rails::Generators::NamedBase
|
6
6
|
include Rails::Generators::ResourceHelpers
|
7
7
|
include GeoScaffold::Generators::GeneratorHelpers
|
8
8
|
|
@@ -17,6 +17,8 @@ module GeoScaffold
|
|
17
17
|
invoke resource_route
|
18
18
|
end
|
19
19
|
|
20
|
+
hook_for :orm, as: :model
|
21
|
+
|
20
22
|
desc "Generates controller, controller_spec and views for the model with the given NAME."
|
21
23
|
|
22
24
|
def copy_controller_and_spec_files
|
@@ -40,17 +42,17 @@ module GeoScaffold
|
|
40
42
|
end
|
41
43
|
|
42
44
|
protected
|
43
|
-
def model_columns_for_attributes
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
45
|
+
# def model_columns_for_attributes
|
46
|
+
# class_name.constantize.columns.reject do |column|
|
47
|
+
# column.name.to_s =~ /^(id|created_at|updated_at)$/
|
48
|
+
# end
|
49
|
+
# end
|
48
50
|
|
49
|
-
def attributes
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
51
|
+
# def attributes
|
52
|
+
# model_columns_for_attributes.map do |column|
|
53
|
+
# Rails::Generators::GeneratedAttribute.new(column.name.to_s, column.type.to_s)
|
54
|
+
# end
|
55
|
+
# end
|
54
56
|
end
|
55
57
|
end
|
56
58
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% module_namespacing do -%>
|
2
|
-
class <%=
|
2
|
+
class <%= plural_table_name.capitalize %>Controller < ApplicationController
|
3
3
|
before_action :set_<%= singular_table_name %>, only: %i[ show edit update destroy ]
|
4
4
|
|
5
5
|
# GET <%= route_url %>
|
@@ -1,7 +1,17 @@
|
|
1
1
|
module <%= controller_class_name %>Helper
|
2
2
|
def marker_content(<%= singular_table_name %>)
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
html = ""
|
4
|
+
<% attributes.reject {|attribute| attribute.password_digest? || ["lat", "lng"].include?(attribute.column_name)}.each do |attribute| -%>
|
5
|
+
<% if attribute.attachment? -%>
|
6
|
+
|
7
|
+
# To use variant of image, you need to add 'image_processing' gem to your Gemfile."
|
8
|
+
# html << "<strong><%= attribute.human_name %>:</strong> #{image_tag <%= singular_name %>.<%= attribute.column_name %>.variant(resize: "100x100^")}<br />" if <%= singular_name %>.<%= attribute.column_name %>.attached?
|
9
|
+
html << "<strong><%= attribute.human_name %>:</strong> #{image_tag <%= singular_name %>.<%= attribute.column_name %>}<br />" if <%= singular_name %>.<%= attribute.column_name %>.attached?
|
10
|
+
|
11
|
+
<% else -%>
|
12
|
+
html << "<strong><%= attribute.human_name %>:</strong> #{<%= singular_name %>.<%= attribute.column_name %>}<br />"
|
13
|
+
<% end -%>
|
14
|
+
<% end -%>
|
15
|
+
return html.html_safe
|
6
16
|
end
|
7
|
-
end
|
17
|
+
end
|
data/lib/geo_scaffold/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geo_scaffold
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Junya Ishihara
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: GeoScaffold generates views with Geolonia Maps for a new resource that
|
14
14
|
has coordinates(lat and lng).
|
@@ -30,8 +30,8 @@ files:
|
|
30
30
|
- bin/console
|
31
31
|
- bin/setup
|
32
32
|
- geo_scaffold_demo.gif
|
33
|
-
- lib/generators/geo_scaffold/controller_generator.rb
|
34
33
|
- lib/generators/geo_scaffold/generator_helpers.rb
|
34
|
+
- lib/generators/geo_scaffold/scaffold_generator.rb
|
35
35
|
- lib/generators/geo_scaffold/templates/controller.rb
|
36
36
|
- lib/generators/geo_scaffold/templates/helpers/helper.rb
|
37
37
|
- lib/generators/geo_scaffold/templates/views/_form.html.erb
|
@@ -52,7 +52,7 @@ metadata:
|
|
52
52
|
homepage_uri: https://github.com/champierre/geo_scaffold
|
53
53
|
source_code_uri: https://github.com/champierre/geo_scaffold
|
54
54
|
changelog_uri: https://github.com/champierre/geo_scaffold
|
55
|
-
post_install_message:
|
55
|
+
post_install_message:
|
56
56
|
rdoc_options: []
|
57
57
|
require_paths:
|
58
58
|
- lib
|
@@ -67,8 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
|
-
rubygems_version: 3.3
|
71
|
-
signing_key:
|
70
|
+
rubygems_version: 3.0.3
|
71
|
+
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: GeoScaffold
|
74
74
|
test_files: []
|