breadcrumbs_on_rails_microdata_builder 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,100 @@
1
+ PATH
2
+ remote: /Users/weppos/Code/breadcrumbs_on_rails
3
+ specs:
4
+ breadcrumbs_on_rails (2.1.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (3.2.1)
10
+ actionpack (= 3.2.1)
11
+ mail (~> 2.4.0)
12
+ actionpack (3.2.1)
13
+ activemodel (= 3.2.1)
14
+ activesupport (= 3.2.1)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ journey (~> 1.0.1)
18
+ rack (~> 1.4.0)
19
+ rack-cache (~> 1.1)
20
+ rack-test (~> 0.6.1)
21
+ sprockets (~> 2.1.2)
22
+ activemodel (3.2.1)
23
+ activesupport (= 3.2.1)
24
+ builder (~> 3.0.0)
25
+ activerecord (3.2.1)
26
+ activemodel (= 3.2.1)
27
+ activesupport (= 3.2.1)
28
+ arel (~> 3.0.0)
29
+ tzinfo (~> 0.3.29)
30
+ activeresource (3.2.1)
31
+ activemodel (= 3.2.1)
32
+ activesupport (= 3.2.1)
33
+ activesupport (3.2.1)
34
+ i18n (~> 0.6)
35
+ multi_json (~> 1.0)
36
+ appraisal (0.4.0)
37
+ bundler
38
+ rake
39
+ arel (3.0.0)
40
+ builder (3.0.0)
41
+ erubis (2.7.0)
42
+ hike (1.2.1)
43
+ i18n (0.6.0)
44
+ journey (1.0.1)
45
+ json (1.6.5)
46
+ mail (2.4.1)
47
+ i18n (>= 0.4.0)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ mime-types (1.17.2)
51
+ mocha (0.9.12)
52
+ multi_json (1.0.4)
53
+ polyglot (0.3.3)
54
+ rack (1.4.1)
55
+ rack-cache (1.1)
56
+ rack (>= 0.4)
57
+ rack-ssl (1.3.2)
58
+ rack
59
+ rack-test (0.6.1)
60
+ rack (>= 1.0)
61
+ rails (3.2.1)
62
+ actionmailer (= 3.2.1)
63
+ actionpack (= 3.2.1)
64
+ activerecord (= 3.2.1)
65
+ activeresource (= 3.2.1)
66
+ activesupport (= 3.2.1)
67
+ bundler (~> 1.0)
68
+ railties (= 3.2.1)
69
+ railties (3.2.1)
70
+ actionpack (= 3.2.1)
71
+ activesupport (= 3.2.1)
72
+ rack-ssl (~> 1.3.2)
73
+ rake (>= 0.8.7)
74
+ rdoc (~> 3.4)
75
+ thor (~> 0.14.6)
76
+ rake (0.9.2.2)
77
+ rdoc (3.12)
78
+ json (~> 1.4)
79
+ sprockets (2.1.2)
80
+ hike (~> 1.2)
81
+ rack (~> 1.0)
82
+ tilt (~> 1.1, != 1.3.0)
83
+ thor (0.14.6)
84
+ tilt (1.3.3)
85
+ treetop (1.4.10)
86
+ polyglot
87
+ polyglot (>= 0.3.1)
88
+ tzinfo (0.3.31)
89
+ yard (0.7.5)
90
+
91
+ PLATFORMS
92
+ ruby
93
+
94
+ DEPENDENCIES
95
+ activerecord (~> 3.0)
96
+ appraisal
97
+ breadcrumbs_on_rails!
98
+ mocha (~> 0.9.10)
99
+ rails (>= 3.0)
100
+ yard
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.1"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,100 @@
1
+ PATH
2
+ remote: /Users/weppos/Code/breadcrumbs_on_rails
3
+ specs:
4
+ breadcrumbs_on_rails (2.1.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (3.2.1)
10
+ actionpack (= 3.2.1)
11
+ mail (~> 2.4.0)
12
+ actionpack (3.2.1)
13
+ activemodel (= 3.2.1)
14
+ activesupport (= 3.2.1)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ journey (~> 1.0.1)
18
+ rack (~> 1.4.0)
19
+ rack-cache (~> 1.1)
20
+ rack-test (~> 0.6.1)
21
+ sprockets (~> 2.1.2)
22
+ activemodel (3.2.1)
23
+ activesupport (= 3.2.1)
24
+ builder (~> 3.0.0)
25
+ activerecord (3.2.1)
26
+ activemodel (= 3.2.1)
27
+ activesupport (= 3.2.1)
28
+ arel (~> 3.0.0)
29
+ tzinfo (~> 0.3.29)
30
+ activeresource (3.2.1)
31
+ activemodel (= 3.2.1)
32
+ activesupport (= 3.2.1)
33
+ activesupport (3.2.1)
34
+ i18n (~> 0.6)
35
+ multi_json (~> 1.0)
36
+ appraisal (0.4.0)
37
+ bundler
38
+ rake
39
+ arel (3.0.0)
40
+ builder (3.0.0)
41
+ erubis (2.7.0)
42
+ hike (1.2.1)
43
+ i18n (0.6.0)
44
+ journey (1.0.1)
45
+ json (1.6.5)
46
+ mail (2.4.1)
47
+ i18n (>= 0.4.0)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ mime-types (1.17.2)
51
+ mocha (0.9.12)
52
+ multi_json (1.0.4)
53
+ polyglot (0.3.3)
54
+ rack (1.4.1)
55
+ rack-cache (1.1)
56
+ rack (>= 0.4)
57
+ rack-ssl (1.3.2)
58
+ rack
59
+ rack-test (0.6.1)
60
+ rack (>= 1.0)
61
+ rails (3.2.1)
62
+ actionmailer (= 3.2.1)
63
+ actionpack (= 3.2.1)
64
+ activerecord (= 3.2.1)
65
+ activeresource (= 3.2.1)
66
+ activesupport (= 3.2.1)
67
+ bundler (~> 1.0)
68
+ railties (= 3.2.1)
69
+ railties (3.2.1)
70
+ actionpack (= 3.2.1)
71
+ activesupport (= 3.2.1)
72
+ rack-ssl (~> 1.3.2)
73
+ rake (>= 0.8.7)
74
+ rdoc (~> 3.4)
75
+ thor (~> 0.14.6)
76
+ rake (0.9.2.2)
77
+ rdoc (3.12)
78
+ json (~> 1.4)
79
+ sprockets (2.1.2)
80
+ hike (~> 1.2)
81
+ rack (~> 1.0)
82
+ tilt (~> 1.1, != 1.3.0)
83
+ thor (0.14.6)
84
+ tilt (1.3.3)
85
+ treetop (1.4.10)
86
+ polyglot
87
+ polyglot (>= 0.3.1)
88
+ tzinfo (0.3.31)
89
+ yard (0.7.5)
90
+
91
+ PLATFORMS
92
+ ruby
93
+
94
+ DEPENDENCIES
95
+ activerecord (~> 3.1)
96
+ appraisal
97
+ breadcrumbs_on_rails!
98
+ mocha (~> 0.9.10)
99
+ rails (>= 3.0)
100
+ yard
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.2"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,100 @@
1
+ PATH
2
+ remote: /Users/weppos/Code/breadcrumbs_on_rails
3
+ specs:
4
+ breadcrumbs_on_rails (2.1.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (3.2.1)
10
+ actionpack (= 3.2.1)
11
+ mail (~> 2.4.0)
12
+ actionpack (3.2.1)
13
+ activemodel (= 3.2.1)
14
+ activesupport (= 3.2.1)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ journey (~> 1.0.1)
18
+ rack (~> 1.4.0)
19
+ rack-cache (~> 1.1)
20
+ rack-test (~> 0.6.1)
21
+ sprockets (~> 2.1.2)
22
+ activemodel (3.2.1)
23
+ activesupport (= 3.2.1)
24
+ builder (~> 3.0.0)
25
+ activerecord (3.2.1)
26
+ activemodel (= 3.2.1)
27
+ activesupport (= 3.2.1)
28
+ arel (~> 3.0.0)
29
+ tzinfo (~> 0.3.29)
30
+ activeresource (3.2.1)
31
+ activemodel (= 3.2.1)
32
+ activesupport (= 3.2.1)
33
+ activesupport (3.2.1)
34
+ i18n (~> 0.6)
35
+ multi_json (~> 1.0)
36
+ appraisal (0.4.0)
37
+ bundler
38
+ rake
39
+ arel (3.0.0)
40
+ builder (3.0.0)
41
+ erubis (2.7.0)
42
+ hike (1.2.1)
43
+ i18n (0.6.0)
44
+ journey (1.0.1)
45
+ json (1.6.5)
46
+ mail (2.4.1)
47
+ i18n (>= 0.4.0)
48
+ mime-types (~> 1.16)
49
+ treetop (~> 1.4.8)
50
+ mime-types (1.17.2)
51
+ mocha (0.9.12)
52
+ multi_json (1.0.4)
53
+ polyglot (0.3.3)
54
+ rack (1.4.1)
55
+ rack-cache (1.1)
56
+ rack (>= 0.4)
57
+ rack-ssl (1.3.2)
58
+ rack
59
+ rack-test (0.6.1)
60
+ rack (>= 1.0)
61
+ rails (3.2.1)
62
+ actionmailer (= 3.2.1)
63
+ actionpack (= 3.2.1)
64
+ activerecord (= 3.2.1)
65
+ activeresource (= 3.2.1)
66
+ activesupport (= 3.2.1)
67
+ bundler (~> 1.0)
68
+ railties (= 3.2.1)
69
+ railties (3.2.1)
70
+ actionpack (= 3.2.1)
71
+ activesupport (= 3.2.1)
72
+ rack-ssl (~> 1.3.2)
73
+ rake (>= 0.8.7)
74
+ rdoc (~> 3.4)
75
+ thor (~> 0.14.6)
76
+ rake (0.9.2.2)
77
+ rdoc (3.12)
78
+ json (~> 1.4)
79
+ sprockets (2.1.2)
80
+ hike (~> 1.2)
81
+ rack (~> 1.0)
82
+ tilt (~> 1.1, != 1.3.0)
83
+ thor (0.14.6)
84
+ tilt (1.3.3)
85
+ treetop (1.4.10)
86
+ polyglot
87
+ polyglot (>= 0.3.1)
88
+ tzinfo (0.3.31)
89
+ yard (0.7.5)
90
+
91
+ PLATFORMS
92
+ ruby
93
+
94
+ DEPENDENCIES
95
+ activerecord (~> 3.2)
96
+ appraisal
97
+ breadcrumbs_on_rails!
98
+ mocha (~> 0.9.10)
99
+ rails (>= 3.0)
100
+ yard
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'breadcrumbs_on_rails_microdata_builder'
@@ -0,0 +1,21 @@
1
+ #--
2
+ # Breadcrumbs On Rails
3
+ #
4
+ # A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
5
+ #
6
+ # Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
7
+ #++
8
+
9
+ require 'breadcrumbs_on_rails_microdata_builder/breadcrumbs'
10
+ require 'breadcrumbs_on_rails_microdata_builder/breadcrumbs/simple_builder'
11
+ require 'breadcrumbs_on_rails_microdata_builder/version'
12
+ require 'breadcrumbs_on_rails_microdata_builder/action_controller'
13
+ require 'breadcrumbs_on_rails_microdata_builder/railtie'
14
+
15
+
16
+ module BreadcrumbsOnRailsMicrodataBuilder
17
+
18
+ NAME = 'Breadcrumbs on Rails Microdata Builder'
19
+ GEM = 'breadcrumbs_on_rails_microdata_builder'
20
+
21
+ end
@@ -0,0 +1,93 @@
1
+ #--
2
+ # Breadcrumbs On Rails
3
+ #
4
+ # A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
5
+ #
6
+ # Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
7
+ #++
8
+
9
+ module BreadcrumbsOnRailsMicrodataBuilder
10
+
11
+ module ActionController
12
+ extend ActiveSupport::Concern
13
+
14
+ included do
15
+ extend ClassMethods
16
+ helper HelperMethods
17
+ helper_method :add_breadcrumb, :breadcrumbs
18
+ end
19
+
20
+ protected
21
+
22
+ def add_breadcrumb(name, path, options = {})
23
+ self.breadcrumbs << Breadcrumbs::Element.new(name, path, options)
24
+ end
25
+
26
+ def breadcrumbs
27
+ @breadcrumbs ||= []
28
+ end
29
+
30
+ module Utils
31
+
32
+ def self.instance_proc(string)
33
+ if string.kind_of?(String)
34
+ proc { |controller| controller.instance_eval(string) }
35
+ else
36
+ string
37
+ end
38
+ end
39
+
40
+ # This is an horrible method with an horrible name.
41
+ #
42
+ # convert_to_set_of_strings(nil, [:foo, :bar])
43
+ # # => nil
44
+ # convert_to_set_of_strings(true, [:foo, :bar])
45
+ # # => ["foo", "bar"]
46
+ # convert_to_set_of_strings(:foo, [:foo, :bar])
47
+ # # => ["foo"]
48
+ # convert_to_set_of_strings([:foo, :bar, :baz], [:foo, :bar])
49
+ # # => ["foo", "bar", "baz"]
50
+ #
51
+ def self.convert_to_set_of_strings(value, keys)
52
+ if value == true
53
+ keys.map(&:to_s).to_set
54
+ elsif value
55
+ Array(value).map(&:to_s).to_set
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ module ClassMethods
62
+
63
+ def add_breadcrumb(name, path, filter_options = {})
64
+ # This isn't really nice here
65
+ if eval = Utils.convert_to_set_of_strings(filter_options.delete(:eval), %w(name path))
66
+ name = Utils.instance_proc(name) if eval.include?("name")
67
+ path = Utils.instance_proc(path) if eval.include?("path")
68
+ end
69
+
70
+ before_filter(filter_options) do |controller|
71
+ controller.send(:add_breadcrumb, name, path)
72
+ end
73
+ end
74
+
75
+ end
76
+
77
+ module HelperMethods
78
+
79
+ def render_breadcrumbs(options = {}, &block)
80
+ builder = (options.delete(:builder) || Breadcrumbs::SimpleBuilder).new(self, breadcrumbs, options)
81
+ content = builder.render.html_safe
82
+ if block_given?
83
+ capture(content, &block)
84
+ else
85
+ content
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ end
92
+
93
+ end
@@ -0,0 +1,100 @@
1
+ #--
2
+ # Breadcrumbs On Rails
3
+ #
4
+ # A simple Ruby on Rails plugin for creating and managing a breadcrumb navigation.
5
+ #
6
+ # Copyright (c) 2009-2012 Simone Carletti <weppos@weppos.net>
7
+ #++
8
+
9
+ module BreadcrumbsOnRailsMicrodataBuilder
10
+
11
+ module Breadcrumbs
12
+
13
+ # The Builder class represents the abstract class for any custom Builder.
14
+ #
15
+ # To create a custom Builder, just extend this class
16
+ # and implement the following abstract methods:
17
+ #
18
+ # * <tt>#render</tt>: Renders and returns the collection of navigation elements
19
+ #
20
+ class Builder
21
+
22
+ # Initializes a new Builder with <tt>context</tt>,
23
+ # <tt>element</tt> and <tt>options</tt>.
24
+ #
25
+ # @param [ActionView::Base] context The view context.
26
+ # @param [Array<Element>] elements The collection of Elements.
27
+ # @param [Hash] options Hash of options to customize the rendering behavior.
28
+ #
29
+ def initialize(context, elements, options = {})
30
+ @context = context
31
+ @elements = elements
32
+ @options = options
33
+ end
34
+
35
+ # Renders Elements and returns the Breadcrumb navigation for the view.
36
+ #
37
+ # @return [String] The result of the breadcrumb rendering.
38
+ #
39
+ # @abstract You must implement this method in your custom Builder.
40
+ def render
41
+ raise NotImplementedError
42
+ end
43
+
44
+
45
+ protected
46
+
47
+ def compute_name(element)
48
+ case name = element.name
49
+ when Symbol
50
+ @context.send(name)
51
+ when Proc
52
+ name.call(@context)
53
+ else
54
+ name.to_s
55
+ end
56
+ end
57
+
58
+ def compute_path(element)
59
+ case path = element.path
60
+ when Symbol
61
+ @context.send(path)
62
+ when Proc
63
+ path.call(@context)
64
+ when Hash
65
+ @context.url_for(path)
66
+ else
67
+ path.to_s
68
+ end
69
+ end
70
+
71
+ end
72
+
73
+ # Represents a navigation element in the breadcrumb collection.
74
+ #
75
+ class Element
76
+
77
+ # @return [String] The element/link name.
78
+ attr_accessor :name
79
+ # @return [String] The element/link URL.
80
+ attr_accessor :path
81
+ # @return [Hash] The element/link URL.
82
+ attr_accessor :options
83
+
84
+ # Initializes the Element with given parameters.
85
+ #
86
+ # @param [String] name The element/link name.
87
+ # @param [String] path The element/link URL.
88
+ # @param [Hash] options The element/link URL.
89
+ # @return [Element]
90
+ #
91
+ def initialize(name, path, options = {})
92
+ self.name = name
93
+ self.path = path
94
+ self.options = options
95
+ end
96
+ end
97
+
98
+ end
99
+
100
+ end