layout_options 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +45 -3
- data/README.textile +9 -19
- data/init.rb +1 -0
- data/layout_options.gemspec +3 -1
- data/lib/generators/layout_options/install/install_generator.rb +13 -0
- data/lib/layout_options/layout_options.rb +34 -3
- data/lib/layout_options/storage.rb +2 -2
- data/lib/layout_options/version.rb +2 -2
- data/lib/layout_options.rb +1 -4
- data/spec/rails_root/.gitignore +4 -0
- data/spec/rails_root/.rspec +1 -0
- data/spec/rails_root/Gemfile +8 -0
- data/spec/rails_root/Gemfile.lock +99 -0
- data/spec/rails_root/Rakefile +7 -0
- data/spec/rails_root/app/controllers/application_controller.rb +4 -0
- data/spec/rails_root/app/controllers/bar_controller.rb +6 -0
- data/spec/rails_root/app/controllers/baz_controller.rb +7 -0
- data/spec/rails_root/app/controllers/foo_controller.rb +6 -0
- data/spec/rails_root/app/views/bar/create.html.erb +0 -0
- data/spec/rails_root/app/views/bar/new.html.erb +0 -0
- data/spec/rails_root/app/views/bar/show.html.erb +0 -0
- data/spec/rails_root/app/views/baz/create.html.erb +0 -0
- data/spec/rails_root/app/views/baz/new.html.erb +0 -0
- data/spec/rails_root/app/views/baz/show.html.erb +0 -0
- data/spec/rails_root/app/views/foo/create.html.erb +0 -0
- data/spec/rails_root/app/views/foo/new.html.erb +0 -0
- data/spec/rails_root/app/views/foo/show.html.erb +0 -0
- data/spec/rails_root/app/views/layouts/application.html.erb +11 -0
- data/spec/rails_root/app/views/layouts/overlay.html.erb +2 -0
- data/spec/rails_root/config/application.rb +42 -0
- data/spec/rails_root/config/boot.rb +13 -0
- data/spec/rails_root/config/database.yml +22 -0
- data/spec/rails_root/config/environment.rb +5 -0
- data/spec/rails_root/config/environments/development.rb +26 -0
- data/spec/rails_root/config/environments/production.rb +49 -0
- data/spec/rails_root/config/environments/test.rb +35 -0
- data/spec/rails_root/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_root/config/initializers/inflections.rb +10 -0
- data/spec/rails_root/config/initializers/mime_types.rb +5 -0
- data/spec/rails_root/config/initializers/secret_token.rb +7 -0
- data/spec/rails_root/config/initializers/session_store.rb +8 -0
- data/spec/rails_root/config/locales/en.yml +5 -0
- data/spec/rails_root/config/routes.rb +6 -0
- data/spec/rails_root/config.ru +4 -0
- data/spec/rails_root/script/rails +6 -0
- data/spec/rails_root/spec/controllers/bar_controller_spec.rb +6 -0
- data/spec/rails_root/spec/controllers/baz_controller_spec.rb +6 -0
- data/spec/rails_root/spec/controllers/foo_controller_spec.rb +6 -0
- data/spec/rails_root/spec/spec_helper.rb +9 -0
- data/spec/rails_root/spec/support/shared.rb +24 -0
- data/spec/spec_helper.rb +2 -0
- metadata +62 -5
- data/spec/layout_options_spec.rb +0 -29
data/Gemfile.lock
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
layout_options (0.1)
|
5
|
-
|
4
|
+
layout_options (0.1.1)
|
5
|
+
rails (~> 3.0.1)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
10
|
abstract (1.0.0)
|
11
|
+
actionmailer (3.0.3)
|
12
|
+
actionpack (= 3.0.3)
|
13
|
+
mail (~> 2.2.9)
|
11
14
|
actionpack (3.0.3)
|
12
15
|
activemodel (= 3.0.3)
|
13
16
|
activesupport (= 3.0.3)
|
@@ -22,21 +25,56 @@ GEM
|
|
22
25
|
activesupport (= 3.0.3)
|
23
26
|
builder (~> 2.1.2)
|
24
27
|
i18n (~> 0.4)
|
28
|
+
activerecord (3.0.3)
|
29
|
+
activemodel (= 3.0.3)
|
30
|
+
activesupport (= 3.0.3)
|
31
|
+
arel (~> 2.0.2)
|
32
|
+
tzinfo (~> 0.3.23)
|
33
|
+
activeresource (3.0.3)
|
34
|
+
activemodel (= 3.0.3)
|
35
|
+
activesupport (= 3.0.3)
|
25
36
|
activesupport (3.0.3)
|
26
37
|
archive-tar-minitar (0.5.2)
|
38
|
+
arel (2.0.4)
|
27
39
|
builder (2.1.2)
|
28
40
|
columnize (0.3.2)
|
29
41
|
diff-lcs (1.1.2)
|
30
42
|
erubis (2.6.6)
|
31
43
|
abstract (>= 1.0.0)
|
44
|
+
has_scope (0.5.0)
|
32
45
|
i18n (0.4.2)
|
46
|
+
inherited_resources (1.1.2)
|
47
|
+
has_scope (~> 0.5.0)
|
48
|
+
responders (~> 0.6.0)
|
33
49
|
linecache19 (0.5.11)
|
34
50
|
ruby_core_source (>= 0.1.4)
|
51
|
+
mail (2.2.10)
|
52
|
+
activesupport (>= 2.3.6)
|
53
|
+
i18n (~> 0.4.1)
|
54
|
+
mime-types (~> 1.16)
|
55
|
+
treetop (~> 1.4.8)
|
56
|
+
mime-types (1.16)
|
57
|
+
polyglot (0.3.1)
|
35
58
|
rack (1.2.1)
|
36
59
|
rack-mount (0.6.13)
|
37
60
|
rack (>= 1.0.0)
|
38
61
|
rack-test (0.5.6)
|
39
62
|
rack (>= 1.0)
|
63
|
+
rails (3.0.3)
|
64
|
+
actionmailer (= 3.0.3)
|
65
|
+
actionpack (= 3.0.3)
|
66
|
+
activerecord (= 3.0.3)
|
67
|
+
activeresource (= 3.0.3)
|
68
|
+
activesupport (= 3.0.3)
|
69
|
+
bundler (~> 1.0)
|
70
|
+
railties (= 3.0.3)
|
71
|
+
railties (3.0.3)
|
72
|
+
actionpack (= 3.0.3)
|
73
|
+
activesupport (= 3.0.3)
|
74
|
+
rake (>= 0.8.7)
|
75
|
+
thor (~> 0.14.4)
|
76
|
+
rake (0.8.7)
|
77
|
+
responders (0.6.2)
|
40
78
|
rspec (2.1.0)
|
41
79
|
rspec-core (~> 2.1.0)
|
42
80
|
rspec-expectations (~> 2.1.0)
|
@@ -57,15 +95,19 @@ GEM
|
|
57
95
|
ruby-debug-base19 (>= 0.11.19)
|
58
96
|
ruby_core_source (0.1.4)
|
59
97
|
archive-tar-minitar (>= 0.5.2)
|
98
|
+
thor (0.14.6)
|
99
|
+
treetop (1.4.9)
|
100
|
+
polyglot (>= 0.3.1)
|
60
101
|
tzinfo (0.3.23)
|
61
102
|
|
62
103
|
PLATFORMS
|
63
104
|
ruby
|
64
105
|
|
65
106
|
DEPENDENCIES
|
66
|
-
actionpack (~> 3.0.1)
|
67
107
|
bundler (>= 1.0.0.rc.6)
|
108
|
+
inherited_resources (~> 1.1.2)
|
68
109
|
layout_options!
|
110
|
+
rails (~> 3.0.1)
|
69
111
|
rspec (~> 2.1.0)
|
70
112
|
rspec-rails (~> 2.1.0)
|
71
113
|
ruby-debug19 (~> 0.11.6)
|
data/README.textile
CHANGED
@@ -8,32 +8,22 @@ This gem came from that exact scenario.
|
|
8
8
|
|
9
9
|
h2. Usage
|
10
10
|
|
11
|
-
To add @layout_options@ to your project
|
12
|
-
in your ApplicationController and define your layouts within each controller.
|
11
|
+
To add @layout_options@ to your Rails project and type 'rails generate layout_options:install'
|
13
12
|
|
14
13
|
h3. Example
|
15
14
|
|
16
15
|
Adding layout_options to your Gemfile:
|
17
16
|
|
18
|
-
|
19
|
-
gem 'layout_options', '~> 0.1'
|
20
|
-
</code>
|
17
|
+
gem 'layout_options', '~> 0.1'
|
21
18
|
|
22
|
-
|
19
|
+
Install @layout_options@:
|
23
20
|
|
24
|
-
|
25
|
-
require 'layout_options' # require the gem
|
26
|
-
|
27
|
-
class ApplicationController < ActionController::Base
|
28
|
-
# ...
|
29
|
-
end
|
30
|
-
</code>
|
21
|
+
rails generate layout_options:install
|
31
22
|
|
32
23
|
Define your layouts in your controllers:
|
33
24
|
|
34
|
-
<
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
</code>
|
25
|
+
class UsersController < ApplicationController
|
26
|
+
layout_options :overlay => [:new, :edit], :none => :destroy
|
27
|
+
end
|
28
|
+
|
29
|
+
Thats it!
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'layout_options'
|
data/layout_options.gemspec
CHANGED
@@ -16,12 +16,14 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.required_rubygems_version = ">= 1.3.6"
|
17
17
|
s.rubyforge_project = "layout_options"
|
18
18
|
|
19
|
-
s.add_dependency '
|
19
|
+
s.add_dependency 'rails', '~> 3.0.1'
|
20
|
+
#s.add_dependency 'actionpack','~> 3.0.1'
|
20
21
|
|
21
22
|
s.add_development_dependency "bundler", ">= 1.0.0.rc.6"
|
22
23
|
s.add_development_dependency "rspec", "~> 2.1.0"
|
23
24
|
s.add_development_dependency "rspec-rails", "~> 2.1.0"
|
24
25
|
s.add_development_dependency 'ruby-debug19', '~> 0.11.6'
|
26
|
+
s.add_development_dependency 'inherited_resources', '~> 1.1.2'
|
25
27
|
|
26
28
|
s.files = `git ls-files`.split("\n")
|
27
29
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module LayoutOptions
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
desc 'prep the application to use layout_options'
|
5
|
+
|
6
|
+
def application_controller_injection # :nodoc:
|
7
|
+
inject_into_class 'app/controllers/application_controller.rb', ApplicationController do
|
8
|
+
" include LayoutOptions\n"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,19 +1,50 @@
|
|
1
1
|
module LayoutOptions
|
2
|
-
def self.included(controller)
|
2
|
+
def self.included(controller) # :nodoc:
|
3
3
|
controller.send(:include, LayoutOptions::InstanceMethods)
|
4
4
|
controller.send(:extend, LayoutOptions::ClassMethods)
|
5
5
|
controller.send(:layout, :layout_options_selector)
|
6
6
|
end
|
7
7
|
|
8
8
|
module ClassMethods
|
9
|
+
# layout_options - This method is available at the class level of your ApplicationController
|
10
|
+
# and any controller that inherits from it.
|
11
|
+
#
|
12
|
+
# <tt>layout_options</tt> accepts a single hash where the index is the layout name and the
|
13
|
+
# is the controller method(s) that will be using that layout. If you set the index to <tt>:none</tt>
|
14
|
+
# no layout will be used. If no layout is specified it will default to using the
|
15
|
+
# 'application' layout.
|
16
|
+
#
|
17
|
+
# All of the following examples will work controllers that inherit from <tt>InheritedResources::Base</tt>.
|
18
|
+
#
|
19
|
+
# # setting an overlay layout for a new method
|
20
|
+
# class UsersController < ApplicationController
|
21
|
+
# layout_options :overlay => :new
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# # setting an overlay layout for multiple methods
|
25
|
+
# class UsersController < ApplicationController
|
26
|
+
# layout_options :overlay => [:new, :edit]
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# # not using a layout
|
30
|
+
# class UsersController < ApplicationController
|
31
|
+
# layout_options :none => [:create, :destroy]
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# # using multiple layouts
|
35
|
+
# class UsersController < ApplicationController
|
36
|
+
# layout_options :overlay => [:new, :edit], :none => [:create, :destroy],
|
37
|
+
# :foo => :show
|
38
|
+
# end
|
9
39
|
def layout_options(args={})
|
10
40
|
LayoutOptions::Storage[controller_name] = args
|
11
41
|
end
|
12
42
|
end
|
13
43
|
|
14
44
|
module InstanceMethods
|
15
|
-
def layout_options_selector
|
16
|
-
layout_options = LayoutOptions::Storage[controller_name]
|
45
|
+
def layout_options_selector # :nodoc:
|
46
|
+
layout_options = LayoutOptions::Storage[controller_name] || {}
|
47
|
+
layout_options = layout_options.clone unless layout_options.empty?
|
17
48
|
no_layout = layout_options.delete(:none) || []
|
18
49
|
no_layout = [no_layout] unless Array === no_layout
|
19
50
|
action = action_name.to_sym
|
data/lib/layout_options.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
@@ -0,0 +1,8 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '3.0.3'
|
4
|
+
gem 'sqlite3-ruby', :require => 'sqlite3'
|
5
|
+
gem 'inherited_resources', '~> 1.1.2'
|
6
|
+
gem 'layout_options', :path => "#{File.expand_path(File.dirname(__FILE__)+'/../../')}"
|
7
|
+
gem 'rspec', '~> 2.1.0'
|
8
|
+
gem 'rspec-rails', '~> 2.1.0'
|
@@ -0,0 +1,99 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/Dane/Projects/layout_options
|
3
|
+
specs:
|
4
|
+
layout_options (0.1.1)
|
5
|
+
rails (~> 3.0.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
abstract (1.0.0)
|
11
|
+
actionmailer (3.0.3)
|
12
|
+
actionpack (= 3.0.3)
|
13
|
+
mail (~> 2.2.9)
|
14
|
+
actionpack (3.0.3)
|
15
|
+
activemodel (= 3.0.3)
|
16
|
+
activesupport (= 3.0.3)
|
17
|
+
builder (~> 2.1.2)
|
18
|
+
erubis (~> 2.6.6)
|
19
|
+
i18n (~> 0.4)
|
20
|
+
rack (~> 1.2.1)
|
21
|
+
rack-mount (~> 0.6.13)
|
22
|
+
rack-test (~> 0.5.6)
|
23
|
+
tzinfo (~> 0.3.23)
|
24
|
+
activemodel (3.0.3)
|
25
|
+
activesupport (= 3.0.3)
|
26
|
+
builder (~> 2.1.2)
|
27
|
+
i18n (~> 0.4)
|
28
|
+
activerecord (3.0.3)
|
29
|
+
activemodel (= 3.0.3)
|
30
|
+
activesupport (= 3.0.3)
|
31
|
+
arel (~> 2.0.2)
|
32
|
+
tzinfo (~> 0.3.23)
|
33
|
+
activeresource (3.0.3)
|
34
|
+
activemodel (= 3.0.3)
|
35
|
+
activesupport (= 3.0.3)
|
36
|
+
activesupport (3.0.3)
|
37
|
+
arel (2.0.4)
|
38
|
+
builder (2.1.2)
|
39
|
+
diff-lcs (1.1.2)
|
40
|
+
erubis (2.6.6)
|
41
|
+
abstract (>= 1.0.0)
|
42
|
+
has_scope (0.5.0)
|
43
|
+
i18n (0.4.2)
|
44
|
+
inherited_resources (1.1.2)
|
45
|
+
has_scope (~> 0.5.0)
|
46
|
+
responders (~> 0.6.0)
|
47
|
+
mail (2.2.10)
|
48
|
+
activesupport (>= 2.3.6)
|
49
|
+
i18n (~> 0.4.1)
|
50
|
+
mime-types (~> 1.16)
|
51
|
+
treetop (~> 1.4.8)
|
52
|
+
mime-types (1.16)
|
53
|
+
polyglot (0.3.1)
|
54
|
+
rack (1.2.1)
|
55
|
+
rack-mount (0.6.13)
|
56
|
+
rack (>= 1.0.0)
|
57
|
+
rack-test (0.5.6)
|
58
|
+
rack (>= 1.0)
|
59
|
+
rails (3.0.3)
|
60
|
+
actionmailer (= 3.0.3)
|
61
|
+
actionpack (= 3.0.3)
|
62
|
+
activerecord (= 3.0.3)
|
63
|
+
activeresource (= 3.0.3)
|
64
|
+
activesupport (= 3.0.3)
|
65
|
+
bundler (~> 1.0)
|
66
|
+
railties (= 3.0.3)
|
67
|
+
railties (3.0.3)
|
68
|
+
actionpack (= 3.0.3)
|
69
|
+
activesupport (= 3.0.3)
|
70
|
+
rake (>= 0.8.7)
|
71
|
+
thor (~> 0.14.4)
|
72
|
+
rake (0.8.7)
|
73
|
+
responders (0.6.2)
|
74
|
+
rspec (2.1.0)
|
75
|
+
rspec-core (~> 2.1.0)
|
76
|
+
rspec-expectations (~> 2.1.0)
|
77
|
+
rspec-mocks (~> 2.1.0)
|
78
|
+
rspec-core (2.1.0)
|
79
|
+
rspec-expectations (2.1.0)
|
80
|
+
diff-lcs (~> 1.1.2)
|
81
|
+
rspec-mocks (2.1.0)
|
82
|
+
rspec-rails (2.1.0)
|
83
|
+
rspec (~> 2.1.0)
|
84
|
+
sqlite3-ruby (1.3.2)
|
85
|
+
thor (0.14.6)
|
86
|
+
treetop (1.4.9)
|
87
|
+
polyglot (>= 0.3.1)
|
88
|
+
tzinfo (0.3.23)
|
89
|
+
|
90
|
+
PLATFORMS
|
91
|
+
ruby
|
92
|
+
|
93
|
+
DEPENDENCIES
|
94
|
+
inherited_resources (~> 1.1.2)
|
95
|
+
layout_options!
|
96
|
+
rails (= 3.0.3)
|
97
|
+
rspec (~> 2.1.0)
|
98
|
+
rspec-rails (~> 2.1.0)
|
99
|
+
sqlite3-ruby
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
RailsRoot::Application.load_tasks
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
# If you have a Gemfile, require the gems listed there, including any gems
|
6
|
+
# you've limited to :test, :development, or :production.
|
7
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
8
|
+
|
9
|
+
module RailsRoot
|
10
|
+
class Application < Rails::Application
|
11
|
+
# Settings in config/environments/* take precedence over those specified here.
|
12
|
+
# Application configuration should go into files in config/initializers
|
13
|
+
# -- all .rb files in that directory are automatically loaded.
|
14
|
+
|
15
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
16
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
17
|
+
|
18
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
19
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
20
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
21
|
+
|
22
|
+
# Activate observers that should always be running.
|
23
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
24
|
+
|
25
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
26
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
27
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
28
|
+
|
29
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
30
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
31
|
+
# config.i18n.default_locale = :de
|
32
|
+
|
33
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
34
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
35
|
+
|
36
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
37
|
+
config.encoding = "utf-8"
|
38
|
+
|
39
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
40
|
+
config.filter_parameters += [:password]
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
# Set up gems listed in the Gemfile.
|
4
|
+
gemfile = File.expand_path('../../Gemfile', __FILE__)
|
5
|
+
begin
|
6
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
7
|
+
require 'bundler'
|
8
|
+
Bundler.setup
|
9
|
+
rescue Bundler::GemNotFound => e
|
10
|
+
STDERR.puts e.message
|
11
|
+
STDERR.puts "Try running `bundle install`."
|
12
|
+
exit!
|
13
|
+
end if File.exist?(gemfile)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
3
|
+
development:
|
4
|
+
adapter: sqlite3
|
5
|
+
database: db/development.sqlite3
|
6
|
+
pool: 5
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
10
|
+
# re-generated from your development database when you run "rake".
|
11
|
+
# Do not set this db to the same as development or production.
|
12
|
+
test:
|
13
|
+
adapter: sqlite3
|
14
|
+
database: db/test.sqlite3
|
15
|
+
pool: 5
|
16
|
+
timeout: 5000
|
17
|
+
|
18
|
+
production:
|
19
|
+
adapter: sqlite3
|
20
|
+
database: db/production.sqlite3
|
21
|
+
pool: 5
|
22
|
+
timeout: 5000
|
@@ -0,0 +1,26 @@
|
|
1
|
+
RailsRoot::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Don't care if the mailer can't send
|
18
|
+
config.action_mailer.raise_delivery_errors = false
|
19
|
+
|
20
|
+
# Print deprecation notices to the Rails logger
|
21
|
+
config.active_support.deprecation = :log
|
22
|
+
|
23
|
+
# Only use best-standards-support built into browsers
|
24
|
+
config.action_dispatch.best_standards_support = :builtin
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
RailsRoot::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
5
|
+
# Code is not reloaded between requests
|
6
|
+
config.cache_classes = true
|
7
|
+
|
8
|
+
# Full error reports are disabled and caching is turned on
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_controller.perform_caching = true
|
11
|
+
|
12
|
+
# Specifies the header that your server uses for sending files
|
13
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
+
|
15
|
+
# For nginx:
|
16
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
+
|
18
|
+
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
+
# just comment this out and Rails will serve the files
|
20
|
+
|
21
|
+
# See everything in the log (default is :info)
|
22
|
+
# config.log_level = :debug
|
23
|
+
|
24
|
+
# Use a different logger for distributed setups
|
25
|
+
# config.logger = SyslogLogger.new
|
26
|
+
|
27
|
+
# Use a different cache store in production
|
28
|
+
# config.cache_store = :mem_cache_store
|
29
|
+
|
30
|
+
# Disable Rails's static asset server
|
31
|
+
# In production, Apache or nginx will already do this
|
32
|
+
config.serve_static_assets = false
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
+
|
37
|
+
# Disable delivery errors, bad email addresses will be ignored
|
38
|
+
# config.action_mailer.raise_delivery_errors = false
|
39
|
+
|
40
|
+
# Enable threaded mode
|
41
|
+
# config.threadsafe!
|
42
|
+
|
43
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
+
# the I18n.default_locale when a translation can not be found)
|
45
|
+
config.i18n.fallbacks = true
|
46
|
+
|
47
|
+
# Send deprecation notices to registered listeners
|
48
|
+
config.active_support.deprecation = :notify
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
RailsRoot::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Raise exceptions instead of rendering exception templates
|
18
|
+
config.action_dispatch.show_exceptions = false
|
19
|
+
|
20
|
+
# Disable request forgery protection in test environment
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
22
|
+
|
23
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
24
|
+
# The :test delivery method accumulates sent emails in the
|
25
|
+
# ActionMailer::Base.deliveries array.
|
26
|
+
config.action_mailer.delivery_method = :test
|
27
|
+
|
28
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
29
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
30
|
+
# like if you have constraints or database-specific column types
|
31
|
+
# config.active_record.schema_format = :sql
|
32
|
+
|
33
|
+
# Print deprecation notices to the stderr
|
34
|
+
config.active_support.deprecation = :stderr
|
35
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
RailsRoot::Application.config.secret_token = 'c9074d143f197e0d16199d1564853c3758c51315e5748d1304b5683bb3c008b6c76518a6cbb6ec0272b0f36393ccf987898b36bcbec62a0afd7650b5914f2911'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
RailsRoot::Application.config.session_store :cookie_store, :key => '_rails_root_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# RailsRoot::Application.config.session_store :active_record_store
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../../config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.mock_with :rspec
|
9
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
shared_examples_for 'layout options' do
|
2
|
+
describe '#new' do
|
3
|
+
before(:each) { get :new, params }
|
4
|
+
it { should render_template("#{controller.controller_name}/new") }
|
5
|
+
it { should render_template('layouts/overlay') }
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#show' do
|
9
|
+
before(:each) { get :show, params.merge(:id => 1) }
|
10
|
+
it { should render_template("#{controller.controller_name}/show") }
|
11
|
+
it { should render_template('layouts/application') }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#create' do
|
15
|
+
before(:each) { post :create, params }
|
16
|
+
it { should render_template("#{controller.controller_name}/create") }
|
17
|
+
|
18
|
+
it 'does not use a layout' do
|
19
|
+
# i know i shouldn't be testing a private method, but i cant figure
|
20
|
+
# out how to test that no layout is used
|
21
|
+
controller.send(:_layout).should == false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
version: "0.
|
7
|
+
- 2
|
8
|
+
version: "0.2"
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- Dane Harrigan
|
@@ -13,11 +13,11 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2010-
|
16
|
+
date: 2010-12-01 00:00:00 -05:00
|
17
17
|
default_executable:
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
|
-
name:
|
20
|
+
name: rails
|
21
21
|
prerelease: false
|
22
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
23
|
none: false
|
@@ -93,6 +93,21 @@ dependencies:
|
|
93
93
|
version: 0.11.6
|
94
94
|
type: :development
|
95
95
|
version_requirements: *id005
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: inherited_resources
|
98
|
+
prerelease: false
|
99
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
segments:
|
105
|
+
- 1
|
106
|
+
- 1
|
107
|
+
- 2
|
108
|
+
version: 1.1.2
|
109
|
+
type: :development
|
110
|
+
version_requirements: *id006
|
96
111
|
description: The layout_options gem provides a single place to set all of your layouts in your controller. This gem really shines when multiple layouts are needed when using inherited_resources.
|
97
112
|
email:
|
98
113
|
- dane.harrigan@gmail.com
|
@@ -108,13 +123,55 @@ files:
|
|
108
123
|
- Gemfile.lock
|
109
124
|
- README.textile
|
110
125
|
- Rakefile
|
126
|
+
- init.rb
|
111
127
|
- layout_options.gemspec
|
128
|
+
- lib/generators/layout_options/install/install_generator.rb
|
112
129
|
- lib/layout_options.rb
|
113
130
|
- lib/layout_options/layout_options.rb
|
114
131
|
- lib/layout_options/storage.rb
|
115
132
|
- lib/layout_options/version.rb
|
116
|
-
- spec/layout_options_spec.rb
|
117
133
|
- spec/layout_options_storage_spec.rb
|
134
|
+
- spec/rails_root/.gitignore
|
135
|
+
- spec/rails_root/.rspec
|
136
|
+
- spec/rails_root/Gemfile
|
137
|
+
- spec/rails_root/Gemfile.lock
|
138
|
+
- spec/rails_root/Rakefile
|
139
|
+
- spec/rails_root/app/controllers/application_controller.rb
|
140
|
+
- spec/rails_root/app/controllers/bar_controller.rb
|
141
|
+
- spec/rails_root/app/controllers/baz_controller.rb
|
142
|
+
- spec/rails_root/app/controllers/foo_controller.rb
|
143
|
+
- spec/rails_root/app/views/bar/create.html.erb
|
144
|
+
- spec/rails_root/app/views/bar/new.html.erb
|
145
|
+
- spec/rails_root/app/views/bar/show.html.erb
|
146
|
+
- spec/rails_root/app/views/baz/create.html.erb
|
147
|
+
- spec/rails_root/app/views/baz/new.html.erb
|
148
|
+
- spec/rails_root/app/views/baz/show.html.erb
|
149
|
+
- spec/rails_root/app/views/foo/create.html.erb
|
150
|
+
- spec/rails_root/app/views/foo/new.html.erb
|
151
|
+
- spec/rails_root/app/views/foo/show.html.erb
|
152
|
+
- spec/rails_root/app/views/layouts/application.html.erb
|
153
|
+
- spec/rails_root/app/views/layouts/overlay.html.erb
|
154
|
+
- spec/rails_root/config.ru
|
155
|
+
- spec/rails_root/config/application.rb
|
156
|
+
- spec/rails_root/config/boot.rb
|
157
|
+
- spec/rails_root/config/database.yml
|
158
|
+
- spec/rails_root/config/environment.rb
|
159
|
+
- spec/rails_root/config/environments/development.rb
|
160
|
+
- spec/rails_root/config/environments/production.rb
|
161
|
+
- spec/rails_root/config/environments/test.rb
|
162
|
+
- spec/rails_root/config/initializers/backtrace_silencers.rb
|
163
|
+
- spec/rails_root/config/initializers/inflections.rb
|
164
|
+
- spec/rails_root/config/initializers/mime_types.rb
|
165
|
+
- spec/rails_root/config/initializers/secret_token.rb
|
166
|
+
- spec/rails_root/config/initializers/session_store.rb
|
167
|
+
- spec/rails_root/config/locales/en.yml
|
168
|
+
- spec/rails_root/config/routes.rb
|
169
|
+
- spec/rails_root/script/rails
|
170
|
+
- spec/rails_root/spec/controllers/bar_controller_spec.rb
|
171
|
+
- spec/rails_root/spec/controllers/baz_controller_spec.rb
|
172
|
+
- spec/rails_root/spec/controllers/foo_controller_spec.rb
|
173
|
+
- spec/rails_root/spec/spec_helper.rb
|
174
|
+
- spec/rails_root/spec/support/shared.rb
|
118
175
|
- spec/spec_helper.rb
|
119
176
|
has_rdoc: true
|
120
177
|
homepage: http://rubygems.org/gems/layout_options
|
data/spec/layout_options_spec.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class FooController < ActionController::Base
|
4
|
-
layout_options :overlay => :edit, :none => :destroy
|
5
|
-
end
|
6
|
-
|
7
|
-
describe LayoutOptions do
|
8
|
-
let(:controller) { FooController.new }
|
9
|
-
describe '#edit' do
|
10
|
-
it 'uses the overlay layout' do
|
11
|
-
controller.stub(:action_name => 'edit')
|
12
|
-
controller.layout_options_selector.should == 'overlay'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#show' do
|
17
|
-
it 'uses the application layout' do
|
18
|
-
controller.stub(:action_name => 'show')
|
19
|
-
controller.layout_options_selector.should == 'application'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#destroy' do
|
24
|
-
it 'uses no layout' do
|
25
|
-
controller.stub(:action_name => 'destroy')
|
26
|
-
controller.layout_options_selector.should == false
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|