bsm-breadcrumbs 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,7 +37,7 @@ class Breadcrumbs
37
37
  end
38
38
 
39
39
  def escape(text)
40
- text.respond_to?(:html_safe?) && text.html_safe? ? text : CGI.escapeHTML(text)
40
+ text.respond_to?(:html_safe?) && text.html_safe? ? text : Rack::Utils.escape_html(text)
41
41
  end
42
42
  end
43
43
  end
@@ -1,8 +1,8 @@
1
- class Breadcrumbs
1
+ class Breadcrumbs < Array
2
2
  module Version # :nodoc: all
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- PATCH = 2
5
+ PATCH = 3
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,116 +1,94 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bsm-breadcrumbs
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 2
10
- version: 0.3.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Nando Vieira
14
9
  - Dimitrij Denissenko
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2011-02-16 00:00:00 +00:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
13
+ date: 2011-10-21 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
23
16
  name: actionpack
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &8433300 !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 3
32
- - 0
33
- - 0
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
34
22
  version: 3.0.0
35
- prerelease: false
23
+ - - <
24
+ - !ruby/object:Gem::Version
25
+ version: 3.2.0
36
26
  type: :runtime
37
- requirement: *id001
38
- - !ruby/object:Gem::Dependency
27
+ prerelease: false
28
+ version_requirements: *8433300
29
+ - !ruby/object:Gem::Dependency
39
30
  name: activemodel
40
- version_requirements: &id002 !ruby/object:Gem::Requirement
31
+ requirement: &8430720 !ruby/object:Gem::Requirement
41
32
  none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 7
46
- segments:
47
- - 3
48
- - 0
49
- - 0
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
50
36
  version: 3.0.0
51
- prerelease: false
37
+ - - <
38
+ - !ruby/object:Gem::Version
39
+ version: 3.2.0
52
40
  type: :runtime
53
- requirement: *id002
54
- description: Breadcrumbs is a simple plugin that adds a `breadcrumbs` object to controllers and views.
41
+ prerelease: false
42
+ version_requirements: *8430720
43
+ - !ruby/object:Gem::Dependency
44
+ name: rake
45
+ requirement: &8422620 !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: *8422620
54
+ description:
55
55
  email: dimitrij@blacksquaremedia.com
56
56
  executables: []
57
-
58
57
  extensions: []
59
-
60
- extra_rdoc_files:
58
+ extra_rdoc_files: []
59
+ files:
61
60
  - README.rdoc
62
- files:
63
- - .bundle/config
64
- - Gemfile
65
- - Gemfile.lock
66
- - README.rdoc
67
- - Rakefile
68
- - bsm-breadcrumbs.gemspec
69
61
  - lib/breadcrumbs.rb
70
- - lib/breadcrumbs/action_controller_ext.rb
71
62
  - lib/breadcrumbs/render.rb
72
- - lib/breadcrumbs/render/base.rb
63
+ - lib/breadcrumbs/action_controller_ext.rb
64
+ - lib/breadcrumbs/version.rb
65
+ - lib/breadcrumbs/render/ordered_list.rb
73
66
  - lib/breadcrumbs/render/inline.rb
67
+ - lib/breadcrumbs/render/base.rb
74
68
  - lib/breadcrumbs/render/list.rb
75
- - lib/breadcrumbs/render/ordered_list.rb
76
- - lib/breadcrumbs/version.rb
77
- - test/breadcrumbs_test.rb
78
- - test/resources/en.yml
79
- - test/test_helper.rb
80
- has_rdoc: true
81
- homepage: http://github.com/bsm/breadcrumbs
69
+ homepage: https://github.com/bsm/breadcrumbs
82
70
  licenses: []
83
-
84
71
  post_install_message:
85
72
  rdoc_options: []
86
-
87
- require_paths:
73
+ require_paths:
88
74
  - lib
89
- required_ruby_version: !ruby/object:Gem::Requirement
75
+ required_ruby_version: !ruby/object:Gem::Requirement
90
76
  none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- hash: 3
95
- segments:
96
- - 0
97
- version: "0"
98
- required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: 1.8.7
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
82
  none: false
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- hash: 3
104
- segments:
105
- - 0
106
- version: "0"
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: 1.3.6
107
87
  requirements: []
108
-
109
88
  rubyforge_project:
110
- rubygems_version: 1.5.0
89
+ rubygems_version: 1.8.10
111
90
  signing_key:
112
91
  specification_version: 3
113
- summary: Breadcrumbs is a simple plugin that adds a `breadcrumbs` object to controllers and views.
114
- test_files:
115
- - test/breadcrumbs_test.rb
116
- - test/test_helper.rb
92
+ summary: Breadcrumbs is a simple plugin that adds a `breadcrumbs` object to controllers
93
+ and views.
94
+ test_files: []
data/.bundle/config DELETED
@@ -1,2 +0,0 @@
1
- ---
2
- BUNDLE_DISABLE_SHARED_GEMS: "1"
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gem "actionpack", '~> 3.0.0'
4
- gem "activemodel", '~> 3.0.0'
5
-
6
- group :test do
7
- gem "test-unit"
8
- end
9
-
data/Gemfile.lock DELETED
@@ -1,38 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- abstract (1.0.0)
5
- actionpack (3.0.3)
6
- activemodel (= 3.0.3)
7
- activesupport (= 3.0.3)
8
- builder (~> 2.1.2)
9
- erubis (~> 2.6.6)
10
- i18n (~> 0.4)
11
- rack (~> 1.2.1)
12
- rack-mount (~> 0.6.13)
13
- rack-test (~> 0.5.6)
14
- tzinfo (~> 0.3.23)
15
- activemodel (3.0.3)
16
- activesupport (= 3.0.3)
17
- builder (~> 2.1.2)
18
- i18n (~> 0.4)
19
- activesupport (3.0.3)
20
- builder (2.1.2)
21
- erubis (2.6.6)
22
- abstract (>= 1.0.0)
23
- i18n (0.5.0)
24
- rack (1.2.1)
25
- rack-mount (0.6.13)
26
- rack (>= 1.0.0)
27
- rack-test (0.5.6)
28
- rack (>= 1.0)
29
- test-unit (2.1.2)
30
- tzinfo (0.3.23)
31
-
32
- PLATFORMS
33
- ruby
34
-
35
- DEPENDENCIES
36
- actionpack (~> 3.0.0)
37
- activemodel (~> 3.0.0)
38
- test-unit
data/Rakefile DELETED
@@ -1,38 +0,0 @@
1
- require "jeweler"
2
- require "rake/testtask"
3
- require "rake/rdoctask"
4
- require "lib/breadcrumbs/version"
5
-
6
- task :default => :test
7
-
8
- Rake::TestTask.new do |t|
9
- t.libs << "test"
10
- t.libs << "lib"
11
- t.test_files = FileList["test/**/*_test.rb"]
12
- t.verbose = true
13
- end
14
-
15
- Rake::RDocTask.new do |rdoc|
16
- rdoc.main = "README.rdoc"
17
- rdoc.rdoc_dir = "doc"
18
- rdoc.title = "Breadcrumbs"
19
- rdoc.options += %w[ --line-numbers --inline-source --charset utf-8 ]
20
- rdoc.rdoc_files.include("README.rdoc")
21
- rdoc.rdoc_files.include("lib/**/*.rb")
22
- end
23
-
24
- begin
25
- require 'jeweler'
26
- Jeweler::Tasks.new do |gem|
27
- gem.name = "bsm-breadcrumbs"
28
- gem.email = "dimitrij@blacksquaremedia.com"
29
- gem.homepage = "http://github.com/bsm/breadcrumbs"
30
- gem.authors = ["Nando Vieira", "Dimitrij Denissenko"]
31
- gem.version = Breadcrumbs::Version::STRING
32
- gem.summary = "Breadcrumbs is a simple plugin that adds a `breadcrumbs` object to controllers and views."
33
- gem.description = "Breadcrumbs is a simple plugin that adds a `breadcrumbs` object to controllers and views."
34
- end
35
- Jeweler::GemcutterTasks.new
36
- rescue LoadError
37
- puts "Jeweler not available. Install it with: gem install jeweler"
38
- end
@@ -1,61 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{bsm-breadcrumbs}
8
- s.version = "0.3.2"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Nando Vieira", "Dimitrij Denissenko"]
12
- s.date = %q{2011-02-16}
13
- s.description = %q{Breadcrumbs is a simple plugin that adds a `breadcrumbs` object to controllers and views.}
14
- s.email = %q{dimitrij@blacksquaremedia.com}
15
- s.extra_rdoc_files = [
16
- "README.rdoc"
17
- ]
18
- s.files = [
19
- ".bundle/config",
20
- "Gemfile",
21
- "Gemfile.lock",
22
- "README.rdoc",
23
- "Rakefile",
24
- "bsm-breadcrumbs.gemspec",
25
- "lib/breadcrumbs.rb",
26
- "lib/breadcrumbs/action_controller_ext.rb",
27
- "lib/breadcrumbs/render.rb",
28
- "lib/breadcrumbs/render/base.rb",
29
- "lib/breadcrumbs/render/inline.rb",
30
- "lib/breadcrumbs/render/list.rb",
31
- "lib/breadcrumbs/render/ordered_list.rb",
32
- "lib/breadcrumbs/version.rb",
33
- "test/breadcrumbs_test.rb",
34
- "test/resources/en.yml",
35
- "test/test_helper.rb"
36
- ]
37
- s.homepage = %q{http://github.com/bsm/breadcrumbs}
38
- s.require_paths = ["lib"]
39
- s.rubygems_version = %q{1.5.0}
40
- s.summary = %q{Breadcrumbs is a simple plugin that adds a `breadcrumbs` object to controllers and views.}
41
- s.test_files = [
42
- "test/breadcrumbs_test.rb",
43
- "test/test_helper.rb"
44
- ]
45
-
46
- if s.respond_to? :specification_version then
47
- s.specification_version = 3
48
-
49
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
- s.add_runtime_dependency(%q<actionpack>, ["~> 3.0.0"])
51
- s.add_runtime_dependency(%q<activemodel>, ["~> 3.0.0"])
52
- else
53
- s.add_dependency(%q<actionpack>, ["~> 3.0.0"])
54
- s.add_dependency(%q<activemodel>, ["~> 3.0.0"])
55
- end
56
- else
57
- s.add_dependency(%q<actionpack>, ["~> 3.0.0"])
58
- s.add_dependency(%q<activemodel>, ["~> 3.0.0"])
59
- end
60
- end
61
-
@@ -1,243 +0,0 @@
1
- require "test_helper"
2
-
3
- class BreadcrumbsTest < Test::Unit::TestCase
4
-
5
- def setup
6
- @controller = TestsController.new
7
- @controller.request = ActionController::TestRequest.new
8
- @breadcrumbs = Breadcrumbs.new(@controller)
9
- @inline = Breadcrumbs::Render::Inline.new(@breadcrumbs)
10
- end
11
-
12
- def test_return_safe_html
13
- @breadcrumbs.add "Terms & Conditions"
14
- assert_equal %(<span class="first last item-0">Terms &amp; Conditions</span>), @breadcrumbs.render(:format => :inline)
15
- end
16
-
17
- def test_allow_custom_text_escaping
18
- @breadcrumbs.add "<em>Home</em>".html_safe
19
- html = @breadcrumbs.render(:format => :inline)
20
- assert_equal %(<span class="first last item-0"><em>Home</em></span>), html
21
- end
22
-
23
- def test_add_item
24
- @breadcrumbs.add "Home"
25
- assert_equal 1, @breadcrumbs.count
26
-
27
- @breadcrumbs << "Home"
28
- assert_equal 2, @breadcrumbs.count
29
- end
30
-
31
- def test_add_empty_item # Just in case, we generate the label
32
- @breadcrumbs.add ""
33
- assert_equal 1, @breadcrumbs.count
34
- end
35
-
36
- def test_tag
37
- assert_equal "<span>Hi!</span>", @inline.tag(:span, "Hi!")
38
- end
39
-
40
- def test_tag_with_attributes
41
- expected = %[<span class="greetings" id="hi">Hi!</span>]
42
- assert_equal expected, @inline.tag(:span, "Hi!", :class => "greetings", :id => "hi")
43
- end
44
-
45
- def test_tag_with_block
46
- assert_equal "<span>Hi!</span>", @inline.tag(:span) { "Hi!" }
47
- end
48
-
49
- def test_tag_with_block_and_attributes
50
- expected = %[<span class="greetings" id="hi">Hi!</span>]
51
- assert_equal expected, @inline.tag(:span, :class => "greetings", :id => "hi") { "Hi!" }
52
- end
53
-
54
- def test_nested_tags
55
- expected = %[<span class="greetings"><strong id="hi">Hi!</strong></span>]
56
- actual = @inline.tag(:span, :class => "greetings") { tag(:strong, "Hi!", :id => "hi") }
57
- assert_equal expected, actual
58
- end
59
-
60
- def test_render_as_list
61
- @breadcrumbs.add "Home", "/", :class => "home"
62
- list = parse_tag(@breadcrumbs.render)
63
- assert_equal "ul", list.name
64
- assert_equal "breadcrumbs", list['class']
65
- end
66
-
67
- def test_render_as_ordered_list
68
- @breadcrumbs.add "Home", "/"
69
- list = parse_tag(@breadcrumbs.render(:format => :ordered_list))
70
- assert_equal "ol", list.name
71
- assert_equal "breadcrumbs", list['class']
72
- end
73
-
74
- def test_render_as_list_with_custom_attributes
75
- @breadcrumbs.add "Home", "/", :class => "home"
76
- ul = parse_tag(@breadcrumbs.render(:id => "breadcrumbs", :class => "top"))
77
- assert_equal "ul", ul.name
78
- assert_equal "top", ul['class']
79
- assert_equal "breadcrumbs", ul['id']
80
- end
81
-
82
- def test_render_as_list_add_items
83
- @breadcrumbs.add "Home", "/", :class => "home"
84
- @breadcrumbs.add "About", "/about", :class => "about"
85
- @breadcrumbs.add "People"
86
-
87
- ul = parse_tag(@breadcrumbs.render)
88
- items = ul.children
89
-
90
- assert_equal 3, items.count
91
-
92
- assert_equal "first item-0", items[0]["class"]
93
- assert_equal %(<a href="/" class="home">Home</a>), items[0].children.join
94
-
95
- assert_equal "item-1", items[1]["class"]
96
- assert_equal %(<a href="/about" class="about">About</a>), items[1].children.join
97
-
98
- assert_equal "last item-2", items[2]["class"]
99
- assert_equal %(<span>People</span>), items[2].children.join
100
- end
101
-
102
- def test_render_inline
103
- @breadcrumbs.add "Home", "/", :class => "home"
104
- item = parse_tag(@breadcrumbs.render(:format => :inline))
105
- assert_not_equal 'ul', item.name
106
- end
107
-
108
- def test_render_inline_add_items
109
- @breadcrumbs.add "Home", "/", :class => "home"
110
- @breadcrumbs.add "About", "/about", :class => "about"
111
- @breadcrumbs.add "People"
112
-
113
- items = parse_tags(@breadcrumbs.render(:format => :inline))
114
- assert_equal 5, items.count
115
-
116
- assert_equal "a", items[0].name
117
- assert_equal "home first item-0", items[0]["class"]
118
- assert_equal "Home", items[0].children.join
119
- assert_equal "/", items[0]["href"]
120
-
121
- assert_equal "span", items[1].name
122
- assert_equal "separator", items[1]["class"]
123
- assert_equal "&#187;", items[1].children.join
124
-
125
- assert_equal "a", items[2].name
126
- assert_equal "about item-1", items[2]["class"]
127
- assert_equal "About", items[2].children.join
128
- assert_equal "/about", items[2]["href"]
129
-
130
- assert_equal "span", items[3].name
131
- assert_equal "separator", items[3]["class"]
132
- assert_equal "&#187;", items[3].children.join
133
-
134
- assert_equal "span", items[4].name
135
- assert_equal "last item-2", items[4]["class"]
136
- assert_equal "People", items[4].children.join
137
- end
138
-
139
- def test_render_inline_with_custom_separator
140
- @breadcrumbs.add "Home", "/", :class => "home"
141
- @breadcrumbs.add "People"
142
-
143
- tags = parse_tags(@breadcrumbs.render(:format => :inline, :separator => "|"))
144
- assert_equal [
145
- %(<a href="/" class="home first item-0">Home</a>),
146
- %(<span class="separator">|</span>),
147
- %(<span class="last item-1">People</span>)
148
- ], tags.map(&:to_s)
149
- end
150
-
151
- def test_render_original_text_when_disabling_translation
152
- @breadcrumbs.add :home, nil, :i18n => false
153
- @breadcrumbs.add :people
154
-
155
- items = parse_tag(@breadcrumbs.render).children
156
- assert_equal "<span>home</span>", items[0].children.join
157
- assert_equal "<span>Our team</span>", items[1].children.join
158
- end
159
-
160
- def test_render_internationalized_text_using_default_scope
161
- @breadcrumbs.add :home
162
- @breadcrumbs.add :people
163
-
164
- items = parse_tag(@breadcrumbs.render).children
165
- assert_equal "<span>Home page</span>", items[0].children.join
166
- assert_equal "<span>Our team</span>", items[1].children.join
167
- end
168
-
169
- def test_render_with_string_is_not_translated
170
- @breadcrumbs.add 'home'
171
- items = parse_tag(@breadcrumbs.render).children
172
- assert_equal "<span>home</span>", items[0].children.join
173
- end
174
-
175
- def test_render_scope_as_text_for_missing_scope
176
- @breadcrumbs.add :contact
177
- @breadcrumbs.add "Help"
178
-
179
- items = parse_tag(@breadcrumbs.render).children
180
- assert_equal "<span>contact</span>", items[0].children.join
181
- assert_equal "<span>Help</span>", items[1].children.join
182
- end
183
-
184
- def test_pimp_action_controller
185
- assert @controller.respond_to?(:breadcrumbs)
186
- assert_equal @controller.breadcrumbs, @controller.breadcrumbs
187
- end
188
-
189
- def test_escape_text_when_rendering_inline
190
- @breadcrumbs.add "<script>alert(1)</script>"
191
- html = @breadcrumbs.render(:format => :inline)
192
-
193
- assert_equal %[<span class="first last item-0">&lt;script&gt;alert(1)&lt;/script&gt;</span>], html
194
- end
195
-
196
- def test_escape_text_when_rendering_list
197
- @breadcrumbs.add "<script>alert(1)</script>"
198
- html = @breadcrumbs.render
199
-
200
- assert_match /&lt;script&gt;alert\(1\)&lt;\/script&gt;/, html
201
- end
202
-
203
- def test_with_polymorphic_urls
204
- @breadcrumbs.add "Resources", [:tests]
205
- prefix = "#{@controller.request.scheme}://#{@controller.request.host}"
206
- tag = parse_tag(@breadcrumbs.render(:format => :inline))
207
-
208
- assert_equal "a", tag.name
209
- assert_equal "first last item-0", tag['class']
210
- assert_equal "#{prefix}/tests", tag['href']
211
- assert_equal "Resources", tag.children.join
212
- end
213
-
214
- def test_crumb_shortcuts
215
- @breadcrumbs.crumb :users
216
- @breadcrumbs.crumb :users, :title => "Custom"
217
- @breadcrumbs.crumb :admin, :users
218
- @breadcrumbs.crumb :admin, User.new
219
-
220
- assert_equal ["Users", "http://test.host/users", {}], @breadcrumbs[0]
221
- assert_equal ["Custom", "http://test.host/users", {}], @breadcrumbs[1]
222
- assert_equal ["Users", "http://test.host/admin/users", {}], @breadcrumbs[2]
223
- assert_equal ["Sam", "http://test.host/admin/users/123", {}], @breadcrumbs[3]
224
- end
225
-
226
- private
227
-
228
- def reject_blanks!(tag)
229
- tag.children.reject! do |child|
230
- child.tag? ? (reject_blanks!(child) && false) : child.to_s.blank?
231
- end
232
- end
233
-
234
- def parse_tags(html)
235
- root = HTML::Document.new(html, true, true).root
236
- reject_blanks!(root)
237
- root.children
238
- end
239
-
240
- def parse_tag(html)
241
- parse_tags(html).first
242
- end
243
- end
@@ -1,12 +0,0 @@
1
- en:
2
- activemodel:
3
- models:
4
- user:
5
- one: User
6
- other: Users
7
-
8
- people: "Our team"
9
-
10
- breadcrumbs:
11
- home: "Home page"
12
- about: "About us"
data/test/test_helper.rb DELETED
@@ -1,43 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- Bundler.setup
4
- Bundler.require :default, :test
5
-
6
- require 'test/unit'
7
- require "breadcrumbs"
8
- require 'action_controller'
9
- require 'action_controller/test_case'
10
- require 'active_model/naming'
11
-
12
- I18n.load_path << File.dirname(__FILE__) + "/resources/en.yml"
13
- I18n.locale = :en
14
-
15
- class TestsController < ActionController::Base
16
- end
17
-
18
- class UsersController < ActionController::Base
19
- end
20
-
21
- module Admin
22
- class UsersController < ActionController::Base
23
- end
24
- end
25
-
26
- routes = ActionDispatch::Routing::RouteSet.new
27
- routes.draw do
28
- resources :tests
29
- resources :users
30
- namespace :admin do
31
- resources :users
32
- end
33
- end
34
- TestsController.send(:include, routes.url_helpers)
35
-
36
- class User
37
- extend ActiveModel::Naming
38
- extend ActiveModel::Translation
39
-
40
- def to_param; "123" end
41
- def name_was; "Sam" end
42
- def name; "" end
43
- end