titler 1.0.1 → 1.3.0

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: 9afaa1c87c03098a84a69fa10354183eb3390c19
4
- data.tar.gz: f6163adcfc53bd99ed6b02aa49e444fe3bf670c4
2
+ SHA256:
3
+ metadata.gz: 245b3b8af826c022cdd490b57b881fb3ca5ce99ca1287514a75dff672e4a32cd
4
+ data.tar.gz: '089dba315f02229fc4f242fbc248273d90fe10f600254793b59627e438bf352b'
5
5
  SHA512:
6
- metadata.gz: 7bcaa580ac6f62dd93621407efe8f7381264bb6e5ae89fa9cb788de6785111c15536554ec3d2820e1aa777aa11006fdea38239ab038e62302643700562c23383
7
- data.tar.gz: 3f7c9be5579e0bf88670b48523dfacbeca81f9d1da3c38882a04baf82102d46769423101f8a04969a143cd51211e6642ef94ac5093e0f1f2d091c26da2172c5e
6
+ metadata.gz: 023dc916006d558135e6930894285f571c4c0cb1b905c5329f86e6b3b970708d2f5b70a8092c236d920f3a157d84bc1c526fcd4d725580d075aac228f7761012
7
+ data.tar.gz: 0604f2f44666dd2edd3ab858a6e41b67c3a94b0c47c16e0dea70df34da304dd81217c9b3a46869bf700965056db074bb287460d797e882824693ab5c1707ad3b
@@ -0,0 +1,25 @@
1
+ version: 2.1
2
+ orbs:
3
+ ruby: circleci/ruby@0.1.2
4
+
5
+ jobs:
6
+ test:
7
+ parameters:
8
+ ruby-version:
9
+ type: string
10
+ docker:
11
+ - image: << parameters.ruby-version >>
12
+ steps:
13
+ - checkout
14
+ - ruby/bundle-install
15
+ - run:
16
+ name: Run tests
17
+ command: bundle exec rake
18
+
19
+ workflows:
20
+ all-tests:
21
+ jobs:
22
+ - test:
23
+ matrix:
24
+ parameters:
25
+ ruby-version: ["ruby:3.0.1", "ruby:2.7.3", "ruby:2.6.7"]
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .DS_Store
10
11
 
11
12
  # rspec failure tracking
12
13
  .rspec_status
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.3.1
1
+ ruby-2.6.5
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in titler.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/roberttravispierce/titler.svg?branch=master)](https://travis-ci.org/roberttravispierce/titler)
4
4
  [![Code Climate](https://codeclimate.com/github/roberttravispierce/titler/badges/gpa.svg)](https://codeclimate.com/github/roberttravispierce/titler)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/roberttravispierce/titler/badge.svg?branch=master)](https://coveralls.io/github/roberttravispierce/titler?branch=master)
6
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
6
7
  [![Gem Version](https://badge.fury.io/rb/titler.svg)](https://badge.fury.io/rb/titler)
7
8
 
8
9
  1. [What is it?](#overview)
@@ -99,7 +100,12 @@ There is a [titler_demo](https://github.com/roberttravispierce/titler_demo) demo
99
100
 
100
101
  ## <a name="customize"></a>How do I customize it?
101
102
 
102
- I'm working on a generator to add a config initializer and i18n locale file. In the meantime you can add the files to change your defaults (see the [titler_demo](https://github.com/roberttravispierce/titler_demo) demonstration app for an example):
103
+
104
+ Customize titler settings for your app by running the generator:
105
+ ```console
106
+ rails generate titler:install
107
+ ```
108
+ This will generate two files to give you customization options (see the [titler_demo](https://github.com/roberttravispierce/titler_demo) demonstration app for an example):
103
109
 
104
110
  *app/config/locales/titler.en.yml*
105
111
  ```yaml
@@ -114,15 +120,43 @@ en:
114
120
  *app/config/initializers/titler.rb*
115
121
  ```ruby
116
122
  Titler.configure do |config|
117
- config.use_env_prefix = true
118
- config.delimiter = ' - '
119
- config.app_name_position = 'append' # append, prepend, none
120
- config.use_app_tagline = true
121
- config.admin_name = 'Admin'
122
- config.admin_controller = AdminController
123
+ # See titler gem README.md (https://github.com/roberttravispierce/titler)
124
+ # for details on these configuration options. Uncomment and change to use:
125
+ #
126
+ # config.use_env_prefix = true
127
+ # config.delimiter = ' - '
128
+ # config.app_name_position = 'append' # append, prepend, none
129
+ # config.use_app_tagline = true
130
+ # config.admin_name = 'Admin'
131
+ # config.admin_controller = AdminController
123
132
  end
124
133
  ```
125
134
 
135
+ ### Configuration options
136
+
137
+ - **use_env_prefix** (Default = 'true')
138
+
139
+ Toggle use of the env_prefix. Note the prefix will never be use in a production environment no matter what the setting.
140
+
141
+ - **delimiter** (Default = ' - ')
142
+
143
+ Change the character delimiter between elements. Be sure to include any spaces you desire.
144
+
145
+ - **app_name_position** (Default = 'append')
146
+
147
+ Adjust how the app name is used. Options are 'append', 'prepend', or 'none'
148
+
149
+ - **use_app_tagline** (Default = 'true')
150
+
151
+ Toggle use of marketing tagline. Position is right before an appended app_name or right after a prepended app_name.
152
+
153
+ - **admin_name** (Default = 'Admin')
154
+
155
+ Change the text to add to the title if an admin controller is being used
156
+
157
+ - **admin_controller** (Default = 'AdminController')
158
+
159
+ Class name of controller to trigger addition of 'admin_name' in title
126
160
 
127
161
  ## <a name="why"></a>So why the fuss about titles anyway?
128
162
 
@@ -136,7 +170,7 @@ Here are some resources to learn more about the importance of thoughtful, well-c
136
170
 
137
171
  Titler was conceived and developed by Robert Travis Pierce ([roberttravispierce](https://github.com/roberttravispierce)), to scratch his own itch and further his education in Ruby and Rails.
138
172
 
139
- Invaluable guidance and encouragment was provided along the way by Jonathan Allured ([jonallured](https://github.com/jonallured)). Thank you Jon, for agreeing to be a mentor and give back to the community.
173
+ Invaluable guidance and encouragement was provided along the way by Jonathan Allured ([jonallured](https://github.com/jonallured)). Thank you Jon, for agreeing to be a mentor and give back to the community.
140
174
 
141
175
  In addition, the [title gem](https://github.com/calebthompson/title) by [calebthompson](https://github.com/calebthompson), helped greatly with figuring out how to structure the gem as a rails engine, and served as a guide for several improvements.
142
176
 
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "standard/rake"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
6
- task :default => :spec
7
+ task default: %i[standard spec]
@@ -1,7 +1,7 @@
1
1
  module Titler
2
2
  module TitlerHelper
3
3
  def page_title(page_title)
4
- content_for(:page_title) {page_title}
4
+ content_for(:page_title) { page_title }
5
5
  end
6
6
 
7
7
  def titler(custom_vars = {})
@@ -24,7 +24,7 @@ module Titler
24
24
  end
25
25
 
26
26
  def to_s
27
- th = title_hash = Hash.new
27
+ th = {}
28
28
  th[:env_prefix] = env_prefix
29
29
  th[:admin_namespace] = admin_namespace
30
30
  th[:title_body] = title_body
@@ -37,14 +37,14 @@ module Titler
37
37
 
38
38
  def env_prefix
39
39
  if @configuration.use_env_prefix
40
- Rails.env.production? ? '' : "(#{Rails.env[0,1].upcase}) "
40
+ Rails.env.production? ? "" : "(#{Rails.env[0, 1].upcase}) "
41
41
  else
42
- ''
42
+ ""
43
43
  end
44
44
  end
45
45
 
46
46
  def admin_namespace
47
- admin_namespace? ? admin_default_name + delimiter : ''
47
+ admin_namespace? ? admin_default_name + delimiter : ""
48
48
  end
49
49
 
50
50
  def admin_namespace?
@@ -56,34 +56,42 @@ module Titler
56
56
  end
57
57
 
58
58
  def delimiter
59
- @i18n.exists?('titler.delimiter') ? @i18n.t('titler.delimiter') : @configuration.delimiter
59
+ if @i18n.exists?("titler.delimiter") && @i18n.t("titler.delimiter").present?
60
+ @i18n.t("titler.delimiter")
61
+ else
62
+ @configuration.delimiter
63
+ end
60
64
  end
61
65
 
62
66
  def app_name
63
- if @i18n.exists?('titler.app_name') && @i18n.t('titler.app_name').present?
64
- @i18n.t('titler.app_name')
67
+ if @i18n.exists?("titler.app_name") && @i18n.t("titler.app_name").present?
68
+ @i18n.t("titler.app_name")
65
69
  else
66
70
  Rails.application.class.to_s.split("::").first
67
71
  end
68
72
  end
69
73
 
70
74
  def app_tagline
71
- tagline = @i18n.exists?('titler.app_tagline') ? @i18n.t('titler.app_tagline') : ''
75
+ @i18n.exists?("titler.app_tagline") ? @i18n.t("titler.app_tagline") : ""
72
76
  end
73
77
 
74
78
  def title_body
75
79
  if @title_as_set.present?
76
80
  @title_as_set
77
81
  else
78
- @controller.controller_name.titleize + ' ' + @controller.action_name.titleize rescue ''
82
+ begin
83
+ @controller.controller_name.titleize + " " + @controller.action_name.titleize
84
+ rescue
85
+ ""
86
+ end
79
87
  end
80
88
  end
81
89
 
82
90
  def build_title_str(th)
83
91
  case @configuration.app_name_position
84
- when 'append'
92
+ when "append"
85
93
  th[:env_prefix] + th[:admin_namespace] + th[:title_body] + app_tagline_str(th) + app_name_str(th)
86
- when 'prepend'
94
+ when "prepend"
87
95
  th[:env_prefix] + app_name_str(th) + app_tagline_str(th) + th[:admin_namespace] + th[:title_body]
88
96
  else
89
97
  th[:env_prefix] + th[:admin_namespace] + th[:title_body] + app_tagline_str(th)
@@ -95,12 +103,12 @@ module Titler
95
103
  th[:app_name]
96
104
  else
97
105
  case @configuration.app_name_position
98
- when 'append'
106
+ when "append"
99
107
  delimiter + th[:app_name]
100
- when 'prepend'
108
+ when "prepend"
101
109
  th[:app_name] + delimiter
102
110
  else
103
- ''
111
+ ""
104
112
  end
105
113
  end
106
114
  end
@@ -108,12 +116,12 @@ module Titler
108
116
  def app_tagline_str(th)
109
117
  tagline = th[:app_tagline]
110
118
  if tagline.blank? || !@configuration.use_app_tagline
111
- ''
119
+ ""
112
120
  else
113
121
  case @configuration.app_name_position
114
- when 'append'
122
+ when "append"
115
123
  delimiter + tagline
116
- when 'prepend'
124
+ when "prepend"
117
125
  tagline + delimiter
118
126
  end
119
127
  end
@@ -1,8 +1,8 @@
1
1
  Titler.configure do |config|
2
2
  config.use_env_prefix = true
3
- config.delimiter = ' - '
4
- config.app_name_position = 'append' # append, prepend, none
3
+ config.delimiter = " - "
4
+ config.app_name_position = "append" # append, prepend, none
5
5
  config.use_app_tagline = true
6
- config.admin_name = 'Admin'
6
+ config.admin_name = "Admin"
7
7
  config.admin_controller = AdminController
8
8
  end
@@ -1,14 +1,20 @@
1
- require 'rails/generators/base'
1
+ require "rails/generators/base"
2
2
 
3
3
  module Titler
4
4
  module Generators
5
5
  class InstallGenerator < Rails::Generators::Base
6
- source_root File.expand_path('../templates', __FILE__)
6
+ source_root File.expand_path("../templates", __FILE__)
7
+ desc "Creates Titler initializer and i18n for your application"
7
8
 
8
- def create_titler_initializer
9
- copy_file 'titler.rb', 'config/initializers/titler.rb'
9
+ def copy_initializer
10
+ template "titler.rb", "config/initializers/titler.rb"
11
+ puts "Initializer install complete."
10
12
  end
11
13
 
14
+ def copy_i18n
15
+ template "titler.en.yml", "config/locales/titler.en.yml"
16
+ puts "Localization install complete."
17
+ end
12
18
  end
13
19
  end
14
20
  end
@@ -0,0 +1,6 @@
1
+ ---
2
+ en:
3
+ titler:
4
+ app_name: ''
5
+ app_tagline: ''
6
+ delimiter: ''
@@ -1,8 +1,11 @@
1
1
  Titler.configure do |config|
2
- config.use_env_prefix = true
3
- config.delimiter = ' - '
4
- config.app_name_position = 'append' # append, prepend, none
5
- config.use_app_tagline = true
6
- config.admin_name = 'Admin'
7
- config.admin_controller = AdminController
2
+ # See titler gem README.md (https://github.com/roberttravispierce/titler)
3
+ # for details on these configuration options. Uncomment and change to use:
4
+ #
5
+ # config.use_env_prefix = true
6
+ # config.delimiter = ' - '
7
+ # config.app_name_position = 'append' # append, prepend, none
8
+ # config.use_app_tagline = true
9
+ # config.admin_name = 'Admin'
10
+ # config.admin_controller = AdminController
8
11
  end
@@ -1,4 +1,4 @@
1
- require 'rails/generators/base'
1
+ require "rails/generators/base"
2
2
 
3
3
  module Titler
4
4
  module Generators
@@ -14,14 +14,14 @@ module Titler
14
14
  private
15
15
 
16
16
  def locales
17
- files_within_root('.', 'config/locales/**/*.*')
17
+ files_within_root(".", "config/locales/**/*.*")
18
18
  end
19
19
 
20
20
  def files_within_root(prefix, glob)
21
21
  root = "#{self.class.source_root}/#{prefix}"
22
22
 
23
23
  Dir["#{root}/#{glob}"].sort.map do |full_path|
24
- full_path.sub(root, '.').gsub('/./', '/')
24
+ full_path.sub(root, ".").gsub("/./", "/")
25
25
  end
26
26
  end
27
27
  end
@@ -3,19 +3,19 @@ class AdminController; end
3
3
  module Titler
4
4
  class Configuration
5
5
  attr_accessor :admin_name,
6
- :admin_controller,
7
- :app_name_position,
8
- :use_env_prefix,
9
- :use_app_tagline,
10
- :delimiter
6
+ :admin_controller,
7
+ :app_name_position,
8
+ :use_env_prefix,
9
+ :use_app_tagline,
10
+ :delimiter
11
11
 
12
12
  def initialize
13
- @admin_name = 'Admin'
13
+ @admin_name = "Admin"
14
14
  @admin_controller = AdminController
15
- @app_name_position = 'append' # append, prepend, none
15
+ @app_name_position = "append" # append, prepend, none
16
16
  @use_env_prefix = true
17
17
  @use_app_tagline = true
18
- @delimiter = ' - ' #Note: (Eventually) a 'titler.delimiter' i18n value will override this
18
+ @delimiter = " - " # Note: (Eventually) a 'titler.delimiter' i18n value will override this
19
19
  end
20
20
  end
21
21
 
@@ -1,3 +1,3 @@
1
1
  module Titler
2
- VERSION = '1.0.1'
2
+ VERSION = "1.3.0"
3
3
  end
data/lib/titler.rb CHANGED
@@ -1,8 +1,8 @@
1
- app = File.expand_path('../../app', __FILE__)
1
+ app = File.expand_path("../../app", __FILE__)
2
2
  $LOAD_PATH.unshift(app) unless $LOAD_PATH.include?(app)
3
3
 
4
- require 'titler/version'
5
- require 'rails/engine'
6
- require 'titler/engine'
7
- require 'titler/configuration'
8
- require 'helpers/titler/titler_helper'
4
+ require "titler/version"
5
+ require "rails/engine"
6
+ require "titler/engine"
7
+ require "titler/configuration"
8
+ require "helpers/titler/titler_helper"
data/titler.gemspec CHANGED
@@ -1,23 +1,24 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'titler/version'
3
+ require "titler/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "titler"
8
- spec.version = Titler::VERSION
9
- spec.authors = ["Robert Travis Pierce", "Jonathan Allured"]
10
- spec.email = ["robert@roberttravispierce.com"]
11
-
12
- spec.summary = %q{Titler is a ruby gem that automaticaly gives you useful and consistent page titles for your Rails application.}
13
- spec.description = %q{Titler is a ruby gem that automaticaly gives you useful and consistent page titles for your Rails application. You can set specific page titles in the controller or view with fallbacks and useful defaults for all situations.}
14
- spec.homepage = "https://github.com/roberttravispierce/titler"
15
- spec.license = "MIT"
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.test_files = spec.files.grep(/\Aspec\//)
6
+ spec.name = "titler"
7
+ spec.version = Titler::VERSION
8
+ spec.authors = ["Robert Travis Pierce", "Jonathan Allured"]
9
+ spec.email = ["robert@roberttravispierce.com"]
10
+
11
+ spec.summary = "Titler is a ruby gem that automaticaly gives you useful and consistent page titles for your Rails application."
12
+ spec.description = "Titler is a ruby gem that automaticaly gives you useful and consistent page titles for your Rails application. You can set specific page titles in the controller or view with fallbacks and useful defaults for all situations."
13
+ spec.homepage = "https://github.com/roberttravispierce/titler"
14
+ spec.license = "MIT"
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.test_files = spec.files.grep(/\Aspec\//)
18
19
  spec.require_path = "lib"
19
20
 
20
- spec.required_ruby_version = "~> 2.0"
21
+ spec.required_ruby_version = ">= 2"
21
22
 
22
23
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
23
24
  # to allow pushing to a single host or delete this section to allow pushing to any host.
@@ -28,28 +29,24 @@ Gem::Specification.new do |spec|
28
29
  # "public gem pushes."
29
30
  # end
30
31
 
31
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
32
- f.match(%r{^(test|spec|features)/})
33
- end
34
- spec.bindir = "exe"
35
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
34
  spec.require_paths = ["lib"]
37
35
 
38
- spec.add_development_dependency 'rails', '~> 5.0.3'
39
- spec.add_development_dependency "bundler", "~> 1.14"
40
- spec.add_development_dependency "rake", "~> 10.0"
41
- spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_development_dependency "bundler"
37
+ spec.add_development_dependency "rake"
38
+ spec.add_development_dependency "rspec"
42
39
  spec.add_development_dependency "rspec-nc"
43
40
  spec.add_development_dependency "guard"
44
41
  spec.add_development_dependency "guard-rspec"
45
42
  spec.add_development_dependency "pry"
46
43
  spec.add_development_dependency "pry-remote"
47
44
  spec.add_development_dependency "pry-nav"
48
- spec.add_development_dependency 'rb-readline'
49
- spec.add_development_dependency 'rspec-rails'
50
- spec.add_development_dependency 'coveralls'
51
-
52
- spec.add_dependency 'rails', '>= 3.1'
53
- spec.add_dependency 'i18n'
45
+ spec.add_development_dependency "rb-readline"
46
+ spec.add_development_dependency "rspec-rails"
47
+ spec.add_development_dependency "coveralls"
48
+ spec.add_development_dependency "standard"
54
49
 
50
+ spec.add_dependency "rails", ">= 5.2"
51
+ spec.add_dependency "i18n"
55
52
  end
metadata CHANGED
@@ -1,72 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: titler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Travis Pierce
8
8
  - Jonathan Allured
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-07-14 00:00:00.000000000 Z
12
+ date: 2022-09-07 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rails
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: 5.0.3
21
- type: :development
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: 5.0.3
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: bundler
30
16
  requirement: !ruby/object:Gem::Requirement
31
17
  requirements:
32
- - - "~>"
18
+ - - ">="
33
19
  - !ruby/object:Gem::Version
34
- version: '1.14'
20
+ version: '0'
35
21
  type: :development
36
22
  prerelease: false
37
23
  version_requirements: !ruby/object:Gem::Requirement
38
24
  requirements:
39
- - - "~>"
25
+ - - ">="
40
26
  - !ruby/object:Gem::Version
41
- version: '1.14'
27
+ version: '0'
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: rake
44
30
  requirement: !ruby/object:Gem::Requirement
45
31
  requirements:
46
- - - "~>"
32
+ - - ">="
47
33
  - !ruby/object:Gem::Version
48
- version: '10.0'
34
+ version: '0'
49
35
  type: :development
50
36
  prerelease: false
51
37
  version_requirements: !ruby/object:Gem::Requirement
52
38
  requirements:
53
- - - "~>"
39
+ - - ">="
54
40
  - !ruby/object:Gem::Version
55
- version: '10.0'
41
+ version: '0'
56
42
  - !ruby/object:Gem::Dependency
57
43
  name: rspec
58
44
  requirement: !ruby/object:Gem::Requirement
59
45
  requirements:
60
- - - "~>"
46
+ - - ">="
61
47
  - !ruby/object:Gem::Version
62
- version: '3.0'
48
+ version: '0'
63
49
  type: :development
64
50
  prerelease: false
65
51
  version_requirements: !ruby/object:Gem::Requirement
66
52
  requirements:
67
- - - "~>"
53
+ - - ">="
68
54
  - !ruby/object:Gem::Version
69
- version: '3.0'
55
+ version: '0'
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: rspec-nc
72
58
  requirement: !ruby/object:Gem::Requirement
@@ -193,20 +179,34 @@ dependencies:
193
179
  - - ">="
194
180
  - !ruby/object:Gem::Version
195
181
  version: '0'
182
+ - !ruby/object:Gem::Dependency
183
+ name: standard
184
+ requirement: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ type: :development
190
+ prerelease: false
191
+ version_requirements: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
196
  - !ruby/object:Gem::Dependency
197
197
  name: rails
198
198
  requirement: !ruby/object:Gem::Requirement
199
199
  requirements:
200
200
  - - ">="
201
201
  - !ruby/object:Gem::Version
202
- version: '3.1'
202
+ version: '5.2'
203
203
  type: :runtime
204
204
  prerelease: false
205
205
  version_requirements: !ruby/object:Gem::Requirement
206
206
  requirements:
207
207
  - - ">="
208
208
  - !ruby/object:Gem::Version
209
- version: '3.1'
209
+ version: '5.2'
210
210
  - !ruby/object:Gem::Dependency
211
211
  name: i18n
212
212
  requirement: !ruby/object:Gem::Requirement
@@ -230,6 +230,7 @@ executables: []
230
230
  extensions: []
231
231
  extra_rdoc_files: []
232
232
  files:
233
+ - ".circleci/config.yml"
233
234
  - ".coveralls.yml"
234
235
  - ".gitignore"
235
236
  - ".rspec"
@@ -246,42 +247,36 @@ files:
246
247
  - config/initializers/titler.rb
247
248
  - config/locales/titler.en.yml
248
249
  - lib/generators/titler/install/install_generator.rb
250
+ - lib/generators/titler/install/templates/titler.en.yml
249
251
  - lib/generators/titler/install/templates/titler.rb
250
252
  - lib/generators/titler/locales/locales_generator.rb
251
253
  - lib/titler.rb
252
254
  - lib/titler/configuration.rb
253
255
  - lib/titler/engine.rb
254
256
  - lib/titler/version.rb
255
- - spec/configure_spec.rb
256
- - spec/helpers/titler_helper_spec.rb
257
- - spec/spec_helper.rb
258
257
  - titler.gemspec
259
258
  homepage: https://github.com/roberttravispierce/titler
260
259
  licenses:
261
260
  - MIT
262
261
  metadata: {}
263
- post_install_message:
262
+ post_install_message:
264
263
  rdoc_options: []
265
264
  require_paths:
266
265
  - lib
267
266
  required_ruby_version: !ruby/object:Gem::Requirement
268
267
  requirements:
269
- - - "~>"
268
+ - - ">="
270
269
  - !ruby/object:Gem::Version
271
- version: '2.0'
270
+ version: '2'
272
271
  required_rubygems_version: !ruby/object:Gem::Requirement
273
272
  requirements:
274
273
  - - ">="
275
274
  - !ruby/object:Gem::Version
276
275
  version: '0'
277
276
  requirements: []
278
- rubyforge_project:
279
- rubygems_version: 2.6.8
280
- signing_key:
277
+ rubygems_version: 3.1.2
278
+ signing_key:
281
279
  specification_version: 4
282
280
  summary: Titler is a ruby gem that automaticaly gives you useful and consistent page
283
281
  titles for your Rails application.
284
- test_files:
285
- - spec/configure_spec.rb
286
- - spec/helpers/titler_helper_spec.rb
287
- - spec/spec_helper.rb
282
+ test_files: []
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
- require 'titler'
3
-
4
- class ManagerController; end
5
-
6
- module Titler
7
- describe Configuration do
8
-
9
- context 'with configuration block' do
10
- it 'uses the options in the configuration block instead of defaults' do
11
- Titler.configure do |config|
12
- config.admin_controller = ManagerController
13
- config.admin_name = 'Manager'
14
- config.app_name_position = 'prepend'
15
- config.delimiter = ' | '
16
- config.use_app_tagline = false
17
- config.use_env_prefix = false
18
- end
19
-
20
- expect(Titler.configuration.admin_controller).to eq ManagerController
21
- expect(Titler.configuration.admin_name).to eq 'Manager'
22
- expect(Titler.configuration.app_name_position).to eq 'prepend'
23
- expect(Titler.configuration.delimiter).to eq ' | '
24
- expect(Titler.configuration.use_app_tagline).to eq false
25
- expect(Titler.configuration.use_env_prefix).to eq false
26
- end
27
- end
28
-
29
- describe "#configure" do
30
- it "sets use_env_prefix to true" do
31
- config = Configuration.new
32
- expect(config.use_env_prefix).to be true
33
- end
34
-
35
- it "can set use_env_prefix to false" do
36
- config = Configuration.new
37
- allow(config).to receive(:use_env_prefix).and_return(false)
38
- expect(config.use_env_prefix).to be false
39
- end
40
-
41
- after :each do
42
- Titler.reset
43
- end
44
- end
45
- end
46
- end
@@ -1,184 +0,0 @@
1
- require 'spec_helper'
2
- require 'titler'
3
-
4
- describe Titler::TitlerHelper do
5
-
6
- # Defaults Only Context ----------------------------------------------------
7
- context 'when no title info is set' do
8
- it '(1) uses defaults' do
9
- controller = MockController.new
10
- stub_rails(controller, 'production', nil)
11
- load_translations({})
12
-
13
- expected_title = "#{env_prefix}#{controller.controller_name.titleize} #{controller.action_name.titleize} - #{app_name}"
14
- expect(titler_helper.titler).to eq(expected_title)
15
- end
16
-
17
- it '(2) prefixes defaults in development' do
18
- controller = MockController.new
19
- stub_rails(controller, 'development', nil)
20
- load_translations({})
21
-
22
- expected_title = "#{env_prefix}#{controller.controller_name.titleize} #{controller.action_name.titleize} - #{app_name}"
23
- expect(titler_helper.titler).to eq(expected_title)
24
- end
25
-
26
- it '(3) adds admin namespace to defaults' do
27
- controller = MockAdminController.new
28
- stub_rails(controller, 'production', nil)
29
- load_translations({})
30
-
31
- expected_title = "#{env_prefix}Admin - #{controller.controller_name.titleize} #{controller.action_name.titleize} - #{app_name}"
32
- expect(titler_helper.titler).to eq(expected_title)
33
- end
34
- end
35
-
36
- # i18n Values Context ----------------------------------------------------
37
- context 'when titler i18n values exist' do
38
- it '(1) adds delimiter to defaults' do
39
- controller = MockController.new
40
- stub_rails(controller, 'production', nil)
41
- load_translations({ delimiter: ' | ' })
42
-
43
- expected_title = "#{env_prefix}#{controller.controller_name.titleize} #{controller.action_name.titleize} | #{app_name}"
44
- expect(titler_helper.titler).to eq(expected_title)
45
- end
46
-
47
- it '(2) adds app name to defaults' do
48
- controller = MockController.new
49
- stub_rails(controller, 'production', nil)
50
- load_translations({ app_name: 'Test App' })
51
-
52
- expected_title = "#{env_prefix}#{controller.controller_name.titleize} #{controller.action_name.titleize} - Test App"
53
- expect(titler_helper.titler).to eq(expected_title)
54
- end
55
-
56
- it '(3) uses default app name if i18n.t is blank' do
57
- controller = MockController.new
58
- stub_rails(controller, 'production', nil)
59
- load_translations({ app_name: '' })
60
-
61
- expected_title = "#{env_prefix}#{controller.controller_name.titleize} #{controller.action_name.titleize} - #{app_name}"
62
- expect(titler_helper.titler).to eq(expected_title)
63
- end
64
-
65
- it '(4) adds tagline to defaults' do
66
- controller = MockController.new
67
- stub_rails(controller, 'production', nil)
68
- load_translations({ app_tagline: 'All the News' })
69
-
70
- expected_title = "#{env_prefix}#{controller.controller_name.titleize} #{controller.action_name.titleize} - All the News - #{app_name}"
71
- expect(titler_helper.titler).to eq(expected_title)
72
- end
73
- end
74
-
75
- # Specific Page Title Context ----------------------------------------------------
76
- context 'when specific page title exists' do
77
- it '(1) uses page_title var when present' do
78
- controller = MockController.new
79
- stub_rails(controller, 'production', nil)
80
- load_translations({})
81
- titler_helper.instance_variable_set(:@page_title, 'Var Test Page')
82
- expected_title = "#{env_prefix}Var Test Page - #{app_name}"
83
- expect(titler_helper.titler).to eq(expected_title)
84
- end
85
-
86
- # it '(1) uses content_for when present' do
87
- # controller = MockController.new
88
- # stub_rails(controller, 'production', nil)
89
- # #TODO setting the content_for is not working for some reason
90
- # titler_helper.content_for(:page_title, 'Test Page')
91
- # expected_title = "#{env_prefix}Test Page - #{app_name}"
92
- # expect(titler_helper.titler).to eq(expected_title)
93
- # end
94
- end
95
-
96
- # Configuration Values Context ----------------------------------------------------
97
- context 'when titler configuration values exist' do
98
- it 'uses the options in the configuration block instead of defaults' do
99
- controller = MockController.new
100
- stub_rails(controller, 'production', nil)
101
- load_translations({})
102
-
103
- Titler.configure do |config|
104
- config.delimiter = ' | '
105
- end
106
-
107
- expect(titler_helper.titler).to include('|')
108
-
109
- Titler.reset
110
- end
111
- end
112
-
113
- def stub_rails(controller, env_str, content_for)
114
- allow(Rails).to receive_message_chain(:application, :class).and_return('TitlerTest::Application')
115
- allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new(env_str))
116
- allow(Rails).to receive(:controller).and_return(controller)
117
-
118
- allow(titler_helper).to receive_message_chain(:content_for).and_return(content_for)
119
- allow(titler_helper).to receive_message_chain(:controller, :view_assigns).and_return({})
120
- allow(titler_helper).to receive_message_chain(:controller).and_return(controller)
121
- end
122
-
123
- def app_name
124
- Rails.application.class.to_s.split("::").first
125
- end
126
-
127
- def load_translations(titles)
128
- I18n.backend.reload!
129
- I18n.backend.store_translations(:en, { titler: titles })
130
- end
131
-
132
- def env_prefix
133
- Rails.env.production? ? '' : "(#{Rails.env[0,1].upcase}) "
134
- end
135
-
136
- # TODO: I think there's a way to do away with this stub style and use something like:
137
- # allow(helper).to receive(:controller).and_return('MockController') but I'm not sure.
138
- class MockController
139
- def controller_name
140
- "mock"
141
- end
142
-
143
- def action_name
144
- "action"
145
- end
146
-
147
- def view_assigns
148
- {}
149
- end
150
- end
151
-
152
- class AdminController; end
153
- class MockAdminController < AdminController
154
- def controller_name
155
- "mock_admin"
156
- end
157
-
158
- def action_name
159
- "action"
160
- end
161
-
162
- def view_assigns
163
- {}
164
- end
165
- end
166
-
167
- class MyAdminController < AdminController
168
- def controller_name
169
- "my_admin"
170
- end
171
-
172
- def action_name
173
- "action"
174
- end
175
-
176
- def view_assigns
177
- {}
178
- end
179
- end
180
-
181
- def titler_helper
182
- @titler_helper ||= Class.new { include Titler::TitlerHelper }.new
183
- end
184
- end
data/spec/spec_helper.rb DELETED
@@ -1,18 +0,0 @@
1
- require 'coveralls'
2
- Coveralls.wear!
3
-
4
- require "bundler/setup"
5
- require 'pry'
6
- require "titler"
7
- require 'rails'
8
-
9
- RSpec.configure do |config|
10
- # Enable flags like --only-failures and --next-failure
11
- config.example_status_persistence_file_path = ".rspec_status"
12
-
13
- config.after(:each) { I18n.locale = :en }
14
-
15
- config.expect_with :rspec do |c|
16
- c.syntax = :expect
17
- end
18
- end