page_title 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b31f68b4a317190bae0c5ddd9f12d6952bbcfdf
4
- data.tar.gz: 6abe236198afc5ec21516fe2aaed2b146e956d78
3
+ metadata.gz: 0442979508a4ac0dc6e2ab080044c3e80fa9fa6d
4
+ data.tar.gz: 7a48f169530fe9f6da8a5cee9f61dbbcd7a1d9af
5
5
  SHA512:
6
- metadata.gz: 607f015ff61a8f3bae0fa9b77b8e022728de7fdd5fa2e4cf39e47eea277df3b00d5c909dc899bb2e28cb61860152e0d6e1e70e0c2b086075c0d27fc0d8934ec8
7
- data.tar.gz: 0d85dc430bd5016a616cbcfd0a9d90288e6561da9a08154f8006f497d286e1195ded1ef54dc2040bc90bb631d6e73bbee95b1c4152bbe4b611375186a299a92b
6
+ metadata.gz: b3c205d7e98777d639c2bbd74aa817150a53979e51eb14d7fde2d3c50c2ca4abd4de879fcf53ce093cbf18f7d1f9b49ceba78064bc7769baa49d1d28c504f267
7
+ data.tar.gz: a5f8dcea30ceaf8b936e12a83ab115ed722c13348aed54140a6c69ab2751d8d965936020bf681700c6254756e2a458385c5fac293122921935d1d051cb08444c
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
@@ -15,3 +14,4 @@ spec/reports
15
14
  test/tmp
16
15
  test/version_tmp
17
16
  tmp
17
+ *.log
@@ -0,0 +1,125 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ page_title (0.0.2)
5
+ rails
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionmailer (4.0.0)
11
+ actionpack (= 4.0.0)
12
+ mail (~> 2.5.3)
13
+ actionpack (4.0.0)
14
+ activesupport (= 4.0.0)
15
+ builder (~> 3.1.0)
16
+ erubis (~> 2.7.0)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ activemodel (4.0.0)
20
+ activesupport (= 4.0.0)
21
+ builder (~> 3.1.0)
22
+ activerecord (4.0.0)
23
+ activemodel (= 4.0.0)
24
+ activerecord-deprecated_finders (~> 1.0.2)
25
+ activesupport (= 4.0.0)
26
+ arel (~> 4.0.0)
27
+ activerecord-deprecated_finders (1.0.3)
28
+ activesupport (4.0.0)
29
+ i18n (~> 0.6, >= 0.6.4)
30
+ minitest (~> 4.2)
31
+ multi_json (~> 1.3)
32
+ thread_safe (~> 0.1)
33
+ tzinfo (~> 0.3.37)
34
+ arel (4.0.0)
35
+ atomic (1.1.14)
36
+ awesome_print (1.2.0)
37
+ builder (3.1.4)
38
+ coderay (1.0.9)
39
+ diff-lcs (1.2.4)
40
+ erubis (2.7.0)
41
+ hike (1.2.3)
42
+ i18n (0.6.5)
43
+ mail (2.5.4)
44
+ mime-types (~> 1.16)
45
+ treetop (~> 1.4.8)
46
+ method_source (0.8.2)
47
+ mime-types (1.25)
48
+ minitest (4.7.5)
49
+ multi_json (1.8.2)
50
+ polyglot (0.3.3)
51
+ pry (0.9.12.2)
52
+ coderay (~> 1.0.5)
53
+ method_source (~> 0.8)
54
+ slop (~> 3.4)
55
+ pry-meta (0.0.5)
56
+ awesome_print
57
+ pry
58
+ pry-nav
59
+ pry-remote
60
+ pry-nav (0.2.3)
61
+ pry (~> 0.9.10)
62
+ pry-remote (0.1.7)
63
+ pry (~> 0.9)
64
+ slop (~> 3.0)
65
+ rack (1.5.2)
66
+ rack-test (0.6.2)
67
+ rack (>= 1.0)
68
+ rails (4.0.0)
69
+ actionmailer (= 4.0.0)
70
+ actionpack (= 4.0.0)
71
+ activerecord (= 4.0.0)
72
+ activesupport (= 4.0.0)
73
+ bundler (>= 1.3.0, < 2.0)
74
+ railties (= 4.0.0)
75
+ sprockets-rails (~> 2.0.0)
76
+ railties (4.0.0)
77
+ actionpack (= 4.0.0)
78
+ activesupport (= 4.0.0)
79
+ rake (>= 0.8.7)
80
+ thor (>= 0.18.1, < 2.0)
81
+ rake (10.1.0)
82
+ rspec (2.14.1)
83
+ rspec-core (~> 2.14.0)
84
+ rspec-expectations (~> 2.14.0)
85
+ rspec-mocks (~> 2.14.0)
86
+ rspec-core (2.14.6)
87
+ rspec-expectations (2.14.3)
88
+ diff-lcs (>= 1.1.3, < 2.0)
89
+ rspec-mocks (2.14.4)
90
+ rspec-rails (2.14.0)
91
+ actionpack (>= 3.0)
92
+ activesupport (>= 3.0)
93
+ railties (>= 3.0)
94
+ rspec-core (~> 2.14.0)
95
+ rspec-expectations (~> 2.14.0)
96
+ rspec-mocks (~> 2.14.0)
97
+ slop (3.4.6)
98
+ sprockets (2.10.0)
99
+ hike (~> 1.2)
100
+ multi_json (~> 1.0)
101
+ rack (~> 1.0)
102
+ tilt (~> 1.1, != 1.3.0)
103
+ sprockets-rails (2.0.1)
104
+ actionpack (>= 3.0)
105
+ activesupport (>= 3.0)
106
+ sprockets (~> 2.8)
107
+ thor (0.18.1)
108
+ thread_safe (0.1.3)
109
+ atomic
110
+ tilt (1.4.1)
111
+ treetop (1.4.15)
112
+ polyglot
113
+ polyglot (>= 0.3.1)
114
+ tzinfo (0.3.38)
115
+
116
+ PLATFORMS
117
+ ruby
118
+
119
+ DEPENDENCIES
120
+ bundler
121
+ page_title!
122
+ pry-meta
123
+ rake
124
+ rspec
125
+ rspec-rails
data/README.md CHANGED
@@ -68,6 +68,15 @@ class WorkshopsController < ApplicationController
68
68
  end
69
69
  ```
70
70
 
71
+ If you're creating a controller that do not extend from `ApplicationController`, remember to use the lines below:
72
+
73
+ ```ruby
74
+ class AdminController < ActionController::Base
75
+ include PageTitle::Helpers
76
+ helper_method :page_title
77
+ end
78
+ ```
79
+
71
80
  ## Contributing
72
81
 
73
82
  1. Fork it
@@ -38,7 +38,9 @@ module PageTitle
38
38
  end
39
39
 
40
40
  def normalized_controller_name
41
- controller.controller_name.gsub(%r[/], ".")
41
+ controller.class.name.underscore
42
+ .gsub(/_controller/, "")
43
+ .gsub(%r[/], ".")
42
44
  end
43
45
 
44
46
  def title_scope
@@ -1,3 +1,3 @@
1
1
  module PageTitle
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,59 @@
1
+ require "spec_helper"
2
+
3
+ describe "Simple controller name" do
4
+ describe SiteController do
5
+ set_translations "titles.base" => "%{title} - SITE",
6
+ "titles.site.index" => "TITLE"
7
+
8
+ it do
9
+ routes.draw { get :index, to: "site#index" }
10
+ get :index
11
+
12
+ expect(response.body).to eql("TITLE - SITE")
13
+ end
14
+ end
15
+ end
16
+
17
+ describe "Namespaced controller name" do
18
+ set_translations "titles.base" => "%{title} - SITE",
19
+ "titles.admin.categories.index" => "TITLE"
20
+
21
+ describe Admin::CategoriesController do
22
+ it do
23
+ routes.draw { get :index, to: "admin/categories#index" }
24
+ get :index
25
+
26
+ expect(response.body).to eql("TITLE - SITE")
27
+ end
28
+ end
29
+ end
30
+
31
+ describe "Using placeholders" do
32
+ set_translations "titles.base" => "%{title} - SITE",
33
+ "titles.categories.show" => "%{name}"
34
+
35
+ describe CategoriesController do
36
+ it do
37
+ routes.draw { get :show, to: "categories#show" }
38
+ get :show
39
+
40
+ expect(response.body).to eql("CATEGORY - SITE")
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "Rendering template" do
46
+ render_views
47
+
48
+ set_translations "titles.base" => "%{title} - SITE",
49
+ "titles.site.contact" => "TITLE"
50
+
51
+ describe SiteController do
52
+ it do
53
+ routes.draw { get :contact, to: "site#contact" }
54
+ get :contact
55
+
56
+ expect(response.body).to match(%r[<title>TITLE - SITE</title>])
57
+ end
58
+ end
59
+ end
@@ -7,6 +7,7 @@ require File.expand_path("../dummy/config/environment.rb", __FILE__)
7
7
  require "rspec/rails"
8
8
  require "rspec/autorun"
9
9
  require "support/helpers"
10
+ require "support/controllers"
10
11
 
11
12
  require "page_title"
12
13
  I18n.locale = :en
@@ -0,0 +1,20 @@
1
+ module Admin
2
+ class CategoriesController < ApplicationController
3
+ def index
4
+ render text: page_title
5
+ end
6
+ end
7
+ end
8
+
9
+ class SiteController < ApplicationController
10
+ def index
11
+ render text: page_title
12
+ end
13
+ end
14
+
15
+ class CategoriesController < ApplicationController
16
+ def show
17
+ page_title[:name] = "CATEGORY"
18
+ render text: page_title
19
+ end
20
+ end
@@ -1,8 +1,10 @@
1
1
  module SpecHelper
2
2
  module ClassMethods
3
3
  def set_controller(name, action_name)
4
+ let!(:controller_class) { stub_const(name.camelize, Class.new) }
5
+
4
6
  let(:controller) {
5
- double(controller_name: name, action_name: action_name)
7
+ double(class: controller_class, controller_name: name, action_name: action_name)
6
8
  }
7
9
  end
8
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_title
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-21 00:00:00.000000000 Z
11
+ date: 2013-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -105,6 +105,7 @@ files:
105
105
  - .rspec
106
106
  - .travis.yml
107
107
  - Gemfile
108
+ - Gemfile.lock
108
109
  - LICENSE.txt
109
110
  - README.md
110
111
  - Rakefile
@@ -113,7 +114,7 @@ files:
113
114
  - lib/page_title/helpers.rb
114
115
  - lib/page_title/version.rb
115
116
  - page_title.gemspec
116
- - spec/controllers/application_controller_spec.rb
117
+ - spec/controllers/controllers_spec.rb
117
118
  - spec/dummy/README.rdoc
118
119
  - spec/dummy/Rakefile
119
120
  - spec/dummy/app/assets/images/.keep
@@ -125,8 +126,8 @@ files:
125
126
  - spec/dummy/app/mailers/.keep
126
127
  - spec/dummy/app/models/.keep
127
128
  - spec/dummy/app/models/concerns/.keep
128
- - spec/dummy/app/views/application/index.html.erb
129
129
  - spec/dummy/app/views/layouts/application.html.erb
130
+ - spec/dummy/app/views/site/contact.html.erb
130
131
  - spec/dummy/bin/bundle
131
132
  - spec/dummy/bin/rails
132
133
  - spec/dummy/bin/rake
@@ -149,13 +150,13 @@ files:
149
150
  - spec/dummy/config/routes.rb
150
151
  - spec/dummy/lib/assets/.keep
151
152
  - spec/dummy/log/.keep
152
- - spec/dummy/log/test.log
153
153
  - spec/dummy/public/404.html
154
154
  - spec/dummy/public/422.html
155
155
  - spec/dummy/public/500.html
156
156
  - spec/dummy/public/favicon.ico
157
157
  - spec/page_title_spec.rb
158
158
  - spec/spec_helper.rb
159
+ - spec/support/controllers.rb
159
160
  - spec/support/helpers.rb
160
161
  homepage: http://github.com/fnando/page_title
161
162
  licenses:
@@ -182,7 +183,7 @@ signing_key:
182
183
  specification_version: 4
183
184
  summary: Set the page title on Rails apps
184
185
  test_files:
185
- - spec/controllers/application_controller_spec.rb
186
+ - spec/controllers/controllers_spec.rb
186
187
  - spec/dummy/README.rdoc
187
188
  - spec/dummy/Rakefile
188
189
  - spec/dummy/app/assets/images/.keep
@@ -194,8 +195,8 @@ test_files:
194
195
  - spec/dummy/app/mailers/.keep
195
196
  - spec/dummy/app/models/.keep
196
197
  - spec/dummy/app/models/concerns/.keep
197
- - spec/dummy/app/views/application/index.html.erb
198
198
  - spec/dummy/app/views/layouts/application.html.erb
199
+ - spec/dummy/app/views/site/contact.html.erb
199
200
  - spec/dummy/bin/bundle
200
201
  - spec/dummy/bin/rails
201
202
  - spec/dummy/bin/rake
@@ -218,11 +219,11 @@ test_files:
218
219
  - spec/dummy/config/routes.rb
219
220
  - spec/dummy/lib/assets/.keep
220
221
  - spec/dummy/log/.keep
221
- - spec/dummy/log/test.log
222
222
  - spec/dummy/public/404.html
223
223
  - spec/dummy/public/422.html
224
224
  - spec/dummy/public/500.html
225
225
  - spec/dummy/public/favicon.ico
226
226
  - spec/page_title_spec.rb
227
227
  - spec/spec_helper.rb
228
+ - spec/support/controllers.rb
228
229
  - spec/support/helpers.rb
@@ -1,85 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe ApplicationController do
4
- context "simple controller name" do
5
- set_translations "titles.base" => "%{title} - SITE",
6
- "titles.site.index" => "TITLE"
7
-
8
- controller do
9
- def controller_name
10
- "site"
11
- end
12
-
13
- def index
14
- render text: page_title
15
- end
16
- end
17
-
18
- it do
19
- get :index
20
- expect(response.body).to eql("TITLE - SITE")
21
- end
22
- end
23
-
24
- context "namespaced controller name" do
25
- set_translations "titles.base" => "%{title} - SITE",
26
- "titles.admin.site.index" => "TITLE"
27
-
28
- controller do
29
- def controller_name
30
- "admin/site"
31
- end
32
-
33
- def index
34
- render text: page_title
35
- end
36
- end
37
-
38
- it do
39
- get :index
40
- expect(response.body).to eql("TITLE - SITE")
41
- end
42
- end
43
-
44
- context "using placeholders" do
45
- set_translations "titles.base" => "%{title} - SITE",
46
- "titles.site.index" => "%{name}"
47
-
48
- controller do
49
- def controller_name
50
- "site"
51
- end
52
-
53
- def index
54
- page_title[:name] = "NAME"
55
- render text: page_title
56
- end
57
- end
58
-
59
- it do
60
- get :index
61
- expect(response.body).to eql("NAME - SITE")
62
- end
63
- end
64
-
65
- context "rendering template" do
66
- render_views
67
-
68
- set_translations "titles.base" => "%{title} - SITE",
69
- "titles.site.index" => "TITLE"
70
-
71
- controller do
72
- def controller_name
73
- "site"
74
- end
75
-
76
- def index
77
- end
78
- end
79
-
80
- it do
81
- get :index
82
- expect(response.body).to match(%r[<title>TITLE - SITE</title>])
83
- end
84
- end
85
- end
@@ -1,81 +0,0 @@
1
- Processing by AnonymousController#index as HTML
2
- Completed 500 Internal Server Error in 2ms
3
- Processing by AnonymousController#index as HTML
4
- Completed 500 Internal Server Error in 2ms
5
- Processing by AnonymousController#index as HTML
6
- Completed 500 Internal Server Error in 1ms
7
- Processing by AnonymousController#index as HTML
8
- Rendered text template (0.0ms)
9
- Completed 200 OK in 12ms (Views: 11.8ms)
10
- Processing by AnonymousController#index as HTML
11
- Rendered text template (0.0ms)
12
- Completed 200 OK in 13ms (Views: 12.6ms)
13
- Processing by AnonymousController#index as HTML
14
- Rendered text template (0.0ms)
15
- Completed 200 OK in 12ms (Views: 12.0ms)
16
- Processing by AnonymousController#index as HTML
17
- Rendered text template (0.0ms)
18
- Completed 200 OK in 14ms (Views: 13.2ms)
19
- Processing by AnonymousController#index as HTML
20
- Rendered text template (0.0ms)
21
- Completed 200 OK in 14ms (Views: 13.4ms)
22
- Processing by AnonymousController#index as HTML
23
- Rendered text template (0.0ms)
24
- Completed 200 OK in 12ms (Views: 11.5ms)
25
- Processing by AnonymousController#index as HTML
26
- Rendered text template (0.0ms)
27
- Completed 200 OK in 12ms (Views: 12.1ms)
28
- Processing by AnonymousController#index as HTML
29
- Completed 200 OK in 1ms (Views: 0.6ms)
30
- Processing by AnonymousController#index as HTML
31
- Rendered text template (0.0ms)
32
- Completed 200 OK in 12ms (Views: 11.5ms)
33
- Processing by AnonymousController#index as HTML
34
- Completed 200 OK in 1ms (Views: 0.8ms)
35
- Processing by AnonymousController#index as HTML
36
- Completed 200 OK in 1ms (Views: 0.5ms)
37
- Processing by AnonymousController#index as HTML
38
- Rendered text template (0.0ms)
39
- Completed 200 OK in 12ms (Views: 11.7ms)
40
- Processing by AnonymousController#index as HTML
41
- Completed 200 OK in 1ms (Views: 0.5ms)
42
- Processing by AnonymousController#index as HTML
43
- Completed 200 OK in 1ms (Views: 0.5ms)
44
- Processing by AnonymousController#index as HTML
45
- Completed 500 Internal Server Error in 9ms
46
- Processing by AnonymousController#index as HTML
47
- Rendered text template (0.0ms)
48
- Completed 200 OK in 12ms (Views: 11.9ms)
49
- Processing by AnonymousController#index as HTML
50
- Completed 200 OK in 1ms (Views: 0.5ms)
51
- Processing by AnonymousController#index as HTML
52
- Completed 200 OK in 1ms (Views: 0.6ms)
53
- Processing by AnonymousController#index as HTML
54
- Completed 200 OK in 12ms (Views: 12.0ms)
55
- Processing by AnonymousController#index as HTML
56
- Rendered text template (0.0ms)
57
- Completed 200 OK in 15ms (Views: 14.7ms)
58
- Processing by AnonymousController#index as HTML
59
- Completed 200 OK in 1ms (Views: 1.0ms)
60
- Processing by AnonymousController#index as HTML
61
- Completed 200 OK in 1ms (Views: 1.0ms)
62
- Processing by AnonymousController#index as HTML
63
- Completed 500 Internal Server Error in 54ms
64
- Processing by AnonymousController#index as HTML
65
- Rendered text template (0.0ms)
66
- Completed 200 OK in 12ms (Views: 11.6ms)
67
- Processing by AnonymousController#index as HTML
68
- Completed 200 OK in 1ms (Views: 0.5ms)
69
- Processing by AnonymousController#index as HTML
70
- Completed 200 OK in 1ms (Views: 0.5ms)
71
- Processing by AnonymousController#index as HTML
72
- Completed 200 OK in 39ms (Views: 38.3ms)
73
- Processing by AnonymousController#index as HTML
74
- Rendered text template (0.0ms)
75
- Completed 200 OK in 12ms (Views: 11.9ms)
76
- Processing by AnonymousController#index as HTML
77
- Completed 200 OK in 1ms (Views: 0.5ms)
78
- Processing by AnonymousController#index as HTML
79
- Completed 200 OK in 1ms (Views: 0.5ms)
80
- Processing by AnonymousController#index as HTML
81
- Completed 200 OK in 34ms (Views: 33.3ms)