From 9d3ff304e35c78ad2f71cbd8b4893583eb06238d Mon Sep 17 00:00:00 2001 From: Rafael Felix Date: Sun, 7 Nov 2010 21:44:33 -0200 Subject: [PATCH 1/6] Added default structure for gem and make the install generator --- .gitignore | 1 + LICENSE | 20 ++++++ Rakefile | 48 +++++++++++++++ haml_rails.gemspec | 58 ++++++++++++++++++ init.rb | 1 + .../haml_rails/install_generator.rb | 23 +++++++ .../controller}/controller_generator.rb | 0 .../controller}/templates/view.html.haml | 0 .../templates/mailer}/mailer_generator.rb | 0 .../mailer}/templates/view.text.haml | 0 .../templates/scaffold}/scaffold_generator.rb | 0 .../scaffold}/templates/_form.html.haml | 0 .../scaffold}/templates/edit.html.haml | 0 .../scaffold}/templates/index.html.haml | 0 .../scaffold}/templates/layout.html.haml | 0 .../scaffold}/templates/new.html.haml | 0 .../scaffold}/templates/show.html.haml | 0 base.rb => lib/haml_rails.rb | 2 +- lib/version.rb | 9 +++ pkg/haml_rails-0.1.0.gem | Bin 0 -> 7168 bytes spec/spec.opts | 1 + spec/spec_helper.rb | 9 +++ 22 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Rakefile create mode 100644 haml_rails.gemspec create mode 100644 init.rb create mode 100644 lib/generators/haml_rails/install_generator.rb rename {controller => lib/generators/haml_rails/templates/controller}/controller_generator.rb (100%) rename {controller => lib/generators/haml_rails/templates/controller}/templates/view.html.haml (100%) rename {mailer => lib/generators/haml_rails/templates/mailer}/mailer_generator.rb (100%) rename {mailer => lib/generators/haml_rails/templates/mailer}/templates/view.text.haml (100%) rename {scaffold => lib/generators/haml_rails/templates/scaffold}/scaffold_generator.rb (100%) rename {scaffold => lib/generators/haml_rails/templates/scaffold}/templates/_form.html.haml (100%) rename {scaffold => lib/generators/haml_rails/templates/scaffold}/templates/edit.html.haml (100%) rename {scaffold => lib/generators/haml_rails/templates/scaffold}/templates/index.html.haml (100%) rename {scaffold => lib/generators/haml_rails/templates/scaffold}/templates/layout.html.haml (100%) rename {scaffold => lib/generators/haml_rails/templates/scaffold}/templates/new.html.haml (100%) rename {scaffold => lib/generators/haml_rails/templates/scaffold}/templates/show.html.haml (100%) rename base.rb => lib/haml_rails.rb (95%) create mode 100644 lib/version.rb create mode 100644 pkg/haml_rails-0.1.0.gem create mode 100644 spec/spec.opts create mode 100644 spec/spec_helper.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f8b9e72 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.redcar \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8d3cfaa --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2009 Rafael Felix + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..01ce823 --- /dev/null +++ b/Rakefile @@ -0,0 +1,48 @@ +require 'rubygems' +require 'rake' +require 'lib/version' + +begin + require 'jeweler' + Jeweler::Tasks.new do |gem| + gem.name = "haml_rails" + gem.summary = %Q{HAML scaffold template engine} + gem.description = %Q{HAML scaffold template engine} + gem.email = "felix.rafael@gmail.com" + gem.homepage = "http://github.com/fellix/haml_rails" + gem.authors = ["Rafael Felix"] + gem.add_development_dependency "rspec", ">= 1.2.9" + gem.version = HamlRails::Version::STRING + gem.files = FileList["[A-Z]*(.rdoc)", "{generators,lib}/**/*", "init.rb"] + # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings + end + Jeweler::GemcutterTasks.new +rescue LoadError + puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler" +end + +require 'spec/rake/spectask' +Spec::Rake::SpecTask.new(:spec) do |spec| + spec.libs << 'lib' << 'spec' + spec.spec_files = FileList['spec/**/*_spec.rb'] +end + +Spec::Rake::SpecTask.new(:rcov) do |spec| + spec.libs << 'lib' << 'spec' + spec.pattern = 'spec/**/*_spec.rb' + spec.rcov = true +end + +task :spec => :check_dependencies + +task :default => :spec + +require 'rake/rdoctask' +Rake::RDocTask.new do |rdoc| + version = File.exist?('VERSION') ? File.read('VERSION') : "" + + rdoc.rdoc_dir = 'rdoc' + rdoc.title = "haml_rails #{version}" + rdoc.rdoc_files.include('README*') + rdoc.rdoc_files.include('lib/**/*.rb') +end diff --git a/haml_rails.gemspec b/haml_rails.gemspec new file mode 100644 index 0000000..45f5d90 --- /dev/null +++ b/haml_rails.gemspec @@ -0,0 +1,58 @@ +# Generated by jeweler +# DO NOT EDIT THIS FILE DIRECTLY +# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{haml_rails} + s.version = "0.1.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Rafael Felix"] + s.date = %q{2010-11-07} + s.description = %q{HAML scaffold template engine} + s.email = %q{felix.rafael@gmail.com} + s.extra_rdoc_files = [ + "LICENSE", + "README.markdown" + ] + s.files = [ + "init.rb", + "lib/generators/haml_rails/install_generator.rb", + "lib/generators/haml_rails/templates/controller/controller_generator.rb", + "lib/generators/haml_rails/templates/controller/templates/view.html.haml", + "lib/generators/haml_rails/templates/mailer/mailer_generator.rb", + "lib/generators/haml_rails/templates/mailer/templates/view.text.haml", + "lib/generators/haml_rails/templates/scaffold/scaffold_generator.rb", + "lib/generators/haml_rails/templates/scaffold/templates/_form.html.haml", + "lib/generators/haml_rails/templates/scaffold/templates/edit.html.haml", + "lib/generators/haml_rails/templates/scaffold/templates/index.html.haml", + "lib/generators/haml_rails/templates/scaffold/templates/layout.html.haml", + "lib/generators/haml_rails/templates/scaffold/templates/new.html.haml", + "lib/generators/haml_rails/templates/scaffold/templates/show.html.haml", + "lib/haml_rails.rb", + "lib/version.rb" + ] + s.homepage = %q{http://github.com/fellix/haml_rails} + s.rdoc_options = ["--charset=UTF-8"] + s.require_paths = ["lib"] + s.rubygems_version = %q{1.3.6} + s.summary = %q{HAML scaffold template engine} + s.test_files = [ + "spec/spec_helper.rb" + ] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_development_dependency(%q, [">= 1.2.9"]) + else + s.add_dependency(%q, [">= 1.2.9"]) + end + else + s.add_dependency(%q, [">= 1.2.9"]) + end +end + diff --git a/init.rb b/init.rb new file mode 100644 index 0000000..eb1033f --- /dev/null +++ b/init.rb @@ -0,0 +1 @@ +require 'haml_rails' \ No newline at end of file diff --git a/lib/generators/haml_rails/install_generator.rb b/lib/generators/haml_rails/install_generator.rb new file mode 100644 index 0000000..f3f09ab --- /dev/null +++ b/lib/generators/haml_rails/install_generator.rb @@ -0,0 +1,23 @@ +module HamlRails + module Generators + class InstallGenerator < Rails::Generators::Base + desc "Copy the defaults template to the application" + source_root File.expand_path('../templates', __FILE__) + + def create_default_folder_structure + @haml_dir = "lib/templates/haml" + Dir.mkdir("lib/templates") unless File.exists? "lib/templates" + Dir.mkdir(@haml_dir) unless File.exists? @haml_dir + end + def copy_controller_template + FileUtils.cp_r File.expand_path('../templates/controller', __FILE__), @haml_dir + end + def copy_mailer_template + FileUtils.cp_r File.expand_path('../templates/mailer', __FILE__), @haml_dir + end + def copy_scaffold_template + FileUtils.cp_r File.expand_path('../templates/scaffold', __FILE__), @haml_dir + end + end + end +end \ No newline at end of file diff --git a/controller/controller_generator.rb b/lib/generators/haml_rails/templates/controller/controller_generator.rb similarity index 100% rename from controller/controller_generator.rb rename to lib/generators/haml_rails/templates/controller/controller_generator.rb diff --git a/controller/templates/view.html.haml b/lib/generators/haml_rails/templates/controller/templates/view.html.haml similarity index 100% rename from controller/templates/view.html.haml rename to lib/generators/haml_rails/templates/controller/templates/view.html.haml diff --git a/mailer/mailer_generator.rb b/lib/generators/haml_rails/templates/mailer/mailer_generator.rb similarity index 100% rename from mailer/mailer_generator.rb rename to lib/generators/haml_rails/templates/mailer/mailer_generator.rb diff --git a/mailer/templates/view.text.haml b/lib/generators/haml_rails/templates/mailer/templates/view.text.haml similarity index 100% rename from mailer/templates/view.text.haml rename to lib/generators/haml_rails/templates/mailer/templates/view.text.haml diff --git a/scaffold/scaffold_generator.rb b/lib/generators/haml_rails/templates/scaffold/scaffold_generator.rb similarity index 100% rename from scaffold/scaffold_generator.rb rename to lib/generators/haml_rails/templates/scaffold/scaffold_generator.rb diff --git a/scaffold/templates/_form.html.haml b/lib/generators/haml_rails/templates/scaffold/templates/_form.html.haml similarity index 100% rename from scaffold/templates/_form.html.haml rename to lib/generators/haml_rails/templates/scaffold/templates/_form.html.haml diff --git a/scaffold/templates/edit.html.haml b/lib/generators/haml_rails/templates/scaffold/templates/edit.html.haml similarity index 100% rename from scaffold/templates/edit.html.haml rename to lib/generators/haml_rails/templates/scaffold/templates/edit.html.haml diff --git a/scaffold/templates/index.html.haml b/lib/generators/haml_rails/templates/scaffold/templates/index.html.haml similarity index 100% rename from scaffold/templates/index.html.haml rename to lib/generators/haml_rails/templates/scaffold/templates/index.html.haml diff --git a/scaffold/templates/layout.html.haml b/lib/generators/haml_rails/templates/scaffold/templates/layout.html.haml similarity index 100% rename from scaffold/templates/layout.html.haml rename to lib/generators/haml_rails/templates/scaffold/templates/layout.html.haml diff --git a/scaffold/templates/new.html.haml b/lib/generators/haml_rails/templates/scaffold/templates/new.html.haml similarity index 100% rename from scaffold/templates/new.html.haml rename to lib/generators/haml_rails/templates/scaffold/templates/new.html.haml diff --git a/scaffold/templates/show.html.haml b/lib/generators/haml_rails/templates/scaffold/templates/show.html.haml similarity index 100% rename from scaffold/templates/show.html.haml rename to lib/generators/haml_rails/templates/scaffold/templates/show.html.haml diff --git a/base.rb b/lib/haml_rails.rb similarity index 95% rename from base.rb rename to lib/haml_rails.rb index e4c2faa..2de3f85 100644 --- a/base.rb +++ b/lib/haml_rails.rb @@ -1,6 +1,6 @@ require 'rails/generators/named_base' -module Haml +module HamlRails module Generators class Base < Rails::Generators::NamedBase # Automatically sets the source root based on the class name. diff --git a/lib/version.rb b/lib/version.rb new file mode 100644 index 0000000..c44117f --- /dev/null +++ b/lib/version.rb @@ -0,0 +1,9 @@ +module HamlRails + module Version + MAJOR = 0 + MINOR = 1 + PATCH = 0 + + STRING = [MAJOR, MINOR, PATCH].compact.join('.') + end +end \ No newline at end of file diff --git a/pkg/haml_rails-0.1.0.gem b/pkg/haml_rails-0.1.0.gem new file mode 100644 index 0000000000000000000000000000000000000000..e63033a99c2550ec5a759c7314a60f47e49678d3 GIT binary patch literal 7168 zcmeHLWmFu>k_HBMLI@rtcoK9NG-z;w1=lc0aF-+yCIkp>A-KD{2Fc(9VIT|=+=9D1 zGqZX7&fC4`{@Gve?c1}r{#19@>F%npT26h|mR^>;UX~ubuis((vxNV*fPg@ZzvVN7hCj9cC;NYf_J`p9H2vST z%M^)^0TG*0#{ldx*n7?@`$+8?w0EglHr2HF@9D^M^!5w1(U{6`q^lNku?XipSFV_d z7-mBq-kLYZ_1e^MawHgas1ol4DEXEzP2v?fdrUIkon>grh)PIMX5$ZKhsbS<-e|1% zjSZ@7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S z4Jq~=zL#14guBI%`rvE`);ARy;+WHiIG*XQPW=X-Y-CFyNuIwES5P?ua>;(Qownde z(U9pZtW^)Q&gl4IIh{cu$X=;0_hFG7O<|{F?%s0o*o0{5T9SN_ol5&=g*&$b(Tq|*gF^b?F{8DLDR_J92=oJ|hB5}O%X O0)HX!7XtrR5cm&xPzz}Q literal 0 HcmV?d00001 diff --git a/spec/spec.opts b/spec/spec.opts new file mode 100644 index 0000000..4e1e0d2 --- /dev/null +++ b/spec/spec.opts @@ -0,0 +1 @@ +--color diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..b32ab23 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,9 @@ +$LOAD_PATH.unshift(File.dirname(__FILE__)) +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) +require 'haml_rails' +require 'spec' +require 'spec/autorun' + +Spec::Runner.configure do |config| + +end From e6cb88932c305337bb34e8d8efbc4eac7347a5a1 Mon Sep 17 00:00:00 2001 From: Rafael Felix Date: Sun, 7 Nov 2010 23:47:06 -0200 Subject: [PATCH 2/6] Added comments for installing --- .gitignore | 3 ++- lib/generators/haml_rails/install_generator.rb | 14 +++++++++++++- pkg/haml_rails-0.1.0.gem | Bin 7168 -> 0 bytes 3 files changed, 15 insertions(+), 2 deletions(-) delete mode 100644 pkg/haml_rails-0.1.0.gem diff --git a/.gitignore b/.gitignore index f8b9e72..a1c5ed6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.redcar \ No newline at end of file +.redcar +pkg \ No newline at end of file diff --git a/lib/generators/haml_rails/install_generator.rb b/lib/generators/haml_rails/install_generator.rb index f3f09ab..e2d017d 100644 --- a/lib/generators/haml_rails/install_generator.rb +++ b/lib/generators/haml_rails/install_generator.rb @@ -5,19 +5,31 @@ class InstallGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) def create_default_folder_structure + puts "Creating folders..." @haml_dir = "lib/templates/haml" Dir.mkdir("lib/templates") unless File.exists? "lib/templates" Dir.mkdir(@haml_dir) unless File.exists? @haml_dir end def copy_controller_template + puts "Coping controllers templates" FileUtils.cp_r File.expand_path('../templates/controller', __FILE__), @haml_dir end def copy_mailer_template + puts "Coping mailer templates" FileUtils.cp_r File.expand_path('../templates/mailer', __FILE__), @haml_dir end - def copy_scaffold_template + def copy_scaffold_template + puts "Coping scaffold templates" FileUtils.cp_r File.expand_path('../templates/scaffold', __FILE__), @haml_dir end + def print_usage + puts "The Rails templates for haml was configured" + puts "Don't forget to add the haml to your Gemfile" + puts "Change your config/application.rb and add" + puts " config.generators do |g| " + puts " g.template_engine :haml " + puts " end " + end end end end \ No newline at end of file diff --git a/pkg/haml_rails-0.1.0.gem b/pkg/haml_rails-0.1.0.gem deleted file mode 100644 index e63033a99c2550ec5a759c7314a60f47e49678d3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7168 zcmeHLWmFu>k_HBMLI@rtcoK9NG-z;w1=lc0aF-+yCIkp>A-KD{2Fc(9VIT|=+=9D1 zGqZX7&fC4`{@Gve?c1}r{#19@>F%npT26h|mR^>;UX~ubuis((vxNV*fPg@ZzvVN7hCj9cC;NYf_J`p9H2vST z%M^)^0TG*0#{ldx*n7?@`$+8?w0EglHr2HF@9D^M^!5w1(U{6`q^lNku?XipSFV_d z7-mBq-kLYZ_1e^MawHgas1ol4DEXEzP2v?fdrUIkon>grh)PIMX5$ZKhsbS<-e|1% zjSZ@7b8<;KmSY_~tNO}?@`0zEV=Ok^tdAg>m+R0sMMKO&KRNW5Ce??A{0~9wHPSV3 z*??ZB4TpL64u2rgNl|o~r4h2`V$c>GiK5m_I*01=WG7J~m+;gXdYWlWSNsk~9Stx( z=1r|sbP8fDj7gHwdFTXt9}(f#sj|ye>zdm?qF3F-vg zMFxPFN&CoTeQ8t%7s%sIVdp z`GccvpG3pMJZ369&2PNv`uvel-dJp_bC`MPXqpNWTj(HH0hIX&G*zih&_&%?hGoFSQ5~9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ject: [PATCH 3/6] some changes for correct work --- README.markdown | 27 +++-------- haml_rails.gemspec | 3 +- .../haml_rails/install_generator.rb | 45 ++++++++++--------- lib/generators/haml_rails/templates/base.rb | 15 +++++++ lib/haml_rails.rb | 15 ------- 5 files changed, 45 insertions(+), 60 deletions(-) create mode 100644 lib/generators/haml_rails/templates/base.rb diff --git a/README.markdown b/README.markdown index b563913..51d9213 100644 --- a/README.markdown +++ b/README.markdown @@ -13,13 +13,14 @@ Original idea from [Paul Barry's article on custom genrators][OriginalIdea] 1. Generate your new rails application: - rails ApplicationName + rails new ApplicationName cd ApplicationName -2. Edit "Gemfile" and add "gem haml" to the gem list +2. Edit "Gemfile" and add "gem haml" and "gem haml_rails_" to the gem list 3. Either gem install haml + gem install haml_rails ...or... @@ -27,24 +28,9 @@ Original idea from [Paul Barry's article on custom genrators][OriginalIdea] 4. Run - haml --rails . - -5. Edit config/application.rb and add the following: - - config.generators do |g| - g.template_engine :haml - end - - -6. Either - - git clone git://github.com/psynix/rails3_haml_scaffold_generator.git lib/generators/haml - - ...or... - - git submodule add git://github.com/psynix/rails3_haml_scaffold_generator.git lib/generators/haml + rails generate haml_rails:install -7. Create stuff with: +5. Create stuff with: rails generate controller ControllerName index rails generate mailer ExamplesNotifications @@ -56,8 +42,5 @@ Original idea from [Paul Barry's article on custom genrators][OriginalIdea] rails generate haml:mailer ExamplesNotifications rails generate haml:scaffold FancyModel -## TODO - -* Gemify (?) [OriginalIdea]: http://paulbarry.com/articles/2010/01/13/customizing-generators-in-rails-3 diff --git a/haml_rails.gemspec b/haml_rails.gemspec index 45f5d90..9d8761a 100644 --- a/haml_rails.gemspec +++ b/haml_rails.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Rafael Felix"] - s.date = %q{2010-11-07} + s.date = %q{2010-11-08} s.description = %q{HAML scaffold template engine} s.email = %q{felix.rafael@gmail.com} s.extra_rdoc_files = [ @@ -19,6 +19,7 @@ Gem::Specification.new do |s| s.files = [ "init.rb", "lib/generators/haml_rails/install_generator.rb", + "lib/generators/haml_rails/templates/base.rb", "lib/generators/haml_rails/templates/controller/controller_generator.rb", "lib/generators/haml_rails/templates/controller/templates/view.html.haml", "lib/generators/haml_rails/templates/mailer/mailer_generator.rb", diff --git a/lib/generators/haml_rails/install_generator.rb b/lib/generators/haml_rails/install_generator.rb index e2d017d..7363ac8 100644 --- a/lib/generators/haml_rails/install_generator.rb +++ b/lib/generators/haml_rails/install_generator.rb @@ -3,32 +3,33 @@ module Generators class InstallGenerator < Rails::Generators::Base desc "Copy the defaults template to the application" source_root File.expand_path('../templates', __FILE__) - - def create_default_folder_structure - puts "Creating folders..." - @haml_dir = "lib/templates/haml" - Dir.mkdir("lib/templates") unless File.exists? "lib/templates" - Dir.mkdir(@haml_dir) unless File.exists? @haml_dir + + def copy_controller_template + @haml_dir = "lib/generators/haml" + copy_file File.expand_path('../templates/controller/controller_generator.rb', __FILE__), "#{@haml_dir}/controller/controller_generator.rb" + copy_file File.expand_path('../templates/controller/templates/view.html.haml', __FILE__), "#{@haml_dir}/controller/templates/view.html.haml" end - def copy_controller_template - puts "Coping controllers templates" - FileUtils.cp_r File.expand_path('../templates/controller', __FILE__), @haml_dir - end - def copy_mailer_template - puts "Coping mailer templates" - FileUtils.cp_r File.expand_path('../templates/mailer', __FILE__), @haml_dir + def copy_mailer_template + copy_file File.expand_path('../templates/mailer/mailer_generator.rb', __FILE__), "#{@haml_dir}/mailer/mailer_generator.rb" + copy_file File.expand_path('../templates/mailer/templates/view.text.haml', __FILE__), "#{@haml_dir}/mailer/templates/view.text.haml" end def copy_scaffold_template - puts "Coping scaffold templates" - FileUtils.cp_r File.expand_path('../templates/scaffold', __FILE__), @haml_dir + copy_file File.expand_path('../templates/scaffold/scaffold_generator.rb', __FILE__), "#{@haml_dir}/scaffold/scaffold_generator.rb" + copy_file File.expand_path('../templates/scaffold/templates/_form.html.haml', __FILE__), "#{@haml_dir}/scaffold/templates/_form.html.haml" + copy_file File.expand_path('../templates/scaffold/templates/edit.html.haml', __FILE__), "#{@haml_dir}/scaffold/templates/edit.html.haml" + copy_file File.expand_path('../templates/scaffold/templates/index.html.haml', __FILE__), "#{@haml_dir}/scaffold/templates/index.html.haml" + copy_file File.expand_path('../templates/scaffold/templates/layout.html.haml', __FILE__), "#{@haml_dir}/scaffold/templates/layout.html.haml" + copy_file File.expand_path('../templates/scaffold/templates/new.html.haml', __FILE__), "#{@haml_dir}/scaffold/templates/new.html.haml" + copy_file File.expand_path('../templates/scaffold/templates/show.html.haml', __FILE__), "#{@haml_dir}/scaffold/templates/show.html.haml" + copy_file File.expand_path('../templates/scaffold/templates/_form.html.haml', __FILE__), "lib/templates/haml/scaffold/templates/_form.html.haml" + end + def copy_base_file + copy_file File.expand_path('../templates/base.rb', __FILE__), "#{@haml_dir}/base.rb" end - def print_usage - puts "The Rails templates for haml was configured" - puts "Don't forget to add the haml to your Gemfile" - puts "Change your config/application.rb and add" - puts " config.generators do |g| " - puts " g.template_engine :haml " - puts " end " + def change_application_rb + inject_into_file "config/application.rb", :after => "class Application < Rails::Application\n" do + " config.generators do |g|\n g.template_engine :haml\n end\n" + end end end end diff --git a/lib/generators/haml_rails/templates/base.rb b/lib/generators/haml_rails/templates/base.rb new file mode 100644 index 0000000..e4c2faa --- /dev/null +++ b/lib/generators/haml_rails/templates/base.rb @@ -0,0 +1,15 @@ +require 'rails/generators/named_base' + +module Haml + module Generators + class Base < Rails::Generators::NamedBase + # Automatically sets the source root based on the class name. + # + def self.source_root + @_haml_source_root ||= begin + File.expand_path(File.join(File.dirname(__FILE__), generator_name, 'templates')) if generator_name + end + end + end + end +end diff --git a/lib/haml_rails.rb b/lib/haml_rails.rb index 2de3f85..e69de29 100644 --- a/lib/haml_rails.rb +++ b/lib/haml_rails.rb @@ -1,15 +0,0 @@ -require 'rails/generators/named_base' - -module HamlRails - module Generators - class Base < Rails::Generators::NamedBase - # Automatically sets the source root based on the class name. - # - def self.source_root - @_haml_source_root ||= begin - File.expand_path(File.join(File.dirname(__FILE__), generator_name, 'templates')) if generator_name - end - end - end - end -end From 27c870635b5d7aa53b191a97612b0341767719ca Mon Sep 17 00:00:00 2001 From: Rafael Felix Date: Mon, 8 Nov 2010 23:17:08 -0200 Subject: [PATCH 4/6] added TODO at README --- README.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.markdown b/README.markdown index 51d9213..961b25f 100644 --- a/README.markdown +++ b/README.markdown @@ -42,5 +42,8 @@ Original idea from [Paul Barry's article on custom genrators][OriginalIdea] rails generate haml:mailer ExamplesNotifications rails generate haml:scaffold FancyModel +## TODO + +* RSpec it (?) [OriginalIdea]: http://paulbarry.com/articles/2010/01/13/customizing-generators-in-rails-3 From 5199513a1d219f25309af30fbd9a7392c45f4412 Mon Sep 17 00:00:00 2001 From: Rafael Felix Date: Mon, 8 Nov 2010 23:18:44 -0200 Subject: [PATCH 5/6] Added contributors file --- CONTRIBUTORS | 1 + README.markdown | 1 + 2 files changed, 2 insertions(+) create mode 100644 CONTRIBUTORS diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..e6f64b3 --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1 @@ +Rafael Felix (felix.rafael@gmail.com) \ No newline at end of file diff --git a/README.markdown b/README.markdown index 961b25f..8c28baf 100644 --- a/README.markdown +++ b/README.markdown @@ -45,5 +45,6 @@ Original idea from [Paul Barry's article on custom genrators][OriginalIdea] ## TODO * RSpec it (?) +* Add Contributors at the CONTRIBUTORS file [OriginalIdea]: http://paulbarry.com/articles/2010/01/13/customizing-generators-in-rails-3 From dc260048f7ce4cde4e682890349b7d4a94490498 Mon Sep 17 00:00:00 2001 From: Rafael Felix Date: Mon, 8 Nov 2010 23:20:43 -0200 Subject: [PATCH 6/6] adjust the README file --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 8c28baf..a7fdf86 100644 --- a/README.markdown +++ b/README.markdown @@ -16,7 +16,7 @@ Original idea from [Paul Barry's article on custom genrators][OriginalIdea] rails new ApplicationName cd ApplicationName -2. Edit "Gemfile" and add "gem haml" and "gem haml_rails_" to the gem list +2. Edit "Gemfile" and add "gem haml" and "gem haml_rails" to the gem list 3. Either gem install haml @@ -36,7 +36,7 @@ Original idea from [Paul Barry's article on custom genrators][OriginalIdea] rails generate mailer ExamplesNotifications rails generate scaffold FancyModel - ... or if you like to mix it up with ERB, ignore step 5 and use ... + ... or if you like to mix it up with ERB, ignore step 4 and use ... rails generate haml:controller ControllerName index rails generate haml:mailer ExamplesNotifications