layout 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +107 -0
- data/Rakefile +5 -0
- data/layout.gemspec +25 -0
- data/lib/layout.rb +4 -0
- data/lib/layout/base.rb +47 -0
- data/lib/layout/railtie.rb +9 -0
- data/lib/layout/version.rb +8 -0
- data/spec/.DS_Store +0 -0
- data/spec/controllers/samples_controller_spec.rb +23 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/support/.DS_Store +0 -0
- data/spec/support/app/.DS_Store +0 -0
- data/spec/support/app/controllers/samples_controller.rb +14 -0
- data/spec/support/app/views/layouts/application.html.erb +2 -0
- data/spec/support/app/views/layouts/modal.html.erb +2 -0
- data/spec/support/app/views/layouts/site.html.erb +2 -0
- data/spec/support/app/views/samples/edit.html.erb +1 -0
- data/spec/support/app/views/samples/index.html.erb +1 -0
- data/spec/support/app/views/samples/show.html.erb +1 -0
- data/spec/support/config/boot.rb +27 -0
- data/spec/support/config/routes.rb +7 -0
- data/spec/support/custom_layout_shared.rb +7 -0
- data/spec/support/log/.gitkeep +0 -0
- data/spec/support/tmp/.gitkeep +0 -0
- data/spec/support/tmp/pagseguro-test.yml +36 -0
- metadata +149 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
layout (0.1.0)
|
5
|
+
rails (>= 3.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
abstract (1.0.0)
|
11
|
+
actionmailer (3.0.1)
|
12
|
+
actionpack (= 3.0.1)
|
13
|
+
mail (~> 2.2.5)
|
14
|
+
actionpack (3.0.1)
|
15
|
+
activemodel (= 3.0.1)
|
16
|
+
activesupport (= 3.0.1)
|
17
|
+
builder (~> 2.1.2)
|
18
|
+
erubis (~> 2.6.6)
|
19
|
+
i18n (~> 0.4.1)
|
20
|
+
rack (~> 1.2.1)
|
21
|
+
rack-mount (~> 0.6.12)
|
22
|
+
rack-test (~> 0.5.4)
|
23
|
+
tzinfo (~> 0.3.23)
|
24
|
+
activemodel (3.0.1)
|
25
|
+
activesupport (= 3.0.1)
|
26
|
+
builder (~> 2.1.2)
|
27
|
+
i18n (~> 0.4.1)
|
28
|
+
activerecord (3.0.1)
|
29
|
+
activemodel (= 3.0.1)
|
30
|
+
activesupport (= 3.0.1)
|
31
|
+
arel (~> 1.0.0)
|
32
|
+
tzinfo (~> 0.3.23)
|
33
|
+
activeresource (3.0.1)
|
34
|
+
activemodel (= 3.0.1)
|
35
|
+
activesupport (= 3.0.1)
|
36
|
+
activesupport (3.0.1)
|
37
|
+
archive-tar-minitar (0.5.2)
|
38
|
+
arel (1.0.1)
|
39
|
+
activesupport (~> 3.0.0)
|
40
|
+
builder (2.1.2)
|
41
|
+
columnize (0.3.1)
|
42
|
+
diff-lcs (1.1.2)
|
43
|
+
erubis (2.6.6)
|
44
|
+
abstract (>= 1.0.0)
|
45
|
+
i18n (0.4.1)
|
46
|
+
linecache19 (0.5.11)
|
47
|
+
ruby_core_source (>= 0.1.4)
|
48
|
+
mail (2.2.7)
|
49
|
+
activesupport (>= 2.3.6)
|
50
|
+
mime-types
|
51
|
+
treetop (>= 1.4.5)
|
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.1)
|
60
|
+
actionmailer (= 3.0.1)
|
61
|
+
actionpack (= 3.0.1)
|
62
|
+
activerecord (= 3.0.1)
|
63
|
+
activeresource (= 3.0.1)
|
64
|
+
activesupport (= 3.0.1)
|
65
|
+
bundler (~> 1.0.0)
|
66
|
+
railties (= 3.0.1)
|
67
|
+
railties (3.0.1)
|
68
|
+
actionpack (= 3.0.1)
|
69
|
+
activesupport (= 3.0.1)
|
70
|
+
rake (>= 0.8.4)
|
71
|
+
thor (~> 0.14.0)
|
72
|
+
rake (0.8.7)
|
73
|
+
rspec (2.0.1)
|
74
|
+
rspec-core (~> 2.0.1)
|
75
|
+
rspec-expectations (~> 2.0.1)
|
76
|
+
rspec-mocks (~> 2.0.1)
|
77
|
+
rspec-core (2.0.1)
|
78
|
+
rspec-expectations (2.0.1)
|
79
|
+
diff-lcs (>= 1.1.2)
|
80
|
+
rspec-mocks (2.0.1)
|
81
|
+
rspec-core (~> 2.0.1)
|
82
|
+
rspec-expectations (~> 2.0.1)
|
83
|
+
rspec-rails (2.0.1)
|
84
|
+
rspec (~> 2.0.0)
|
85
|
+
ruby-debug-base19 (0.11.24)
|
86
|
+
columnize (>= 0.3.1)
|
87
|
+
linecache19 (>= 0.5.11)
|
88
|
+
ruby_core_source (>= 0.1.4)
|
89
|
+
ruby-debug19 (0.11.6)
|
90
|
+
columnize (>= 0.3.1)
|
91
|
+
linecache19 (>= 0.5.11)
|
92
|
+
ruby-debug-base19 (>= 0.11.19)
|
93
|
+
ruby_core_source (0.1.4)
|
94
|
+
archive-tar-minitar (>= 0.5.2)
|
95
|
+
thor (0.14.3)
|
96
|
+
treetop (1.4.8)
|
97
|
+
polyglot (>= 0.3.1)
|
98
|
+
tzinfo (0.3.23)
|
99
|
+
|
100
|
+
PLATFORMS
|
101
|
+
ruby
|
102
|
+
|
103
|
+
DEPENDENCIES
|
104
|
+
layout!
|
105
|
+
rails (>= 3.0.0)
|
106
|
+
rspec-rails (= 2.0.1)
|
107
|
+
ruby-debug19
|
data/Rakefile
ADDED
data/layout.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "layout/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "layout"
|
7
|
+
s.version = Layout::Version::STRING
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Nando Vieira"]
|
10
|
+
s.email = ["fnando.vieira@gmail.com"]
|
11
|
+
s.homepage = "http://rubygems.org/gems/layout"
|
12
|
+
s.summary = "Specify which layout will be rendered on Rails 3 apps"
|
13
|
+
s.description = "Specify which layout will be rendered on Rails 3 apps"
|
14
|
+
|
15
|
+
s.rubyforge_project = "layout"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency "rails", ">= 3.0.0"
|
23
|
+
s.add_development_dependency "rspec-rails", "2.0.1"
|
24
|
+
s.add_development_dependency "ruby-debug19"
|
25
|
+
end
|
data/lib/layout.rb
ADDED
data/lib/layout/base.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module Layout
|
2
|
+
module Base
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
include InstanceMethods
|
6
|
+
|
7
|
+
def self.layout_options
|
8
|
+
@layout_options ||= []
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.layout_options=(options)
|
12
|
+
@layout_options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
# Set current action's layout.
|
16
|
+
# Works in the same old fashion, but you can have multiple calls to it.
|
17
|
+
#
|
18
|
+
# set_layout "application"
|
19
|
+
# set_layout "site", :only => %w[show edit]
|
20
|
+
# set_layout "site", :except => %w[remove index]
|
21
|
+
#
|
22
|
+
def self.set_layout(name, options = {})
|
23
|
+
self.layout_options << [name, options]
|
24
|
+
end
|
25
|
+
|
26
|
+
before_filter :choose_layout
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module InstanceMethods
|
31
|
+
private
|
32
|
+
def choose_layout
|
33
|
+
self.class.layout_options.each do |name, options|
|
34
|
+
if options[:only] && validates_action_for_layout(true, options[:only])
|
35
|
+
self.class.layout(name)
|
36
|
+
elsif options[:except] && validates_action_for_layout(false, options[:except])
|
37
|
+
self.class.layout(name)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def validates_action_for_layout(compares_to, actions)
|
43
|
+
[actions].flatten.collect(&:to_sym).include?(action_name.to_sym) == compares_to
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe SamplesController do
|
4
|
+
render_views
|
5
|
+
|
6
|
+
context "GET :index" do
|
7
|
+
let(:layout) { "application" }
|
8
|
+
let(:action) { :index }
|
9
|
+
it_should_behave_like "custom layout"
|
10
|
+
end
|
11
|
+
|
12
|
+
context "GET :show" do
|
13
|
+
let(:layout) { "site" }
|
14
|
+
let(:action) { :show }
|
15
|
+
it_should_behave_like "custom layout"
|
16
|
+
end
|
17
|
+
|
18
|
+
context "GET :edit" do
|
19
|
+
let(:layout) { "modal" }
|
20
|
+
let(:action) { :edit }
|
21
|
+
it_should_behave_like "custom layout"
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
Viewing the edit page
|
@@ -0,0 +1 @@
|
|
1
|
+
Viewing the index page
|
@@ -0,0 +1 @@
|
|
1
|
+
Viewing the show page
|
@@ -0,0 +1,27 @@
|
|
1
|
+
ENV["BUNDLE_GEMFILE"] = File.dirname(__FILE__) + "/../../../../Gemfile"
|
2
|
+
require "bundler"
|
3
|
+
Bundler.setup
|
4
|
+
|
5
|
+
require "rails"
|
6
|
+
|
7
|
+
%w(
|
8
|
+
action_controller
|
9
|
+
rails/test_unit
|
10
|
+
).each do |framework|
|
11
|
+
begin
|
12
|
+
require "#{framework}/railtie"
|
13
|
+
rescue LoadError
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
Bundler.require(:default)
|
19
|
+
|
20
|
+
module Layout
|
21
|
+
class Application < Rails::Application
|
22
|
+
config.root = File.dirname(__FILE__) + "/.."
|
23
|
+
config.active_support.deprecation = :log
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Layout::Application.initialize!
|
File without changes
|
File without changes
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
ABC: !map:HashWithIndifferentAccess
|
3
|
+
commit: Pagar com PagSeguro
|
4
|
+
email_cobranca: user@example.com
|
5
|
+
encoding: utf-8
|
6
|
+
|
7
|
+
item_descr_1: Ruby 1.9 PDF
|
8
|
+
item_frete_1: "0"
|
9
|
+
item_id_1: "1"
|
10
|
+
item_peso_1: "0"
|
11
|
+
item_quant_1: "1"
|
12
|
+
item_valor_1: "900"
|
13
|
+
|
14
|
+
item_descr_2: Ruby 1.9 Screencast
|
15
|
+
item_frete_2: "0"
|
16
|
+
item_id_2: "2"
|
17
|
+
item_peso_2: "0"
|
18
|
+
item_quant_2: "1"
|
19
|
+
item_valor_2: "1250"
|
20
|
+
|
21
|
+
item_descr_3: Ruby T-Shirt
|
22
|
+
item_frete_3: "250"
|
23
|
+
item_id_3: "3"
|
24
|
+
item_peso_3: "300"
|
25
|
+
item_quant_3: "2"
|
26
|
+
item_valor_3: "1989"
|
27
|
+
|
28
|
+
item_descr_4: Ruby Mug
|
29
|
+
item_id_4: "4"
|
30
|
+
item_peso_4: "100"
|
31
|
+
item_quant_4: "1"
|
32
|
+
item_valor_4: "1599"
|
33
|
+
|
34
|
+
moeda: BRL
|
35
|
+
ref_transacao: ABC
|
36
|
+
tipo: CP
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: layout
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Nando Vieira
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-11-06 00:00:00 -02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rails
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 3
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
version: 3.0.0
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec-rails
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - "="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 2
|
45
|
+
- 0
|
46
|
+
- 1
|
47
|
+
version: 2.0.1
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: ruby-debug19
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
description: Specify which layout will be rendered on Rails 3 apps
|
64
|
+
email:
|
65
|
+
- fnando.vieira@gmail.com
|
66
|
+
executables: []
|
67
|
+
|
68
|
+
extensions: []
|
69
|
+
|
70
|
+
extra_rdoc_files: []
|
71
|
+
|
72
|
+
files:
|
73
|
+
- .gitignore
|
74
|
+
- Gemfile
|
75
|
+
- Gemfile.lock
|
76
|
+
- Rakefile
|
77
|
+
- layout.gemspec
|
78
|
+
- lib/layout.rb
|
79
|
+
- lib/layout/base.rb
|
80
|
+
- lib/layout/railtie.rb
|
81
|
+
- lib/layout/version.rb
|
82
|
+
- spec/.DS_Store
|
83
|
+
- spec/controllers/samples_controller_spec.rb
|
84
|
+
- spec/spec_helper.rb
|
85
|
+
- spec/support/.DS_Store
|
86
|
+
- spec/support/app/.DS_Store
|
87
|
+
- spec/support/app/controllers/samples_controller.rb
|
88
|
+
- spec/support/app/views/layouts/application.html.erb
|
89
|
+
- spec/support/app/views/layouts/modal.html.erb
|
90
|
+
- spec/support/app/views/layouts/site.html.erb
|
91
|
+
- spec/support/app/views/samples/edit.html.erb
|
92
|
+
- spec/support/app/views/samples/index.html.erb
|
93
|
+
- spec/support/app/views/samples/show.html.erb
|
94
|
+
- spec/support/config/boot.rb
|
95
|
+
- spec/support/config/routes.rb
|
96
|
+
- spec/support/custom_layout_shared.rb
|
97
|
+
- spec/support/log/.gitkeep
|
98
|
+
- spec/support/tmp/.gitkeep
|
99
|
+
- spec/support/tmp/pagseguro-test.yml
|
100
|
+
has_rdoc: true
|
101
|
+
homepage: http://rubygems.org/gems/layout
|
102
|
+
licenses: []
|
103
|
+
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
version: "0"
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
version: "0"
|
125
|
+
requirements: []
|
126
|
+
|
127
|
+
rubyforge_project: layout
|
128
|
+
rubygems_version: 1.3.7
|
129
|
+
signing_key:
|
130
|
+
specification_version: 3
|
131
|
+
summary: Specify which layout will be rendered on Rails 3 apps
|
132
|
+
test_files:
|
133
|
+
- spec/controllers/samples_controller_spec.rb
|
134
|
+
- spec/spec_helper.rb
|
135
|
+
- spec/support/.DS_Store
|
136
|
+
- spec/support/app/.DS_Store
|
137
|
+
- spec/support/app/controllers/samples_controller.rb
|
138
|
+
- spec/support/app/views/layouts/application.html.erb
|
139
|
+
- spec/support/app/views/layouts/modal.html.erb
|
140
|
+
- spec/support/app/views/layouts/site.html.erb
|
141
|
+
- spec/support/app/views/samples/edit.html.erb
|
142
|
+
- spec/support/app/views/samples/index.html.erb
|
143
|
+
- spec/support/app/views/samples/show.html.erb
|
144
|
+
- spec/support/config/boot.rb
|
145
|
+
- spec/support/config/routes.rb
|
146
|
+
- spec/support/custom_layout_shared.rb
|
147
|
+
- spec/support/log/.gitkeep
|
148
|
+
- spec/support/tmp/.gitkeep
|
149
|
+
- spec/support/tmp/pagseguro-test.yml
|