crumbs 1.0.9 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/lib/crumbs/action_controller/base.rb +26 -33
- data/lib/crumbs/version.rb +1 -1
- data/test/dummy/config/application.rb +2 -2
- data/test/dummy/log/test.log +14287 -0
- data/test/with_last_test.rb +26 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7de3dbbb857eb4469756682e3ad60e55088e4d2
|
4
|
+
data.tar.gz: 32c47f6e9baf0c2eea655548ec895832e7d1fca4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3863266a5fc2e73132384ed76e07c9b3efb7f515779a8e95351e7ee56e794241940604b6091e14ded0cd17f4461077d92c5fe040829d4d206c2731bebec4fcee
|
7
|
+
data.tar.gz: 0954ec6072305b562961214bfbdc747e594d2546d010853da18f3071b4a74307e7ede34c84e4354c3fba0bb53bc851414b3d101391114a32ba3131d332031deb
|
data/MIT-LICENSE
CHANGED
@@ -10,29 +10,30 @@ module Crumbs
|
|
10
10
|
protected
|
11
11
|
|
12
12
|
def define_crumbs
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
paths = [request.path]
|
14
|
+
paths.unshift File.dirname(paths.first) until paths.first == '/'
|
15
|
+
if referers.empty? or referers.last[:base_url] != request.base_url
|
16
|
+
self.referers = [build_referer]
|
17
|
+
elsif request.path.starts_with? "#{referers.last[:path]}/".squeeze('/')
|
18
|
+
self.referers << build_referer
|
19
|
+
elsif index = find_referer_index(paths)
|
20
|
+
self.referers = referers[0...index] + [build_referer]
|
21
|
+
elsif
|
22
|
+
self.referers = [build_referer]
|
23
|
+
end
|
24
|
+
paths.pop unless Rails.application.config.crumbs.show_last
|
16
25
|
@crumbs = []
|
17
|
-
|
18
|
-
|
19
|
-
|
26
|
+
paths.each do |path|
|
27
|
+
params = Rails.application.routes.recognize_path("#{request.base_url}#{path}") rescue next
|
28
|
+
if name = Crumbs::Definitions.find(params[:controller], params[:action], params)
|
29
|
+
if index = find_referer_index(path)
|
30
|
+
path = referers[index][:fullpath]
|
31
|
+
end
|
32
|
+
@crumbs << { name: name, path: path }
|
20
33
|
end
|
21
|
-
parts.pop
|
22
34
|
end
|
23
|
-
@crumbs.reverse!
|
24
35
|
end
|
25
36
|
|
26
|
-
def find_crumb(path)
|
27
|
-
params = Rails.application.routes.recognize_path(request.base_url + path) rescue return
|
28
|
-
if name = Crumbs::Definitions.find(params[:controller], params[:action], params)
|
29
|
-
if index = find_referer_index(path)
|
30
|
-
path = referers[index][:fullpath]
|
31
|
-
end
|
32
|
-
{ name: name, path: path }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
37
|
def referers
|
37
38
|
session[:referers] ||= []
|
38
39
|
end
|
@@ -40,22 +41,14 @@ module Crumbs
|
|
40
41
|
def referers=(value)
|
41
42
|
session[:referers] = value
|
42
43
|
end
|
43
|
-
|
44
|
-
def find_referer_index(path)
|
45
|
-
referers.index { |referer| referer[:base_url] == request.base_url and referer[:path] == path }
|
46
|
-
end
|
47
44
|
|
48
|
-
def
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
referers << { base_url: request.base_url, path: request.path, fullpath: request.fullpath }
|
56
|
-
else
|
57
|
-
self.referers = [{ base_url: request.base_url, path: request.path, fullpath: request.fullpath }]
|
58
|
-
end
|
45
|
+
def build_referer
|
46
|
+
{ base_url: request.base_url, path: request.path, fullpath: request.fullpath }
|
47
|
+
end
|
48
|
+
|
49
|
+
def find_referer_index(paths)
|
50
|
+
paths = [paths] unless paths.is_a? Array
|
51
|
+
referers.rindex { |referer| paths.include? referer[:path] }
|
59
52
|
end
|
60
53
|
|
61
54
|
module ClassMethods
|
data/lib/crumbs/version.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../boot', __FILE__)
|
|
3
3
|
require 'rails/all'
|
4
4
|
|
5
5
|
Bundler.require(*Rails.groups)
|
6
|
-
require
|
6
|
+
require 'crumbs'
|
7
7
|
|
8
8
|
module Dummy
|
9
9
|
class Application < Rails::Application
|
@@ -18,6 +18,6 @@ module Dummy
|
|
18
18
|
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
19
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
20
|
# config.i18n.default_locale = :de
|
21
|
+
I18n.enforce_available_locales = false
|
21
22
|
end
|
22
23
|
end
|
23
|
-
|