page_title 0.0.4 → 0.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 215dc2d630f1b4e71a4d2e3e1ca19d5f2a69dcae
4
- data.tar.gz: 60a2cd8a0ad272528fcc7df82f7c9be5730cea1f
3
+ metadata.gz: 566efe6e91936fdb642695020c3d37caf542266c
4
+ data.tar.gz: 8e5cfd6307972be29ad5b73bad9bfb030ed21f1c
5
5
  SHA512:
6
- metadata.gz: 958b5197893b578fcdef3c35ed2ed59d7fd073747cf2c5b214846e5d8eab76dca56c98efeb1ceab19771c671486e1819f2cc81f5600641864a105758bee30b3e
7
- data.tar.gz: 7a6512b2644acde0ec5f762293e2bd834d04ca0bb4d208f1a29f0e7ba59917f3f938cff783621322038caa1adcc350662267488bc976271fa8989a46b71924ad
6
+ metadata.gz: 3d715c6eca59072f22f0f14dcb3632bef77ccf96edc891097939805de56fb6972dd1230d8e238c7967ad4eba92b96b931e0f002bf1c96ee0938ef28f5db3a558
7
+ data.tar.gz: 7aeac1dbfbcb5f9e5f9966dc06c7e51076937267088cbd63644c43910d6a50c02a80e613a92be8469efcba6385106fabf0f848ad40b96cf55594bef2dce5492b
data/.rspec CHANGED
@@ -1,2 +1 @@
1
- --format documentation
2
1
  --color
@@ -1,3 +1,7 @@
1
1
  language: ruby
2
+ sudo: false
3
+ cache: bundler
2
4
  rvm:
3
- - 2.0.0
5
+ - 2.2
6
+ - 2.1
7
+ - 2.0
@@ -1,103 +1,128 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- page_title (0.0.4)
4
+ page_title (0.1.0)
5
5
  rails
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actionmailer (4.1.1)
11
- actionpack (= 4.1.1)
12
- actionview (= 4.1.1)
13
- mail (~> 2.5.4)
14
- actionpack (4.1.1)
15
- actionview (= 4.1.1)
16
- activesupport (= 4.1.1)
17
- rack (~> 1.5.2)
10
+ actionmailer (4.2.0)
11
+ actionpack (= 4.2.0)
12
+ actionview (= 4.2.0)
13
+ activejob (= 4.2.0)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ rails-dom-testing (~> 1.0, >= 1.0.5)
16
+ actionpack (4.2.0)
17
+ actionview (= 4.2.0)
18
+ activesupport (= 4.2.0)
19
+ rack (~> 1.6.0)
18
20
  rack-test (~> 0.6.2)
19
- actionview (4.1.1)
20
- activesupport (= 4.1.1)
21
+ rails-dom-testing (~> 1.0, >= 1.0.5)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
23
+ actionview (4.2.0)
24
+ activesupport (= 4.2.0)
21
25
  builder (~> 3.1)
22
26
  erubis (~> 2.7.0)
23
- activemodel (4.1.1)
24
- activesupport (= 4.1.1)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
29
+ activejob (4.2.0)
30
+ activesupport (= 4.2.0)
31
+ globalid (>= 0.3.0)
32
+ activemodel (4.2.0)
33
+ activesupport (= 4.2.0)
25
34
  builder (~> 3.1)
26
- activerecord (4.1.1)
27
- activemodel (= 4.1.1)
28
- activesupport (= 4.1.1)
29
- arel (~> 5.0.0)
30
- activesupport (4.1.1)
31
- i18n (~> 0.6, >= 0.6.9)
35
+ activerecord (4.2.0)
36
+ activemodel (= 4.2.0)
37
+ activesupport (= 4.2.0)
38
+ arel (~> 6.0)
39
+ activesupport (4.2.0)
40
+ i18n (~> 0.7)
32
41
  json (~> 1.7, >= 1.7.7)
33
42
  minitest (~> 5.1)
34
- thread_safe (~> 0.1)
43
+ thread_safe (~> 0.3, >= 0.3.4)
35
44
  tzinfo (~> 1.1)
36
- arel (5.0.1.20140414130214)
45
+ arel (6.0.0)
37
46
  builder (3.2.2)
38
47
  diff-lcs (1.2.5)
39
48
  erubis (2.7.0)
49
+ globalid (0.3.3)
50
+ activesupport (>= 4.1.0)
40
51
  hike (1.2.3)
41
- i18n (0.6.9)
42
- json (1.8.1)
43
- mail (2.5.4)
44
- mime-types (~> 1.16)
45
- treetop (~> 1.4.8)
46
- mime-types (1.25.1)
47
- minitest (5.3.4)
48
- multi_json (1.10.0)
49
- polyglot (0.3.4)
50
- rack (1.5.2)
51
- rack-test (0.6.2)
52
+ i18n (0.7.0)
53
+ json (1.8.2)
54
+ loofah (2.0.1)
55
+ nokogiri (>= 1.5.9)
56
+ mail (2.6.3)
57
+ mime-types (>= 1.16, < 3)
58
+ mime-types (2.4.3)
59
+ mini_portile (0.6.2)
60
+ minitest (5.5.1)
61
+ multi_json (1.11.0)
62
+ nokogiri (1.6.6.2)
63
+ mini_portile (~> 0.6.0)
64
+ rack (1.6.0)
65
+ rack-test (0.6.3)
52
66
  rack (>= 1.0)
53
- rails (4.1.1)
54
- actionmailer (= 4.1.1)
55
- actionpack (= 4.1.1)
56
- actionview (= 4.1.1)
57
- activemodel (= 4.1.1)
58
- activerecord (= 4.1.1)
59
- activesupport (= 4.1.1)
67
+ rails (4.2.0)
68
+ actionmailer (= 4.2.0)
69
+ actionpack (= 4.2.0)
70
+ actionview (= 4.2.0)
71
+ activejob (= 4.2.0)
72
+ activemodel (= 4.2.0)
73
+ activerecord (= 4.2.0)
74
+ activesupport (= 4.2.0)
60
75
  bundler (>= 1.3.0, < 2.0)
61
- railties (= 4.1.1)
62
- sprockets-rails (~> 2.0)
63
- railties (4.1.1)
64
- actionpack (= 4.1.1)
65
- activesupport (= 4.1.1)
76
+ railties (= 4.2.0)
77
+ sprockets-rails
78
+ rails-deprecated_sanitizer (1.0.3)
79
+ activesupport (>= 4.2.0.alpha)
80
+ rails-dom-testing (1.0.5)
81
+ activesupport (>= 4.2.0.beta, < 5.0)
82
+ nokogiri (~> 1.6.0)
83
+ rails-deprecated_sanitizer (>= 1.0.1)
84
+ rails-html-sanitizer (1.0.1)
85
+ loofah (~> 2.0)
86
+ railties (4.2.0)
87
+ actionpack (= 4.2.0)
88
+ activesupport (= 4.2.0)
66
89
  rake (>= 0.8.7)
67
90
  thor (>= 0.18.1, < 2.0)
68
- rake (10.3.2)
69
- rspec (2.14.1)
70
- rspec-core (~> 2.14.0)
71
- rspec-expectations (~> 2.14.0)
72
- rspec-mocks (~> 2.14.0)
73
- rspec-core (2.14.8)
74
- rspec-expectations (2.14.5)
75
- diff-lcs (>= 1.1.3, < 2.0)
76
- rspec-mocks (2.14.6)
77
- rspec-rails (2.14.2)
78
- actionpack (>= 3.0)
79
- activemodel (>= 3.0)
80
- activesupport (>= 3.0)
81
- railties (>= 3.0)
82
- rspec-core (~> 2.14.0)
83
- rspec-expectations (~> 2.14.0)
84
- rspec-mocks (~> 2.14.0)
85
- sprockets (2.12.1)
91
+ rake (10.4.2)
92
+ rspec (3.2.0)
93
+ rspec-core (~> 3.2.0)
94
+ rspec-expectations (~> 3.2.0)
95
+ rspec-mocks (~> 3.2.0)
96
+ rspec-core (3.2.1)
97
+ rspec-support (~> 3.2.0)
98
+ rspec-expectations (3.2.0)
99
+ diff-lcs (>= 1.2.0, < 2.0)
100
+ rspec-support (~> 3.2.0)
101
+ rspec-mocks (3.2.1)
102
+ diff-lcs (>= 1.2.0, < 2.0)
103
+ rspec-support (~> 3.2.0)
104
+ rspec-rails (3.2.1)
105
+ actionpack (>= 3.0, < 4.3)
106
+ activesupport (>= 3.0, < 4.3)
107
+ railties (>= 3.0, < 4.3)
108
+ rspec-core (~> 3.2.0)
109
+ rspec-expectations (~> 3.2.0)
110
+ rspec-mocks (~> 3.2.0)
111
+ rspec-support (~> 3.2.0)
112
+ rspec-support (3.2.2)
113
+ sprockets (2.12.3)
86
114
  hike (~> 1.2)
87
115
  multi_json (~> 1.0)
88
116
  rack (~> 1.0)
89
117
  tilt (~> 1.1, != 1.3.0)
90
- sprockets-rails (2.1.3)
118
+ sprockets-rails (2.2.4)
91
119
  actionpack (>= 3.0)
92
120
  activesupport (>= 3.0)
93
- sprockets (~> 2.8)
121
+ sprockets (>= 2.8, < 4.0)
94
122
  thor (0.19.1)
95
- thread_safe (0.3.3)
123
+ thread_safe (0.3.4)
96
124
  tilt (1.4.1)
97
- treetop (1.4.15)
98
- polyglot
99
- polyglot (>= 0.3.1)
100
- tzinfo (1.1.0)
125
+ tzinfo (1.2.2)
101
126
  thread_safe (~> 0.1)
102
127
 
103
128
  PLATFORMS
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # page_title
2
2
 
3
+ [![Build Status](https://travis-ci.org/fnando/page_title.svg?branch=master)](https://travis-ci.org/fnando/page_title)
4
+
3
5
  Set the page title on Rails apps.
4
6
 
5
7
  ## Installation
@@ -74,6 +76,16 @@ class WorkshopsController < ApplicationController
74
76
  end
75
77
  ```
76
78
 
79
+ You can also use a custom translation scope. Just set the `:scope` option.
80
+
81
+ ```ruby
82
+ class PagesController < ApplicationController
83
+ def show
84
+ page_title[:scope] = "pages.titles.#{params[:page]}"
85
+ end
86
+ end
87
+ ```
88
+
77
89
  If you're creating a controller that do not extend from `ApplicationController`, remember to use the lines below:
78
90
 
79
91
  ```ruby
@@ -38,10 +38,14 @@ module PageTitle
38
38
 
39
39
  private
40
40
  def title_translation
41
- I18n.t(
42
- title_scope,
43
- options.merge(scope: "titles")
44
- )
41
+ if options[:scope]
42
+ I18n.t(options[:scope])
43
+ else
44
+ I18n.t(
45
+ title_scope,
46
+ options.merge(scope: "titles")
47
+ )
48
+ end
45
49
  end
46
50
 
47
51
  def base_translation
@@ -1,3 +1,3 @@
1
1
  module PageTitle
2
- VERSION = "0.0.4"
2
+ VERSION = '0.1.0'
3
3
  end
@@ -5,7 +5,7 @@ describe "Simple controller name" do
5
5
  set_translations "titles.base" => "%{title} - SITE",
6
6
  "titles.site.index" => "TITLE"
7
7
 
8
- it do
8
+ example do
9
9
  routes.draw { get :index, to: "site#index" }
10
10
  get :index
11
11
 
@@ -19,7 +19,7 @@ describe "Namespaced controller name" do
19
19
  "titles.admin.categories.index" => "TITLE"
20
20
 
21
21
  describe Admin::CategoriesController do
22
- it do
22
+ example do
23
23
  routes.draw { get :index, to: "admin/categories#index" }
24
24
  get :index
25
25
 
@@ -28,12 +28,26 @@ describe "Namespaced controller name" do
28
28
  end
29
29
  end
30
30
 
31
+ describe "Using custom scope" do
32
+ set_translations "titles.base" => "%{title} - SITE",
33
+ "custom_scope.title" => "CUSTOM SCOPE"
34
+
35
+ describe SiteController do
36
+ example do
37
+ routes.draw { get :about, to: "site#about" }
38
+ get :about
39
+
40
+ expect(response.body).to eql("CUSTOM SCOPE - SITE")
41
+ end
42
+ end
43
+ end
44
+
31
45
  describe "Using placeholders" do
32
46
  set_translations "titles.base" => "%{title} - SITE",
33
47
  "titles.categories.show" => "%{name}"
34
48
 
35
49
  describe CategoriesController do
36
- it do
50
+ example do
37
51
  routes.draw { get :show, to: "categories#show" }
38
52
  get :show
39
53
 
@@ -43,13 +57,11 @@ describe "Using placeholders" do
43
57
  end
44
58
 
45
59
  describe "Rendering template" do
46
- render_views
47
-
48
60
  set_translations "titles.base" => "%{title} - SITE",
49
61
  "titles.site.contact" => "TITLE"
50
62
 
51
63
  describe SiteController do
52
- it do
64
+ example do
53
65
  routes.draw { get :contact, to: "site#contact" }
54
66
  get :contact
55
67
 
@@ -13,7 +13,7 @@ Dummy::Application.configure do
13
13
  config.eager_load = false
14
14
 
15
15
  # Configure static asset server for tests with Cache-Control for performance.
16
- config.serve_static_assets = true
16
+ config.serve_static_files = true
17
17
  config.static_cache_control = "public, max-age=3600"
18
18
 
19
19
  # Show full error reports and disable caching.
@@ -5,7 +5,6 @@ ENV["RAILS_ENV"] = "test"
5
5
 
6
6
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
7
7
  require "rspec/rails"
8
- require "rspec/autorun"
9
8
  require "support/helpers"
10
9
  require "support/controllers"
11
10
 
@@ -14,4 +13,6 @@ I18n.locale = :en
14
13
 
15
14
  RSpec.configure do |config|
16
15
  config.extend SpecHelper::ClassMethods
16
+ config.render_views
17
+ config.infer_spec_type_from_file_location!
17
18
  end
@@ -10,6 +10,11 @@ class SiteController < ApplicationController
10
10
  def index
11
11
  render text: page_title
12
12
  end
13
+
14
+ def about
15
+ page_title[:scope] = 'custom_scope.title'
16
+ render text: page_title
17
+ end
13
18
  end
14
19
 
15
20
  class CategoriesController < ApplicationController
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.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-20 00:00:00.000000000 Z
11
+ date: 2015-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  requirements: []
166
166
  rubyforge_project:
167
- rubygems_version: 2.2.2
167
+ rubygems_version: 2.4.5
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Set the page title on Rails apps
@@ -213,4 +213,3 @@ test_files:
213
213
  - spec/spec_helper.rb
214
214
  - spec/support/controllers.rb
215
215
  - spec/support/helpers.rb
216
- has_rdoc: