response_for_rc_rails 0.2.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/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ doc/*
3
+ pkg/
4
+ Gemfile.lock
5
+ .rvmrc
data/CHANGELOG ADDED
@@ -0,0 +1,3 @@
1
+ * 0.2.1 - Gemify [tahnks Josh Goebel], and remove Ardes module (bc ok)
2
+
3
+ * response_for_rc - if you're using github resources_controller and response_for, you probably want this!
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007-2012 Ian White - ian.w.white@ardes.com
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,75 @@
1
+ response_for_rc
2
+
3
+ if you're using resources_controller[http://github.com/ianwhite/resources_controller] and
4
+ response_for[http://github.com/ianwhite/response_for], you probably want this!
5
+
6
+ == What is it?
7
+
8
+ It's an alternate set of RC actions, written in response_for style.
9
+
10
+ == How to use it?
11
+
12
+ For Rails 3.0 and newer just add it to your Gemfile:
13
+
14
+ gem 'response_for_rc'
15
+
16
+ This will install resources_controller and response_for.
17
+
18
+ For older versions of rails you'll need to install the rails2 branch in vendor/plugins:
19
+
20
+ cd vendor/plugins
21
+ git clone git://github.com/ianwhite/response_for_rc.git
22
+ cd response_for_rc
23
+ git checkout rails2
24
+ rmdir -f .git
25
+
26
+ == What else can I do with it?
27
+
28
+ If you're writing your own RC actions with responses, refactored in modules, you've probably noticed what an ass it
29
+ is to add the responses (you need to stick it in self.included and add them on the including class, etc, etc).
30
+
31
+ Recent developments on response_for resources_controller, and now response_for_rc, mean you can now do stuff like this
32
+
33
+ module MyActions
34
+ extend RcResponseFor::ResponsesModule # <= this baby gives your module the ability to understand response_for
35
+ # <= and to add responses to any including controller
36
+ def new
37
+ # your new
38
+ end
39
+
40
+ response_for :new do |format|
41
+ # your new response
42
+ end
43
+
44
+ def show
45
+ # your show
46
+ end
47
+
48
+ response_for :show do |format|
49
+ # your show response
50
+ end
51
+
52
+ # and others
53
+ end
54
+
55
+ # later
56
+
57
+ class FoosController < ApplicationController
58
+ resources_controller_for :foos, :actions => MyActions
59
+
60
+ # you get all of the above actions and responses
61
+ end
62
+
63
+ # also works with :only and :except
64
+ class BarsController < ApplicationController
65
+ resources_controller_for :bars, :actions => MyActions, :only => [:new]
66
+
67
+ # only get new and new response
68
+ end
69
+
70
+ # if you want to set your own actions globally (as the default, look in init.rb to see how)
71
+
72
+ == Requirements
73
+
74
+ You need resources_controller (gem rc_rails) and response_for (gem response_for_rails). These are installed for you if using bundler.
75
+
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'ResponseForRc'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG', 'MIT-LICENSE')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ Bundler::GemHelper.install_tasks
24
+
25
+ require 'rspec/core/rake_task'
26
+
27
+ task :default => [:spec]
28
+
29
+ desc "Run the specs"
30
+ RSpec::Core::RakeTask.new(:spec => []) do |t|
31
+ t.pattern = "./spec/**/*_spec.rb"
32
+ end
@@ -0,0 +1,92 @@
1
+ module ResponseForRc#:nodoc:
2
+ # actions using response_for
3
+ module Actions
4
+ extend ResponseForRc::ResponsesModule
5
+
6
+ def index
7
+ self.resources = find_resources
8
+ end
9
+
10
+ response_for :index do |format|
11
+ format.html
12
+ format.js
13
+ format.xml { render :xml => resources }
14
+ end
15
+
16
+
17
+ def show
18
+ self.resource = find_resource
19
+ end
20
+
21
+ def new
22
+ self.resource = new_resource
23
+ end
24
+
25
+ def edit
26
+ self.resource = find_resource
27
+ end
28
+
29
+ response_for :show, :new, :edit do |format|
30
+ format.html
31
+ format.js
32
+ format.xml { render :xml => resource }
33
+ end
34
+
35
+
36
+ def create
37
+ self.resource = new_resource
38
+ @resource_saved = resource.save
39
+ end
40
+
41
+ response_for :create do |format|
42
+ if @resource_saved
43
+ format.html do
44
+ flash[:notice] = "#{resource_name.humanize} was successfully created."
45
+ redirect_to resource_url
46
+ end
47
+ format.js
48
+ format.xml { render :xml => resource, :status => :created, :location => resource_url }
49
+ else
50
+ format.html { render :action => "new" }
51
+ format.js { render :action => "new" }
52
+ format.xml { render :xml => resource.errors, :status => :unprocessable_entity }
53
+ end
54
+ end
55
+
56
+
57
+ def update
58
+ self.resource = find_resource
59
+ @resource_saved = resource.update_attributes(params[resource_name])
60
+ end
61
+
62
+ response_for :update do |format|
63
+ if @resource_saved
64
+ format.html do
65
+ flash[:notice] = "#{resource_name.humanize} was successfully updated."
66
+ redirect_to resource_url
67
+ end
68
+ format.js
69
+ format.xml { head :ok }
70
+ else
71
+ format.html { render :action => "edit" }
72
+ format.js { render :action => "edit" }
73
+ format.xml { render :xml => resource.errors, :status => :unprocessable_entity }
74
+ end
75
+ end
76
+
77
+
78
+ def destroy
79
+ self.resource = find_resource
80
+ resource.destroy
81
+ end
82
+
83
+ response_for :destroy do |format|
84
+ format.html do
85
+ flash[:notice] = "#{resource_name.humanize} was successfully destroyed."
86
+ redirect_to resources_url
87
+ end
88
+ format.js
89
+ format.xml
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,24 @@
1
+ module ResponseForRc
2
+ # Just like ResponseFor::ResponsesModule, but also handles the :except, :only options
3
+ module ResponsesModule
4
+ include ResourcesController::IncludeActions
5
+
6
+ def self.extended(mixin)
7
+ mixin.extend ResponseFor::ResponsesModule
8
+ end
9
+
10
+ # as well as undefing an exlcuded action from the dup mixin, we
11
+ # also remove its response
12
+ def remove_action_method(action)
13
+ undef_method action
14
+ remove_response_for action
15
+ end
16
+
17
+ # when we clone, we need to copy our action_responses
18
+ def clone
19
+ c=super
20
+ c.instance_variable_set('@action_responses', action_responses.clone)
21
+ c
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,21 @@
1
+ module ResponseForRc#:nodoc:
2
+ # singleton actions using response_for
3
+ module SingletonActions
4
+ extend ResponseForRc::ResponsesModule
5
+
6
+ include ResponseForRc::Actions
7
+
8
+ undef_method :index
9
+
10
+ remove_response_for :index, :destroy
11
+
12
+ response_for :destroy do |format|
13
+ format.html do
14
+ flash[:notice] = "#{resource_name.humanize} was successfully destroyed."
15
+ redirect_to enclosing_resource_url if enclosing_resource
16
+ end
17
+ format.js
18
+ format.xml
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module ResponseForRc #:nodoc:
2
+ VERSION = "0.2.1"
3
+ end
@@ -0,0 +1,14 @@
1
+ require 'response_for_rc/responses_module'
2
+ require 'response_for_rc/actions'
3
+ require 'response_for_rc/singleton_actions'
4
+
5
+ if defined? ResourcesController
6
+ ResourcesController.actions = ResponseForRc::Actions
7
+ ResourcesController.singleton_actions = ResponseForRc::SingletonActions
8
+ end
9
+
10
+ # BC
11
+ module Ardes
12
+ ResponseForRc = ::ResponseForRc
13
+ RcResponsesModule = ::ResponseForRc::ResponsesModule
14
+ end
@@ -0,0 +1 @@
1
+ require 'response_for_rc'
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
4
+ require 'response_for_rc/version'
5
+ version = ResponseForRc::VERSION
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "response_for_rc_rails"
9
+ s.version = version
10
+ s.platform = Gem::Platform::RUBY
11
+ s.authors = ["Ian White"]
12
+ s.email = "ian.w.white@gmail.com"
13
+ s.homepage = "http://github.com/ianwhite/response_for_rc"
14
+ s.summary = "response_for_rc-#{version}"
15
+ s.description = "It's an alternate set of RC actions, written in response_for style."
16
+
17
+ s.rubygems_version = "1.3.7"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
21
+ s.extra_rdoc_files = [ "README.rdoc" ]
22
+ s.rdoc_options = ["--charset=UTF-8"]
23
+ s.require_path = "lib"
24
+
25
+ s.add_runtime_dependency "rc_rails", '>= 2.1'
26
+ s.add_runtime_dependency "response_for_rails", '>= 0.4'
27
+ s.add_runtime_dependency "rails", '>= 3.0.0'
28
+
29
+ s.add_development_dependency "rspec", '>= 2.8.0'
30
+ s.add_development_dependency "rspec-rails", '>= 2.8.0'
31
+ s.add_development_dependency 'sqlite3'
32
+ end
@@ -0,0 +1,13 @@
1
+ # load up the resources_controller specs
2
+
3
+ # TODO: figure out how to do this with gems
4
+ #plugins_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
5
+ #rc_path = File.join(plugins_path, 'resources_controller')
6
+ #
7
+ #unless File.exist?(rc_path) && File.exist?(File.join(plugins_path, 'response_for'))
8
+ # raise "response_for_rc specs require resources_controller and response_for"
9
+ #end
10
+ #
11
+ #Dir[File.join("#{rc_path}", '**', '*_spec.rb')].each do |spec|
12
+ # require spec
13
+ #end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: response_for_rc_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ian White
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rc_rails
16
+ requirement: &70318778361040 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '2.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70318778361040
25
+ - !ruby/object:Gem::Dependency
26
+ name: response_for_rails
27
+ requirement: &70318778360240 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0.4'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70318778360240
36
+ - !ruby/object:Gem::Dependency
37
+ name: rails
38
+ requirement: &70318778359560 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 3.0.0
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70318778359560
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70318778359020 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.8.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70318778359020
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec-rails
60
+ requirement: &70318778357940 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: 2.8.0
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70318778357940
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: &70318778356740 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70318778356740
80
+ description: It's an alternate set of RC actions, written in response_for style.
81
+ email: ian.w.white@gmail.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files:
85
+ - README.rdoc
86
+ files:
87
+ - .gitignore
88
+ - CHANGELOG
89
+ - Gemfile
90
+ - MIT-LICENSE
91
+ - README.rdoc
92
+ - Rakefile
93
+ - lib/response_for_rc.rb
94
+ - lib/response_for_rc/actions.rb
95
+ - lib/response_for_rc/responses_module.rb
96
+ - lib/response_for_rc/singleton_actions.rb
97
+ - lib/response_for_rc/version.rb
98
+ - lib/response_for_rc_rails.rb
99
+ - response_for_rc.gemspec
100
+ - spec/specs/resources_controller_spec.rb
101
+ homepage: http://github.com/ianwhite/response_for_rc
102
+ licenses: []
103
+ post_install_message:
104
+ rdoc_options:
105
+ - --charset=UTF-8
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ segments:
115
+ - 0
116
+ hash: 3669672760041450546
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ segments:
124
+ - 0
125
+ hash: 3669672760041450546
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 1.8.10
129
+ signing_key:
130
+ specification_version: 3
131
+ summary: response_for_rc-0.2.1
132
+ test_files: []