Skip to content

Commit

Permalink
Using Gemcutter as gem-source now.
Browse files Browse the repository at this point in the history
  • Loading branch information
grimen committed Dec 31, 2009
1 parent 8533a5c commit e8bdef1
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 62 deletions.
5 changes: 3 additions & 2 deletions .gitignore
@@ -1,2 +1,3 @@
.tmproj
pkg
.DS_Store
pkg
.*~
4 changes: 4 additions & 0 deletions CHANGELOG.textile
@@ -1,3 +1,7 @@
h1. 0.3.6 (2009-12-31)

* Gemcutter as gem source.

h1. 0.3.4 (2009-09-16)

* Fixed bug: Make it possible to require rake tasks (In Rakefile: require 'dry_scaffold/tasks')
Expand Down
87 changes: 52 additions & 35 deletions README.textile
Expand Up @@ -62,7 +62,8 @@ h4. Standard

HAML + ActionView FormHelpers:

<pre>- form_for(@duck) do |f|
<pre>
- form_for(@duck) do |f|
= f.error_messages
%ul
%li
Expand All @@ -72,18 +73,21 @@ HAML + ActionView FormHelpers:
= f.label :about, 'About'
= f.text_area :about
%p.buttons
= f.submit 'Create'</pre>
= f.submit 'Create'
</pre>

h4. Formtastic

HAML + Formtastic:

<pre>- semantic_form_for(@duck) do |f|
<pre>
- semantic_form_for(@duck) do |f|
- f.inputs do
= f.input :name
= f.input :about
- f.buttons do
= f.commit_button 'Create'</pre>
= f.commit_button 'Create'
</pre>

Find out more about *formtastic*: "http://github.com/justinfrench/formtastic":http://github.com/justinfrench/formtastic

Expand All @@ -95,22 +99,26 @@ h4. Standard

Using ActionController:

<pre>def new
<pre>
def new
@duck = Duck.new

respond_to do |format|
format.html # new.html.haml
format.xml { render :xml => @duck }
format.json { render :json => @duck }
end
end</pre>
end
</pre>

h4. Resourceful

Using InheritedResources:

<pre>actions :new
respond_to :html, :xml, :json</pre>
<pre>
actions :new
respond_to :html, :xml, :json
</pre>

Find out more about *inherited_resources*: "http://github.com/josevalim/inherited_resources":http://github.com/josevalim/inherited_resources

Expand All @@ -128,7 +136,8 @@ h4. Standard

ActionController with pagination:

<pre>before_filter :load_resource, :only => [:show, :edit, :update, :destroy]
<pre>
before_filter :load_resource, :only => [:show, :edit, :update, :destroy]
before_filter :load_and_paginate_resources, :only => [:index]

...
Expand All @@ -146,20 +155,23 @@ protected
def resource
@resource = @resource = ||= Duck.find(params[:id])
end
alias :load_resource :resource</pre>
alias :load_resource :resource
</pre>

h4. Resourceful

InheritedResources with pagination:

<pre>protected
<pre>
protected

def collection
paginate_options ||= {}
paginate_options[:page] ||= (params[:page] || 1)
paginate_options[:per_page] ||= (params[:per_page] || 20)
@resources ||= end_of_association_chain.paginate(paginate_options)
end</pre>
end
</pre>

h3. View Partials

Expand All @@ -168,13 +180,6 @@ A very common pattern is to break up views in partials, which is also what DrySc
* @new@/@edit@ => @_form@
* @index@ => @_item@

h3. More To Come... (TODO)

These are things I have in mind:

* Handle belongs_to, i.e. specify MODEL --belongs-to PARENT_MODEL, which generates proper routes, proper before-filters if inherited_resources-controller, adding belongs_to-association in model, and correct form_for arguments.
* RSpec-support?

h2. Setup

Installing DryScaffold is easy:
Expand All @@ -185,11 +190,11 @@ Install DryScaffold...

h4. Gem (Recommended)

<pre>sudo gem install grimen-dry_scaffold --source http://gems.github.com</pre>
<pre>sudo gem install dry_scaffold</pre>

...and in config: @config/environments/development.rb@

<pre>config.gem 'grimen-dry_scaffold', :lib => false, :source => 'http://gems.github.com'</pre>
<pre>config.gem 'dry_scaffold', :lib => false</pre>

h4. Plugin

Expand All @@ -211,46 +216,58 @@ h4. Manual

Get the gems...you want:

<pre>sudo gem install haml
sudo gem install mislav-will_paginate
sudo gem install justinfrench-formtastic
sudo gem install josevalim-inherited_resources</pre>
<pre>
sudo gem install haml
sudo gem install will_paginate
sudo gem install formtastic
sudo gem install inherited_resources
</pre>

...and same for the config config: @config/environments/development.rb@

<pre>config.gem 'haml'
<pre>
config.gem 'haml'
config.gem 'will_paginate'
config.gem 'justinfrench-formtastic', :lib => 'formtastic', :source => 'http://gems.github.com'
config.gem 'josevalim-inherited_resources', :lib => 'inherited_resources', :source => 'http://gems.github.com'</pre>
config.gem 'formtastic'
config.gem 'inherited_resources'
</pre>

Also configure @config/environments/test.rb@ with the RSpec library if you want to

<pre>config.gem 'rspec'
config.gem 'rspec-rails'</pre>
<pre>
config.gem 'rspec'
config.gem 'rspec-rails'
</pre>

And don't forget to initialize it as well:

<pre>./script/generate rspec</pre>
<pre>
./script/generate rspec
</pre>

To access Rake tasks in Rails from the gem version of DryScaffold you need to do this:

In your project @Rakefile@:

<pre>
require 'dry_scaffold/tasks'
require 'dry_scaffold/tasks'
</pre>

Don't ask me why me why this is the only way with gems...Ask the Rails core team, because this is not conventions over configuration. Raur...

h2. Usage

<pre>./script/generate dry_scaffold ModelName [attribute:type attribute:type] [_actions:new,create,...] [_formats:html,json,...] [_indexes:attribute,...] [--skip-pagination] [--skip-resourceful] [--skip-formtastic] [--skip-views] [--skip-helpers] [--skip-migration] [--skip-timestamps] [--skip-tests] [--skip-controller-tests] [--layout] [--tunit] [--shoulda] [--rspec] [--fixtures] [--fgirl] [--machinist] [--odaddy]</pre>
<pre>
./script/generate dry_scaffold ModelName [attribute:type attribute:type] [_actions:new,create,...] [_formats:html,json,...] [_indexes:attribute,...] [--skip-pagination] [--skip-resourceful] [--skip-formtastic] [--skip-views] [--skip-helpers] [--skip-migration] [--skip-timestamps] [--skip-tests] [--skip-controller-tests] [--layout] [--tunit] [--shoulda] [--rspec] [--fixtures] [--fgirl] [--machinist] [--odaddy]
</pre>

...or use the alias @dscaffold@ instead of @dry_scaffold@.

For generating just a *model*, then use:

<pre>./script/generate dry_model ModelName [attribute:type attribute:type] [_indexes:attribute,...] [--skip-migration] [--skip-timestamps] [--skip-tests] [--tunit] [--shoulda] [--rspec] [--fixtures] [--fgirl] [--machinist] [--odaddy]</pre>
<pre>
./script/generate dry_model ModelName [attribute:type attribute:type] [_indexes:attribute,...] [--skip-migration] [--skip-timestamps] [--skip-tests] [--tunit] [--shoulda] [--rspec] [--fixtures] [--fgirl] [--machinist] [--odaddy]
</pre>

...or use the alias @dmodel@ instead of @dry_model@.

Expand Down Expand Up @@ -453,4 +470,4 @@ At last, positive feedback is always appreciated!

h2. License

Copyright (c) 2009 Jonas Grimfelt, released under the MIT-license.
Copyright (c) 2009 Jonas Grimfelt, released under the MIT-license.
34 changes: 20 additions & 14 deletions Rakefile
Expand Up @@ -4,28 +4,34 @@ require 'rake/rdoctask'

NAME = "dry_scaffold"
SUMMARY = %Q{A DRYer scaffold generator for Rails. Generates dry semantic and standards compliant views, and dry RESTful controllers.}
HOMEPAGE = "http://github.com/grimen/#{NAME}/tree/master"
HOMEPAGE = "http://github.com/grimen/#{NAME}"
AUTHOR = "Jonas Grimfelt"
EMAIL = "grimen@gmail.com"
SUPPORT_FILES = %w(README.textile TODO.textile CHANGELOG.textile)

begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = NAME
gem.summary = SUMMARY
gem.description = SUMMARY
gem.homepage = HOMEPAGE
gem.author = AUTHOR
gem.email = EMAIL
Jeweler::Tasks.new do |gemspec|
gemspec.name = NAME
gemspec.summary = SUMMARY
gemspec.description = SUMMARY
gemspec.homepage = HOMEPAGE
gemspec.author = AUTHOR
gemspec.email = EMAIL

gem.require_paths = %w{lib}
gem.files = %w(MIT-LICENSE Rakefile) + SUPPORT_FILES + Dir.glob(File.join('{bin,config,generators,lib,rails,tasks}', '**', '*'))
gem.executables = %w(dscaffold dry_scaffold dmodel dry_model)
gem.extra_rdoc_files = SUPPORT_FILES
gemspec.require_paths = %w{lib}
gemspec.files = %w(MIT-LICENSE Rakefile) << SUPPORT_FILES <<
Dir.glob(File.join('{bin,config,generators,lib,tasks}', '**', '*').to_s)
gemspec.executables = %w(dscaffold dry_scaffold dmodel dry_model)
gemspec.extra_rdoc_files = SUPPORT_FILES

gemspec.add_dependency 'haml'
end

Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
puts "Jeweler, or one of its dependencies, is not available. " <<
"Install it with: sudo gem install jeweler -s http://gemcutter.org"
end

desc %Q{Run unit tests for "#{NAME}".}
Expand All @@ -45,4 +51,4 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.options << '--line-numbers' << '--inline-source' << '--charset=UTF-8'
rdoc.rdoc_files.include(SUPPORT_FILES)
rdoc.rdoc_files.include(File.join('lib', '**', '*.rb'))
end
end
6 changes: 1 addition & 5 deletions TODO.textile
Expand Up @@ -3,16 +3,12 @@ h1. TODO
h2. Next

* Bug/Issue: InheritedResources functional testing issue.
* Feature: RSpec-templates?
* Optimization: Write even better functional tests for REST-actions. Goal: Killer-tests, i.e. "best practice"-tests. Suggestion: Routing, formats, ...
* Feature: Auto-detection of testing frameworks in working project.
* Feature: Check for overridden templates in: RAILS_ROOT/lib/dry_scaffold/templates/

h2. Maybe

* Feature: Check for overridden templates in: RAILS_ROOT/lib/dry_scaffold/templates/
* Feature: Handle belongs_to, i.e. specify MODEL --belongs-to PARENT_MODEL, which generates proper routes, proper before-filters if inherited_resources-controller, adding belongs_to-association in model, and correct form_for arguments.
* Feature: Builder for podcast-feed, similar to RSS/Atom-builders. http://wiki.github.com/radiant/radiant/host-a-podcast
* Tests: Generator tests. =P (Not very straightforward...)

h2. Issues

Expand Down
2 changes: 1 addition & 1 deletion VERSION.yml
@@ -1,4 +1,4 @@
---
:minor: 3
:patch: 5
:patch: 6
:major: 0
12 changes: 7 additions & 5 deletions dry_scaffold.gemspec
Expand Up @@ -5,11 +5,11 @@

Gem::Specification.new do |s|
s.name = %q{dry_scaffold}
s.version = "0.3.5"
s.version = "0.3.6"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Jonas Grimfelt"]
s.date = %q{2009-09-16}
s.date = %q{2009-12-31}
s.description = %q{A DRYer scaffold generator for Rails. Generates dry semantic and standards compliant views, and dry RESTful controllers.}
s.email = %q{grimen@gmail.com}
s.executables = ["dscaffold", "dry_scaffold", "dmodel", "dry_model"]
Expand Down Expand Up @@ -90,22 +90,24 @@ Gem::Specification.new do |s|
"lib/dry_generator.rb",
"lib/dry_scaffold/tasks.rb",
"lib/setup_helper.rb",
"rails/init.rb",
"tasks/dry_scaffold.rake"
]
s.homepage = %q{http://github.com/grimen/dry_scaffold/tree/master}
s.homepage = %q{http://github.com/grimen/dry_scaffold}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.3}
s.rubygems_version = %q{1.3.5}
s.summary = %q{A DRYer scaffold generator for Rails. Generates dry semantic and standards compliant views, and dry RESTful controllers.}

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_runtime_dependency(%q<haml>, [">= 0"])
else
s.add_dependency(%q<haml>, [">= 0"])
end
else
s.add_dependency(%q<haml>, [">= 0"])
end
end

0 comments on commit e8bdef1

Please sign in to comment.