loaf 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -3
  3. data/.rspec +1 -0
  4. data/.travis.yml +30 -12
  5. data/Appraisals +27 -9
  6. data/CHANGELOG.md +59 -11
  7. data/Gemfile +11 -11
  8. data/Gemfile.lock +182 -0
  9. data/README.md +120 -56
  10. data/assets/loaf_logo.png +0 -0
  11. data/bin/appraisal +16 -0
  12. data/bin/rake +16 -0
  13. data/gemfiles/rails3.2.gemfile +15 -13
  14. data/gemfiles/rails4.0.gemfile +13 -12
  15. data/gemfiles/rails4.1.gemfile +14 -13
  16. data/gemfiles/rails4.2.gemfile +14 -13
  17. data/gemfiles/rails5.0.gemfile +22 -0
  18. data/gemfiles/rails5.1.gemfile +22 -0
  19. data/lib/loaf.rb +2 -22
  20. data/lib/loaf/breadcrumb.rb +30 -0
  21. data/lib/loaf/configuration.rb +7 -8
  22. data/lib/loaf/controller_extensions.rb +13 -28
  23. data/lib/loaf/crumb.rb +5 -4
  24. data/lib/loaf/crumb_formatter.rb +3 -1
  25. data/lib/loaf/errors.rb +1 -3
  26. data/lib/loaf/options_validator.rb +2 -2
  27. data/lib/loaf/railtie.rb +19 -13
  28. data/lib/loaf/translation.rb +1 -1
  29. data/lib/loaf/version.rb +1 -3
  30. data/lib/loaf/view_extensions.rb +69 -18
  31. data/loaf.gemspec +20 -13
  32. data/spec/integration/{crumbs_routing_spec.rb → breadcrumb_trail_spec.rb} +19 -12
  33. data/spec/rails_app/app/controllers/application_controller.rb +2 -0
  34. data/spec/rails_app/app/controllers/posts_controller.rb +1 -4
  35. data/spec/rails_app/app/views/layouts/_breadcrumbs.html.erb +7 -5
  36. data/spec/rails_app/app/views/layouts/application.html.erb +0 -2
  37. data/spec/rails_app/config/environments/test.rb +1 -1
  38. data/spec/rails_app/config/secrets.yml +22 -0
  39. data/spec/spec_helper.rb +3 -3
  40. data/spec/support/dummy_controller.rb +9 -0
  41. data/spec/support/dummy_view.rb +42 -2
  42. data/spec/unit/configuration_spec.rb +35 -0
  43. data/spec/unit/controller_extensions_spec.rb +5 -14
  44. data/spec/unit/generators/install_generator_spec.rb +2 -1
  45. data/spec/unit/view_extensions/breadcrumb_trail_spec.rb +232 -0
  46. metadata +65 -31
  47. data/.ruby-version +0 -1
  48. data/init.rb +0 -3
  49. data/lib/loaf/builder.rb +0 -38
  50. data/spec/rails_app/.gitignore +0 -5
  51. data/spec/rails_app/lib/assets/.gitkeep +0 -0
  52. data/spec/rails_app/lib/tasks/.gitkeep +0 -0
  53. data/spec/rails_app/script/rails +0 -6
  54. data/spec/unit/view_extensions/breadcrumbs_spec.rb +0 -128
metadata CHANGED
@@ -1,60 +1,94 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-31 00:00:00.000000000 Z
11
+ date: 2017-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '3.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
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
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  description: Loaf manages and displays breadcrumb trails in your Rails app. It aims
28
56
  to handle breadcrumb data through easy dsl and expose it through view helpers without
29
57
  any assumptions about markup.
30
58
  email:
31
59
  - ''
32
60
  executables:
61
+ - appraisal
62
+ - rake
33
63
  - setup
34
64
  extensions: []
35
65
  extra_rdoc_files: []
36
66
  files:
37
- - .document
38
- - .gitignore
39
- - .rspec
40
- - .ruby-version
41
- - .travis.yml
67
+ - ".document"
68
+ - ".gitignore"
69
+ - ".rspec"
70
+ - ".travis.yml"
42
71
  - Appraisals
43
72
  - CHANGELOG.md
44
73
  - Gemfile
74
+ - Gemfile.lock
45
75
  - LICENSE.txt
46
76
  - README.md
47
77
  - Rakefile
78
+ - assets/loaf_logo.png
79
+ - bin/appraisal
80
+ - bin/rake
48
81
  - bin/setup
49
82
  - config/locales/loaf.en.yml
50
83
  - gemfiles/rails3.2.gemfile
51
84
  - gemfiles/rails4.0.gemfile
52
85
  - gemfiles/rails4.1.gemfile
53
86
  - gemfiles/rails4.2.gemfile
54
- - init.rb
87
+ - gemfiles/rails5.0.gemfile
88
+ - gemfiles/rails5.1.gemfile
55
89
  - lib/generators/loaf/install_generator.rb
56
90
  - lib/loaf.rb
57
- - lib/loaf/builder.rb
91
+ - lib/loaf/breadcrumb.rb
58
92
  - lib/loaf/configuration.rb
59
93
  - lib/loaf/controller_extensions.rb
60
94
  - lib/loaf/crumb.rb
@@ -66,9 +100,8 @@ files:
66
100
  - lib/loaf/version.rb
67
101
  - lib/loaf/view_extensions.rb
68
102
  - loaf.gemspec
103
+ - spec/integration/breadcrumb_trail_spec.rb
69
104
  - spec/integration/configuration_spec.rb
70
- - spec/integration/crumbs_routing_spec.rb
71
- - spec/rails_app/.gitignore
72
105
  - spec/rails_app/Rakefile
73
106
  - spec/rails_app/app/controllers/application_controller.rb
74
107
  - spec/rails_app/app/controllers/comments_controller.rb
@@ -98,58 +131,60 @@ files:
98
131
  - spec/rails_app/config/locales/en.yml
99
132
  - spec/rails_app/config/locales/loaf.en.yml
100
133
  - spec/rails_app/config/routes.rb
134
+ - spec/rails_app/config/secrets.yml
101
135
  - spec/rails_app/db/seeds.rb
102
- - spec/rails_app/lib/assets/.gitkeep
103
- - spec/rails_app/lib/tasks/.gitkeep
104
136
  - spec/rails_app/log/.gitkeep
105
137
  - spec/rails_app/public/404.html
106
138
  - spec/rails_app/public/422.html
107
139
  - spec/rails_app/public/500.html
108
140
  - spec/rails_app/public/favicon.ico
109
141
  - spec/rails_app/public/robots.txt
110
- - spec/rails_app/script/rails
111
142
  - spec/spec_helper.rb
112
143
  - spec/support/capybara.rb
144
+ - spec/support/dummy_controller.rb
113
145
  - spec/support/dummy_view.rb
114
146
  - spec/support/load_routes.rb
147
+ - spec/unit/configuration_spec.rb
115
148
  - spec/unit/controller_extensions_spec.rb
116
149
  - spec/unit/crumb_formatter_spec.rb
117
150
  - spec/unit/generators/install_generator_spec.rb
118
151
  - spec/unit/options_validator_spec.rb
119
152
  - spec/unit/translation_spec.rb
120
153
  - spec/unit/view_extensions/breadcrumb_spec.rb
121
- - spec/unit/view_extensions/breadcrumbs_spec.rb
154
+ - spec/unit/view_extensions/breadcrumb_trail_spec.rb
122
155
  - spec/unit/view_extensions/has_breadcrumbs_spec.rb
123
156
  - tasks/console.rake
124
157
  - tasks/coverage.rake
125
158
  - tasks/spec.rake
126
- homepage: https://github.com/peter-murach/loaf
159
+ homepage: https://github.com/piotrmurach/loaf
127
160
  licenses: []
128
- metadata: {}
161
+ metadata:
162
+ allowed_push_host: https://rubygems.org
163
+ source_code_uri: https://github.com/piotrmurach/loaf
164
+ changelog_uri: https://github.com/piotrmurach/loaf/blob/master/CHANGELOG.md
129
165
  post_install_message:
130
166
  rdoc_options: []
131
167
  require_paths:
132
168
  - lib
133
169
  required_ruby_version: !ruby/object:Gem::Requirement
134
170
  requirements:
135
- - - '>='
171
+ - - ">="
136
172
  - !ruby/object:Gem::Version
137
173
  version: '0'
138
174
  required_rubygems_version: !ruby/object:Gem::Requirement
139
175
  requirements:
140
- - - '>='
176
+ - - ">="
141
177
  - !ruby/object:Gem::Version
142
178
  version: '0'
143
179
  requirements: []
144
180
  rubyforge_project:
145
- rubygems_version: 2.0.3
181
+ rubygems_version: 2.5.1
146
182
  signing_key:
147
183
  specification_version: 4
148
184
  summary: Loaf manages and displays breadcrumb trails in your Rails application.
149
185
  test_files:
186
+ - spec/integration/breadcrumb_trail_spec.rb
150
187
  - spec/integration/configuration_spec.rb
151
- - spec/integration/crumbs_routing_spec.rb
152
- - spec/rails_app/.gitignore
153
188
  - spec/rails_app/Rakefile
154
189
  - spec/rails_app/app/controllers/application_controller.rb
155
190
  - spec/rails_app/app/controllers/comments_controller.rb
@@ -179,26 +214,25 @@ test_files:
179
214
  - spec/rails_app/config/locales/en.yml
180
215
  - spec/rails_app/config/locales/loaf.en.yml
181
216
  - spec/rails_app/config/routes.rb
217
+ - spec/rails_app/config/secrets.yml
182
218
  - spec/rails_app/db/seeds.rb
183
- - spec/rails_app/lib/assets/.gitkeep
184
- - spec/rails_app/lib/tasks/.gitkeep
185
219
  - spec/rails_app/log/.gitkeep
186
220
  - spec/rails_app/public/404.html
187
221
  - spec/rails_app/public/422.html
188
222
  - spec/rails_app/public/500.html
189
223
  - spec/rails_app/public/favicon.ico
190
224
  - spec/rails_app/public/robots.txt
191
- - spec/rails_app/script/rails
192
225
  - spec/spec_helper.rb
193
226
  - spec/support/capybara.rb
227
+ - spec/support/dummy_controller.rb
194
228
  - spec/support/dummy_view.rb
195
229
  - spec/support/load_routes.rb
230
+ - spec/unit/configuration_spec.rb
196
231
  - spec/unit/controller_extensions_spec.rb
197
232
  - spec/unit/crumb_formatter_spec.rb
198
233
  - spec/unit/generators/install_generator_spec.rb
199
234
  - spec/unit/options_validator_spec.rb
200
235
  - spec/unit/translation_spec.rb
201
236
  - spec/unit/view_extensions/breadcrumb_spec.rb
202
- - spec/unit/view_extensions/breadcrumbs_spec.rb
237
+ - spec/unit/view_extensions/breadcrumb_trail_spec.rb
203
238
  - spec/unit/view_extensions/has_breadcrumbs_spec.rb
204
- has_rdoc:
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.0.0
data/init.rb DELETED
@@ -1,3 +0,0 @@
1
- require 'loaf'
2
- require 'loaf/railtie'
3
- Loaf::Railtie.insert
data/lib/loaf/builder.rb DELETED
@@ -1,38 +0,0 @@
1
- module Loaf
2
- class Builder
3
-
4
- attr_accessor :crumbs
5
-
6
- def initialize(view_context, collection, options = {})
7
-
8
- @params = default_options.merge(options)
9
-
10
- set_breadcrumbs
11
-
12
- build @params
13
- end
14
-
15
- private
16
-
17
- def set_breadcrumbs(breadcrumbs)
18
- @params[:breadcrumbs] = breadcrumbs
19
- end
20
-
21
- def build
22
- @params.each_pair do |option, value|
23
-
24
- end
25
- end
26
-
27
- def default_options
28
- {
29
- :breadcrumbs => [],
30
- :delimiter => " &raquo ",
31
- :style_class => 'selected',
32
- :crumb_length => '30',
33
- :last_crumb_linked => false
34
- }
35
- end
36
-
37
- end # Builder
38
- end # Loaf
@@ -1,5 +0,0 @@
1
- .bundle
2
- db/*.sqlite3
3
- log/*.log
4
- tmp/
5
- .sass-cache/
File without changes
File without changes
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'
@@ -1,128 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Loaf::ViewExtensions, '.breadcrumbs' do
6
- it "yields to block all breadcrumbs" do
7
- instance = DummyView.new
8
- instance.breadcrumb('home', :home_path)
9
- instance.breadcrumb('posts', :posts_path)
10
-
11
- yielded = []
12
- block = lambda { |name, url, styles| yielded << [name, url, styles]}
13
- expect {
14
- instance.breadcrumbs(&block)
15
- }.to change { yielded.size }.from(0).to(2)
16
- end
17
-
18
- it "resolves breadcrumb paths" do
19
- instance = DummyView.new
20
- instance.breadcrumb('home', :home_path)
21
- instance.breadcrumb('posts', :posts_path)
22
-
23
- allow(instance).to receive(:url_for).with(:home_path).and_return('/home')
24
- allow(instance).to receive(:url_for).with(:posts_path).and_return('/posts')
25
- yielded = []
26
- block = lambda { |name, url, styles| yielded << [name, url, styles]}
27
- instance.breadcrumbs(&block)
28
- expect(yielded).to eq([
29
- ['home', '/home', ''],
30
- ['posts', '/posts', '']
31
- ])
32
- end
33
-
34
- it "checks current path and provides styles" do
35
- instance = DummyView.new
36
- instance.breadcrumb('home', :home_path)
37
- instance.breadcrumb('posts', :posts_path)
38
-
39
- allow(instance).to receive(:url_for).with(:home_path).and_return('/home')
40
- allow(instance).to receive(:url_for).with(:posts_path).and_return('/posts')
41
- allow(instance).to receive(:current_page?).with('/home').and_return(false)
42
- allow(instance).to receive(:current_page?).with('/posts').and_return(true)
43
-
44
- yielded = []
45
- block = lambda { |name, url, styles| yielded << [name, url, styles]}
46
- instance.breadcrumbs(&block)
47
- expect(yielded).to eq([
48
- ['home', '/home', ''],
49
- ['posts', '/posts', 'selected']
50
- ])
51
- end
52
-
53
- it "allows to force current path" do
54
- instance = DummyView.new
55
- instance.breadcrumb('home', :home_path)
56
- instance.breadcrumb('posts', :posts_path, force: true)
57
-
58
- allow(instance).to receive(:url_for).with(:home_path).and_return('/home')
59
- allow(instance).to receive(:url_for).with(:posts_path).and_return('/posts')
60
- allow(instance).to receive(:current_page?).and_return(false)
61
-
62
- yielded = []
63
- block = lambda { |name, url, styles| yielded << [name, url, styles]}
64
- instance.breadcrumbs(&block)
65
- expect(yielded).to eq([
66
- ['home', '/home', ''],
67
- ['posts', '/posts', 'selected']
68
- ])
69
- end
70
-
71
- it "returns enumerator without block" do
72
- instance = DummyView.new
73
- instance.breadcrumb('home', :home_path)
74
- instance.breadcrumb('posts', :posts_path)
75
-
76
- allow(instance).to receive(:url_for).with(:home_path).and_return('/home')
77
- allow(instance).to receive(:url_for).with(:posts_path).and_return('/posts')
78
-
79
- result = instance.breadcrumbs
80
- expect(result).to be_a(Enumerable)
81
- expect(result.take(2)).to eq([
82
- ['home', '/home', ''],
83
- ['posts', '/posts', '']
84
- ])
85
- end
86
-
87
- it 'validates passed options' do
88
- instance = DummyView.new
89
- block = lambda { |name, url, styles| }
90
- expect {
91
- instance.breadcrumbs(unknown: true, &block)
92
- }.to raise_error(Loaf::InvalidOptions)
93
- end
94
-
95
- it 'uses global configuration for crumb formatting' do
96
- allow(Loaf.configuration).to receive(:crumb_length).and_return(10)
97
- instance = DummyView.new
98
- instance.breadcrumb('home-sweet-home', :home_path)
99
- instance.breadcrumb('posts-for-everybody', :posts_path)
100
-
101
- allow(instance).to receive(:url_for).with(:home_path).and_return('/home')
102
- allow(instance).to receive(:url_for).with(:posts_path).and_return('/posts')
103
- yielded = []
104
- block = lambda { |name, url, styles| yielded << [name, url, styles]}
105
- instance.breadcrumbs(&block)
106
- expect(yielded).to eq([
107
- ['home-sw...', '/home', ''],
108
- ['posts-f...', '/posts', '']
109
- ])
110
- end
111
-
112
- it "allows to overwrite global configuration" do
113
- allow(Loaf.configuration).to receive(:crumb_length).and_return(10)
114
- instance = DummyView.new
115
- instance.breadcrumb('home-sweet-home', :home_path)
116
- instance.breadcrumb('posts-for-everybody', :posts_path)
117
-
118
- allow(instance).to receive(:url_for).with(:home_path).and_return('/home')
119
- allow(instance).to receive(:url_for).with(:posts_path).and_return('/posts')
120
- yielded = []
121
- block = lambda { |name, url, styles| yielded << [name, url, styles]}
122
- instance.breadcrumbs(crumb_length: 15, &block)
123
- expect(yielded).to eq([
124
- ['home-sweet-home', '/home', ''],
125
- ['posts-for-ev...', '/posts', '']
126
- ])
127
- end
128
- end