loaf 0.6.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +67 -12
  3. data/LICENSE.txt +1 -1
  4. data/README.md +82 -39
  5. data/lib/loaf.rb +1 -0
  6. data/lib/loaf/configuration.rb +0 -12
  7. data/lib/loaf/controller_extensions.rb +9 -1
  8. data/lib/loaf/errors.rb +1 -1
  9. data/lib/loaf/translation.rb +12 -4
  10. data/lib/loaf/version.rb +3 -1
  11. data/lib/loaf/view_extensions.rb +16 -8
  12. metadata +19 -161
  13. data/.document +0 -5
  14. data/.gitignore +0 -23
  15. data/.rspec +0 -2
  16. data/.travis.yml +0 -48
  17. data/Appraisals +0 -36
  18. data/Gemfile +0 -19
  19. data/Gemfile.lock +0 -185
  20. data/Rakefile +0 -10
  21. data/assets/loaf_logo.png +0 -0
  22. data/bin/appraisal +0 -16
  23. data/bin/rake +0 -16
  24. data/bin/setup +0 -7
  25. data/gemfiles/rails3.2.gemfile +0 -24
  26. data/gemfiles/rails4.0.gemfile +0 -24
  27. data/gemfiles/rails4.1.gemfile +0 -23
  28. data/gemfiles/rails4.2.gemfile +0 -23
  29. data/gemfiles/rails5.0.gemfile +0 -22
  30. data/gemfiles/rails5.1.gemfile +0 -22
  31. data/lib/loaf/crumb_formatter.rb +0 -24
  32. data/loaf.gemspec +0 -28
  33. data/spec/integration/breadcrumb_trail_spec.rb +0 -60
  34. data/spec/integration/configuration_spec.rb +0 -12
  35. data/spec/rails_app/Rakefile +0 -8
  36. data/spec/rails_app/app/controllers/application_controller.rb +0 -5
  37. data/spec/rails_app/app/controllers/comments_controller.rb +0 -17
  38. data/spec/rails_app/app/controllers/home_controller.rb +0 -4
  39. data/spec/rails_app/app/controllers/posts_controller.rb +0 -20
  40. data/spec/rails_app/app/views/comments/index.html.erb +0 -1
  41. data/spec/rails_app/app/views/home/index.html.erb +0 -1
  42. data/spec/rails_app/app/views/layouts/_breadcrumbs.html.erb +0 -12
  43. data/spec/rails_app/app/views/layouts/application.html.erb +0 -14
  44. data/spec/rails_app/app/views/posts/index.html.erb +0 -1
  45. data/spec/rails_app/app/views/posts/new.html.erb +0 -4
  46. data/spec/rails_app/app/views/posts/show.html.erb +0 -1
  47. data/spec/rails_app/config.ru +0 -4
  48. data/spec/rails_app/config/application.rb +0 -48
  49. data/spec/rails_app/config/boot.rb +0 -10
  50. data/spec/rails_app/config/database.yml +0 -25
  51. data/spec/rails_app/config/environment.rb +0 -5
  52. data/spec/rails_app/config/environments/development.rb +0 -32
  53. data/spec/rails_app/config/environments/production.rb +0 -62
  54. data/spec/rails_app/config/environments/test.rb +0 -41
  55. data/spec/rails_app/config/initializers/backtrace_silencers.rb +0 -7
  56. data/spec/rails_app/config/initializers/inflections.rb +0 -10
  57. data/spec/rails_app/config/initializers/mime_types.rb +0 -5
  58. data/spec/rails_app/config/initializers/secret_token.rb +0 -7
  59. data/spec/rails_app/config/initializers/session_store.rb +0 -8
  60. data/spec/rails_app/config/initializers/wrap_parameters.rb +0 -14
  61. data/spec/rails_app/config/locales/en.yml +0 -5
  62. data/spec/rails_app/config/locales/loaf.en.yml +0 -6
  63. data/spec/rails_app/config/routes.rb +0 -7
  64. data/spec/rails_app/config/secrets.yml +0 -22
  65. data/spec/rails_app/public/404.html +0 -26
  66. data/spec/rails_app/public/422.html +0 -26
  67. data/spec/rails_app/public/500.html +0 -26
  68. data/spec/rails_app/public/favicon.ico +0 -0
  69. data/spec/rails_app/public/robots.txt +0 -5
  70. data/spec/spec_helper.rb +0 -52
  71. data/spec/support/capybara.rb +0 -8
  72. data/spec/support/dummy_controller.rb +0 -9
  73. data/spec/support/dummy_view.rb +0 -47
  74. data/spec/support/load_routes.rb +0 -4
  75. data/spec/unit/configuration_spec.rb +0 -39
  76. data/spec/unit/controller_extensions_spec.rb +0 -54
  77. data/spec/unit/crumb_formatter_spec.rb +0 -36
  78. data/spec/unit/crumb_spec.rb +0 -15
  79. data/spec/unit/generators/install_generator_spec.rb +0 -17
  80. data/spec/unit/options_validator_spec.rb +0 -15
  81. data/spec/unit/translation_spec.rb +0 -22
  82. data/spec/unit/view_extensions/breadcrumb_spec.rb +0 -22
  83. data/spec/unit/view_extensions/breadcrumb_trail_spec.rb +0 -232
  84. data/spec/unit/view_extensions/has_breadcrumbs_spec.rb +0 -10
  85. data/tasks/console.rake +0 -10
  86. data/tasks/coverage.rake +0 -11
  87. data/tasks/spec.rake +0 -29
@@ -11,7 +11,7 @@ module Loaf #:nodoc:
11
11
  end
12
12
 
13
13
  def translate(key, options)
14
- ::I18n.translate("#{BASE_KEY}.#{key}", { :locale => :en }.merge(options))
14
+ ::I18n.translate("#{BASE_KEY}.#{key}", **{ :locale => :en }.merge(options))
15
15
  end
16
16
  end
17
17
 
@@ -2,12 +2,15 @@
2
2
 
3
3
  module Loaf
4
4
  module Translation
5
- extend self
6
-
7
5
  # Returns translation lookup
6
+ #
7
+ # @return [String]
8
+ #
9
+ # @api private
8
10
  def translation_scope
9
- "loaf.breadcrumbs"
11
+ 'loaf.breadcrumbs'
10
12
  end
13
+ module_function :translation_scope
11
14
 
12
15
  # Translate breadcrumb title
13
16
  #
@@ -18,12 +21,17 @@ module Loaf
18
21
  # @option options [String] :default
19
22
  # The default translation
20
23
  #
24
+ # @return [String]
25
+ #
21
26
  # @api public
22
27
  def find_title(title, options = {})
28
+ return title if title.nil? || title.empty?
29
+
23
30
  options[:scope] ||= translation_scope
24
31
  options[:default] = Array(options[:default])
25
32
  options[:default] << title if options[:default].empty?
26
- I18n.t("#{title}", options)
33
+ I18n.t(title.to_s, **options)
27
34
  end
35
+ module_function :find_title
28
36
  end # Translation
29
37
  end # Loaf
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Loaf
2
- VERSION = '0.6.2'
4
+ VERSION = "0.10.0"
3
5
  end # Loaf
@@ -2,13 +2,12 @@
2
2
 
3
3
  require_relative 'breadcrumb'
4
4
  require_relative 'crumb'
5
- require_relative 'crumb_formatter'
6
5
  require_relative 'options_validator'
6
+ require_relative 'translation'
7
7
 
8
8
  module Loaf
9
9
  # A mixin to define view extensions
10
10
  module ViewExtensions
11
- include Loaf::CrumbFormatter
12
11
  include Loaf::OptionsValidator
13
12
 
14
13
  def initialize(*)
@@ -46,14 +45,14 @@ module Loaf
46
45
  #
47
46
  # @api public
48
47
  def breadcrumb_trail(options = {})
49
- return enum_for(:breadcrumb_trail) unless block_given?
48
+ return enum_for(:breadcrumb_trail, options) unless block_given?
50
49
 
51
50
  valid?(options)
52
- options = Loaf.configuration.to_hash.merge(options)
51
+
53
52
  _breadcrumbs.each do |crumb|
54
- name = format_name(crumb.name, options)
53
+ name = title_for(crumb.name)
55
54
  path = url_for(_expand_url(crumb.url))
56
- current = current_crumb?(path, crumb.match)
55
+ current = current_crumb?(path, options.fetch(:match) { crumb.match })
57
56
 
58
57
  yield(Loaf::Breadcrumb[name, path, current])
59
58
  end
@@ -69,10 +68,10 @@ module Loaf
69
68
  def current_crumb?(path, pattern = :inclusive)
70
69
  return false unless request.get? || request.head?
71
70
 
72
- origin_path = URI.parser.unescape(path).force_encoding(Encoding::BINARY)
71
+ origin_path = URI::DEFAULT_PARSER.unescape(path).force_encoding(Encoding::BINARY)
73
72
 
74
73
  request_uri = request.fullpath
75
- request_uri = URI.parser.unescape(request_uri)
74
+ request_uri = URI::DEFAULT_PARSER.unescape(request_uri)
76
75
  request_uri.force_encoding(Encoding::BINARY)
77
76
 
78
77
  # strip away trailing slash
@@ -107,6 +106,15 @@ module Loaf
107
106
 
108
107
  private
109
108
 
109
+ # Find title translation for a crumb name
110
+ #
111
+ # @return [String]
112
+ #
113
+ # @api private
114
+ def title_for(name)
115
+ Translation.find_title(name)
116
+ end
117
+
110
118
  # Expand url in the current context of the view
111
119
  #
112
120
  # @api private
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-30 00:00:00.000000000 Z
11
+ date: 2020-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.5'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.5'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rake
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -56,113 +42,40 @@ description: Loaf manages and displays breadcrumb trails in your Rails app. It a
56
42
  to handle breadcrumb data through easy dsl and expose it through view helpers without
57
43
  any assumptions about markup.
58
44
  email:
59
- - ''
60
- executables:
61
- - appraisal
62
- - rake
63
- - setup
45
+ - piotr@piotrmurach.com
46
+ executables: []
64
47
  extensions: []
65
- extra_rdoc_files: []
48
+ extra_rdoc_files:
49
+ - README.md
50
+ - CHANGELOG.md
51
+ - LICENSE.txt
66
52
  files:
67
- - ".document"
68
- - ".gitignore"
69
- - ".rspec"
70
- - ".travis.yml"
71
- - Appraisals
72
53
  - CHANGELOG.md
73
- - Gemfile
74
- - Gemfile.lock
75
54
  - LICENSE.txt
76
55
  - README.md
77
- - Rakefile
78
- - assets/loaf_logo.png
79
- - bin/appraisal
80
- - bin/rake
81
- - bin/setup
82
56
  - config/locales/loaf.en.yml
83
- - gemfiles/rails3.2.gemfile
84
- - gemfiles/rails4.0.gemfile
85
- - gemfiles/rails4.1.gemfile
86
- - gemfiles/rails4.2.gemfile
87
- - gemfiles/rails5.0.gemfile
88
- - gemfiles/rails5.1.gemfile
89
57
  - lib/generators/loaf/install_generator.rb
90
58
  - lib/loaf.rb
91
59
  - lib/loaf/breadcrumb.rb
92
60
  - lib/loaf/configuration.rb
93
61
  - lib/loaf/controller_extensions.rb
94
62
  - lib/loaf/crumb.rb
95
- - lib/loaf/crumb_formatter.rb
96
63
  - lib/loaf/errors.rb
97
64
  - lib/loaf/options_validator.rb
98
65
  - lib/loaf/railtie.rb
99
66
  - lib/loaf/translation.rb
100
67
  - lib/loaf/version.rb
101
68
  - lib/loaf/view_extensions.rb
102
- - loaf.gemspec
103
- - spec/integration/breadcrumb_trail_spec.rb
104
- - spec/integration/configuration_spec.rb
105
- - spec/rails_app/Rakefile
106
- - spec/rails_app/app/controllers/application_controller.rb
107
- - spec/rails_app/app/controllers/comments_controller.rb
108
- - spec/rails_app/app/controllers/home_controller.rb
109
- - spec/rails_app/app/controllers/posts_controller.rb
110
- - spec/rails_app/app/views/comments/index.html.erb
111
- - spec/rails_app/app/views/home/index.html.erb
112
- - spec/rails_app/app/views/layouts/_breadcrumbs.html.erb
113
- - spec/rails_app/app/views/layouts/application.html.erb
114
- - spec/rails_app/app/views/posts/index.html.erb
115
- - spec/rails_app/app/views/posts/new.html.erb
116
- - spec/rails_app/app/views/posts/show.html.erb
117
- - spec/rails_app/config.ru
118
- - spec/rails_app/config/application.rb
119
- - spec/rails_app/config/boot.rb
120
- - spec/rails_app/config/database.yml
121
- - spec/rails_app/config/environment.rb
122
- - spec/rails_app/config/environments/development.rb
123
- - spec/rails_app/config/environments/production.rb
124
- - spec/rails_app/config/environments/test.rb
125
- - spec/rails_app/config/initializers/backtrace_silencers.rb
126
- - spec/rails_app/config/initializers/inflections.rb
127
- - spec/rails_app/config/initializers/mime_types.rb
128
- - spec/rails_app/config/initializers/secret_token.rb
129
- - spec/rails_app/config/initializers/session_store.rb
130
- - spec/rails_app/config/initializers/wrap_parameters.rb
131
- - spec/rails_app/config/locales/en.yml
132
- - spec/rails_app/config/locales/loaf.en.yml
133
- - spec/rails_app/config/routes.rb
134
- - spec/rails_app/config/secrets.yml
135
- - spec/rails_app/db/seeds.rb
136
- - spec/rails_app/log/.gitkeep
137
- - spec/rails_app/public/404.html
138
- - spec/rails_app/public/422.html
139
- - spec/rails_app/public/500.html
140
- - spec/rails_app/public/favicon.ico
141
- - spec/rails_app/public/robots.txt
142
- - spec/spec_helper.rb
143
- - spec/support/capybara.rb
144
- - spec/support/dummy_controller.rb
145
- - spec/support/dummy_view.rb
146
- - spec/support/load_routes.rb
147
- - spec/unit/configuration_spec.rb
148
- - spec/unit/controller_extensions_spec.rb
149
- - spec/unit/crumb_formatter_spec.rb
150
- - spec/unit/crumb_spec.rb
151
- - spec/unit/generators/install_generator_spec.rb
152
- - spec/unit/options_validator_spec.rb
153
- - spec/unit/translation_spec.rb
154
- - spec/unit/view_extensions/breadcrumb_spec.rb
155
- - spec/unit/view_extensions/breadcrumb_trail_spec.rb
156
- - spec/unit/view_extensions/has_breadcrumbs_spec.rb
157
- - tasks/console.rake
158
- - tasks/coverage.rake
159
- - tasks/spec.rake
160
69
  homepage: https://github.com/piotrmurach/loaf
161
- licenses: []
70
+ licenses:
71
+ - MIT
162
72
  metadata:
163
73
  allowed_push_host: https://rubygems.org
164
- source_code_uri: https://github.com/piotrmurach/loaf
74
+ bug_tracker_uri: https://github.com/piotrmurach/loaf/issues
165
75
  changelog_uri: https://github.com/piotrmurach/loaf/blob/master/CHANGELOG.md
76
+ documentation_uri: https://www.rubydoc.info/gems/loaf
77
+ homepage_uri: https://github.com/piotrmurach/loaf
78
+ source_code_uri: https://github.com/piotrmurach/loaf
166
79
  post_install_message:
167
80
  rdoc_options: []
168
81
  require_paths:
@@ -171,70 +84,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
84
  requirements:
172
85
  - - ">="
173
86
  - !ruby/object:Gem::Version
174
- version: '0'
87
+ version: 1.9.3
175
88
  required_rubygems_version: !ruby/object:Gem::Requirement
176
89
  requirements:
177
90
  - - ">="
178
91
  - !ruby/object:Gem::Version
179
92
  version: '0'
180
93
  requirements: []
181
- rubyforge_project:
182
- rubygems_version: 2.5.1
94
+ rubygems_version: 3.1.2
183
95
  signing_key:
184
96
  specification_version: 4
185
97
  summary: Loaf manages and displays breadcrumb trails in your Rails application.
186
- test_files:
187
- - spec/integration/breadcrumb_trail_spec.rb
188
- - spec/integration/configuration_spec.rb
189
- - spec/rails_app/Rakefile
190
- - spec/rails_app/app/controllers/application_controller.rb
191
- - spec/rails_app/app/controllers/comments_controller.rb
192
- - spec/rails_app/app/controllers/home_controller.rb
193
- - spec/rails_app/app/controllers/posts_controller.rb
194
- - spec/rails_app/app/views/comments/index.html.erb
195
- - spec/rails_app/app/views/home/index.html.erb
196
- - spec/rails_app/app/views/layouts/_breadcrumbs.html.erb
197
- - spec/rails_app/app/views/layouts/application.html.erb
198
- - spec/rails_app/app/views/posts/index.html.erb
199
- - spec/rails_app/app/views/posts/new.html.erb
200
- - spec/rails_app/app/views/posts/show.html.erb
201
- - spec/rails_app/config.ru
202
- - spec/rails_app/config/application.rb
203
- - spec/rails_app/config/boot.rb
204
- - spec/rails_app/config/database.yml
205
- - spec/rails_app/config/environment.rb
206
- - spec/rails_app/config/environments/development.rb
207
- - spec/rails_app/config/environments/production.rb
208
- - spec/rails_app/config/environments/test.rb
209
- - spec/rails_app/config/initializers/backtrace_silencers.rb
210
- - spec/rails_app/config/initializers/inflections.rb
211
- - spec/rails_app/config/initializers/mime_types.rb
212
- - spec/rails_app/config/initializers/secret_token.rb
213
- - spec/rails_app/config/initializers/session_store.rb
214
- - spec/rails_app/config/initializers/wrap_parameters.rb
215
- - spec/rails_app/config/locales/en.yml
216
- - spec/rails_app/config/locales/loaf.en.yml
217
- - spec/rails_app/config/routes.rb
218
- - spec/rails_app/config/secrets.yml
219
- - spec/rails_app/db/seeds.rb
220
- - spec/rails_app/log/.gitkeep
221
- - spec/rails_app/public/404.html
222
- - spec/rails_app/public/422.html
223
- - spec/rails_app/public/500.html
224
- - spec/rails_app/public/favicon.ico
225
- - spec/rails_app/public/robots.txt
226
- - spec/spec_helper.rb
227
- - spec/support/capybara.rb
228
- - spec/support/dummy_controller.rb
229
- - spec/support/dummy_view.rb
230
- - spec/support/load_routes.rb
231
- - spec/unit/configuration_spec.rb
232
- - spec/unit/controller_extensions_spec.rb
233
- - spec/unit/crumb_formatter_spec.rb
234
- - spec/unit/crumb_spec.rb
235
- - spec/unit/generators/install_generator_spec.rb
236
- - spec/unit/options_validator_spec.rb
237
- - spec/unit/translation_spec.rb
238
- - spec/unit/view_extensions/breadcrumb_spec.rb
239
- - spec/unit/view_extensions/breadcrumb_trail_spec.rb
240
- - spec/unit/view_extensions/has_breadcrumbs_spec.rb
98
+ test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/.gitignore DELETED
@@ -1,23 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- gemfiles/*.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- spec/rails_app/tmp
16
- spec/rails_app/db
17
- spec/rails_app/log
18
- tmp
19
- *.bundle
20
- *.so
21
- *.o
22
- *.a
23
- mkmf.log
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --color
2
- --require spec_helper
@@ -1,48 +0,0 @@
1
- ---
2
- language: ruby
3
- sudo: false
4
- cache: bundler
5
- install:
6
- - bundle install
7
- - bundle exec bin/appraisal install
8
- script:
9
- - bundle exec appraisal rake ci
10
- rvm:
11
- - 2.1.10
12
- - 2.2.9
13
- - 2.3.6
14
- - 2.4.3
15
- - 2.5.0
16
- matrix:
17
- include:
18
- - rvm: jruby-9.1.1.0
19
- - rvm: jruby-head
20
- - rvm: ruby-head
21
- exclude:
22
- - rvm: 2.1.10
23
- gemfile:
24
- - gemfiles/rails5.0.gemfile
25
- - gemfiles/rails5.1.gemfile
26
- - rvm: 2.2.9
27
- gemfile: gemfiles/rails3.2.gemfile
28
- - rvm: 2.3.6
29
- gemfile: gemfiles/rails3.2.gemfile
30
- - rvm: 2.4.3
31
- gemfile:
32
- - gemfiles/rails3.2.gemfile
33
- - gemfiles/rails4.0.gemfile
34
- - gemfiles/rails4.1.gemfile
35
- - rvm: 2.5.0
36
- gemfile:
37
- - gemfiles/rails3.2.gemfile
38
- - gemfiles/rails4.0.gemfile
39
- - gemfiles/rails4.1.gemfile
40
- allow_failures:
41
- - rvm: ruby-head
42
- - rvm: jruby-9.1.1.0
43
- - rvm: jruby-head
44
- fast_finish: true
45
- branches:
46
- only: master
47
- notifications:
48
- email: false
data/Appraisals DELETED
@@ -1,36 +0,0 @@
1
- if RUBY_VERSION < '2.2.0'
2
- appraise 'rails3.2' do
3
- gem 'rails', '~> 3.2.22.5'
4
- gem 'test-unit', '~> 3.0'
5
- end
6
- end
7
-
8
- if RUBY_VERSION < '2.4.0'
9
- appraise 'rails4.0' do
10
- gem 'rails', '~> 4.0.13'
11
- gem 'test-unit'
12
- gem 'mime-types', '~> 2.99'
13
- end
14
-
15
- appraise 'rails4.1' do
16
- gem 'rails', '~> 4.1.16'
17
- gem 'mime-types', '~> 2.99'
18
- end
19
- end
20
-
21
- appraise 'rails4.2' do
22
- gem 'rails', '~> 4.2.9'
23
- gem 'mime-types', '~> 2.99'
24
- end
25
-
26
- if RUBY_VERSION >= '2.2.0'
27
- appraise 'rails5.0' do
28
- gem 'rails', '~> 5.0.6'
29
- gem 'rspec-rails', '~> 3.6.1'
30
- end
31
-
32
- appraise 'rails5.1' do
33
- gem 'rails', '~> 5.1.4'
34
- gem 'rspec-rails', '~> 3.6.1'
35
- end
36
- end