shakes 0.3.0 → 0.3.1

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.
data/README.md CHANGED
@@ -1,6 +1,3 @@
1
- __WARNING__ At this point I am making no attempt at maintaining backwards compatibility. Consider Shakes alpha
2
- level code and use at your own risk.
3
-
4
1
  Welcome to Shakes
5
2
  =================
6
3
  Using `script/generate scaffold` creates a bunch of boilerplate code that you then have to modify by hand every time you
@@ -11,6 +8,8 @@ Shakes provides default implementations for your Rails controller actions and vi
11
8
  once place for all controllers. You can add the boilerplate by adding just a single line to your controller. By
12
9
  necessity, Shakes views are dynamic so as you make changes to your models those changes are reflected in the views.
13
10
 
11
+ Shakes also provides a collection of generators that are designed to help you better take advantage of Shakes.
12
+
14
13
  Installing Shakes
15
14
  -----------------
16
15
  Add it to your environment.rb configuration as a gem dependency:
@@ -52,35 +51,41 @@ Overriding the default views for a specific resource is just as simple. You just
52
51
  I wanted to change the view for `articles#show`, I could just create my custom view at `app/views/article/show.html.erb`
53
52
  and that view will be used.
54
53
 
55
- Generators
56
- ----------
57
- Shakes provides a collection of generators that are designed to help you better take advantage of Shakes.
58
-
59
- If you want to change the default views that Shakes uses you can run the following command and editable files will be
60
- placed in `app/views/shakes`:
61
-
62
- script/generate shakes_views
54
+ Change The Default Actions
55
+ --------------------------
56
+ You can change the default actions that Shakes uses. First you need to install the Shakes initializer at
57
+ `config/initializers/shakes.rb`. Run the following command to install the initialization file:
63
58
 
64
- If you want to install the Formtastic stylesheets and create a version of `app/views/layout/application.html.erb` that
65
- includes them for you, run the following command:
59
+ script/generate shakes_actions
66
60
 
67
- script/generate shakes_layout
61
+ Then you can create your new default implementation for you custom default action. For example, to change the index
62
+ action I would create a module like so:
68
63
 
69
- Additionally, you can create more named layouts by running the command and passing the layout name. For example, the
70
- following command will create a new layout at `app/views/layouts/article.html.erb`:
64
+ module ShakesIndexOverride
65
+ def index
66
+ # default index implementation goes here
67
+ end
68
+ end
71
69
 
72
- script/generate shakes_layout article
70
+ Finally, you need to change the Shakes configuration in `config/initializers/shakes.rb` to tell Shakes to use your
71
+ new default action implementation. For example, to use the index action in the previous example I would change to
72
+ configuration to the following:
73
73
 
74
- You can create the customizable default views and the application layout in one easy step. Just run the following
75
- command and both generators will execute for you:
74
+ # Set the default index action module. Default is Shakes::Actions::Index
75
+ Shakes::HasTheShakes::Configuration.index_action = ShakesIndexOverride
76
+
77
+ Change The Default Views
78
+ ------------------------
79
+ If you want to change the default views that Shakes uses, you can run the following command and editable files will be
80
+ placed in `app/views/shakes`:
76
81
 
77
- script/generate shakes
82
+ script/generate shakes_views
78
83
 
79
- Formtastic
80
- ----------
84
+ Formtastic Aware Layouts
85
+ ------------------------
81
86
  The default `new` and `edit` view implementations use Formtastic to create the form HTML. To get the most out of
82
- Formtastic, I suggest you install and use the stylesheets that are included in the gem. See the section on Generators
83
- above to see how this can be done automatically for you.
87
+ Formtastic, I suggest you install and use the stylesheets that are included in the gem. See the section on Formtastic
88
+ Aware Layouts above to see how this can be done automatically for you.
84
89
 
85
90
  Run the following command to install the stylesheets (and the Formtastic initializer):
86
91
 
@@ -94,9 +99,25 @@ Then add the following code to your layout to include the stylesheets:
94
99
  ...
95
100
  </head>
96
101
 
102
+ Because this is likely to be common, Shakes provides a generator that will install the Formtastic stylesheets and create
103
+ a version of `app/views/layout/application.html.erb` that includes them for you. Just run the following command:
104
+
105
+ script/generate shakes_layout
106
+
107
+ Additionally, you can create more named layouts by running the command and passing the layout name. For example, the
108
+ following command will create a new Formtastic aware layout at `app/views/layouts/article.html.erb`:
109
+
110
+ script/generate shakes_layout article
111
+
97
112
  See the [Formtastic](http://github.com/justinfrench/formtastic) project page for more information.
98
113
 
114
+ You Can Have It All
115
+ -------------------
116
+ You can create the customizable default views and actions and the application layout in one easy step. Just run the
117
+ following command and it will run the `shakes_actions`, `shakes_views` and `shakes_layout` generators all at once:
118
+
119
+ script/generate shakes
120
+
99
121
  TODO
100
122
  ----
101
123
  * Test against Rails 3 (needs GA'ed Formtastic support for Rails 3)
102
- * Allow for application specific overrides of default action implementations
@@ -5,10 +5,9 @@ class ShakesGenerator < Rails::Generator::Base
5
5
 
6
6
  def manifest
7
7
  record do |m|
8
- m.directory 'config/initializers'
9
- m.file 'initializer.rb', "config/initializers/shakes.rb"
10
8
  m.dependency 'shakes_layout', []
11
9
  m.dependency 'shakes_views', []
10
+ m.dependency 'shakes_actions', []
12
11
  end
13
12
  end
14
13
 
@@ -0,0 +1,22 @@
1
+ class ShakesActionsGenerator < Rails::Generator::Base
2
+ def initialize(runtime_args, runtime_options = {})
3
+ super
4
+ end
5
+
6
+ def manifest
7
+ record do |m|
8
+ m.directory 'config/initializers'
9
+ m.file 'initializer.rb', "config/initializers/shakes.rb"
10
+ end
11
+ end
12
+
13
+ def file_name
14
+ @name.underscore
15
+ end
16
+
17
+ protected
18
+
19
+ def banner
20
+ "Usage: #{$0} #{spec.name}"
21
+ end
22
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shakes
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Stahl
@@ -49,7 +49,8 @@ files:
49
49
  - app/views/shakes/new.html.erb
50
50
  - app/views/shakes/show.html.erb
51
51
  - generators/shakes/shakes_generator.rb
52
- - generators/shakes/templates/initializer.rb
52
+ - generators/shakes_actions/shakes_actions_generator.rb
53
+ - generators/shakes_actions/templates/initializer.rb
53
54
  - generators/shakes_layout/shakes_layout_generator.rb
54
55
  - generators/shakes_layout/templates/layout.html.erb
55
56
  - generators/shakes_layout/templates/stylesheet.css