exposure 0.0.6 → 0.0.7
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 +3 -0
- data/NOTES +57 -0
- data/Rakefile +11 -20
- data/VERSION +1 -0
- data/lib/exposure/behaviors/building.rb +36 -0
- data/lib/exposure/behaviors/callbacks.rb +53 -0
- data/lib/exposure/behaviors/finding.rb +84 -0
- data/lib/exposure/behaviors/flashing.rb +62 -0
- data/lib/exposure/behaviors/responding.rb +80 -0
- data/lib/exposure/configuration.rb +23 -41
- data/lib/exposure/options.rb +55 -0
- data/lib/exposure/patterns/resources.rb +21 -116
- data/lib/exposure.rb +7 -2
- data/spec/callbacks_spec.rb +46 -0
- data/spec/configuration_spec.rb +82 -0
- data/spec/exposure_spec.rb +16 -6
- data/spec/finders/finder_spec.rb +18 -12
- data/spec/finders/nested_resources_finder_spec.rb +19 -9
- data/spec/flashers/flash_with_block_spec.rb +20 -10
- data/spec/flashers/flash_with_method_spec.rb +19 -15
- data/spec/flashers/flash_with_proc_spec.rb +15 -9
- data/spec/flashers/flash_with_string_spec.rb +15 -10
- data/spec/resources_spec.rb +19 -7
- data/spec/responder_spec.rb +41 -0
- data/spec/responders/respond_to_mime_types_spec.rb +16 -10
- data/spec/responders/respond_with_block_spec.rb +14 -8
- data/spec/responders/respond_with_method_spec.rb +20 -14
- data/spec/responders/respond_with_proc_spec.rb +15 -8
- data/spec/spec_helper.rb +2 -5
- metadata +42 -25
- data/Manifest.txt +0 -39
- data/exposure.gemspec +0 -31
- data/lib/exposure/common.rb +0 -143
@@ -1,19 +1,25 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
|
-
describe "flash messages with strings", :type => :controller do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
describe "flash messages with strings", :type => :controller do
|
4
|
+
setup = lambda {
|
5
|
+
class PiratesController < ActionController::Base
|
6
|
+
expose_many(:pirates)
|
7
|
+
end
|
8
|
+
|
9
|
+
ActionController::Routing::Routes.draw do |map|
|
10
|
+
map.resources :pirates, :collection => {:test => :any}
|
11
|
+
end
|
12
|
+
}
|
13
|
+
setup.call
|
8
14
|
controller_name :pirates
|
15
|
+
Object.remove_class(PiratesController)
|
16
|
+
|
9
17
|
|
10
18
|
before(:each) do
|
19
|
+
setup.call
|
11
20
|
@controller = PiratesController.new
|
12
21
|
@request = ActionController::TestRequest.new
|
13
22
|
@response = ActionController::TestResponse.new
|
14
|
-
ActionController::Routing::Routes.draw do |map|
|
15
|
-
map.resources :pirates, :collection => {:test => :any}
|
16
|
-
end
|
17
23
|
|
18
24
|
@custom_flash_message = 'the flash was set'
|
19
25
|
|
@@ -22,8 +28,7 @@ describe "flash messages with strings", :type => :controller do
|
|
22
28
|
end
|
23
29
|
|
24
30
|
after(:each) do
|
25
|
-
PiratesController
|
26
|
-
PiratesController::FlashMessages[false].clear
|
31
|
+
Object.remove_class(PiratesController)
|
27
32
|
end
|
28
33
|
|
29
34
|
describe "responding with a method call" do
|
data/spec/resources_spec.rb
CHANGED
@@ -1,18 +1,30 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
|
-
describe "a REST patterned resource of 'pirates'", :type => :controller do
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
describe "a REST patterned resource of 'pirates'", :type => :controller do
|
4
|
+
setup = lambda {
|
5
|
+
class PiratesController < ActionController::Base
|
6
|
+
expose_many(:pirates)
|
7
|
+
end
|
8
|
+
}
|
9
|
+
setup.call
|
10
|
+
|
11
|
+
ActionController::Routing::Routes.draw do |map|
|
12
|
+
map.resources :pirates
|
13
|
+
end
|
14
|
+
|
7
15
|
controller_name :pirates
|
16
|
+
Object.remove_class(PiratesController)
|
17
|
+
|
8
18
|
|
9
19
|
before(:each) do
|
20
|
+
setup.call
|
10
21
|
@controller = PiratesController.new
|
11
22
|
@request = ActionController::TestRequest.new
|
12
23
|
@response = ActionController::TestResponse.new
|
13
|
-
|
14
|
-
|
15
|
-
|
24
|
+
end
|
25
|
+
|
26
|
+
after(:each) do
|
27
|
+
Object.remove_class(PiratesController)
|
16
28
|
end
|
17
29
|
|
18
30
|
describe 'configuration' do
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "responders'", :type => :controller do
|
4
|
+
setup = lambda {
|
5
|
+
class PiratesController < ActionController::Base
|
6
|
+
expose_many(:pirates)
|
7
|
+
private
|
8
|
+
def custom_response
|
9
|
+
redirect_to({:action => "test"})
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
ActionController::Routing::Routes.draw do |map|
|
14
|
+
map.resources :pirates, :collection => {:test => :any}
|
15
|
+
end
|
16
|
+
}
|
17
|
+
setup.call
|
18
|
+
|
19
|
+
controller_name :pirates
|
20
|
+
Object.remove_class(PiratesController)
|
21
|
+
|
22
|
+
before(:each) do
|
23
|
+
setup.call
|
24
|
+
@controller = PiratesController.new
|
25
|
+
@request = ActionController::TestRequest.new
|
26
|
+
@response = ActionController::TestResponse.new
|
27
|
+
Pirate.stub(:find, Factory.stub(:pirate))
|
28
|
+
end
|
29
|
+
|
30
|
+
after(:each) do
|
31
|
+
Object.remove_class(PiratesController)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "can respond to multiple actions with the same method, proc, or block" do
|
35
|
+
PiratesController.response_for :show, :new, :is => :custom_response
|
36
|
+
get(:show, {:id => 1})
|
37
|
+
should respond_with(:redirect).to(:test)
|
38
|
+
get(:new)
|
39
|
+
should respond_with(:redirect).to(:test)
|
40
|
+
end
|
41
|
+
end
|
@@ -1,25 +1,31 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
|
-
describe "mime type responders", :type => :controller do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
describe "mime type responders", :type => :controller do
|
4
|
+
setup = lambda {
|
5
|
+
class PiratesController < ActionController::Base
|
6
|
+
expose_many(:pirates)
|
7
|
+
end
|
8
|
+
}
|
9
|
+
setup.call
|
10
|
+
|
11
|
+
ActionController::Routing::Routes.draw do |map|
|
12
|
+
map.resources :pirates, :collection => {:test => :any}
|
13
|
+
end
|
14
|
+
|
8
15
|
controller_name :pirates
|
16
|
+
Object.remove_class(PiratesController)
|
9
17
|
|
10
18
|
before(:each) do
|
19
|
+
setup.call
|
11
20
|
@controller = PiratesController.new
|
12
21
|
@request = ActionController::TestRequest.new
|
13
22
|
@response = ActionController::TestResponse.new
|
14
|
-
ActionController::Routing::Routes.draw do |map|
|
15
|
-
map.resources :pirates, :collection => {:test => :any}
|
16
|
-
end
|
17
23
|
@pirate = Factory.stub(:pirate)
|
18
|
-
|
24
|
+
Pirate.stub(:new => @pirate)
|
19
25
|
end
|
20
26
|
|
21
27
|
after(:each) do
|
22
|
-
PiratesController
|
28
|
+
Object.remove_class(PiratesController)
|
23
29
|
end
|
24
30
|
|
25
31
|
it "should respond with not acceptable if no acceptable mime type is not found" do
|
@@ -1,25 +1,31 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
|
-
describe "responders", :type => :controller do
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
describe "responders", :type => :controller do
|
4
|
+
setup = lambda {
|
5
|
+
class PiratesController < ActionController::Base
|
6
|
+
expose_many(:pirates)
|
7
|
+
end
|
8
|
+
}
|
9
|
+
setup.call
|
10
|
+
|
11
|
+
ActionController::Routing::Routes.draw do |map|
|
12
|
+
map.resources :pirates, :collection => {:test => :any}
|
13
|
+
end
|
7
14
|
|
8
15
|
controller_name :pirates
|
16
|
+
Object.remove_class(PiratesController)
|
9
17
|
|
10
18
|
before(:each) do
|
19
|
+
setup.call
|
11
20
|
@controller = PiratesController.new
|
12
21
|
@request = ActionController::TestRequest.new
|
13
22
|
@response = ActionController::TestResponse.new
|
14
|
-
ActionController::Routing::Routes.draw do |map|
|
15
|
-
map.resources :pirates, :collection => {:test => :any}
|
16
|
-
end
|
17
23
|
@pirate = Factory.stub(:pirate)
|
18
24
|
Pirate.stub(:new => @pirate)
|
19
25
|
end
|
20
26
|
|
21
27
|
after(:each) do
|
22
|
-
PiratesController
|
28
|
+
Object.remove_class(PiratesController)
|
23
29
|
end
|
24
30
|
|
25
31
|
describe "responding with a method call" do
|
@@ -1,31 +1,37 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
|
-
describe "responders", :type => :controller do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
describe "responders", :type => :controller do
|
4
|
+
setup = lambda {
|
5
|
+
class PiratesController < ActionController::Base
|
6
|
+
expose_many(:pirates)
|
7
|
+
|
8
|
+
private
|
9
|
+
def example
|
10
|
+
redirect_to({:action => "test"})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
}
|
14
|
+
setup.call
|
15
|
+
|
16
|
+
ActionController::Routing::Routes.draw do |map|
|
17
|
+
map.resources :pirates, :collection => {:test => :any}
|
18
|
+
end
|
12
19
|
|
13
20
|
controller_name :pirates
|
21
|
+
Object.remove_class(PiratesController)
|
14
22
|
|
15
23
|
before(:each) do
|
24
|
+
setup.call
|
16
25
|
@controller = PiratesController.new
|
17
26
|
@request = ActionController::TestRequest.new
|
18
27
|
@response = ActionController::TestResponse.new
|
19
|
-
ActionController::Routing::Routes.draw do |map|
|
20
|
-
map.resources :pirates, :collection => {:test => :any}
|
21
|
-
end
|
22
28
|
|
23
29
|
@pirate = Factory.stub(:pirate)
|
24
30
|
Pirate.stub(:new => @pirate)
|
25
31
|
end
|
26
32
|
|
27
33
|
after(:each) do
|
28
|
-
PiratesController
|
34
|
+
Object.remove_class(PiratesController)
|
29
35
|
end
|
30
36
|
|
31
37
|
describe "responding with a method call" do
|
@@ -69,7 +75,7 @@ describe "responders", :type => :controller do
|
|
69
75
|
PiratesController.response_for :create, :is => :example, :on => :failure
|
70
76
|
end
|
71
77
|
|
72
|
-
it "should not respond with custom response
|
78
|
+
it "should not respond with custom response on success" do
|
73
79
|
@pirate.stub(:save => true)
|
74
80
|
post(:create)
|
75
81
|
should_not redirect_to({:action => 'test'})
|
@@ -1,26 +1,33 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
|
-
describe "responders", :type => :controller do
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
describe "responders", :type => :controller do
|
4
|
+
setup = lambda {
|
5
|
+
class PiratesController < ActionController::Base
|
6
|
+
expose_many(:pirates)
|
7
|
+
end
|
8
|
+
}
|
9
|
+
setup.call
|
7
10
|
|
11
|
+
ActionController::Routing::Routes.draw do |map|
|
12
|
+
map.resources :pirates, :collection => {:test => :any}
|
13
|
+
end
|
14
|
+
|
8
15
|
controller_name :pirates
|
16
|
+
Object.remove_class(PiratesController)
|
9
17
|
|
10
18
|
before(:each) do
|
19
|
+
setup.call
|
11
20
|
@controller = PiratesController.new
|
12
21
|
@request = ActionController::TestRequest.new
|
13
22
|
@response = ActionController::TestResponse.new
|
14
|
-
|
15
|
-
map.resources :pirates, :collection => {:test => :any}
|
16
|
-
end
|
23
|
+
|
17
24
|
@response_proc = Proc.new { redirect_to({:action => "test"}) }
|
18
25
|
@pirate = Factory.stub(:pirate)
|
19
26
|
Pirate.stub(:new => @pirate)
|
20
27
|
end
|
21
28
|
|
22
29
|
after(:each) do
|
23
|
-
PiratesController
|
30
|
+
Object.remove_class(PiratesController)
|
24
31
|
end
|
25
32
|
|
26
33
|
describe "responding with a method call" do
|
data/spec/spec_helper.rb
CHANGED
@@ -3,24 +3,22 @@ RAILS_ENV = 'test' unless defined? RAILS_ENV
|
|
3
3
|
|
4
4
|
module Rails
|
5
5
|
module VERSION
|
6
|
-
STRING = '2.3.4'
|
6
|
+
STRING = '2.3.4' unless defined? STRING
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
|
11
|
-
require 'rubygems'
|
12
11
|
# require 'multi_rails_init'
|
13
12
|
|
14
13
|
require 'rubygems'
|
15
14
|
require 'action_controller'
|
16
15
|
require 'action_view'
|
17
16
|
require 'active_record'
|
18
|
-
require 'test_help'
|
19
17
|
|
20
18
|
require 'spec'
|
21
19
|
require File.dirname(__FILE__) + '/spec_rails_helper'
|
22
20
|
require 'shoulda'
|
23
|
-
require File.dirname(__FILE__) +
|
21
|
+
require File.dirname(__FILE__) + '/custom_matchers'
|
24
22
|
require 'factory_girl'
|
25
23
|
|
26
24
|
|
@@ -29,7 +27,6 @@ require 'exposure'
|
|
29
27
|
|
30
28
|
ActiveRecord::Base.logger = Logger.new(STDOUT) if ENV['DEBUG']
|
31
29
|
ActionController::Base.logger = Logger.new(STDOUT) if ENV['DEBUG']
|
32
|
-
# ActionController::Base.send :include, Exposure
|
33
30
|
ActionController::Base.view_paths=(File.dirname(__FILE__) + '/fixtures')
|
34
31
|
|
35
32
|
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exposure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trek Glowacki
|
@@ -9,40 +9,38 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-26 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 2.3.3
|
24
|
-
version:
|
25
|
-
description: ""
|
26
|
-
email:
|
27
|
-
- trek.glowacki@gmail.com
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: exposed resources
|
17
|
+
email: trek.glowacki@gmail.com
|
28
18
|
executables: []
|
29
19
|
|
30
20
|
extensions: []
|
31
21
|
|
32
22
|
extra_rdoc_files:
|
33
|
-
-
|
23
|
+
- README.mdown
|
34
24
|
files:
|
35
|
-
-
|
25
|
+
- .gitignore
|
26
|
+
- NOTES
|
36
27
|
- README.mdown
|
37
28
|
- Rakefile
|
38
|
-
-
|
29
|
+
- VERSION
|
39
30
|
- lib/exposure.rb
|
40
|
-
- lib/exposure/
|
31
|
+
- lib/exposure/behaviors/building.rb
|
32
|
+
- lib/exposure/behaviors/callbacks.rb
|
33
|
+
- lib/exposure/behaviors/finding.rb
|
34
|
+
- lib/exposure/behaviors/flashing.rb
|
35
|
+
- lib/exposure/behaviors/responding.rb
|
41
36
|
- lib/exposure/configuration.rb
|
37
|
+
- lib/exposure/options.rb
|
42
38
|
- lib/exposure/patterns/resources.rb
|
43
39
|
- script/console
|
44
40
|
- script/destroy
|
45
41
|
- script/generate
|
42
|
+
- spec/callbacks_spec.rb
|
43
|
+
- spec/configuration_spec.rb
|
46
44
|
- spec/custom_matchers.rb
|
47
45
|
- spec/exposure_spec.rb
|
48
46
|
- spec/factories/pirate_factory.rb
|
@@ -62,6 +60,7 @@ files:
|
|
62
60
|
- spec/flashers/flash_with_proc_spec.rb
|
63
61
|
- spec/flashers/flash_with_string_spec.rb
|
64
62
|
- spec/resources_spec.rb
|
63
|
+
- spec/responder_spec.rb
|
65
64
|
- spec/responders/respond_to_mime_types_spec.rb
|
66
65
|
- spec/responders/respond_with_block_spec.rb
|
67
66
|
- spec/responders/respond_with_method_spec.rb
|
@@ -77,8 +76,7 @@ licenses: []
|
|
77
76
|
|
78
77
|
post_install_message:
|
79
78
|
rdoc_options:
|
80
|
-
- --
|
81
|
-
- README.rdoc
|
79
|
+
- --charset=UTF-8
|
82
80
|
require_paths:
|
83
81
|
- lib
|
84
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -95,10 +93,29 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
93
|
version:
|
96
94
|
requirements: []
|
97
95
|
|
98
|
-
rubyforge_project:
|
96
|
+
rubyforge_project:
|
99
97
|
rubygems_version: 1.3.4
|
100
98
|
signing_key:
|
101
99
|
specification_version: 3
|
102
100
|
summary: exposed resources
|
103
|
-
test_files:
|
104
|
-
|
101
|
+
test_files:
|
102
|
+
- spec/callbacks_spec.rb
|
103
|
+
- spec/configuration_spec.rb
|
104
|
+
- spec/custom_matchers.rb
|
105
|
+
- spec/exposure_spec.rb
|
106
|
+
- spec/factories/pirate_factory.rb
|
107
|
+
- spec/factories/ship_factory.rb
|
108
|
+
- spec/finders/finder_spec.rb
|
109
|
+
- spec/finders/nested_resources_finder_spec.rb
|
110
|
+
- spec/flashers/flash_with_block_spec.rb
|
111
|
+
- spec/flashers/flash_with_method_spec.rb
|
112
|
+
- spec/flashers/flash_with_proc_spec.rb
|
113
|
+
- spec/flashers/flash_with_string_spec.rb
|
114
|
+
- spec/resources_spec.rb
|
115
|
+
- spec/responder_spec.rb
|
116
|
+
- spec/responders/respond_to_mime_types_spec.rb
|
117
|
+
- spec/responders/respond_with_block_spec.rb
|
118
|
+
- spec/responders/respond_with_method_spec.rb
|
119
|
+
- spec/responders/respond_with_proc_spec.rb
|
120
|
+
- spec/spec_helper.rb
|
121
|
+
- spec/spec_rails_helper.rb
|
data/Manifest.txt
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
Manifest.txt
|
2
|
-
README.mdown
|
3
|
-
Rakefile
|
4
|
-
exposure.gemspec
|
5
|
-
lib/exposure.rb
|
6
|
-
lib/exposure/common.rb
|
7
|
-
lib/exposure/configuration.rb
|
8
|
-
lib/exposure/patterns/resources.rb
|
9
|
-
script/console
|
10
|
-
script/destroy
|
11
|
-
script/generate
|
12
|
-
spec/custom_matchers.rb
|
13
|
-
spec/exposure_spec.rb
|
14
|
-
spec/factories/pirate_factory.rb
|
15
|
-
spec/factories/ship_factory.rb
|
16
|
-
spec/finders/finder_spec.rb
|
17
|
-
spec/finders/nested_resources_finder_spec.rb
|
18
|
-
spec/fixtures/pirates/edit.erb
|
19
|
-
spec/fixtures/pirates/index.erb
|
20
|
-
spec/fixtures/pirates/new.erb
|
21
|
-
spec/fixtures/pirates/show.erb
|
22
|
-
spec/fixtures/ships/edit.erb
|
23
|
-
spec/fixtures/ships/index.erb
|
24
|
-
spec/fixtures/ships/new.erb
|
25
|
-
spec/fixtures/ships/show.erb
|
26
|
-
spec/flashers/flash_with_block_spec.rb
|
27
|
-
spec/flashers/flash_with_method_spec.rb
|
28
|
-
spec/flashers/flash_with_proc_spec.rb
|
29
|
-
spec/flashers/flash_with_string_spec.rb
|
30
|
-
spec/resources_spec.rb
|
31
|
-
spec/responders/respond_to_mime_types_spec.rb
|
32
|
-
spec/responders/respond_with_block_spec.rb
|
33
|
-
spec/responders/respond_with_method_spec.rb
|
34
|
-
spec/responders/respond_with_proc_spec.rb
|
35
|
-
spec/spec.opts
|
36
|
-
spec/spec_helper.rb
|
37
|
-
spec/spec_rails_helper.rb
|
38
|
-
tasks/rspec.rake
|
39
|
-
tasks/shoulda.rake
|
data/exposure.gemspec
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{exposure}
|
5
|
-
s.version = "0.0.4"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Trek Glowacki"]
|
9
|
-
s.date = %q{2009-10-07}
|
10
|
-
s.description = %q{Expose your data}
|
11
|
-
s.email = ["trek.glowacki@gmail.com"]
|
12
|
-
s.extra_rdoc_files = ["Manifest.txt"]
|
13
|
-
s.files = ["Manifest.txt", "README.mdown", "Rakefile", "exposure.gemspec", "lib/exposure.rb", "lib/exposure/common.rb", "lib/exposure/configuration.rb", "lib/exposure/patterns/resource.rb", "lib/exposure/patterns/resources.rb", "script/console", "script/destroy", "script/generate", "spec/custom_matchers.rb", "spec/exposure_spec.rb", "spec/factories/pirate_factory.rb", "spec/factories/ship_factory.rb", "spec/finders/finder_spec.rb", "spec/finders/nested_resources_finder_spec.rb", "spec/fixtures/pirates/edit.erb", "spec/fixtures/pirates/index.erb", "spec/fixtures/pirates/new.erb", "spec/fixtures/pirates/show.erb", "spec/fixtures/ships/edit.erb", "spec/fixtures/ships/index.erb", "spec/fixtures/ships/new.erb", "spec/fixtures/ships/show.erb", "spec/flashers/flash_with_block_spec.rb", "spec/flashers/flash_with_method_spec.rb", "spec/flashers/flash_with_proc_spec.rb", "spec/flashers/flash_with_string_spec.rb", "spec/resource_spec.rb", "spec/resources_spec.rb", "spec/responders/respond_to_mime_types_spec.rb", "spec/responders/respond_with_block_spec.rb", "spec/responders/respond_with_method_spec.rb", "spec/responders/respond_with_proc_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/spec_rails_helper.rb", "tasks/rspec.rake", "tasks/shoulda.rake"]
|
14
|
-
s.rdoc_options = ["--main", "README.rdoc"]
|
15
|
-
s.require_paths = ["lib"]
|
16
|
-
s.rubygems_version = %q{1.3.4}
|
17
|
-
s.summary = %q{Expose your data}
|
18
|
-
|
19
|
-
if s.respond_to? :specification_version then
|
20
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
21
|
-
s.specification_version = 3
|
22
|
-
|
23
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
24
|
-
s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
|
25
|
-
else
|
26
|
-
s.add_dependency(%q<hoe>, [">= 2.3.3"])
|
27
|
-
end
|
28
|
-
else
|
29
|
-
s.add_dependency(%q<hoe>, [">= 2.3.3"])
|
30
|
-
end
|
31
|
-
end
|
data/lib/exposure/common.rb
DELETED
@@ -1,143 +0,0 @@
|
|
1
|
-
module Exposure
|
2
|
-
module Common
|
3
|
-
class <<
|
4
|
-
attr_accessor :resource_name, :resources_name,
|
5
|
-
:resource_chain, :resources_chain,
|
6
|
-
:collection_nesting, :member_nesting,
|
7
|
-
:parent_model
|
8
|
-
end
|
9
|
-
|
10
|
-
# response_for :create, :on => :success, :is => { proc }
|
11
|
-
# response_for :show, :formats => [:html] do
|
12
|
-
# @resource.activated ? render('show') : render('next_steps')
|
13
|
-
# end
|
14
|
-
# response_for :new, :is => :new_foo_built
|
15
|
-
#
|
16
|
-
# valid action names are
|
17
|
-
# :index :show :new :create :edit :update :destroy
|
18
|
-
# valid options are
|
19
|
-
# :on (optional)
|
20
|
-
# :success, :failure, :any
|
21
|
-
# default is :any
|
22
|
-
# :is (option if block given)
|
23
|
-
# can be a Proc or method name as symbol.
|
24
|
-
# :formats
|
25
|
-
# array of formats as symbols.
|
26
|
-
# defaults to [:html]
|
27
|
-
def response_for(*args, &block)
|
28
|
-
options = args.extract_options!
|
29
|
-
options[:is] ||= block
|
30
|
-
formats = options[:formats] || [:html]
|
31
|
-
|
32
|
-
case options[:on]
|
33
|
-
when NilClass, :any
|
34
|
-
build_custom_response(args, :success, formats, options[:is])
|
35
|
-
build_custom_response(args, :failure, formats, options[:is])
|
36
|
-
when :success
|
37
|
-
build_custom_response(args, :success, formats, options[:is])
|
38
|
-
when :failure
|
39
|
-
build_custom_response(args, :failure, formats, options[:is])
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# find :person, :with => Proc.new { Person.find_by_permalink(params[:permalink]) }
|
44
|
-
# find :people, :with => Proc.new { Person.send(params[:scope]) }
|
45
|
-
# find :dogs, :with => :dogs_adopted_after_date
|
46
|
-
# find :dogs do
|
47
|
-
# Dog.all
|
48
|
-
# end
|
49
|
-
#
|
50
|
-
# valid options are
|
51
|
-
# :with
|
52
|
-
# :only (unimplemented)
|
53
|
-
# :except (unimplemented)
|
54
|
-
def find(name, options = {}, &block)
|
55
|
-
options[:with] ||= block
|
56
|
-
self.const_get(:Finders)[name] = options[:with]
|
57
|
-
end
|
58
|
-
|
59
|
-
# configure flash messages
|
60
|
-
# valid action names are
|
61
|
-
# :index :show :new :create :edit :update :destroy
|
62
|
-
# valid options are
|
63
|
-
# :on (optional)
|
64
|
-
# :success, :failure, :any
|
65
|
-
# default is :any
|
66
|
-
# :is (optional if block given)
|
67
|
-
# can be a Proc or method name as symbol.
|
68
|
-
def flash_for(action_name, options = {}, &block)
|
69
|
-
options[:is] ||= block
|
70
|
-
|
71
|
-
case options[:on]
|
72
|
-
when NilClass, :any
|
73
|
-
self.const_get(:FlashMessages)[true][action_name] = options[:is]
|
74
|
-
self.const_get(:FlashMessages)[false][action_name] = options[:is]
|
75
|
-
when :success
|
76
|
-
self.const_get(:FlashMessages)[true][action_name] = options[:is]
|
77
|
-
when :failure
|
78
|
-
self.const_get(:FlashMessages)[false][action_name] = options[:is]
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# access point for creating and configuring before_ callbacks.
|
83
|
-
def before(trigger, *actions)
|
84
|
-
options = actions.extract_options!
|
85
|
-
actions.each do |action|
|
86
|
-
build_callback('before', trigger, action, options)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
# access point for creating and configuring before_ callbacks.
|
91
|
-
def after(trigger, *actions)
|
92
|
-
options = actions.extract_options!
|
93
|
-
actions.each do |action|
|
94
|
-
build_callback('after', trigger, action, options)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# builds default finders
|
99
|
-
def build_default_finders(member, nesting) #:nodoc:
|
100
|
-
finders = self::const_set(:DefaultFinders, {
|
101
|
-
self.resource_name.intern => Proc.new { [:find, params[:id] ] },
|
102
|
-
self.resources_name.intern => Proc.new { [:all] }
|
103
|
-
})
|
104
|
-
|
105
|
-
nesting.each do |association_name|
|
106
|
-
finders[association_name.to_s.singularize.to_sym] = Proc.new { [:find, params[:"#{association_name.to_s.singularize}_id"]] }
|
107
|
-
finders[association_name] = Proc.new { [ :all ] }
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def build_custom_response(action_names, success_status, formats, response)
|
112
|
-
action_names.each do |action_name|
|
113
|
-
formats.each do |format|
|
114
|
-
self.const_get(:Responses)["#{action_name}.#{success_status}.#{format}"] = response
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
# builds callbacks that adhere to the ActiveSupport::Callbacks interface
|
120
|
-
def build_callback(prefix, trigger, action, options) #:nodoc:
|
121
|
-
callback_name = "#{prefix}_#{trigger}"
|
122
|
-
|
123
|
-
if options[:on]
|
124
|
-
callback_name += "_on_#{options.delete(:on)}"
|
125
|
-
end
|
126
|
-
|
127
|
-
options[:if] ||= []
|
128
|
-
|
129
|
-
only_methods = options.delete(:only)
|
130
|
-
except_methods = options.delete(:except)
|
131
|
-
|
132
|
-
if only_methods
|
133
|
-
options[:if] << Proc.new {|c| only_methods.include?(c.action_name.intern) }
|
134
|
-
end
|
135
|
-
|
136
|
-
if except_methods
|
137
|
-
options[:if] << Proc.new {|c| !except_methods.include?(c.action_name.intern) }
|
138
|
-
end
|
139
|
-
|
140
|
-
self.send(callback_name, action, options)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|