crummy 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/.gitignore +1 -1
  2. data/.rvmrc +48 -0
  3. data/.travis.yml +13 -0
  4. data/CHANGELOG +3 -0
  5. data/README.md +78 -55
  6. data/example/.gitignore +5 -0
  7. data/example/.rspec +1 -0
  8. data/example/.rvmrc +48 -0
  9. data/example/Gemfile +30 -0
  10. data/example/README.md +40 -0
  11. data/example/Rakefile +7 -0
  12. data/example/app/assets/images/rails.png +0 -0
  13. data/example/app/assets/javascripts/application.js +9 -0
  14. data/example/app/assets/javascripts/pages.js.coffee +3 -0
  15. data/example/app/assets/javascripts/post.js.coffee +3 -0
  16. data/example/app/assets/stylesheets/application.css +7 -0
  17. data/example/app/assets/stylesheets/layout.css.sass +26 -0
  18. data/example/app/assets/stylesheets/post.css.scss +3 -0
  19. data/example/app/controllers/application_controller.rb +6 -0
  20. data/example/app/controllers/pages_controller.rb +5 -0
  21. data/example/app/controllers/posts_controller.rb +19 -0
  22. data/example/app/helpers/application_helper.rb +9 -0
  23. data/example/app/helpers/pages_helper.rb +2 -0
  24. data/example/app/helpers/post_helper.rb +2 -0
  25. data/example/app/mailers/.gitkeep +0 -0
  26. data/example/app/models/.gitkeep +0 -0
  27. data/example/app/models/category.rb +6 -0
  28. data/example/app/models/post.rb +19 -0
  29. data/example/app/views/layouts/application.html.haml +16 -0
  30. data/example/app/views/pages/index.html.haml +4 -0
  31. data/example/app/views/posts/index.html.haml +5 -0
  32. data/example/app/views/posts/new.html.haml +1 -0
  33. data/example/app/views/posts/show.html.haml +3 -0
  34. data/example/config.ru +4 -0
  35. data/example/config/application.rb +48 -0
  36. data/example/config/boot.rb +6 -0
  37. data/example/config/database.yml +25 -0
  38. data/example/config/environment.rb +5 -0
  39. data/example/config/environments/development.rb +30 -0
  40. data/example/config/environments/production.rb +60 -0
  41. data/example/config/environments/test.rb +39 -0
  42. data/example/config/initializers/backtrace_silencers.rb +7 -0
  43. data/example/config/initializers/inflections.rb +10 -0
  44. data/example/config/initializers/mime_types.rb +5 -0
  45. data/example/config/initializers/secret_token.rb +7 -0
  46. data/example/config/initializers/session_store.rb +8 -0
  47. data/example/config/initializers/wrap_parameters.rb +14 -0
  48. data/example/config/locales/en.yml +5 -0
  49. data/example/config/routes.rb +5 -0
  50. data/example/db/migrate/20111104103150_create_posts.rb +10 -0
  51. data/example/db/migrate/20111104103738_create_categories.rb +12 -0
  52. data/example/db/migrate/20111104104040_add_category_id_to_posts.rb +5 -0
  53. data/example/db/schema.rb +32 -0
  54. data/example/db/seeds.rb +15 -0
  55. data/example/doc/README_FOR_APP +2 -0
  56. data/example/lib/assets/.gitkeep +0 -0
  57. data/example/lib/tasks/.gitkeep +0 -0
  58. data/example/log/.gitkeep +0 -0
  59. data/example/public/404.html +26 -0
  60. data/example/public/422.html +26 -0
  61. data/example/public/500.html +26 -0
  62. data/example/public/favicon.ico +0 -0
  63. data/example/public/robots.txt +5 -0
  64. data/example/script/rails +6 -0
  65. data/example/spec/controllers/posts_controller_spec.rb +7 -0
  66. data/example/spec/spec_helper.rb +38 -0
  67. data/example/vendor/assets/stylesheets/.gitkeep +0 -0
  68. data/example/vendor/plugins/.gitkeep +0 -0
  69. data/gemfiles/rails3_2/Gemfile +6 -0
  70. data/gemfiles/rails4_0/Gemfile +6 -0
  71. data/lib/crummy.rb +10 -2
  72. data/lib/crummy/standard_renderer.rb +14 -13
  73. data/lib/crummy/version.rb +1 -1
  74. data/test/standard_renderer_test.rb +33 -3
  75. metadata +78 -10
data/.gitignore CHANGED
@@ -2,5 +2,5 @@ rdoc
2
2
  nbproject
3
3
  *.gem
4
4
  .bundle
5
- Gemfile.lock
6
5
  pkg/*
6
+ Gemfile.lock
data/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-head@crummy"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.17.7 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ gemfile:
6
+ - gemfiles/rails3_2/Gemfile
7
+ - gemfiles/rails4_0/Gemfile
8
+ matrix:
9
+ allow_failures:
10
+ - rvm: 1.9.3
11
+ gemfile: gemfiles/rails4_0/Gemfile
12
+ - rvm: 2.0.0
13
+ gemfile: gemfiles/rails4_0/Gemfile
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ 1.7.1
2
+ * [ADDED] :last_crumb_linked option to disable linking crumb on current page
3
+
1
4
  1.7.0
2
5
  * [ADDED] Added option for google microdata
3
6
  * [REFACTORED] Cleaned up development internals
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Crummy
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/crummy.png)](http://badge.fury.io/rb/crummy)
4
- [![Build Status](https://secure.travis-ci.org/zachinglis/crummy.png?branch=master)](http://travis-ci.org/zachinglis/crummy)
4
+ [![Build Status](https://secure.travis-ci.org/zachinglis/crummy.png)](http://travis-ci.org/zachinglis/crummy)
5
5
  [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/zachinglis/crummy)
6
6
 
7
7
  Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.
@@ -10,38 +10,44 @@ Crummy is a simple and tasty way to add breadcrumbs to your Rails applications.
10
10
 
11
11
  Simply add the dependency to your Gemfile:
12
12
 
13
- gem "crummy", "~> 1.6.0"
13
+ ```ruby
14
+ gem "crummy", "~> 1.7.1"
15
+ ```
14
16
 
15
17
  # Example
16
18
 
17
19
  In your controllers you may add\_crumb either like a before\_filter or
18
20
  within a method (It is also available to views).
19
21
 
20
- class ApplicationController
21
- add_crumb "Home", '/'
22
- end
22
+ ```ruby
23
+ class ApplicationController
24
+ add_crumb "Home", '/'
25
+ end
23
26
 
24
- class BusinessController < ApplicationController
25
- add_crumb("Businesses") { |instance| instance.send :businesses_path }
26
- add_crumb("Comments", :only => "comments") { |instance| instance.send :businesses_comments_path }
27
- before_filter :load_comment, :only => "show"
28
- add_crumb :comment, :only => "show"
27
+ class BusinessController < ApplicationController
28
+ add_crumb("Businesses") { |instance| instance.send :businesses_path }
29
+ add_crumb("Comments", only: "comments") { |instance| instance.send :businesses_comments_path }
30
+ before_filter :load_comment, only: "show"
31
+ add_crumb :comment, only: "show"
29
32
 
30
- # Example for nested routes:
31
- add_crumb(:document) { [:account, :document] }
33
+ # Example for nested routes:
34
+ add_crumb(:document) { [:account, :document] }
32
35
 
33
- def show
34
- add_crumb @business.display_name, @business
35
- end
36
+ def show
37
+ add_crumb @business.display_name, @business
38
+ end
36
39
 
37
- def load_comment
38
- @comment = Comment.find(params[:id])
39
- end
40
- end
40
+ def load_comment
41
+ @comment = Comment.find(params[:id])
42
+ end
43
+ end
44
+ ```
41
45
 
42
46
  Then in your view:
43
47
 
44
- <%= render_crumbs %>
48
+ ```erb
49
+ <%= render_crumbs %>
50
+ ```
45
51
 
46
52
  ## Options for render\_crumbs
47
53
 
@@ -52,42 +58,57 @@ It takes 3 options
52
58
  The output format. Can either be :xml or :html or :html\_list. Defaults
53
59
  to :html
54
60
 
55
- :format => (:html|:html_list|:xml)
61
+ ```ruby
62
+ format: (:html|:html_list|:xml)
63
+ ```
56
64
 
57
65
  The separator text. It does not assume you want spaces on either side so
58
66
  you must specify. Defaults to `&raquo;` for :html and
59
67
  `<crumb>` for :xml
60
68
 
61
- :separator => string
69
+ ```ruby
70
+ separator: string
71
+ ```
62
72
 
63
73
  Render links in the output. Defaults to *true*
64
74
 
65
- :links => boolean
75
+ ```ruby
76
+ links: boolean
66
77
 
67
- :skip_if_blank => true
78
+ skip_if_blank: true
79
+ ```
68
80
 
69
81
  Render
70
82
  [Richsnipet](http:/support.google.com/webmasters/bin/answer.py?hl=en&answer=99170&topic=1088472&ctx=topic/)
71
83
  Default to *false*
72
84
 
73
- :microdata => true
85
+ ```
86
+ last_crumb_linked: false
87
+ ```
88
+
89
+ Optionally disable linking of the last crumb, Defaults to *true*
90
+
91
+ ```ruby
92
+ microdata: true
93
+ ```
74
94
 
75
95
  With this option, output will be blank if there are no breadcrumbs.
76
96
 
77
97
  ### Examples
78
98
 
79
- render_crumbs #=> <a href="/">Home</a> &raquo; <a href="/businesses">Businesses</a>
80
- render_crumbs :separator => ' | ' #=> <a href="/">Home</a> | <a href="/businesses">Businesses</a>
81
- render_crumbs :format => :xml #=> <crumb href="/">Home</crumb><crumb href="/businesses">Businesses</crumb>
82
- render_crumbs :format => :html_list #=> <ul class="" id=""><li class=""><a href="/">Home</a></li><li class=""><a href="/">Businesses</a></li></ul>
83
- render_crumbs :format => :html_list, :microdata => true
84
- #=> <ul class="" id=""><li class="" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
85
- # <a href="/" itemprop="url"><span itemprop="title">Home</span></a></li></ul>
99
+ ```ruby
100
+ render_crumbs #=> <a href="/">Home</a> &raquo; <a href="/businesses">Businesses</a>
101
+ render_crumbs separator: ' | ' #=> <a href="/">Home</a> | <a href="/businesses">Businesses</a>
102
+ render_crumbs format: :xml #=> <crumb href="/">Home</crumb><crumb href="/businesses">Businesses</crumb>
103
+ render_crumbs format: :html_list #=> <ul class="" id=""><li class=""><a href="/">Home</a></li><li class=""><a href="/">Businesses</a></li></ul>
104
+ render_crumbs format: :html_list, :microdata => true
105
+ #=> <ul class="" id=""><li class="" itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb">
106
+ # <a href="/" itemprop="url"><span itemprop="title">Home</span></a></li></ul>
107
+ ```
86
108
 
87
109
  A crumb with a nil argument for the link will output an unlinked crumb.
88
110
 
89
- With `:format => :html_list` you can specify additional `params:
90
- :active_li_class, :li_class, :ul_class, :ul_id`
111
+ With `format: :html_list` you can specify additional `params: :li_class, :ul_class, :ul_id`
91
112
 
92
113
  ### App-wide configuration
93
114
 
@@ -102,31 +123,34 @@ overridden in the view.
102
123
 
103
124
  Insert the following in a file named `config/initializers/crummy.rb`:
104
125
 
105
- Crummy.configure do |config|
106
- config.format = :xml
107
- end
126
+ ```ruby
127
+ Crummy.configure do |config|
128
+ config.format = :xml
129
+ end
130
+ ```
108
131
 
109
132
  Possible parameters for configuration are:
110
133
 
111
- :format
112
- :links
113
- :skip_if_blank
114
- :html_separator
115
- :xml_separator
116
- :html_list_separator
117
- :first_class
118
- :last_class
119
- :ul_id
120
- :ul_class
121
- :li_class
122
- :active_li_class
123
- :microdata
134
+ ```ruby
135
+ :format
136
+ :links
137
+ :skip_if_blank
138
+ :html_separator
139
+ :xml_separator
140
+ :html_list_separator
141
+ :first_class
142
+ :last_class
143
+ :ul_id
144
+ :ul_class
145
+ :li_class
146
+ :microdata
147
+ ```
124
148
 
125
149
  See `lib/crummy.rb` for a list of these parameters and their defaults.
126
150
 
127
- ## Notes
151
+ ## Live example application
128
152
 
129
- Test library is at [Crummy Test](https://github.com/zachinglis/crummy-test)
153
+ An example application is available right inside this gem. That application is documented, see `example/README` for details about usage.
130
154
 
131
155
  ## Todo
132
156
 
@@ -138,8 +162,8 @@ Test library is at [Crummy Test](https://github.com/zachinglis/crummy-test)
138
162
 
139
163
  ## Credits
140
164
 
141
- - [Zach Inglis](http://zachinglis.com) of [London
142
- Made](http://londonmade.co.uk)
165
+ - [Zach Inglis](http://zachinglis.com) of [Superhero Studios](http://superhero-studios.com)
166
+ - [Andrew Nesbitt](http://github.com/andrew)
143
167
  - [Rein Henrichs](http://reinh.com)
144
168
  - [Les Hill](http://blog.leshill.org/)
145
169
  - [Sandro Turriate](http://turriate.com/)
@@ -157,6 +181,5 @@ Test library is at [Crummy Test](https://github.com/zachinglis/crummy-test)
157
181
  - [Jan Szumiec](http://github.com/jasiek)
158
182
  - [Jeff Browning](http://github.com/jbrowning)
159
183
  - [Bill Turner](http://github.com/billturner)
160
- - [Andrew Nesbitt](http://github.com/andrew)
161
184
 
162
185
  **Copyright 2008-2013 Zach Inglis, released under the MIT license**
@@ -0,0 +1,5 @@
1
+ .bundle
2
+ db/*.sqlite3
3
+ log/*.log
4
+ tmp/
5
+ .sass-cache/
@@ -0,0 +1 @@
1
+ --color --format documentation
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-head@crummy-test"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.17.7 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
@@ -0,0 +1,30 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '3.1.1'
4
+
5
+ # Bundle edge Rails instead:
6
+ # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
+
8
+ gem 'sqlite3'
9
+
10
+ # Gems used only for assets and not required
11
+ # in production environments by default.
12
+ group :assets do
13
+ gem 'sass-rails', '~> 3.1.4'
14
+ gem 'coffee-rails', '~> 3.1.1'
15
+ gem 'uglifier', '>= 1.0.3'
16
+ end
17
+
18
+ gem 'jquery-rails'
19
+
20
+ gem 'haml'
21
+ gem 'crummy', :path => '../'
22
+
23
+ group :test do
24
+ # Pretty printed test output
25
+ gem 'turn', :require => false
26
+ end
27
+
28
+ group :test, :development do
29
+ gem "rspec-rails", "~> 2.0"
30
+ end
@@ -0,0 +1,40 @@
1
+ # Crummy Test
2
+
3
+ ## Introduction
4
+
5
+ This is a test application for [Crummy][crummy], and also a good place where you can see it in action.
6
+
7
+ [crummy]: http://github.com/zachinglis/crummy
8
+
9
+ ## Usage
10
+
11
+ I recommend you to use [RVM][rvm] in order to keep this application gemset distinct from the gem one. Here we use a full Rails stack, which is not true when developping the gem. I you only want to see Crummy in action, you might not care about that. Anyways RVM is not required, but if you use it you'll find an `.rvmrc` file for each context: `example/.rvmrc` and `.rvmrc` respectively for the example app and the gem. Using them is easy and only requires to take care of the directory from where you `bundle install`: if from `example`, you'll update the app bundle, else the gem bundle.
12
+
13
+ [rvm]: https://rvm.io
14
+
15
+ To quickly start the example app:
16
+
17
+ ```bash
18
+ # Enter the example directory and trust the .rvmrc file
19
+ cd crummy/example
20
+
21
+ # Install the bundle
22
+ bundle install
23
+ # Create the database
24
+ bundle exec rake db:schema:load
25
+ bundle exec rake db:seed
26
+ # Create the test database
27
+ bundle exec rake db:test:clone
28
+
29
+ # Get the tests green
30
+ bundle exec rake
31
+
32
+ # Start the server
33
+ rails server
34
+ ```
35
+
36
+ Your app waits for you at [http://localhost:3000](http://localhost:3000).
37
+
38
+ * * *
39
+
40
+ I hope this makes the example application a better place to test the gem.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ CrummyTest::Application.load_tasks
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/