dream_gens 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,11 +4,16 @@ h1. Dream Gens
4
4
 
5
5
  _If you enjoy these tools please give me a recommendation at: "working with rails!":http://www.workingwithrails.com/recommendation/new/person/10611_
6
6
 
7
+ These generators can be used stand-alone, however, to ensure that you have all of the gems needed and your file structure the way these gens expect it does go hand in hand with my rails template...
8
+
9
+ h4. "dream_template":http://github.com/dreamr/dream_template
10
+
11
+ The easiest path to to create your rails app with the template above, then install the dream_gens gem and you are ready to go with cucumber, rspec, and more with autospec!
12
+
7
13
  Please be restful. If you decide you want to leave the golden path you should fork this and make it so you can do your weird, non restful shit. These gens are purely an effort to get back to the original beauty of what drew many to rails, only updated for TDD/BDD using the technologies listed below.
8
14
 
9
15
  Step by step these generators will build the bare bones skeleton for a restfully designed resource to match a feature.
10
16
 
11
-
12
17
  h3. Generators for rapid rails development WITH testing!
13
18
 
14
19
  Preconfigured for development using:
@@ -1,4 +1,9 @@
1
1
  class <%= plural_name.capitalize %>Controller < ApplicationController
2
+
3
+ <% actions = (rest_actions & [":show", ":edit", ":update", ":destroy"]).join(", ") if rest_actions -%>
4
+ <%= " before_filter :find_#{singular_name}, :only => [#{actions}] " unless actions.empty? -%>
5
+
6
+
2
7
  <% action = <<-EOS
3
8
 
4
9
  # GET /#{plural_name}
@@ -19,8 +24,6 @@ EOS
19
24
  # GET /#{plural_name}/1
20
25
  # GET /#{plural_name}/1.xml
21
26
  def show
22
- @#{singular_name} = #{singular_name.capitalize}.find(params[:id])
23
-
24
27
  respond_to do |format|
25
28
  format.html # show.html.erb
26
29
  format.xml { render :xml => @#{singular_name} }
@@ -48,7 +51,6 @@ EOS
48
51
 
49
52
  # GET /#{plural_name}/1/edit
50
53
  def edit
51
- @#{singular_name} = #{singular_name.capitalize}.find(params[:id])
52
54
  end
53
55
  EOS
54
56
  -%>
@@ -79,8 +81,6 @@ EOS
79
81
  # PUT /#{plural_name}/1
80
82
  # PUT /#{plural_name}/1.xml
81
83
  def update
82
- @#{singular_name} = #{singular_name.capitalize}.find(params[:id])
83
-
84
84
  respond_to do |format|
85
85
  if @#{singular_name}.update_attributes(params[:#{singular_name}])
86
86
  flash[:notice] = '#{singular_name.capitalize} was successfully updated.'
@@ -100,7 +100,6 @@ EOS
100
100
  # DELETE /#{plural_name}/1
101
101
  # DELETE /#{plural_name}/1.xml
102
102
  def destroy
103
- @#{singular_name} = #{singular_name.capitalize}.find(params[:id])
104
103
  @#{singular_name}.destroy
105
104
 
106
105
  respond_to do |format|
@@ -112,3 +111,15 @@ EOS
112
111
  -%>
113
112
  <%= action if rest_actions.include?(":destroy") -%>
114
113
  end
114
+
115
+ <% method = <<-EOS
116
+
117
+ def find_#{singular_name}
118
+ @#{singular_name} = #{singular_name.camelize}.find(params[:id])
119
+ end
120
+ EOS
121
+ -%>
122
+ <%= method unless (rest_actions & [":show", ":edit", ":update", ":destroy"]).empty? -%>
123
+
124
+
125
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dream_gens
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dreamr (James OKelly)