gretel 1.2.1 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.gitignore +23 -0
  2. data/.travis.yml +6 -0
  3. data/CHANGELOG.md +15 -0
  4. data/Gemfile +17 -0
  5. data/Gemfile.lock +98 -0
  6. data/{MIT-LICENSE → LICENSE.txt} +3 -1
  7. data/README.md +56 -62
  8. data/Rakefile +6 -34
  9. data/gretel.gemspec +22 -0
  10. data/lib/generators/gretel/templates/initializer.rb +2 -3
  11. data/lib/gretel/crumb.rb +33 -4
  12. data/lib/gretel/crumbs.rb +20 -40
  13. data/lib/gretel/link.rb +4 -4
  14. data/lib/gretel/version.rb +3 -0
  15. data/lib/gretel/view_helpers.rb +122 -0
  16. data/lib/gretel.rb +4 -5
  17. data/test/dummy/app/mailers/.gitkeep +0 -0
  18. data/test/dummy/app/models/.gitkeep +0 -0
  19. data/test/dummy/config/initializers/breadcrumbs.rb +21 -0
  20. data/test/dummy/config/initializers/session_store.rb +1 -1
  21. data/test/dummy/config/initializers/wrap_parameters.rb +1 -1
  22. data/test/dummy/lib/assets/.gitkeep +0 -0
  23. data/test/dummy/log/.gitkeep +0 -0
  24. data/test/helper_methods_test.rb +76 -51
  25. metadata +38 -48
  26. data/lib/gretel/helper_methods.rb +0 -122
  27. data/lib/gretel/parent.rb +0 -9
  28. data/lib/gretel/view_link.rb +0 -13
  29. data/test/dummy/db/development.sqlite3 +0 -0
  30. data/test/dummy/db/test.sqlite3 +0 -0
  31. data/test/dummy/log/development.log +0 -899
  32. data/test/dummy/log/test.log +0 -9038
  33. data/test/dummy/tmp/cache/assets/CD0/C10/sprockets%2F54298310314d4114afd54d090ef4eae3 +0 -0
  34. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  35. data/test/dummy/tmp/cache/assets/D11/910/sprockets%2Fa4743dda75a6c1d923065da98d729f21 +0 -0
  36. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  37. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  38. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  39. data/test/dummy/tmp/cache/assets/D5F/7E0/sprockets%2F25f5ca97d1c1c044514dd8d2c5cb6d02 +0 -0
  40. data/test/dummy/tmp/cache/assets/D79/060/sprockets%2Fa2cf91ba98db7115dd35bcd7881934f8 +0 -0
  41. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  42. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
@@ -1,122 +0,0 @@
1
- module Gretel
2
- module HelperMethods
3
- def breadcrumb(*args)
4
- options = args.extract_options!
5
- name, object = args[0], args[1]
6
-
7
- if name
8
- @_breadcrumb_name = name
9
- @_breadcrumb_object = object
10
- else
11
- if @_breadcrumb_name
12
- crumb = breadcrumb_for(@_breadcrumb_name, @_breadcrumb_object, options)
13
- elsif options[:show_root_alone]
14
- crumb = breadcrumb_for(:root, options)
15
- end
16
- end
17
-
18
- if crumb
19
- if options[:pretext]
20
- crumb = options[:pretext].html_safe + crumb
21
- end
22
- if options[:posttext]
23
- crumb = crumb + options[:posttext].html_safe
24
- end
25
- end
26
-
27
- if crumb
28
- content_tag(:div, crumb, :class => "breadcrumbs", :id => options[:id])
29
- else
30
- ""
31
- end
32
- end
33
-
34
- def breadcrumbs(*args)
35
- options = args.extract_options!
36
-
37
- if @_breadcrumb_name
38
- links = []
39
-
40
- crumb = Crumbs.get_crumb(@_breadcrumb_name, @_breadcrumb_object)
41
- while link = crumb.links.pop
42
- links.unshift ViewLink.new(link.text, link.url, link.options)
43
- end
44
-
45
- while crumb = crumb.parent
46
- last_parent = crumb.name
47
- crumb = Crumbs.get_crumb(crumb.name, crumb.object)
48
- while link = crumb.links.pop
49
- links.unshift ViewLink.new(link.text, link.url, link.options)
50
- end
51
- end
52
-
53
- if options[:autoroot] && @_breadcrumb_name != :root && last_parent != :root
54
- crumb = Crumbs.get_crumb(:root)
55
- while link = crumb.links.pop
56
- links.unshift ViewLink.new(link.text, link.url, link.options)
57
- end
58
- end
59
-
60
- current_link = links.pop
61
-
62
- out = []
63
- while link = links.shift
64
- out << ViewLink.new(link.text, link.url, link.options)
65
- end
66
-
67
- if current_link
68
- out << ViewLink.new(current_link.text, current_link.url, current_link.options, true)
69
- end
70
- else
71
- out = []
72
- end
73
-
74
- out
75
- end
76
-
77
- def breadcrumb_for(*args)
78
- options = args.extract_options!
79
- name, object = args[0], args[1]
80
-
81
- links = breadcrumbs(name, object, options)
82
-
83
- current_link = links.pop
84
-
85
- out = []
86
- while link = links.shift
87
- out << get_crumb(link.text, link.url, options[:semantic], nil, link.options)
88
- end
89
-
90
- if current_link
91
- if options[:link_last] || options[:link_current]
92
- out << get_crumb(current_link.text, current_link.url, options[:semantic], "current", current_link.options)
93
- else
94
- out << get_crumb(current_link.text, nil, options[:semantic], "current")
95
- end
96
- end
97
-
98
- out.join(options[:separator] || " &gt; ").html_safe
99
- end
100
-
101
- def get_crumb(text, url, semantic, css_class, options = {})
102
- if url.blank?
103
- if semantic
104
- content_tag(:div, content_tag(:span, text, :class => css_class, :itemprop => "title"), :itemscope => "", :itemtype => "http://data-vocabulary.org/Breadcrumb")
105
- else
106
- if css_class
107
- content_tag(:span, text, :class => css_class)
108
- else
109
- text
110
- end
111
- end
112
- else
113
- options.merge! :class => (options[:class] ? options[:class] + " " : "") + css_class if css_class
114
- if semantic
115
- content_tag(:div, link_to(content_tag(:span, text, :itemprop => "title"), url, options.merge(:itemprop => "url")), :itemscope => "", :itemtype => "http://data-vocabulary.org/Breadcrumb")
116
- else
117
- link_to(text, url, options)
118
- end
119
- end
120
- end
121
- end
122
- end
data/lib/gretel/parent.rb DELETED
@@ -1,9 +0,0 @@
1
- module Gretel
2
- class Parent
3
- attr_accessor :name, :object
4
-
5
- def initialize(name, object)
6
- @name, @object = name, object
7
- end
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- module Gretel
2
- class ViewLink
3
- attr_reader :text, :url, :options, :current
4
-
5
- def initialize(text, url, options, current = false)
6
- @text, @url, @options, @current = text, url, options, current
7
- end
8
-
9
- def current?
10
- current
11
- end
12
- end
13
- end
Binary file
Binary file