title 0.0.7 → 0.0.9

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
- SHA1:
3
- metadata.gz: c9ed9cfe7986e563d62faa4cefe3b89f306024a1
4
- data.tar.gz: 3037d1aab90cb329e833afba0289ab77441fbb1f
2
+ SHA256:
3
+ metadata.gz: 90cbc40b402c00597bbf47a9637eb5a1361b70ca679d7268fa6391d8702d35a8
4
+ data.tar.gz: 194ed85c40d3ad13a538f3be9f99124eab853b908f2a7bf9b5d881b2e143afcf
5
5
  SHA512:
6
- metadata.gz: f268b193660c5dccf85016a73baca651a74790c33d84912c6be41b81cf66b654bf062fc920158d7dedf5c46ee50f09b82ffca3a7f08083464cd21c0ba51d9b45
7
- data.tar.gz: 1f42157da292bbfc7cba1c9bcc8b6e21b23d441d5eee7ed64dd1a4120dfb79b941bdfa82b013fcd2b2d527a29f7c0e05dfe39bf5616b8795f0152e6d7e61a697
6
+ metadata.gz: 4d81ca5ae9e0be311e2b0032e47a08f7b47e4dbd57cf3c6b82475d492ea36ea9c3b3fa13134ec6c2604a171c4d96f22678a5cbfe961f17cf7380ba4d70cbb0a7
7
+ data.tar.gz: 062ce6f86129d3ed849ad2b67e4b6b488a3ac6392bbb2f2ff1f7e51ec7cce8df879c32f3ec7620888cd5b50e7e9b1e3f4718a0884cd9a152aae353c6d5b5a4fe
@@ -0,0 +1,45 @@
1
+ name: CI
2
+
3
+ "on":
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches: "*"
9
+
10
+ jobs:
11
+ build:
12
+ name: Ruby ${{ matrix.ruby }}, Rails ${{ matrix.rails }}
13
+
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ ruby: ["3.0", "3.1", "3.2", "3.3"]
18
+ rails: ["6.1", "7.0", "7.1", "main"]
19
+ continue-on-error: [false]
20
+
21
+ env:
22
+ RAILS_VERSION: ${{ matrix.rails }}
23
+
24
+ runs-on: "ubuntu-latest"
25
+
26
+ steps:
27
+ - uses: actions/checkout@v3
28
+ - uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby }}
31
+
32
+ - name: Generate lockfile
33
+ run: bundle lock
34
+
35
+ - name: Cache dependencies
36
+ uses: actions/cache@v3
37
+ with:
38
+ path: vendor/bundle
39
+ key: bundle-${{ hashFiles('Gemfile.lock') }}
40
+
41
+ - run: bundle check || bundle install
42
+
43
+ - name: Run rspec tests
44
+ run: bundle exec rspec
45
+ continue-on-error: ${{ matrix.continue-on-error }}
data/Gemfile CHANGED
@@ -1,4 +1,14 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ rails_version = ENV.fetch("RAILS_VERSION", "7.1")
4
+
5
+ if rails_version == "main"
6
+ rails_constraint = { github: "rails/rails" }
7
+ else
8
+ rails_constraint = "~> #{rails_version}.0"
9
+ end
10
+
11
+ gem "rails", rails_constraint
12
+
3
13
  # Specify your gem's dependencies in title.gemspec
4
14
  gemspec
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Caleb Thompson
1
+ Copyright (c) 2013 Caleb Hearth
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # Title
2
2
 
3
- [![Build Status](https://travis-ci.org/calebthompson/title.png)](https://travis-ci.org/calebthompson/title)
4
- [![Code Climate](https://codeclimate.com/github/calebthompson/title.png)](https://codeclimate.com/github/calebthompson/title)
5
- [![Coverage Status](https://coveralls.io/repos/calebthompson/title/badge.png)](https://coveralls.io/r/calebthompson/title)
6
-
7
3
  Translations for \<title\>s!
8
4
 
9
5
  ## Usage
@@ -58,4 +54,4 @@ extremely similar approach, and from whence came the idea of using the view
58
54
  context to get local assigns to be used in interpolation.
59
55
 
60
56
  [Brandon Keepers]: https://github.com/bkeepers
61
- [Abusing Rails I18N to Set Page Titles]: http://opensoul.org/blog/archives/2012/11/05/abusing-rails-i18n-to-set-page-titles/
57
+ [Abusing Rails I18N to Set Page Titles]: https://opensoul.org/2012/11/05/abusing-rails-i18n-to-set-page-titles/
@@ -15,7 +15,7 @@ module Title
15
15
  def to_s
16
16
  I18n.t(
17
17
  [:titles, controller_name, action_name].join('.'),
18
- context.merge(default: defaults)
18
+ **safe_context.merge(default: defaults)
19
19
  )
20
20
  end
21
21
 
@@ -59,6 +59,10 @@ module Title
59
59
  action_name
60
60
  end
61
61
  end
62
+
63
+ def safe_context
64
+ context.except(*I18n::RESERVED_KEYS)
65
+ end
62
66
  end
63
67
  end
64
68
  end
data/lib/title/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Title
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.9'
3
3
  end
data/lib/title.rb CHANGED
@@ -2,6 +2,7 @@ app = File.expand_path('../../app', __FILE__)
2
2
  $LOAD_PATH.unshift(app) unless $LOAD_PATH.include?(app)
3
3
 
4
4
  require 'title/version'
5
+ require 'active_support'
5
6
  require 'rails/engine'
6
7
  require 'title/engine'
7
8
  require 'helpers/title/title_helper'
@@ -1,6 +1,3 @@
1
- require 'coveralls'
2
- Coveralls.wear!
3
-
4
1
  require 'title'
5
2
 
6
3
  describe Title::TitleHelper do
@@ -37,7 +34,7 @@ describe Title::TitleHelper do
37
34
  stub_rails
38
35
  stub_controller_and_action(:users, :show)
39
36
  load_translations(users: { show: '%{name}' })
40
- helper.stub_chain(:controller, :view_assigns).and_return('name' => 'Caleb')
37
+ allow(helper).to receive_message_chain(:controller, :view_assigns).and_return('name' => 'Caleb')
41
38
 
42
39
  expect(helper.title).to eq('Caleb')
43
40
  end
@@ -46,20 +43,30 @@ describe Title::TitleHelper do
46
43
  stub_rails
47
44
  stub_controller_and_action(:users, :show)
48
45
  load_translations(users: { show: '%{greeting} %{name}' })
49
- helper.stub_chain(:controller, :view_assigns).and_return('name' => 'Caleb')
46
+ allow(helper).to receive_message_chain(:controller, :view_assigns).and_return('name' => 'Caleb')
50
47
 
51
48
  expect(helper.title(greeting: 'Hello')).to eq('Hello Caleb')
52
49
  end
53
50
 
51
+ it 'makes context safe to be passed as interpolation options' do
52
+ stub_rails
53
+ stub_controller_and_action(:users, :show)
54
+ load_translations(users: { show: 'User' })
55
+ allow(helper).to receive_message_chain(:controller, :view_assigns).and_return('scope' => 'Foo')
56
+
57
+ expect(helper.title).to eq('User')
58
+ end
59
+
54
60
  def stub_rails
55
- helper.stub(:controller_path).and_return('dashboards')
56
- helper.stub(:action_name)
57
- helper.stub_chain(:controller, :view_assigns).and_return({})
58
- Rails.stub_chain(:application, :class).and_return('Dummy::Application')
61
+ allow(helper).to receive(:controller_path).and_return('dashboards')
62
+ allow(helper).to receive(:action_name)
63
+ allow(helper).to receive_message_chain(:controller, :view_assigns).and_return({})
64
+ allow(Rails).to receive_message_chain(:application, :class).and_return('Dummy::Application')
59
65
  end
60
66
 
61
67
  def stub_controller_and_action(controller, action)
62
- helper.stub(controller_path: controller.to_s, action_name: action.to_s)
68
+ allow(helper).to receive(:controller_path).and_return(controller.to_s)
69
+ allow(helper).to receive(:action_name).and_return(action.to_s)
63
70
  end
64
71
 
65
72
  def helper
data/title.gemspec CHANGED
@@ -7,22 +7,20 @@ require 'title/version'
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'title'
9
9
  spec.version = Title::VERSION
10
- spec.authors = ['Caleb Thompson']
11
- spec.email = ['caleb@calebthompson.io']
10
+ spec.authors = ['Caleb Hearth']
11
+ spec.email = ['caleb@calebhearth.com']
12
12
  spec.summary = 'I18n your <title>s'
13
13
  spec.description = 'Abuses I18n to set HTML <title>s'
14
- spec.homepage = 'https://github.com/calebthompson/title'
14
+ spec.homepage = 'https://github.com/calebhearth/title'
15
15
  spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files`.split($/)
18
18
  spec.test_files = spec.files.grep(%r{^spec/})
19
19
  spec.require_paths = ['lib', 'app']
20
20
 
21
- spec.add_development_dependency 'bundler', '~> 1.3'
21
+ spec.add_development_dependency 'bundler'
22
22
  spec.add_development_dependency 'rake'
23
23
  spec.add_development_dependency 'rspec'
24
- spec.add_development_dependency 'coveralls'
25
- spec.add_development_dependency 'pry'
26
24
 
27
25
  spec.add_dependency 'rails', '>= 3.1'
28
26
  spec.add_dependency 'i18n'
metadata CHANGED
@@ -1,45 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: title
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
- - Caleb Thompson
8
- autorequire:
7
+ - Caleb Hearth
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-29 00:00:00.000000000 Z
11
+ date: 2023-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.3'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.3'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
15
  requirement: !ruby/object:Gem::Requirement
44
16
  requirements:
45
17
  - - ">="
@@ -53,7 +25,7 @@ dependencies:
53
25
  - !ruby/object:Gem::Version
54
26
  version: '0'
55
27
  - !ruby/object:Gem::Dependency
56
- name: coveralls
28
+ name: rake
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - ">="
@@ -67,7 +39,7 @@ dependencies:
67
39
  - !ruby/object:Gem::Version
68
40
  version: '0'
69
41
  - !ruby/object:Gem::Dependency
70
- name: pry
42
+ name: rspec
71
43
  requirement: !ruby/object:Gem::Requirement
72
44
  requirements:
73
45
  - - ">="
@@ -110,11 +82,12 @@ dependencies:
110
82
  version: '0'
111
83
  description: Abuses I18n to set HTML <title>s
112
84
  email:
113
- - caleb@calebthompson.io
85
+ - caleb@calebhearth.com
114
86
  executables: []
115
87
  extensions: []
116
88
  extra_rdoc_files: []
117
89
  files:
90
+ - ".github/workflows/ci.yml"
118
91
  - ".gitignore"
119
92
  - CONTRIBUTING.md
120
93
  - Gemfile
@@ -127,11 +100,11 @@ files:
127
100
  - lib/title/version.rb
128
101
  - spec/helpers/title_helper_spec.rb
129
102
  - title.gemspec
130
- homepage: https://github.com/calebthompson/title
103
+ homepage: https://github.com/calebhearth/title
131
104
  licenses:
132
105
  - MIT
133
106
  metadata: {}
134
- post_install_message:
107
+ post_install_message:
135
108
  rdoc_options: []
136
109
  require_paths:
137
110
  - lib
@@ -147,9 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
120
  - !ruby/object:Gem::Version
148
121
  version: '0'
149
122
  requirements: []
150
- rubyforge_project:
151
- rubygems_version: 2.5.1
152
- signing_key:
123
+ rubygems_version: 3.4.21
124
+ signing_key:
153
125
  specification_version: 4
154
126
  summary: I18n your <title>s
155
127
  test_files: