Objective3-resource_controller_extensions 0.0.2
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/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +26 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/init.rb +3 -0
- data/lib/resource_controller_extensions.rb +3 -0
- data/lib/resource_controller_extensions/fbml.rb +51 -0
- data/lib/resource_controller_extensions/json.rb +31 -0
- data/lib/resource_controller_extensions/xml.rb +32 -0
- data/resource_controller_extensions.gemspec +51 -0
- data/test/resource_controller_extensions_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +69 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Blake Watters
|
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,26 @@
|
|
1
|
+
= resource_controller_extensions
|
2
|
+
|
3
|
+
This plugin provides support for adding reasonable default action handlers for
|
4
|
+
several types of Resources that you may wants to export via ResourceController:
|
5
|
+
* XML - For XML web services
|
6
|
+
* JSON - For JSON web services
|
7
|
+
* FBML - For Facebook FBML based pages.
|
8
|
+
|
9
|
+
Installation:
|
10
|
+
$ sudo gem install Objective3-resource_controller_extensions --source http://sources.github.com
|
11
|
+
|
12
|
+
Then for the types of responses you need support for:
|
13
|
+
|
14
|
+
require 'resource_controller_extensions/xml'
|
15
|
+
require 'resource_controller_extensions/json'
|
16
|
+
require 'resource_controller_extensions/fbml'
|
17
|
+
|
18
|
+
or pull them all in via:
|
19
|
+
|
20
|
+
require 'resource_controller_extensions'
|
21
|
+
|
22
|
+
And enjoy!
|
23
|
+
|
24
|
+
== Copyright
|
25
|
+
|
26
|
+
Copyright (c) 2009 Blake Watters. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "resource_controller_extensions"
|
8
|
+
gem.summary = %Q{TODO}
|
9
|
+
gem.email = "blake@objective3.com"
|
10
|
+
gem.homepage = "http://github.com/Objective3/resource_controller_extensions"
|
11
|
+
gem.authors = ["Blake Watters"]
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
end
|
14
|
+
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
Rake::TestTask.new(:test) do |test|
|
21
|
+
test.libs << 'lib' << 'test'
|
22
|
+
test.pattern = 'test/**/*_test.rb'
|
23
|
+
test.verbose = true
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
require 'rcov/rcovtask'
|
28
|
+
Rcov::RcovTask.new do |test|
|
29
|
+
test.libs << 'test'
|
30
|
+
test.pattern = 'test/**/*_test.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
rescue LoadError
|
34
|
+
task :rcov do
|
35
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :test
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
if File.exist?('VERSION.yml')
|
45
|
+
config = YAML.load(File.read('VERSION.yml'))
|
46
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
47
|
+
else
|
48
|
+
version = ""
|
49
|
+
end
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "resource_controller_extensions #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
56
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
data/init.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module ResourceControllerExtensions
|
2
|
+
module FBML
|
3
|
+
def self.included(base)
|
4
|
+
base.extend ClassMethods
|
5
|
+
base.class_eval do
|
6
|
+
class << self
|
7
|
+
alias_method_chain :init_default_actions, :fbml
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def init_default_actions_with_fbml(klass)
|
14
|
+
init_default_actions_without_fbml(klass)
|
15
|
+
klass.class_eval do
|
16
|
+
index.wants.fbml
|
17
|
+
new_action.wants.fbml
|
18
|
+
edit.wants.fbml
|
19
|
+
|
20
|
+
show do
|
21
|
+
wants.fbml
|
22
|
+
|
23
|
+
failure.wants.fbml { render :text => "Member object not found." }
|
24
|
+
end
|
25
|
+
|
26
|
+
create do
|
27
|
+
flash "Successfully created!"
|
28
|
+
wants.fbml { redirect_to object_url }
|
29
|
+
|
30
|
+
failure.wants.fbml { render :action => "new" }
|
31
|
+
end
|
32
|
+
|
33
|
+
update do
|
34
|
+
flash "Successfully updated!"
|
35
|
+
wants.fbml { redirect_to object_url }
|
36
|
+
|
37
|
+
failure.wants.fbml { render :action => "edit" }
|
38
|
+
end
|
39
|
+
|
40
|
+
destroy do
|
41
|
+
flash "Successfully removed!"
|
42
|
+
wants.fbml { redirect_to collection_url }
|
43
|
+
failure.wants.fbml { redirect_to object_url }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
ResourceController::Controller.send :include, ResourceControllerExtensions::FBML
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ResourceControllerExtensions
|
2
|
+
module JSON
|
3
|
+
def self.included(base)
|
4
|
+
base.extend ClassMethods
|
5
|
+
base.class_eval do
|
6
|
+
class << self
|
7
|
+
alias_method_chain :init_default_actions, :json
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def init_default_actions_with_json(klass)
|
14
|
+
init_default_actions_without_json(klass)
|
15
|
+
klass.class_eval do
|
16
|
+
index.wants.json { render :json => collection.to_json, :status => :ok }
|
17
|
+
show.wants.json { render :json => object}
|
18
|
+
edit.wants.json { render :json => object}
|
19
|
+
|
20
|
+
create.wants.json { render :json => object, :status => :created, :location => object }
|
21
|
+
create.failure.wants.json { render :json => object.errors, :status => :unprocessable_entity }
|
22
|
+
destroy.wants.json { head :ok }
|
23
|
+
update.wants.json { head :ok }
|
24
|
+
update.failure.wants.json { render :json => object.errors, :status => :unprocessable_entity }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
ResourceController::Controller.send :include, ResourceControllerExtensions::JSON
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module ResourceControllerExtensions
|
2
|
+
module XML
|
3
|
+
def self.included(base)
|
4
|
+
base.extend ClassMethods
|
5
|
+
base.class_eval do
|
6
|
+
class << self
|
7
|
+
alias_method_chain :init_default_actions, :xml
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def init_default_actions_with_xml(klass)
|
14
|
+
init_default_actions_without_xml(klass)
|
15
|
+
klass.class_eval do
|
16
|
+
index.wants.xml { render :xml => collection.to_xml, :status => :ok }
|
17
|
+
show.wants.xml { render :xml => object}
|
18
|
+
edit.wants.xml { render :xml => object}
|
19
|
+
new_action.wants.xml { render :xml => object }
|
20
|
+
|
21
|
+
create.wants.xml { render :xml => object, :status => :created, :location => object }
|
22
|
+
create.failure.wants.xml { render :xml => object.errors, :status => :unprocessable_entity }
|
23
|
+
destroy.wants.xml { head :ok }
|
24
|
+
update.wants.xml { head :ok }
|
25
|
+
update.failure.wants.xml { render :xml => object.errors, :status => :unprocessable_entity }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
ResourceController::Controller.send :include, ResourceControllerExtensions::XML
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{resource_controller_extensions}
|
5
|
+
s.version = "0.0.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Blake Watters"]
|
9
|
+
s.date = %q{2009-08-12}
|
10
|
+
s.email = %q{blake@objective3.com}
|
11
|
+
s.extra_rdoc_files = [
|
12
|
+
"LICENSE",
|
13
|
+
"README.rdoc"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".document",
|
17
|
+
".gitignore",
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"init.rb",
|
23
|
+
"lib/resource_controller_extensions.rb",
|
24
|
+
"lib/resource_controller_extensions/fbml.rb",
|
25
|
+
"lib/resource_controller_extensions/json.rb",
|
26
|
+
"lib/resource_controller_extensions/xml.rb",
|
27
|
+
"resource_controller_extensions.gemspec",
|
28
|
+
"test/resource_controller_extensions_test.rb",
|
29
|
+
"test/test_helper.rb"
|
30
|
+
]
|
31
|
+
s.has_rdoc = true
|
32
|
+
s.homepage = %q{http://github.com/Objective3/resource_controller_extensions}
|
33
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = %q{1.3.1}
|
36
|
+
s.summary = %q{TODO}
|
37
|
+
s.test_files = [
|
38
|
+
"test/resource_controller_extensions_test.rb",
|
39
|
+
"test/test_helper.rb"
|
40
|
+
]
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
|
+
s.specification_version = 2
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
47
|
+
else
|
48
|
+
end
|
49
|
+
else
|
50
|
+
end
|
51
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Objective3-resource_controller_extensions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Blake Watters
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-12 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: blake@objective3.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- .document
|
27
|
+
- .gitignore
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
- Rakefile
|
31
|
+
- VERSION
|
32
|
+
- init.rb
|
33
|
+
- lib/resource_controller_extensions.rb
|
34
|
+
- lib/resource_controller_extensions/fbml.rb
|
35
|
+
- lib/resource_controller_extensions/json.rb
|
36
|
+
- lib/resource_controller_extensions/xml.rb
|
37
|
+
- resource_controller_extensions.gemspec
|
38
|
+
- test/resource_controller_extensions_test.rb
|
39
|
+
- test/test_helper.rb
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: http://github.com/Objective3/resource_controller_extensions
|
42
|
+
licenses:
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --charset=UTF-8
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.3.5
|
64
|
+
signing_key:
|
65
|
+
specification_version: 2
|
66
|
+
summary: TODO
|
67
|
+
test_files:
|
68
|
+
- test/resource_controller_extensions_test.rb
|
69
|
+
- test/test_helper.rb
|