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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79af904e67bbb7df082dd34d5b41c3ed63675404242b4d065b10eb3689385398
4
- data.tar.gz: 9aaa8a8c1c569a859e3081c664385c92abc84a0655bb2767a5497c8f4e1e83b8
3
+ metadata.gz: 6b0e6a4be67267122c3266f9175d2b83d478a944d792181448b527c216f0cd97
4
+ data.tar.gz: 57d5986d1b771f127406907559307bf52532180740b9218a2cd9c4f06a7f6c1a
5
5
  SHA512:
6
- metadata.gz: bf499763ac20ce1c5d51129b716d6beb177cedd452516049735713a34ed31064b295dc330275fa137aa6a51371df8f54a24a83d82f1c56ba2d23275b1c63103b
7
- data.tar.gz: 92ae4a8f89aa098d16359ffbd14a6bec758b4eb832b7bde97b24c8a366575b3b1f51d54c67b77f682ebdfe64d3d50e8c9be2a94f1236718b468bf757ba96e663
6
+ metadata.gz: e0e976186f26f5f9e035fb82da3019a3235cc04a8a4bf18ea83719c76a2950151d1aab8b3d05796a0d08332f454200f688474ff703bf5af9f6f6ea483b8c54b1
7
+ data.tar.gz: 8946a732884faac5ed0bfd739f78e1f29a01745a7952c7fb53439464839007506fdc0eb6ebe98cf43b9cae615714120aff5d6319ff00a9de678afebc63ef8198
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geo_scaffold (0.1.1)
4
+ geo_scaffold (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -24,22 +24,23 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
- Generate a model for a new resource that has coordinates.
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 model <resource name> name:string lng:float lat:float
31
+ % bin/rails g geo_scaffold:scaffold <resource name> name:string lat:float lng:float
31
32
  ```
32
33
 
33
- Run the migration.
34
+ You may add attachment column like `photo` and it will be handled as an image.
34
35
 
35
36
  ```
36
- % bin/rails db:migrate
37
+ % bin/rails g geo_scaffold:scaffold <resource name> name:string photo:attachment lat:float lng:float
37
38
  ```
38
39
 
39
- Use GeoScaffold generator to create controllers and views.
40
+ Run the migration.
40
41
 
41
42
  ```
42
- % bin/rails g geo_scaffold:controller <resource name>
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 ControllerGenerator < Rails::Generators::NamedBase
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
- class_name.constantize.columns.reject do |column|
45
- column.name.to_s =~ /^(id|created_at|updated_at)$/
46
- end
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
- model_columns_for_attributes.map do |column|
51
- Rails::Generators::GeneratedAttribute.new(column.name.to_s, column.type.to_s)
52
- end
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 <%= controller_class_name %>Controller < ApplicationController
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
- <%= singular_table_name %>.attributes.except("id", "created_at", "updated_at", "lat", "lng").map do |key, value|
4
- "<strong>#{key}</strong> #{key == 'name' ? link_to(value, <%= singular_table_name %>) : value }<br />"
5
- end.join.html_safe
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GeoScaffold
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
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.2
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-17 00:00:00.000000000 Z
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.26
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: []