prefab 1.0.0

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.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +43 -0
  3. data/.travis.yml +9 -0
  4. data/Gemfile +26 -0
  5. data/LICENSE +21 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.md +134 -0
  8. data/Rakefile +154 -0
  9. data/lib/generators/api/USAGE +8 -0
  10. data/lib/generators/api/api_generator.rb +11 -0
  11. data/lib/generators/api/templates/api.rb +8 -0
  12. data/lib/generators/api/templates/api_spec.rb +5 -0
  13. data/lib/generators/datatable/USAGE +8 -0
  14. data/lib/generators/datatable/datatable_generator.rb +12 -0
  15. data/lib/generators/datatable/templates/datatable.rb +55 -0
  16. data/lib/generators/datatable/templates/javascript.js.coffee +8 -0
  17. data/lib/generators/report/USAGE +8 -0
  18. data/lib/generators/report/report_generator.rb +12 -0
  19. data/lib/generators/report/templates/report.rb +54 -0
  20. data/lib/generators/report/templates/report_spec.rb +14 -0
  21. data/lib/generators/service/USAGE +8 -0
  22. data/lib/generators/service/service_generator.rb +11 -0
  23. data/lib/generators/service/templates/service.rb +4 -0
  24. data/lib/generators/service/templates/service_spec.rb +8 -0
  25. data/lib/prefab.rb +18 -0
  26. data/lib/prefab/install/install_generator.rb +43 -0
  27. data/lib/prefab/install/templates/assets/stylesheets/bootstrap-variables.less +829 -0
  28. data/lib/prefab/install/templates/assets/stylesheets/bootstrap-variables.scss +833 -0
  29. data/lib/prefab/install/templates/assets/stylesheets/starter.css +22 -0
  30. data/lib/prefab/install/templates/assets/stylesheets/starter.less +23 -0
  31. data/lib/prefab/install/templates/assets/stylesheets/starter.scss +22 -0
  32. data/lib/prefab/install/templates/form_builders/form_builder/_form.html.erb +28 -0
  33. data/lib/prefab/install/templates/form_builders/form_builder/_form.html.haml +19 -0
  34. data/lib/prefab/install/templates/form_builders/form_builder/_form.html.slim +18 -0
  35. data/lib/prefab/install/templates/layouts/starter.html.erb +51 -0
  36. data/lib/prefab/install/templates/layouts/starter.html.haml +40 -0
  37. data/lib/prefab/install/templates/layouts/starter.html.slim +44 -0
  38. data/lib/prefab/install/templates/lib/templates/erb/controller/view.html.erb +4 -0
  39. data/lib/prefab/install/templates/lib/templates/erb/scaffold/edit.html.erb +13 -0
  40. data/lib/prefab/install/templates/lib/templates/erb/scaffold/index.html.erb +33 -0
  41. data/lib/prefab/install/templates/lib/templates/erb/scaffold/new.html.erb +9 -0
  42. data/lib/prefab/install/templates/lib/templates/erb/scaffold/show.html.erb +19 -0
  43. data/lib/prefab/install/templates/lib/templates/haml/controller/view.html.haml +3 -0
  44. data/lib/prefab/install/templates/lib/templates/haml/scaffold/edit.html.haml +10 -0
  45. data/lib/prefab/install/templates/lib/templates/haml/scaffold/index.html.haml +26 -0
  46. data/lib/prefab/install/templates/lib/templates/haml/scaffold/new.html.haml +7 -0
  47. data/lib/prefab/install/templates/lib/templates/haml/scaffold/show.html.haml +14 -0
  48. data/lib/prefab/install/templates/lib/templates/slim/controller/view.html.slim +5 -0
  49. data/lib/prefab/install/templates/lib/templates/slim/scaffold/edit.html.slim +12 -0
  50. data/lib/prefab/install/templates/lib/templates/slim/scaffold/index.html.slim +31 -0
  51. data/lib/prefab/install/templates/lib/templates/slim/scaffold/new.html.slim +9 -0
  52. data/lib/prefab/install/templates/lib/templates/slim/scaffold/show.html.slim +16 -0
  53. data/lib/prefab/version.rb +3 -0
  54. data/lib/templates/active_record/model/model.rb +26 -0
  55. data/lib/templates/haml/scaffold/_form.html.haml +16 -0
  56. data/lib/templates/haml/scaffold/edit.html.haml +9 -0
  57. data/lib/templates/haml/scaffold/index.html.haml +22 -0
  58. data/lib/templates/haml/scaffold/new.html.haml +7 -0
  59. data/lib/templates/haml/scaffold/show.html.haml +12 -0
  60. data/lib/templates/rails/scaffold_controller/controller.rb +68 -0
  61. data/lib/templates/rspec/model/model_spec.rb +13 -0
  62. data/prefab.gemspec +29 -0
  63. data/test/dummy/Rakefile +7 -0
  64. data/test/dummy/app/assets/javascripts/application.js +13 -0
  65. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  66. data/test/dummy/config.ru +4 -0
  67. data/test/dummy/config/application.rb +68 -0
  68. data/test/dummy/config/boot.rb +6 -0
  69. data/test/dummy/config/environment.rb +5 -0
  70. data/test/dummy/config/environments/test.rb +34 -0
  71. data/test/generators/prefab/install_generator_test.rb +86 -0
  72. data/test/test_helper.rb +7 -0
  73. metadata +198 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9deed1e9db474cd286c31d32750dd4c3c52ae507
4
+ data.tar.gz: 5bc67bb2859a91a01c34800dca7591e0eff7a49f
5
+ SHA512:
6
+ metadata.gz: 3f6fc6cf34fa80201d94b1aca98378fb23e164bf5076114ec66edf00f1bf4700a368113336503cd1127eb0bbe07a4a6ccc43578b10a1df1440d5eb4330eaa925
7
+ data.tar.gz: 7442e32a896f9580fc5efc592450d3542d99e9ff27b633204e6dbe2ff99daf20aeae8b57a60c09982a68e8fa7d86595c31738a8e33e8eda34056ba90c1618ab3
data/.gitignore ADDED
@@ -0,0 +1,43 @@
1
+ *.gem
2
+ *.rbc
3
+ capybara-*.html
4
+ .rspec
5
+ /log
6
+ /tmp
7
+ /db/*.sqlite3
8
+ /public/system
9
+ /coverage/
10
+ /spec/tmp
11
+ **.orig
12
+ rerun.txt
13
+ pickle-email-*.html
14
+ config/initializers/secret_token.rb
15
+ config/secrets.yml
16
+
17
+ .bundle
18
+ .config
19
+ .yardoc
20
+ Gemfile.lock
21
+ InstalledFiles
22
+ _yardoc
23
+ coverage
24
+ doc/
25
+ lib/bundler/man
26
+ pkg
27
+ rdoc
28
+ spec/reports
29
+ test/dummy/db/*.sqlite3
30
+ test/dummy/log/*.log
31
+ test/tmp
32
+ test/version_tmp
33
+ tmp
34
+
35
+ ## Environment normalisation:
36
+ /.bundle
37
+ /vendor/bundle
38
+
39
+ # these should all be checked in to normalise the environment:
40
+ # Gemfile.lock, .ruby-version, .ruby-gemset
41
+
42
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
43
+ .rvmrc
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ env:
5
+ - "RAILS_VERSION=3.1.0"
6
+ - "RAILS_VERSION=3.2.0"
7
+ - "RAILS_VERSION=4.0.0"
8
+ - "RAILS_VERSION=4.1.0.rc2"
9
+ - "RAILS_VERSION=master"
data/Gemfile ADDED
@@ -0,0 +1,26 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in prefab.gemspec
4
+ gemspec
5
+
6
+ # Dummy application
7
+ rails_version = ENV["RAILS_VERSION"] || "default"
8
+ case rails_version
9
+ when "master"
10
+ rails = { github: "rails/rails" }
11
+ gem 'sass-rails', '>= 4.0.2'
12
+ when "default"
13
+ rails = ">= 3.1.0"
14
+ gem 'sass-rails'
15
+ else
16
+ rails = "~> #{rails_version}"
17
+
18
+ if rails_version[0] == '4'
19
+ gem 'sass-rails', '>= 4.0.2'
20
+ else
21
+ gem 'sass-rails'
22
+ end
23
+ end
24
+
25
+ gem 'rails', rails
26
+ gem 'uglifier'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 John Perkins
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 Décio Ferreira
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,134 @@
1
+ Prefab
2
+ ======
3
+ [![Build Status](https://travis-ci.org/jeperkins4/prefab.png?branch=master)](https://travis-ci.org/jeperkins4/prefab)
4
+
5
+ Prefab provides [Twitter Bootstrap](http://getbootstrap.com/), jQuery Datatable, Spreadsheet, and Service class generators for Rails 4 (supported Rails >= 3.1). Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites.
6
+
7
+ This gem is heavily inspired by [Bootstrap-generator](https://github.com/decioferreira/bootstrap-generators). This gem began as a fork of his project, but then took on a life of its own.
8
+
9
+ ## Current Twitter Bootstrap version
10
+
11
+ The current version of Twitter Bootstrap is 3.1.1.
12
+
13
+ ## Installing Gem
14
+
15
+ In your Gemfile, add this line:
16
+
17
+ gem 'prefab', '~> 3.1.1'
18
+
19
+ Or you can install from latest build:
20
+
21
+ gem 'prefab', :git => 'git://github.com/jeperkins4/prefab.git'
22
+
23
+ Run bundle install:
24
+
25
+ bundle install
26
+
27
+ ## Generators
28
+
29
+ Get started:
30
+
31
+ rails generate prefab:install -f
32
+
33
+ Once you've done that, any time you generate a controller or scaffold, you'll get [Bootstrap](http://twitter.github.com/bootstrap/) templates.
34
+
35
+ ### Give it a try
36
+
37
+ rails generate scaffold post title body:text published:boolean
38
+
39
+ You can easily customize colors, grid system, fonts, and much more by editing `bootstrap-variables.[less|scss]` on your application assets folder.
40
+
41
+ ## Usage
42
+
43
+ To print the options and usage run the command `rails generate bootstrap:install --help`
44
+
45
+ rails generate bootstrap:install [options]
46
+
47
+ Options:
48
+ -e, [--template-engine=TEMPLATE_ENGINE] # Indicates when to generate template engine
49
+ # Default: erb
50
+ -se, [--stylesheet-engine=STYLESHEET_ENGINE] # Indicates when to generate stylesheet engine
51
+ # Default: scss
52
+
53
+ Runtime options:
54
+ -f, [--force] # Overwrite files that already exist
55
+ -p, [--pretend] # Run but do not make any changes
56
+ -q, [--quiet] # Supress status output
57
+ -s, [--skip] # Skip files that already exist
58
+
59
+ Copy BootstrapGenerators default files
60
+
61
+ ### Options
62
+
63
+ #### Template engines
64
+
65
+ Supported template engines:
66
+
67
+ * Haml
68
+
69
+ ##### Haml
70
+
71
+ Add the dependency on your Gemfile:
72
+
73
+ gem 'haml-rails'
74
+
75
+ And then run:
76
+
77
+ rails generate bootstrap:install --template-engine=haml
78
+
79
+
80
+ #### Stylesheet engines
81
+
82
+ Supported stylesheet engines:
83
+
84
+ * CSS
85
+ * SCSS
86
+
87
+ Make sure you have `sass-rails` dependency on your Gemfile:
88
+
89
+ gem 'sass-rails'
90
+
91
+ And then run:
92
+
93
+ rails generate bootstrap:install --stylesheet-engine=scss
94
+
95
+ Now you can customize the look and feel of Bootstrap.
96
+
97
+ ## Assets
98
+
99
+ ### Customize and extend Bootstrap
100
+
101
+ You will get an `app/assets/stylesheets/bootstrap-variables.[less|scss]` file with all of the default variables of Bootstrap. This way you can customize the look and feel of Bootstrap without having to download any extra file.
102
+
103
+ ### Javascript
104
+
105
+ Select all jQuery plugins (`app/assets/javascripts/bootstrap.js`)
106
+
107
+ //= require bootstrap
108
+
109
+ Or quickly add only the necessary javascript (Transitions: required for any animation; Popovers: requires Tooltips)
110
+
111
+ //= require bootstrap/scrollspy
112
+ //= require bootstrap/dropdown
113
+ //= require bootstrap/tab
114
+ //= require bootstrap/button
115
+ //= require bootstrap/collapse
116
+ //= require bootstrap/modal
117
+ //= require bootstrap/carousel
118
+ //= require bootstrap/alert
119
+ //= require bootstrap/transition
120
+ //= require bootstrap/tooltip
121
+ //= require bootstrap/popover
122
+ //= require bootstrap/affix
123
+
124
+
125
+ ## Customizing Templates
126
+
127
+ In Rails 3.0 and above, generators don’t just look in the source root for templates, they also search for templates in other paths. And one of them is lib/templates.
128
+
129
+ Since Bootstrap Generators installs its templates under lib/templates, you can go and customize them.
130
+
131
+ ## Credits
132
+
133
+ * [Twitter Bootstrap](http://getbootstrap.com)
134
+ =======
data/Rakefile ADDED
@@ -0,0 +1,154 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'lib'
6
+ t.libs << 'test'
7
+ t.pattern = 'test/**/*_test.rb'
8
+ t.verbose = false
9
+ end
10
+
11
+ task :default => :test
12
+
13
+ namespace :bootstrap do
14
+ desc "Update to a new version of Twitter Bootstrap"
15
+ task :update do
16
+ bootstrap_version = "3.1.1"
17
+ striped_bootstrap_generators_version = "3.1.1"
18
+
19
+ twitter_latest_dist_zip_url = "https://github.com/twbs/bootstrap/archive/v#{bootstrap_version}.zip"
20
+ twitter_sass_lastest_dist_zip_url = "https://github.com/twbs/bootstrap-sass/archive/v#{bootstrap_version}.zip"
21
+ twitter_bootstrap_dir = "tmp/bootstrap-#{bootstrap_version}"
22
+ twitter_sass_bootstrap_dir = "tmp/bootstrap-sass-#{bootstrap_version}"
23
+
24
+ # Make sure tmp/ dir exists
25
+ Dir.mkdir('tmp') unless File.exists?('tmp')
26
+
27
+ if File.exists?(twitter_bootstrap_dir)
28
+ puts "Twitter Bootstrap already downloaded."
29
+ else
30
+ # Download the latest version of Twitter Bootstrap
31
+ `wget -O tmp/bootstrap.zip #{twitter_latest_dist_zip_url}`
32
+
33
+ # Extract Twitter Bootstrap
34
+ `unzip -d tmp tmp/bootstrap.zip`
35
+ end
36
+
37
+ if File.exists?(twitter_sass_bootstrap_dir)
38
+ puts "Twitter Bootstrap Sass already downloaded."
39
+ else
40
+ # Download the latest version of Twitter Bootstrap Sass
41
+ `wget -O tmp/sass-bootstrap.zip #{twitter_sass_lastest_dist_zip_url}`
42
+
43
+ # Extract Twitter Bootstrap
44
+ `unzip -d tmp tmp/sass-bootstrap.zip`
45
+ end
46
+
47
+ # Reset Twitter Bootstrap JS files
48
+ bootstrap_javascript_dir = 'vendor/assets/javascripts/bootstrap'
49
+ bootstrap_main_javascript = 'vendor/assets/javascripts/bootstrap.js'
50
+
51
+ FileUtils.rm Dir.glob("#{bootstrap_javascript_dir}/*.js")
52
+ FileUtils.cp Dir.glob("#{twitter_bootstrap_dir}/js/*.js"), bootstrap_javascript_dir
53
+
54
+ # Rewrite base bootstrap.js
55
+ require_files = []
56
+ Dir.glob("#{bootstrap_javascript_dir}/*.js") do |js_file|
57
+ require_files << File.basename(js_file, '.*')
58
+ end
59
+
60
+ # Make sure that tooltip.js is before popover.js (Popover requires tooltip.js)
61
+ tooltip_position = require_files.index('tooltip')
62
+ popover_position = require_files.index('popover')
63
+ require_files.insert(tooltip_position, require_files.delete_at(popover_position)) if tooltip_position > popover_position
64
+
65
+ File.open(bootstrap_main_javascript, 'w') do |file|
66
+ require_files.each do |require_file|
67
+ file.write("//= require bootstrap/#{require_file}\n")
68
+ end
69
+ end
70
+
71
+ # Reset Twitter Bootstrap Fonts
72
+ bootstrap_fonts_dir = 'vendor/assets/fonts/bootstrap'
73
+
74
+ FileUtils.rm Dir.glob("#{bootstrap_fonts_dir}/*")
75
+ FileUtils.cp Dir.glob("#{twitter_bootstrap_dir}/fonts/*"), bootstrap_fonts_dir
76
+
77
+ # Reset Twitter Bootstrap CSS file
78
+ FileUtils.cp "#{twitter_bootstrap_dir}/dist/css/bootstrap.css", "vendor/assets/stylesheets/bootstrap.css.erb"
79
+
80
+ # Reset Twitter Bootstrap LESS files
81
+ bootstrap_less_dir = 'vendor/twitter/bootstrap/less'
82
+
83
+ FileUtils.rm Dir.glob("#{bootstrap_less_dir}/*.less")
84
+ FileUtils.cp Dir.glob("#{twitter_bootstrap_dir}/less/*.less"), bootstrap_less_dir
85
+
86
+ # Reset Twitter Bootstrap SASS files
87
+ bootstrap_sass_dir = 'vendor/twitter/bootstrap/sass'
88
+
89
+ FileUtils.rm Dir.glob("#{bootstrap_sass_dir}/*.scss")
90
+ FileUtils.cp Dir.glob("#{twitter_sass_bootstrap_dir}/vendor/assets/stylesheets/bootstrap/*.scss"), bootstrap_sass_dir
91
+
92
+ # Copy bootstrap variables
93
+ FileUtils.cp "#{bootstrap_less_dir}/variables.less", "lib/generators/bootstrap/install/templates/assets/stylesheets/bootstrap-variables.less"
94
+ FileUtils.cp "#{bootstrap_sass_dir}/_variables.scss", "lib/generators/bootstrap/install/templates/assets/stylesheets/bootstrap-variables.scss"
95
+
96
+ # Asset helpers
97
+ Dir.glob('**/*.css.erb').each do |filepath|
98
+ file_content = File.read(filepath)
99
+
100
+ # Remove fonts path
101
+ file_content.gsub!("../fonts/", "bootstrap/")
102
+
103
+ # Asset helpers for fonts
104
+ file_content.gsub!(%r{(["'][\w\-@{}$#\/]+\.(eot|woff|ttf|svg)["'])}, '\'<%= font_path(\1) %>\'')
105
+ file_content.gsub!(%r{(["'])([\w\-@{}$#\/]+\.(eot|woff|ttf|svg))(\??#[\w\-@{}$#]+["'])}, '\'<%= font_path(\1\2\1) %>\4')
106
+
107
+ File.open(filepath, 'w') { |file| file.puts file_content }
108
+ end
109
+
110
+ Dir.glob('**/*.scss').each do |filepath|
111
+ file_content = File.read(filepath)
112
+
113
+ # Remove fonts path
114
+ file_content.gsub!("../fonts/", "bootstrap/")
115
+
116
+ # Asset helpers for fonts
117
+ file_content.gsub!(%r{(["'\w\-@{}$#\/]+\.(eot|woff|ttf|svg)(\??#[\w\-@{}$#]+)?["'])}, 'font-path(\1)')
118
+
119
+ # Asset helpers for images
120
+ file_content.gsub!(%r{image: url\(}, 'image: image-url(')
121
+
122
+ File.open(filepath, 'w') { |file| file.puts file_content }
123
+ end
124
+
125
+ Dir.glob('**/*.less').each do |filepath|
126
+ file_content = File.read(filepath)
127
+
128
+ # Remove fonts path
129
+ file_content.gsub!("../fonts/", "bootstrap/")
130
+
131
+ # Asset helpers for fonts
132
+ file_content.gsub!(%r{~"url\(([^)]+)\)( [^"]*)?"}, 'font-url(~"\1")\2')
133
+
134
+ # Asset helpers for images
135
+ file_content.gsub!(%r{image: url\(}, 'image: image-url(')
136
+
137
+ File.open(filepath, 'w') { |file| file.puts file_content }
138
+ end
139
+
140
+ # Generate README.md
141
+ require 'erb'
142
+
143
+ javascript_bootstrap_content_code = ""
144
+ File.open(bootstrap_main_javascript, 'r').each_line do |line|
145
+ javascript_bootstrap_content_code += " #{line}"
146
+ end
147
+
148
+ template = ERB.new File.read("readme-template.md.erb")
149
+
150
+ File.open('README.md', 'w') do |file|
151
+ file.write(template.result(binding))
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate api Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,11 @@
1
+ class ApiGenerator < Rails::Generators::NamedBase
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def generate_api_file
5
+ template "api.rb", "lib/#{file_name.underscore}.rb"
6
+ end
7
+
8
+ def generate_report_spec_file
9
+ template "api_spec.rb", "spec/lib/#{file_name.underscore}_spec.rb"
10
+ end
11
+ end