decent_ham 0.0.3 → 0.0.4

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: ef2ab4ac4bcea5f49f0fc522c44d97863fdad728
4
- data.tar.gz: eab7d0ba3f8b4684f75ac1c1fce9e995743c7ff7
3
+ metadata.gz: 2432af19ed3b2ecdc446888996f690f46d5c3842
4
+ data.tar.gz: 561f0748c8006bd4ec254dae85dd9eaf6e637cec
5
5
  SHA512:
6
- metadata.gz: d7f8f191d3c3b570805bc227902083ae66a7d956cdd2ad42f9b3a6d27a03683b589b9aa570a8a25a31fe7dab1045bbbe492c66465ab271dd52de4f50545ec1dd
7
- data.tar.gz: 8b8a6c38a5f911444c5b9782a4013d1d5b2adc6ebc448023db56ca19c3d98e6bfd75fc09132975823cc8368e5ad32e75cc9e38de8e40de14974ef055d16da7c7
6
+ metadata.gz: 4f5d21d1981ee35332f204ffbf978a9e88697fc2c52b16665f4d4732e14210f32b11ca27640e05b408439c991683aeddbfbfbf284d0ce1d191bb6df018662472
7
+ data.tar.gz: c75803d69cb410e9bd05950abae76e740201ea646f7a25775ed2466d1e576c1f0a77adf5fb512454fa87d7b77d55a908a291a1c0f4bb985c5501f8dc1a4bb1d1
@@ -1,67 +1,70 @@
1
- class DecentHamGenerator < Rails::Generators::NamedBase
2
- source_root File.expand_path('../templates', __FILE__)
1
+ require 'rails/generators'
3
2
 
4
- def singular_name
5
- name.singularize
6
- end
3
+ module DecentHam
4
+ class DecentHamGenerator < Rails::Generators::NamedBase
5
+ source_root File.expand_path('../templates', __FILE__)
7
6
 
8
- def plural_name
9
- name
10
- end
7
+ def singular_name
8
+ name.singularize
9
+ end
11
10
 
12
- def strong_params
13
- strong_params = ":#{singular_name}_params"
14
- end
11
+ def plural_name
12
+ name
13
+ end
15
14
 
16
- def create_model
17
- template "model.rb", "app/models/#{singular_name}.rb"
18
- end
15
+ def strong_params
16
+ strong_params = ":#{singular_name}_params"
17
+ end
19
18
 
20
- def model_attributes
21
- constant_name.columns_hash.map do |key, value|
22
- OpenStruct.new(name: key, data_type: value.type)
23
- end.delete_if { |column| %w(id created_at updated_at).include? column.name }
24
- end
19
+ def create_model
20
+ template "model.rb", "app/models/#{singular_name}.rb"
21
+ end
25
22
 
26
- def create_controller
27
- @attributes = model_attributes
28
- template "controller.rb", "app/controllers/#{name}_controller.rb"
29
- end
23
+ def model_attributes
24
+ constant_name.columns_hash.map do |key, value|
25
+ OpenStruct.new(name: key, data_type: value.type)
26
+ end.delete_if { |column| %w(id created_at updated_at).include? column.name }
27
+ end
30
28
 
31
- def add_route
32
- route "resources :#{name}"
33
- end
29
+ def create_controller
30
+ @attributes = model_attributes
31
+ template "controller.rb", "app/controllers/#{name}_controller.rb"
32
+ end
34
33
 
35
- def constant_name
36
- singular_name.capitalize.constantize
37
- end
34
+ def add_route
35
+ route "resources :#{name}"
36
+ end
37
+
38
+ def constant_name
39
+ singular_name.capitalize.constantize
40
+ end
38
41
 
39
- def attach_form_fields
40
- model_attributes.each do |attribute|
41
- attribute.form_field =
42
- case attribute.data_type
43
- when :string || :decimal || :integer || :float || :references
44
- "f.text_field :#{attribute.name}"
45
- when :text
46
- "f.text_area :#{attribute.name}"
47
- when :datetime || :timestamp
48
- "f.datetime_select :#{attribute.name}"
49
- when :boolean
50
- "f.check_box :#{attribute.name}"
51
- when :date
52
- "f.date_select :#{attribute.name}"
53
- when :time
54
- "f.time_select :#{attribute.name}"
42
+ def attach_form_fields
43
+ model_attributes.each do |attribute|
44
+ attribute.form_field =
45
+ case attribute.data_type
46
+ when :string || :decimal || :integer || :float || :references
47
+ "f.text_field :#{attribute.name}"
48
+ when :text
49
+ "f.text_area :#{attribute.name}"
50
+ when :datetime || :timestamp
51
+ "f.datetime_select :#{attribute.name}"
52
+ when :boolean
53
+ "f.check_box :#{attribute.name}"
54
+ when :date
55
+ "f.date_select :#{attribute.name}"
56
+ when :time
57
+ "f.time_select :#{attribute.name}"
58
+ end
55
59
  end
56
60
  end
57
- end
58
61
 
59
- def create_views
60
- @attributes = attach_form_fields
61
- %w(index new edit _form show).each do |view_name|
62
- template "#{view_name}.html.haml", "app/views/#{name}/#{view_name}.html.haml"
62
+ def create_views
63
+ @attributes = attach_form_fields
64
+ %w(index new edit _form show).each do |view_name|
65
+ template "#{view_name}.html.haml", "app/views/#{name}/#{view_name}.html.haml"
66
+ end
63
67
  end
64
- end
65
68
 
69
+ end
66
70
  end
67
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decent_ham
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vic Ramon