breadcrumbs 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/.github/FUNDING.yml +3 -0
  3. data/.gitignore +4 -0
  4. data/.rubocop.yml +22 -0
  5. data/.travis.yml +11 -0
  6. data/Gemfile +4 -0
  7. data/README.md +143 -0
  8. data/Rakefile +15 -0
  9. data/breadcrumbs.gemspec +38 -0
  10. data/examples/myapp/.gitignore +12 -0
  11. data/examples/myapp/Gemfile +12 -0
  12. data/examples/myapp/README.rdoc +28 -0
  13. data/examples/myapp/Rakefile +6 -0
  14. data/examples/myapp/app/assets/images/.keep +0 -0
  15. data/examples/myapp/app/assets/stylesheets/application.css +49 -0
  16. data/examples/myapp/app/controllers/application_controller.rb +13 -0
  17. data/examples/myapp/app/controllers/concerns/.keep +0 -0
  18. data/examples/myapp/app/controllers/site_controller.rb +9 -0
  19. data/examples/myapp/app/helpers/application_helper.rb +2 -0
  20. data/examples/myapp/app/mailers/.keep +0 -0
  21. data/examples/myapp/app/models/.keep +0 -0
  22. data/examples/myapp/app/models/concerns/.keep +0 -0
  23. data/examples/myapp/app/views/layouts/application.html.erb +15 -0
  24. data/examples/myapp/app/views/site/contact.html.erb +1 -0
  25. data/examples/myapp/app/views/site/home.html.erb +1 -0
  26. data/examples/myapp/bin/bundle +3 -0
  27. data/examples/myapp/bin/rails +4 -0
  28. data/examples/myapp/bin/rake +4 -0
  29. data/examples/myapp/bin/setup +29 -0
  30. data/examples/myapp/config.ru +4 -0
  31. data/examples/myapp/config/application.rb +30 -0
  32. data/examples/myapp/config/boot.rb +3 -0
  33. data/examples/myapp/config/environment.rb +5 -0
  34. data/examples/myapp/config/environments/development.rb +38 -0
  35. data/examples/myapp/config/environments/production.rb +73 -0
  36. data/examples/myapp/config/environments/test.rb +39 -0
  37. data/examples/myapp/config/initializers/assets.rb +11 -0
  38. data/examples/myapp/config/initializers/backtrace_silencers.rb +7 -0
  39. data/examples/myapp/config/initializers/cookies_serializer.rb +3 -0
  40. data/examples/myapp/config/initializers/filter_parameter_logging.rb +4 -0
  41. data/examples/myapp/config/initializers/inflections.rb +16 -0
  42. data/examples/myapp/config/initializers/mime_types.rb +4 -0
  43. data/examples/myapp/config/initializers/session_store.rb +3 -0
  44. data/examples/myapp/config/initializers/wrap_parameters.rb +9 -0
  45. data/examples/myapp/config/locales/en.yml +28 -0
  46. data/examples/myapp/config/routes.rb +5 -0
  47. data/examples/myapp/config/secrets.yml +22 -0
  48. data/examples/myapp/db/seeds.rb +7 -0
  49. data/examples/myapp/lib/assets/.keep +0 -0
  50. data/examples/myapp/lib/tasks/.keep +0 -0
  51. data/examples/myapp/log/.keep +0 -0
  52. data/examples/myapp/public/404.html +67 -0
  53. data/examples/myapp/public/422.html +67 -0
  54. data/examples/myapp/public/500.html +66 -0
  55. data/examples/myapp/public/favicon.ico +0 -0
  56. data/examples/myapp/public/robots.txt +5 -0
  57. data/examples/myapp/vendor/assets/stylesheets/.keep +0 -0
  58. data/lib/breadcrumbs.rb +49 -19
  59. data/lib/breadcrumbs/action_controller_ext.rb +3 -1
  60. data/lib/breadcrumbs/render.rb +10 -3
  61. data/lib/breadcrumbs/render/base.rb +14 -17
  62. data/lib/breadcrumbs/render/inline.rb +12 -14
  63. data/lib/breadcrumbs/render/list.rb +13 -9
  64. data/lib/breadcrumbs/render/ordered_list.rb +11 -0
  65. data/lib/breadcrumbs/version.rb +4 -2
  66. data/test/breadcrumbs_test.rb +45 -30
  67. data/test/{resources/pt.yml → support/pt-BR.yml} +2 -2
  68. data/test/test_helper.rb +11 -4
  69. metadata +273 -50
  70. data/README.rdoc +0 -96
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 638b77085849ea1f06cb4c55b11f3baecaaeae84b5fce2c98e8421ac18e20929
4
+ data.tar.gz: 3bd0227aa31d6630f29b6d2c7e37a1ba3a76df992cfe716bb1bc343473abff19
5
+ SHA512:
6
+ metadata.gz: 676edfeedcdd4a914bfbb2ad3caa6a29e6be4ab9f50f4106f715510a52a669eca7504c1ee99854f712cb929a0723436d7cfd63fccd8e471050249c4c40ef9e1e
7
+ data.tar.gz: 4a015506ccc94efa8cd8b228ac38dda10409e88e60191036a4e3fc5a6fc1f909e36292b9fe3dace9cf5541bc4886f0e5491e250f7a1386aaab66c620e2802bb7
@@ -0,0 +1,3 @@
1
+ ---
2
+ github: [fnando]
3
+ custom: ["https://www.paypal.me/nandovieira/🍕"]
@@ -0,0 +1,4 @@
1
+ pkg
2
+ doc
3
+ *.lock
4
+ coverage
@@ -0,0 +1,22 @@
1
+ ---
2
+ inherit_gem:
3
+ rubocop-fnando: .rubocop.yml
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.7
7
+ NewCops: enable
8
+ Exclude:
9
+ - examples/**/*
10
+ - vendor/**/*
11
+
12
+ Metrics/MethodLength:
13
+ Enabled: false
14
+
15
+ Metrics/AbcSize:
16
+ Enabled: false
17
+
18
+ Metrics/MethodLength:
19
+ Enabled: false
20
+
21
+ Metrics/ClassLength:
22
+ Enabled: false
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ cache: bundler
3
+ sudo: false
4
+ rvm:
5
+ - 2.7.1
6
+ - 2.6.5
7
+ notifications:
8
+ email: false
9
+ env:
10
+ global:
11
+ secure: e3cKbK2ru5Wx2Jir+PUUTQFx/lrYESRMhqPPgGQ1Eq6Xc8kQ+ACxuLmgFZEZOD1aUlCVfvm8kpIJ8uVhKystwotjV3ObK2imgWvpoJLfvgIWXZ3dhIWmVI98Da1I2t66LM+1l9LREzQm2bN7zAx7NPr2oRHasDpuNc13BnIcIsg=
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec
@@ -0,0 +1,143 @@
1
+ # Breadcrumbs
2
+
3
+ [![Travis-CI](https://travis-ci.org/fnando/breadcrumbs.svg)](https://travis-ci.org/fnando/breadcrumbs)
4
+ [![Code Climate](https://codeclimate.com/github/fnando/breadcrumbs/badges/gpa.svg)](https://codeclimate.com/github/fnando/breadcrumbs)
5
+ [![Gem](https://img.shields.io/gem/v/breadcrumbs.svg)](https://rubygems.org/gems/breadcrumbs)
6
+ [![Gem](https://img.shields.io/gem/dt/breadcrumbs.svg)](https://rubygems.org/gems/breadcrumbs)
7
+
8
+ Breadcrumbs is a simple plugin that adds a `breadcrumbs` object to controllers
9
+ and views.
10
+
11
+ ## Instalation
12
+
13
+ Just run `gem install breadcrumbs`. Or add `gem "breadcrumbs"` to your Gemfile.
14
+
15
+ ## Usage
16
+
17
+ On your controller (optional):
18
+
19
+ ```ruby
20
+ class ApplicationController < ActionController::Base
21
+ before_filter :add_initial_breadcrumbs
22
+
23
+ private
24
+ def add_initial_breadcrumbs
25
+ breadcrumbs.add "Home", root_path
26
+ end
27
+ end
28
+
29
+ class ThingsController < ApplicationController
30
+ def index
31
+ breadcrumbs.add "Things", things_path
32
+ end
33
+ end
34
+ ```
35
+
36
+ You don't need to provide an URL; in that case, a span will be generated instead
37
+ of a link:
38
+
39
+ ```ruby
40
+ breadcrumbs.add "Some page"
41
+ ```
42
+
43
+ You can set additional HTML attributes if you need to:
44
+
45
+ ```ruby
46
+ breadcrumbs.add "Home", root_path, id: "home", title: "Go to the home page"
47
+ ```
48
+
49
+ On your view (possibly application.html.erb):
50
+
51
+ ```erb
52
+ <%= breadcrumbs.render %>
53
+ ```
54
+
55
+ You can render as ordered list.
56
+
57
+ ```erb
58
+ <%= breadcrumbs.render(format: :ordered_list) %>
59
+ ```
60
+
61
+ You can render as inline links.
62
+
63
+ ```erb
64
+ <%= breadcrumbs.render(format: :inline) %>
65
+ ```
66
+
67
+ You can set your own separator:
68
+
69
+ ```erb
70
+ <p>
71
+ You are here: <%= breadcrumbs.render(format: :inline, separator: "|") %>
72
+ </p>
73
+ ```
74
+
75
+ You can also define your own formatter. Just create a class that implements a
76
+ `render` instance method and you're good to go.
77
+
78
+ ```ruby
79
+ class Breadcrumbs::Render::Dl
80
+ def render
81
+ # return breadcrumbs wrapped in a <dl> tag
82
+ end
83
+ end
84
+ ```
85
+
86
+ To use your new format, just provide the `:format` option.
87
+
88
+ ```ruby
89
+ breadcrumbs.render(format: :dl)
90
+ ```
91
+
92
+ ### I18n
93
+
94
+ Breadcrumbs is integrated with I18n. You can set translations like:
95
+
96
+ ```yaml
97
+ en:
98
+ breadcrumbs:
99
+ home: "Home"
100
+ ```
101
+
102
+ And then you just call
103
+
104
+ ```ruby
105
+ breadcrumbs.add :home
106
+ ```
107
+
108
+ In fact, you can provide any scope you want.
109
+
110
+ ```ruby
111
+ breadcrumbs.add :"titles.home"
112
+ ```
113
+
114
+ If you don't want to translate a label, just pass the option `:i18n` as `false`.
115
+
116
+ ```ruby
117
+ breadcrumbs.add :home, nil, i18n: false
118
+ ```
119
+
120
+ ## Maintainer
121
+
122
+ - Nando Vieira - http://nandovieira.com
123
+
124
+ ## License
125
+
126
+ (The MIT License)
127
+
128
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
129
+ this software and associated documentation files (the 'Software'), to deal in
130
+ the Software without restriction, including without limitation the rights to
131
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
132
+ the Software, and to permit persons to whom the Software is furnished to do so,
133
+ subject to the following conditions:
134
+
135
+ The above copyright notice and this permission notice shall be included in all
136
+ copies or substantial portions of the Software.
137
+
138
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
139
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
140
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
141
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
142
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
143
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+ require "rubocop/rake_task"
6
+
7
+ Rake::TestTask.new(:test) do |t|
8
+ t.libs << "test"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ t.warning = false
11
+ end
12
+
13
+ RuboCop::RakeTask.new
14
+
15
+ task default: %i[test rubocop]
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "./lib/breadcrumbs/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "breadcrumbs"
7
+ s.version = Breadcrumbs::Version::STRING
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Nando Vieira"]
10
+ s.email = ["fnando.vieira@gmail.com"]
11
+ s.homepage = "http://rubygems.org/gems/breadcrumbs"
12
+ s.summary = "Breadcrumbs is a simple plugin that adds a `breadcrumbs` " \
13
+ "object to controllers and views."
14
+ s.description = s.summary
15
+ s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`
20
+ .split("\n")
21
+ .map {|f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+
24
+ s.add_dependency "actionview"
25
+ s.add_dependency "activesupport"
26
+ s.add_dependency "i18n"
27
+
28
+ s.add_development_dependency "actionpack"
29
+ s.add_development_dependency "bundler"
30
+ s.add_development_dependency "minitest-utils"
31
+ s.add_development_dependency "mocha"
32
+ s.add_development_dependency "nokogiri"
33
+ s.add_development_dependency "pry-meta"
34
+ s.add_development_dependency "rake"
35
+ s.add_development_dependency "rubocop"
36
+ s.add_development_dependency "rubocop-fnando"
37
+ s.add_development_dependency "simplecov"
38
+ end
@@ -0,0 +1,12 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore all logfiles and tempfiles.
11
+ /log/*.log
12
+ /tmp
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '4.2.0.beta1'
4
+ gem 'sass-rails', '~> 5.0.0.beta1'
5
+ gem 'uglifier', '>= 1.3.0'
6
+ gem 'rails-html-sanitizer', '~> 1.0'
7
+ gem 'breadcrumbs', path: '../..'
8
+
9
+ group :development, :test do
10
+ gem 'spring'
11
+ end
12
+
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
File without changes
@@ -0,0 +1,49 @@
1
+ /*
2
+ *= require_tree .
3
+ *= require_self
4
+ */
5
+
6
+ .breadcrumbs {
7
+ font-family: sans-serif;
8
+ font-size: 14px;
9
+ background: #f5f5f5;
10
+ list-style: none;
11
+ margin: 0;
12
+ padding: 10px;
13
+ overflow: hidden;
14
+ color: #777;
15
+ border-radius: 5px;
16
+ }
17
+
18
+ .breadcrumbs li {
19
+ float: left;
20
+ }
21
+
22
+ .breadcrumbs li + li:before {
23
+ content: '/';
24
+ color: #ccc;
25
+ margin: 0 10px;
26
+ }
27
+
28
+ .breadcrumbs a {
29
+ color: #428bca;
30
+ text-decoration: none;
31
+ }
32
+
33
+ .breadcrumbs a:hover {
34
+ text-decoration: underline;
35
+ }
36
+
37
+ .breadcrumbs .first {
38
+ position: relative;
39
+ padding-left: 18px;
40
+ }
41
+
42
+ .breadcrumbs .first:before {
43
+ content: '\2302';
44
+ font-size: 20px;
45
+ position: absolute;
46
+ left: 0;
47
+ top: -2px;
48
+ color: #ccc;
49
+ }
@@ -0,0 +1,13 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+
6
+ before_action :set_root_breadcrumb
7
+
8
+ private
9
+
10
+ def set_root_breadcrumb
11
+ breadcrumbs.add :home, root_path
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class SiteController < ApplicationController
2
+ def home
3
+ end
4
+
5
+ def contact
6
+ breadcrumbs.add :pages
7
+ breadcrumbs.add :contact, contact_path
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Myapp</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all' %>
6
+ <%= csrf_meta_tags %>
7
+ </head>
8
+ <body>
9
+
10
+ <%= breadcrumbs.render(format: 'list') %>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -0,0 +1 @@
1
+ <h1>Contact</h1>
@@ -0,0 +1 @@
1
+ <h1>Home page</h1>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'