layout_options 0.2 → 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/README.textile CHANGED
@@ -14,16 +14,19 @@ h3. Example
14
14
 
15
15
  Adding layout_options to your Gemfile:
16
16
 
17
- gem 'layout_options', '~> 0.1'
17
+ @gem 'layout_options', '~> 0.1'@
18
18
 
19
19
  Install @layout_options@:
20
20
 
21
- rails generate layout_options:install
21
+ @rails generate layout_options:install@
22
22
 
23
23
  Define your layouts in your controllers:
24
24
 
25
+ <pre><code>
25
26
  class UsersController < ApplicationController
26
27
  layout_options :overlay => [:new, :edit], :none => :destroy
28
+ # use :none for your hash key if you don't want any layout to be used
27
29
  end
30
+ </code></pre>
28
31
 
29
32
  Thats it!
@@ -9,15 +9,11 @@ Gem::Specification.new do |s|
9
9
  s.email = ['dane.harrigan@gmail.com']
10
10
  s.homepage = "http://rubygems.org/gems/layout_options"
11
11
  s.summary = 'A single place for setting all of your layouts in a controller'
12
- s.description = 'The layout_options gem provides a single place to set all of your ' <<
13
- 'layouts in your controller. This gem really shines when multiple layouts are needed ' <<
14
- 'when using inherited_resources.'
15
-
12
+ s.description = 'Need an easy way to manage multiple layouts? Done.'
16
13
  s.required_rubygems_version = ">= 1.3.6"
17
14
  s.rubyforge_project = "layout_options"
18
15
 
19
16
  s.add_dependency 'rails', '~> 3.0.1'
20
- #s.add_dependency 'actionpack','~> 3.0.1'
21
17
 
22
18
  s.add_development_dependency "bundler", ">= 1.0.0.rc.6"
23
19
  s.add_development_dependency "rspec", "~> 2.1.0"
@@ -2,12 +2,17 @@ module LayoutOptions
2
2
  module Generators
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
  desc 'prep the application to use layout_options'
5
+ source_root File.expand_path('../templates', __FILE__)
5
6
 
6
7
  def application_controller_injection # :nodoc:
7
8
  inject_into_class 'app/controllers/application_controller.rb', ApplicationController do
8
9
  " include LayoutOptions\n"
9
10
  end
10
11
  end
12
+
13
+ def copy_initializer # :nodoc
14
+ copy_file 'layout_options.rb', 'config/initializers/layout_options.rb'
15
+ end
11
16
  end
12
17
  end
13
18
  end
@@ -0,0 +1,11 @@
1
+ LayoutOptions.setup do |config|
2
+ # layout_options assumes the default layout to use is the 'applicaiton' layout.
3
+ # If this isn't the case just change the value here.
4
+ #
5
+ # "Why would I ever want a different default layout?"
6
+ # Creating a stock rails app gives you an 'application.html.erb' layout file.
7
+ # If you make a Rails engine and try to use an 'application' layout it will
8
+ # pull the auto-generated one from the rails root. Setting your default layout
9
+ # to something different, like the name of your engine, will fix the conflict.
10
+ config.default_layout = :application
11
+ end
@@ -1,10 +1,27 @@
1
1
  module LayoutOptions
2
+ mattr_accessor :default_layout
3
+ @@default_layout = 'application'
4
+
2
5
  def self.included(controller) # :nodoc:
3
6
  controller.send(:include, LayoutOptions::InstanceMethods)
4
7
  controller.send(:extend, LayoutOptions::ClassMethods)
5
8
  controller.send(:layout, :layout_options_selector)
6
9
  end
7
10
 
11
+ # setup - This method allows you to configure the layout_options gem. You can find the setup
12
+ # block in the config/initializers/layout_options.rb file.
13
+ #
14
+ # # layout_options assumes the default layout for all of your views is 'application'. If you
15
+ # # want to deviate from this assumption you can set a 'default_layout' value.
16
+ #
17
+ # LayoutOptions.setup do |config|
18
+ # config.default_layout = :custom_layout
19
+ # end
20
+ def self.setup
21
+ yield(self)
22
+ end
23
+
24
+
8
25
  module ClassMethods
9
26
  # layout_options - This method is available at the class level of your ApplicationController
10
27
  # and any controller that inherits from it.
@@ -55,7 +72,7 @@ module LayoutOptions
55
72
  end
56
73
 
57
74
  no_layout.map! { |value| value.to_sym }
58
- return no_layout.include?(action) ? false : 'application'
75
+ return no_layout.include?(action) ? false : LayoutOptions.default_layout.to_s
59
76
  end
60
77
  end
61
78
  end
@@ -1,7 +1,3 @@
1
1
  module LayoutOptions
2
- module VERSION
3
- def self.to_s # :nodoc:
4
- '0.2'
5
- end
6
- end
2
+ VERSION = '0.2.1'
7
3
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/Dane/Projects/layout_options
3
3
  specs:
4
- layout_options (0.1.1)
4
+ layout_options (0.2)
5
5
  rails (~> 3.0.1)
6
6
 
7
7
  GEM
@@ -0,0 +1,3 @@
1
+ class CuxController < ApplicationController
2
+ def index; end
3
+ end
File without changes
@@ -0,0 +1,9 @@
1
+ LayoutOptions.setup do |config|
2
+ # layout_options assumes the default layout to use is the 'applicaiton' layout.
3
+ # If this isn't the case just change the value here.
4
+ #
5
+ # When wouldn't you want the default layout to be 'application?' If you make a
6
+ # rails engine and assume the 'application' layout, your views will conflict with
7
+ # the 'application.html.erb' layout that gets generated with a rails install.
8
+ config.default_layout = :application
9
+ end
@@ -1,4 +1,5 @@
1
1
  RailsRoot::Application.routes.draw do
2
+ resources :cux
2
3
  resources :foo
3
4
  resources :bar do
4
5
  resources :baz
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe CuxController do
4
+ describe '#index' do
5
+ before(:each) do
6
+ LayoutOptions.setup do |config|
7
+ config.default_layout = :custom_default
8
+ end
9
+ end
10
+
11
+ after(:each) do
12
+ LayoutOptions.setup do |config|
13
+ config.default_layout = :application
14
+ end
15
+ end
16
+
17
+ it 'uses a different default layout' do
18
+ get :index
19
+ response.should render_template('layouts/custom_default')
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- version: "0.2"
8
+ - 1
9
+ version: 0.2.1
9
10
  platform: ruby
10
11
  authors:
11
12
  - Dane Harrigan
@@ -13,7 +14,7 @@ autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
16
 
16
- date: 2010-12-01 00:00:00 -05:00
17
+ date: 2011-01-26 00:00:00 -05:00
17
18
  default_executable:
18
19
  dependencies:
19
20
  - !ruby/object:Gem::Dependency
@@ -108,7 +109,7 @@ dependencies:
108
109
  version: 1.1.2
109
110
  type: :development
110
111
  version_requirements: *id006
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.
112
+ description: Need an easy way to manage multiple layouts? Done.
112
113
  email:
113
114
  - dane.harrigan@gmail.com
114
115
  executables: []
@@ -120,12 +121,12 @@ extra_rdoc_files: []
120
121
  files:
121
122
  - .gitignore
122
123
  - Gemfile
123
- - Gemfile.lock
124
124
  - README.textile
125
125
  - Rakefile
126
126
  - init.rb
127
127
  - layout_options.gemspec
128
- - lib/generators/layout_options/install/install_generator.rb
128
+ - lib/generators/layout_options/install_generator.rb
129
+ - lib/generators/layout_options/templates/layout_options.rb
129
130
  - lib/layout_options.rb
130
131
  - lib/layout_options/layout_options.rb
131
132
  - lib/layout_options/storage.rb
@@ -139,6 +140,7 @@ files:
139
140
  - spec/rails_root/app/controllers/application_controller.rb
140
141
  - spec/rails_root/app/controllers/bar_controller.rb
141
142
  - spec/rails_root/app/controllers/baz_controller.rb
143
+ - spec/rails_root/app/controllers/cux_controller.rb
142
144
  - spec/rails_root/app/controllers/foo_controller.rb
143
145
  - spec/rails_root/app/views/bar/create.html.erb
144
146
  - spec/rails_root/app/views/bar/new.html.erb
@@ -146,10 +148,12 @@ files:
146
148
  - spec/rails_root/app/views/baz/create.html.erb
147
149
  - spec/rails_root/app/views/baz/new.html.erb
148
150
  - spec/rails_root/app/views/baz/show.html.erb
151
+ - spec/rails_root/app/views/cux/index.html.erb
149
152
  - spec/rails_root/app/views/foo/create.html.erb
150
153
  - spec/rails_root/app/views/foo/new.html.erb
151
154
  - spec/rails_root/app/views/foo/show.html.erb
152
155
  - spec/rails_root/app/views/layouts/application.html.erb
156
+ - spec/rails_root/app/views/layouts/custom_default.html.erb
153
157
  - spec/rails_root/app/views/layouts/overlay.html.erb
154
158
  - spec/rails_root/config.ru
155
159
  - spec/rails_root/config/application.rb
@@ -161,6 +165,7 @@ files:
161
165
  - spec/rails_root/config/environments/test.rb
162
166
  - spec/rails_root/config/initializers/backtrace_silencers.rb
163
167
  - spec/rails_root/config/initializers/inflections.rb
168
+ - spec/rails_root/config/initializers/layout_options.rb
164
169
  - spec/rails_root/config/initializers/mime_types.rb
165
170
  - spec/rails_root/config/initializers/secret_token.rb
166
171
  - spec/rails_root/config/initializers/session_store.rb
@@ -169,6 +174,7 @@ files:
169
174
  - spec/rails_root/script/rails
170
175
  - spec/rails_root/spec/controllers/bar_controller_spec.rb
171
176
  - spec/rails_root/spec/controllers/baz_controller_spec.rb
177
+ - spec/rails_root/spec/controllers/cux_controller_spec.rb
172
178
  - spec/rails_root/spec/controllers/foo_controller_spec.rb
173
179
  - spec/rails_root/spec/spec_helper.rb
174
180
  - spec/rails_root/spec/support/shared.rb
data/Gemfile.lock DELETED
@@ -1,113 +0,0 @@
1
- PATH
2
- remote: .
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
- archive-tar-minitar (0.5.2)
38
- arel (2.0.4)
39
- builder (2.1.2)
40
- columnize (0.3.2)
41
- diff-lcs (1.1.2)
42
- erubis (2.6.6)
43
- abstract (>= 1.0.0)
44
- has_scope (0.5.0)
45
- i18n (0.4.2)
46
- inherited_resources (1.1.2)
47
- has_scope (~> 0.5.0)
48
- responders (~> 0.6.0)
49
- linecache19 (0.5.11)
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)
58
- rack (1.2.1)
59
- rack-mount (0.6.13)
60
- rack (>= 1.0.0)
61
- rack-test (0.5.6)
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)
78
- rspec (2.1.0)
79
- rspec-core (~> 2.1.0)
80
- rspec-expectations (~> 2.1.0)
81
- rspec-mocks (~> 2.1.0)
82
- rspec-core (2.1.0)
83
- rspec-expectations (2.1.0)
84
- diff-lcs (~> 1.1.2)
85
- rspec-mocks (2.1.0)
86
- rspec-rails (2.1.0)
87
- rspec (~> 2.1.0)
88
- ruby-debug-base19 (0.11.24)
89
- columnize (>= 0.3.1)
90
- linecache19 (>= 0.5.11)
91
- ruby_core_source (>= 0.1.4)
92
- ruby-debug19 (0.11.6)
93
- columnize (>= 0.3.1)
94
- linecache19 (>= 0.5.11)
95
- ruby-debug-base19 (>= 0.11.19)
96
- ruby_core_source (0.1.4)
97
- archive-tar-minitar (>= 0.5.2)
98
- thor (0.14.6)
99
- treetop (1.4.9)
100
- polyglot (>= 0.3.1)
101
- tzinfo (0.3.23)
102
-
103
- PLATFORMS
104
- ruby
105
-
106
- DEPENDENCIES
107
- bundler (>= 1.0.0.rc.6)
108
- inherited_resources (~> 1.1.2)
109
- layout_options!
110
- rails (~> 3.0.1)
111
- rspec (~> 2.1.0)
112
- rspec-rails (~> 2.1.0)
113
- ruby-debug19 (~> 0.11.6)