responders 0.4.3 → 0.4.4
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.rdoc +5 -22
- data/lib/responders/http_cache_responder.rb +2 -1
- data/lib/responders/version.rb +1 -1
- data/test/test_helper.rb +0 -1
- metadata +2 -6
- data/lib/generators/USAGE +0 -11
- data/lib/generators/responders_controller_generator.rb +0 -17
- data/lib/generators/responders_install_generator.rb +0 -14
- data/lib/generators/templates/controller.rb +0 -53
data/README.rdoc
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
== Responders
|
2
2
|
|
3
|
-
A set of responders modules to dry up your Rails
|
3
|
+
A set of responders modules to dry up your Rails application. This branch (v0.4) is meant
|
4
|
+
to be used with Rails 2.3 with Inherited Resources. Check the master branch for Rails 3
|
5
|
+
version.
|
4
6
|
|
5
7
|
* FlashResponder - Sets the flash based on the controller action and resource status.
|
6
8
|
For instance, if you do: respond_with(@post) on a POST request and the resource @post
|
@@ -34,28 +36,9 @@ A set of responders modules to dry up your Rails 3 app:
|
|
34
36
|
allows clients to easily query the server if a resource changed and if the client tries
|
35
37
|
to retrieve a resource that has not been modified, it returns not_modified status.
|
36
38
|
|
37
|
-
==
|
39
|
+
== Installation
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
sudo gem install responders
|
42
|
-
|
43
|
-
Responders only provides a set of modules, to use them, you have to create your own
|
44
|
-
responder. This can be done in an initializer for example:
|
45
|
-
|
46
|
-
class AppResponder < ActionController::Responder
|
47
|
-
include Responders::FlashResponder
|
48
|
-
include Responders::HttpCacheResponder
|
49
|
-
end
|
50
|
-
|
51
|
-
== Generator
|
52
|
-
|
53
|
-
This gem also includes a responders controller generator, so your scaffold can be customized
|
54
|
-
to use respond_with instead of default respond_to blocks just by configuring your environment:
|
55
|
-
|
56
|
-
config.generators do |g|
|
57
|
-
g.scaffold_controller = :responders_controller
|
58
|
-
end
|
41
|
+
sudo gem install responders --version=0.4.2
|
59
42
|
|
60
43
|
== Bugs and Feedback
|
61
44
|
|
@@ -33,7 +33,8 @@ module Responders
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def do_http_cache?
|
36
|
-
get? && @http_cache != false &&
|
36
|
+
get? && @http_cache != false && ActionController::Base.perform_caching &&
|
37
|
+
!new_record? && controller.response.last_modified.nil?
|
37
38
|
end
|
38
39
|
|
39
40
|
def new_record?
|
data/lib/responders/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -18,7 +18,6 @@ require 'mocha'
|
|
18
18
|
ENV["RAILS_ENV"] = "test"
|
19
19
|
RAILS_ROOT = "anywhere"
|
20
20
|
|
21
|
-
require File.expand_path(File.dirname(__FILE__) + "/../../rails/vendor/gems/environment")
|
22
21
|
require 'active_support'
|
23
22
|
require 'action_controller'
|
24
23
|
require 'action_controller/test_case'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: responders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Jos\xC3\xA9 Valim"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02
|
12
|
+
date: 2010-03-02 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -26,10 +26,6 @@ files:
|
|
26
26
|
- MIT-LICENSE
|
27
27
|
- README.rdoc
|
28
28
|
- Rakefile
|
29
|
-
- lib/generators/USAGE
|
30
|
-
- lib/generators/responders_controller_generator.rb
|
31
|
-
- lib/generators/responders_install_generator.rb
|
32
|
-
- lib/generators/templates/controller.rb
|
33
29
|
- lib/responders.rb
|
34
30
|
- lib/responders/flash_responder.rb
|
35
31
|
- lib/responders/http_cache_responder.rb
|
data/lib/generators/USAGE
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
Description:
|
2
|
-
Stubs out a scaffolded controller and its views. Different from rails
|
3
|
-
scaffold_controller, it uses respond_with instead of respond_to blocks.
|
4
|
-
Pass the model name, either CamelCased or under_scored. The controller
|
5
|
-
name is retrieved as a pluralized version of the model name.
|
6
|
-
|
7
|
-
To create a controller within a module, specify the model name as a
|
8
|
-
path like 'parent_module/controller_name'.
|
9
|
-
|
10
|
-
This generates a controller class in app/controllers and invokes helper,
|
11
|
-
template engine and test framework generators.
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'generators/rails/scaffold_controller/scaffold_controller_generator'
|
2
|
-
|
3
|
-
module Rails
|
4
|
-
module Generators
|
5
|
-
class RespondersControllerGenerator < ScaffoldControllerGenerator
|
6
|
-
def self.source_root
|
7
|
-
@source_root ||= File.expand_path("templates", File.dirname(__FILE__))
|
8
|
-
end
|
9
|
-
|
10
|
-
protected
|
11
|
-
|
12
|
-
def flash?
|
13
|
-
!ApplicationController.responder.ancestors.include?(Responders::FlashResponder)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class RespondersInstallGenerator < Rails::Generators::Base
|
2
|
-
desc "Creates an initializer with default responder configuration"
|
3
|
-
|
4
|
-
def create_responder_initializer
|
5
|
-
create_file "config/initializers/responders.rb", <<-FILE
|
6
|
-
class #{Rails.application.class.name}Responder
|
7
|
-
include FlashResponder
|
8
|
-
include HttpCacheResponder
|
9
|
-
end
|
10
|
-
|
11
|
-
ApplicationController.responder = #{Rails.application.class.name}Responder
|
12
|
-
FILE
|
13
|
-
end
|
14
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
class <%= controller_class_name %>Controller < ApplicationController
|
2
|
-
<% unless options[:singleton] -%>
|
3
|
-
# GET /<%= table_name %>
|
4
|
-
# GET /<%= table_name %>.xml
|
5
|
-
def index
|
6
|
-
@<%= table_name %> = <%= orm_class.all(class_name) %>
|
7
|
-
respond_with(@<%= table_name %>)
|
8
|
-
end
|
9
|
-
<% end -%>
|
10
|
-
|
11
|
-
# GET /<%= table_name %>/1
|
12
|
-
# GET /<%= table_name %>/1.xml
|
13
|
-
def show
|
14
|
-
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
15
|
-
respond_with(@<%= file_name %>)
|
16
|
-
end
|
17
|
-
|
18
|
-
# GET /<%= table_name %>/new
|
19
|
-
# GET /<%= table_name %>/new.xml
|
20
|
-
def new
|
21
|
-
@<%= file_name %> = <%= orm_class.build(class_name) %>
|
22
|
-
respond_with(@<%= file_name %>)
|
23
|
-
end
|
24
|
-
|
25
|
-
# GET /<%= table_name %>/1/edit
|
26
|
-
def edit
|
27
|
-
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
28
|
-
end
|
29
|
-
|
30
|
-
# POST /<%= table_name %>
|
31
|
-
# POST /<%= table_name %>.xml
|
32
|
-
def create
|
33
|
-
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
|
34
|
-
<%= "flash[:notice] = '#{class_name} was successfully created.' if " if flash? %>@<%= orm_instance.save %>
|
35
|
-
respond_with(@<%= file_name %>)
|
36
|
-
end
|
37
|
-
|
38
|
-
# PUT /<%= table_name %>/1
|
39
|
-
# PUT /<%= table_name %>/1.xml
|
40
|
-
def update
|
41
|
-
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
42
|
-
<%= "flash[:notice] = '#{class_name} was successfully updated.' if " if flash? %>@<%= orm_instance.update_attributes("params[:#{file_name}]") %>
|
43
|
-
respond_with(@<%= file_name %>)
|
44
|
-
end
|
45
|
-
|
46
|
-
# DELETE /<%= table_name %>/1
|
47
|
-
# DELETE /<%= table_name %>/1.xml
|
48
|
-
def destroy
|
49
|
-
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
50
|
-
@<%= orm_instance.destroy %>
|
51
|
-
respond_with(@<%= file_name %>)
|
52
|
-
end
|
53
|
-
end
|