Skip to content

Gemfied #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.redcar
pkg
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rafael Felix ([email protected])
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
29 changes: 8 additions & 21 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,38 @@ 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...

bundle install

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
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
rails generate haml:scaffold FancyModel

## TODO

* Gemify (?)
* RSpec it (?)
* Add Contributors at the CONTRIBUTORS file

[OriginalIdea]: http://paulbarry.com/articles/2010/01/13/customizing-generators-in-rails-3
48 changes: 48 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"
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
59 changes: 59 additions & 0 deletions haml_rails.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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-08}
s.description = %q{HAML scaffold template engine}
s.email = %q{[email protected]}
s.extra_rdoc_files = [
"LICENSE",
"README.markdown"
]
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",
"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<rspec>, [">= 1.2.9"])
else
s.add_dependency(%q<rspec>, [">= 1.2.9"])
end
else
s.add_dependency(%q<rspec>, [">= 1.2.9"])
end
end

1 change: 1 addition & 0 deletions init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'haml_rails'
36 changes: 36 additions & 0 deletions lib/generators/haml_rails/install_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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 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_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
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 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
end
File renamed without changes.
Empty file added lib/haml_rails.rb
Empty file.
9 changes: 9 additions & 0 deletions lib/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module HamlRails
module Version
MAJOR = 0
MINOR = 1
PATCH = 0

STRING = [MAJOR, MINOR, PATCH].compact.join('.')
end
end
1 change: 1 addition & 0 deletions spec/spec.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -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