bsm-breadcrumbs 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bsm-breadcrumbs}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nando Vieira", "Dimitrij Denissenko"]
@@ -1,16 +1,14 @@
1
- class Breadcrumbs
2
- module ActionController # :nodoc: all
3
- extend ActiveSupport::Concern
1
+ module Breadcrumbs::ActionController # :nodoc: all
2
+ extend ActiveSupport::Concern
4
3
 
5
- included do
6
- helper_method :breadcrumbs
7
- end
8
-
9
- def breadcrumbs
10
- @breadcrumbs ||= Breadcrumbs.new(self)
11
- end
4
+ included do
5
+ helper_method :breadcrumbs
6
+ end
12
7
 
8
+ def breadcrumbs
9
+ @breadcrumbs ||= Breadcrumbs.new(self)
13
10
  end
11
+
14
12
  end
15
13
 
16
14
  ActionController::Base.send :include, Breadcrumbs::ActionController
@@ -5,10 +5,9 @@ class Breadcrumbs
5
5
  options = {:class => "breadcrumbs", :separator => "»"}.merge(default_options)
6
6
 
7
7
  html = []
8
- items = breadcrumbs.items
9
- size = items.size
8
+ size = breadcrumbs.size
10
9
 
11
- items.each_with_index do |item, i|
10
+ breadcrumbs.each_with_index do |item, i|
12
11
  html << render_item(item, i, size)
13
12
  end
14
13
 
@@ -8,10 +8,9 @@ class Breadcrumbs
8
8
 
9
9
  tag(list_style, options) do
10
10
  html = ""
11
- items = breadcrumbs.items
12
- size = items.size
11
+ size = breadcrumbs.size
13
12
 
14
- items.each_with_index do |item, i|
13
+ breadcrumbs.each_with_index do |item, i|
15
14
  html << render_item(item, i, size)
16
15
  end
17
16
 
@@ -1,8 +1,6 @@
1
- class Breadcrumbs
2
- module Render
3
- autoload :Base, "breadcrumbs/render/base"
4
- autoload :Inline, "breadcrumbs/render/inline"
5
- autoload :List, "breadcrumbs/render/list"
6
- autoload :OrderedList, "breadcrumbs/render/ordered_list"
7
- end
1
+ module Breadcrumbs::Render
2
+ autoload :Base, "breadcrumbs/render/base"
3
+ autoload :Inline, "breadcrumbs/render/inline"
4
+ autoload :List, "breadcrumbs/render/list"
5
+ autoload :OrderedList, "breadcrumbs/render/ordered_list"
8
6
  end
@@ -2,7 +2,7 @@ class Breadcrumbs
2
2
  module Version # :nodoc: all
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- PATCH = 0
5
+ PATCH = 1
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
data/lib/breadcrumbs.rb CHANGED
@@ -1,14 +1,15 @@
1
1
  require "action_controller"
2
- require "breadcrumbs/render"
3
- require "breadcrumbs/action_controller_ext"
4
2
  require "active_support/inflector"
5
3
 
6
- class Breadcrumbs
4
+ class Breadcrumbs < Array
5
+ autoload :Render, "breadcrumbs/render"
6
+ autoload :Version, "breadcrumbs/version"
7
+
7
8
  attr_accessor :controller, :items
8
9
 
9
10
  def initialize(controller) # :nodoc:
10
11
  self.controller = controller
11
- self.items = []
12
+ super([])
12
13
  end
13
14
 
14
15
  # Add a new breadcrumbs.
@@ -24,7 +25,7 @@ class Breadcrumbs
24
25
  options.reverse_merge!(:i18n => true)
25
26
  text = translate(text) if options.delete(:i18n)
26
27
  url = controller.__send__(:url_for, url) if url
27
- items << [text.to_s, url, options]
28
+ push [text.to_s, url, options]
28
29
  end
29
30
 
30
31
  alias :<< :add
@@ -69,3 +70,5 @@ class Breadcrumbs
69
70
  text
70
71
  end
71
72
  end
73
+
74
+ require "breadcrumbs/action_controller_ext"
@@ -22,10 +22,10 @@ class BreadcrumbsTest < Test::Unit::TestCase
22
22
 
23
23
  def test_add_item
24
24
  @breadcrumbs.add "Home"
25
- assert_equal 1, @breadcrumbs.items.count
25
+ assert_equal 1, @breadcrumbs.count
26
26
 
27
27
  @breadcrumbs << "Home"
28
- assert_equal 2, @breadcrumbs.items.count
28
+ assert_equal 2, @breadcrumbs.count
29
29
  end
30
30
 
31
31
  def test_tag
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bsm-breadcrumbs
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nando Vieira