firstdraft_generators 0.0.1 → 0.0.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
  SHA1:
3
- metadata.gz: a8861506b5e0befc40be62d566c2095952d33c38
4
- data.tar.gz: 3e5116e4e05e2e6bdc6280f2789927009295fe5d
3
+ metadata.gz: 05ce296f2147d9ee8589e2edf27423c29ffff329
4
+ data.tar.gz: e5ed2515799f2a788a30a5f44a8e4bce8250c54b
5
5
  SHA512:
6
- metadata.gz: 3edbb67602865e417551531f752383aa0410914aef94da0ab7e9797a8a987b482060a9df31e4b134d26f32c92ddf3c732e910ffc39c33e6145d47d565e8924a2
7
- data.tar.gz: c5adfe8cc1ad03ddbad80f872fe9929afdc4fa61678b37ab18042a2bf24cd93d5de5c2f3332a9d14a92202d2ace0b0eb5bd119dd88df1c3125ef205ec3fd90d8
6
+ metadata.gz: 6ceb91f38e6320893067b032c5084982bb1ed38757c8088b91a581e3f2e1c0b63be7cf48d9f51743ff15dcb0fd007f1c19323f83d6e02130b28ce65559923cfd
7
+ data.tar.gz: 17e633018e7d9d4f133a0558030651f87e721e6f75d6f71d5fbdeef015d96fe50d85bef686a826737c22be12fa3de19a4a2c7566e0cdfe2902562590d1e75c5e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.3
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: firstdraft_generators 0.0.1 ruby lib
5
+ # stub: firstdraft_generators 0.0.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "firstdraft_generators".freeze
9
- s.version = "0.0.1"
9
+ s.version = "0.0.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Raghu Betina".freeze]
14
- s.date = "2017-05-08"
14
+ s.date = "2017-05-20"
15
15
  s.description = "This is a set of generators that help beginners learn to program. Primarily, they generate code that is more explicit and verbose and less idiomatic and \u{201c}magical\u{201d} than the built-in scaffold generator, which is helpful for beginners while they are learning how exactly things are wired together.".freeze
16
16
  s.email = "raghu@firstdraft.com".freeze
17
17
  s.extra_rdoc_files = [
@@ -55,7 +55,7 @@ Gem::Specification.new do |s|
55
55
  ]
56
56
  s.homepage = "http://github.com/raghubetina/firstdraft_generators".freeze
57
57
  s.licenses = ["MIT".freeze]
58
- s.rubygems_version = "2.6.11".freeze
58
+ s.rubygems_version = "2.6.12".freeze
59
59
  s.summary = "Generators that help beginners learn to program.".freeze
60
60
 
61
61
  if s.respond_to? :specification_version then
@@ -52,9 +52,14 @@ module Draft
52
52
  end
53
53
 
54
54
  def app_resources
55
- route_names.reject do |name|
56
- /^rails_info.*/.match(name) || /^rails_mailers.*/.match(name) || name.pluralize != name
55
+ models = ApplicationRecord.descendants.reject do |klass|
56
+ if klass.name == "AdminUser"
57
+ true
58
+ else
59
+ false
60
+ end
57
61
  end
62
+ models.collect { |clazz| clazz.name.underscore.pluralize }
58
63
  end
59
64
 
60
65
  def devise_routes
@@ -1,10 +1,6 @@
1
+ require "rails/generators/rails/model/model_generator"
1
2
  module Draft
2
- class ModelGenerator < Rails::Generators::NamedBase
3
- argument :attributes, type: :array, default: [], banner: "field:type field:type"
4
-
5
- def generate_model
6
- invoke "active_record:model", ARGV
7
- end
3
+ class ModelGenerator < Rails::Generators::ModelGenerator
8
4
 
9
5
  def generate_active_admin
10
6
  if Gem.loaded_specs.has_key? "activeadmin"
@@ -1,25 +1,25 @@
1
1
  class <%= plural_table_name.camelize %>Controller < ApplicationController
2
2
  def index
3
- @<%= plural_table_name.underscore %> = <%= class_name %>.all
3
+ @<%= plural_table_name.underscore %> = <%= class_name.singularize %>.all
4
4
 
5
5
  render("<%= plural_table_name.underscore %>_templates/index.html.erb")
6
6
  end
7
7
 
8
8
  def show
9
- @<%= singular_table_name.underscore %> = <%= class_name %>.find(params[:id_to_display])
9
+ @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:id_to_display])
10
10
 
11
11
  render("<%= plural_table_name.underscore %>_templates/show.html.erb")
12
12
  end
13
13
 
14
14
  def new_form
15
15
  <% unless skip_validation_alerts? -%>
16
- @<%= singular_table_name.underscore %> = <%= class_name %>.new
16
+ @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.new
17
17
  <% end -%>
18
18
  render("<%= plural_table_name.underscore %>_templates/new_form.html.erb")
19
19
  end
20
20
 
21
21
  def create_row
22
- @<%= singular_table_name.underscore %> = <%= class_name %>.new
22
+ @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.new
23
23
 
24
24
  <% attributes.each do |attribute| -%>
25
25
  @<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params[:<%= attribute.column_name %>]
@@ -39,7 +39,7 @@ class <%= plural_table_name.camelize %>Controller < ApplicationController
39
39
  <% unless skip_redirect? -%>
40
40
  redirect_to("/<%= @plural_table_name.underscore %>")
41
41
  <% else -%>
42
- @current_count = <%= class_name %>.count
42
+ @current_count = <%= class_name.singularize %>.count
43
43
 
44
44
  render("<%= plural_table_name.underscore %>_templates/create_row.html.erb")
45
45
  <% end -%>
@@ -47,13 +47,13 @@ class <%= plural_table_name.camelize %>Controller < ApplicationController
47
47
  end
48
48
 
49
49
  def edit_form
50
- @<%= singular_table_name.underscore %> = <%= class_name %>.find(params[:prefill_with_id])
50
+ @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:prefill_with_id])
51
51
 
52
52
  render("<%= plural_table_name.underscore %>_templates/edit_form.html.erb")
53
53
  end
54
54
 
55
55
  def update_row
56
- @<%= singular_table_name.underscore %> = <%= class_name %>.find(params[:id_to_modify])
56
+ @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:id_to_modify])
57
57
 
58
58
  <% attributes.each do |attribute| -%>
59
59
  @<%= singular_table_name.underscore %>.<%= attribute.column_name %> = params[:<%= attribute.column_name %>]
@@ -79,7 +79,7 @@ class <%= plural_table_name.camelize %>Controller < ApplicationController
79
79
  end
80
80
 
81
81
  def destroy_row
82
- @<%= singular_table_name.underscore %> = <%= class_name %>.find(params[:id_to_remove])
82
+ @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:id_to_remove])
83
83
 
84
84
  @<%= singular_table_name.underscore %>.destroy
85
85
 
@@ -89,7 +89,7 @@ class <%= plural_table_name.camelize %>Controller < ApplicationController
89
89
  <% unless skip_redirect? -%>
90
90
  redirect_to("/<%= @plural_table_name.underscore %>")
91
91
  <% else -%>
92
- @remaining_count = <%= class_name %>.count
92
+ @remaining_count = <%= class_name.singularize %>.count
93
93
 
94
94
  render("<%= plural_table_name.underscore %>_templates/destroy_row.html.erb")
95
95
  <% end -%>
@@ -1,9 +1,9 @@
1
1
  class <%= plural_table_name.camelize %>Controller < ApplicationController
2
2
  def index
3
- @<%= plural_table_name.underscore %> = <%= class_name %>.all
3
+ @<%= plural_table_name.underscore %> = <%= class_name.singularize %>.all
4
4
  end
5
5
 
6
6
  def show
7
- @<%= singular_table_name.underscore %> = <%= class_name %>.find(params[:id])
7
+ @<%= singular_table_name.underscore %> = <%= class_name.singularize %>.find(params[:id])
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firstdraft_generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raghu Betina
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-08 00:00:00.000000000 Z
11
+ date: 2017-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  requirements: []
146
146
  rubyforge_project:
147
- rubygems_version: 2.6.11
147
+ rubygems_version: 2.6.12
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: Generators that help beginners learn to program.