dat_gretel 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/.travis.yml +16 -0
- data/CHANGELOG.md +56 -0
- data/Gemfile +23 -0
- data/LICENSE.txt +22 -0
- data/README.md +359 -0
- data/Rakefile +10 -0
- data/dat_gretel.gemspec +22 -0
- data/gemfiles/Gemfile-rails.3.1.x +19 -0
- data/gemfiles/Gemfile-rails.3.2.x +19 -0
- data/gemfiles/Gemfile-rails.4.0.x +19 -0
- data/gemfiles/Gemfile-rails.4.1.x +19 -0
- data/gemfiles/Gemfile-rails.5.2.x +19 -0
- data/lib/dat_gretel.rb +82 -0
- data/lib/dat_gretel/crumb.rb +70 -0
- data/lib/dat_gretel/crumbs.rb +64 -0
- data/lib/dat_gretel/deprecated.rb +1 -0
- data/lib/dat_gretel/deprecated/default_style_key.rb +25 -0
- data/lib/dat_gretel/deprecated/layout.rb +15 -0
- data/lib/dat_gretel/deprecated/show_root_alone.rb +27 -0
- data/lib/dat_gretel/deprecated/yield_links.rb +44 -0
- data/lib/dat_gretel/link.rb +40 -0
- data/lib/dat_gretel/renderer.rb +259 -0
- data/lib/dat_gretel/resettable.rb +13 -0
- data/lib/dat_gretel/version.rb +3 -0
- data/lib/dat_gretel/view_helpers.rb +71 -0
- data/lib/generators/dat_gretel/USAGE +8 -0
- data/lib/generators/dat_gretel/install_generator.rb +12 -0
- data/lib/generators/dat_gretel/templates/breadcrumbs.rb +28 -0
- data/test/dat_gretel_test.rb +24 -0
- data/test/deprecated_test.rb +45 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +5 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/models/issue.rb +3 -0
- data/test/dummy/app/models/project.rb +3 -0
- data/test/dummy/app/views/breadcrumbs/site.rb +3 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +14 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/breadcrumbs.rb +3 -0
- data/test/dummy/config/breadcrumbs/test_crumbs.rb +85 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +2 -0
- data/test/dummy/config/environments/production.rb +2 -0
- data/test/dummy/config/environments/test.rb +2 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +11 -0
- data/test/dummy/db/migrate/20130122163007_create_projects.rb +9 -0
- data/test/dummy/db/migrate/20130122163051_create_issues.rb +10 -0
- data/test/dummy/db/schema.rb +28 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/fixtures/issues.yml +4 -0
- data/test/fixtures/projects.yml +3 -0
- data/test/gretel_test.rb +24 -0
- data/test/helper_methods_test.rb +552 -0
- data/test/test_helper.rb +15 -0
- metadata +193 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DeprecatedTest < ActionView::TestCase
|
4
|
+
include Gretel::ViewHelpers
|
5
|
+
fixtures :all
|
6
|
+
helper :application
|
7
|
+
|
8
|
+
setup do
|
9
|
+
Gretel.reset!
|
10
|
+
Gretel.suppress_deprecation_warnings = true
|
11
|
+
end
|
12
|
+
|
13
|
+
test "show root alone" do
|
14
|
+
breadcrumb :root
|
15
|
+
assert_equal %{<div class="breadcrumbs"><span class="current">Home</span></div>},
|
16
|
+
breadcrumbs(show_root_alone: true).to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
test "deprecated configuration block" do
|
20
|
+
assert_raises RuntimeError do
|
21
|
+
Gretel::Crumbs.layout do
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
test ":default style key" do
|
27
|
+
breadcrumb :basic
|
28
|
+
|
29
|
+
assert_equal %{<div class="breadcrumbs"><a href="/">Home</a> › <span class="current">About</span></div>},
|
30
|
+
breadcrumbs(style: :default).to_s
|
31
|
+
end
|
32
|
+
|
33
|
+
test "yield links" do
|
34
|
+
breadcrumb :multiple_links_with_parent
|
35
|
+
|
36
|
+
out = breadcrumbs do |links|
|
37
|
+
links.map { |link| [link.key, link.text, link.url] }
|
38
|
+
end
|
39
|
+
|
40
|
+
assert_equal [[:root, "Home", "/"],
|
41
|
+
[:basic, "About", "/about"],
|
42
|
+
[:multiple_links_with_parent, "Contact", "/about/contact"],
|
43
|
+
[:multiple_links_with_parent, "Contact form", "/about/contact/form"]], out
|
44
|
+
end
|
45
|
+
end
|
data/test/dummy/Rakefile
ADDED
@@ -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
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
File without changes
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require
|
6
|
+
require "gretel"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
config.secret_token = "secret token"
|
11
|
+
config.active_support.deprecation = :log
|
12
|
+
config.eager_load = false
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
crumb :basic do
|
2
|
+
link "About", about_path
|
3
|
+
end
|
4
|
+
|
5
|
+
crumb :with_root do
|
6
|
+
link "About", about_path
|
7
|
+
parent :root
|
8
|
+
end
|
9
|
+
|
10
|
+
crumb :with_parent do
|
11
|
+
link "Contact", contact_path
|
12
|
+
parent :basic
|
13
|
+
end
|
14
|
+
|
15
|
+
crumb :object do |project|
|
16
|
+
link project.name, project
|
17
|
+
end
|
18
|
+
|
19
|
+
crumb :with_autopath do |project|
|
20
|
+
link project.name, project
|
21
|
+
end
|
22
|
+
|
23
|
+
crumb :with_parent_object do |issue|
|
24
|
+
link issue.title, project_issue_path(issue.project, issue)
|
25
|
+
parent :object, issue.project
|
26
|
+
end
|
27
|
+
|
28
|
+
crumb :multiple_links do
|
29
|
+
link "Contact", contact_path
|
30
|
+
link "Contact form", contact_form_path
|
31
|
+
end
|
32
|
+
|
33
|
+
crumb :multiple_links_with_parent do
|
34
|
+
link "Contact", contact_path
|
35
|
+
link "Contact form", contact_form_path
|
36
|
+
parent :basic
|
37
|
+
end
|
38
|
+
|
39
|
+
crumb :with_proc do
|
40
|
+
link Proc.new { "Name from proc" }, Proc.new { "URL from proc" }
|
41
|
+
end
|
42
|
+
|
43
|
+
crumb :with_multiple_arguments do |a, b, c|
|
44
|
+
link "#{a} and #{b} and #{c}", contact_path
|
45
|
+
parent :parent_with_multiple_arguments, a * 2, b * 2, c * 2
|
46
|
+
end
|
47
|
+
|
48
|
+
crumb :parent_with_multiple_arguments do |d, e, f|
|
49
|
+
link "First #{d} then #{e} then #{f}", about_path
|
50
|
+
end
|
51
|
+
|
52
|
+
crumb :with_unsafe_html do
|
53
|
+
link "Test <strong>bold text</strong>", about_path
|
54
|
+
end
|
55
|
+
|
56
|
+
crumb :with_safe_html do
|
57
|
+
link "Test <strong>bold text</strong>".html_safe, about_path
|
58
|
+
end
|
59
|
+
|
60
|
+
crumb :without_link do
|
61
|
+
link "Without link"
|
62
|
+
parent :parent_without_link
|
63
|
+
end
|
64
|
+
|
65
|
+
crumb :parent_without_link do
|
66
|
+
link "Also without link"
|
67
|
+
end
|
68
|
+
|
69
|
+
crumb :using_view_helper do
|
70
|
+
link times_two("Test"), about_path
|
71
|
+
end
|
72
|
+
|
73
|
+
crumb :project do |project|
|
74
|
+
link project.name, project
|
75
|
+
end
|
76
|
+
|
77
|
+
crumb :with_link_options do
|
78
|
+
link "Test", about_path, title: "My Title", other: "Other Option"
|
79
|
+
link "Other Link", some_option: "Test"
|
80
|
+
end
|
81
|
+
|
82
|
+
crumb :with_inferred_parent do
|
83
|
+
link "Test", about_path
|
84
|
+
parent Project.first
|
85
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
# These inflection rules are supported but not enabled by default:
|
13
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
14
|
+
# inflect.acronym 'RESTful'
|
15
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = '42da708db5725479ebd37530644412b9a6203a31f1db83d8799995365f1c026abb0c9fed978d81a80388b8bbfc9f9b9b33683330f4b657e6253d1a6df55860bb'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Disable root element in JSON by default.
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
13
|
+
self.include_root_in_json = false
|
14
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
root to: "dummy#dummy"
|
3
|
+
|
4
|
+
get "about" => "dummy#dummy", as: :about
|
5
|
+
get "about/contact" => "dummy#dummy", as: :contact
|
6
|
+
get "about/contact/form" => "dummy#dummy", as: :contact_form
|
7
|
+
|
8
|
+
resources :projects do
|
9
|
+
resources :issues
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your
|
6
|
+
# database schema. If you need to create the application database on another
|
7
|
+
# system, you should be using db:schema:load, not running all the migrations
|
8
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(version: 2013_01_22_163051) do
|
14
|
+
|
15
|
+
create_table "issues", force: :cascade do |t|
|
16
|
+
t.string "title"
|
17
|
+
t.integer "project_id"
|
18
|
+
t.datetime "created_at"
|
19
|
+
t.datetime "updated_at"
|
20
|
+
end
|
21
|
+
|
22
|
+
create_table "projects", force: :cascade do |t|
|
23
|
+
t.string "name"
|
24
|
+
t.datetime "created_at"
|
25
|
+
t.datetime "updated_at"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|