loaf 0.6.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +67 -12
- data/LICENSE.txt +1 -1
- data/README.md +82 -39
- data/lib/loaf.rb +1 -0
- data/lib/loaf/configuration.rb +0 -12
- data/lib/loaf/controller_extensions.rb +9 -1
- data/lib/loaf/errors.rb +1 -1
- data/lib/loaf/translation.rb +12 -4
- data/lib/loaf/version.rb +3 -1
- data/lib/loaf/view_extensions.rb +16 -8
- metadata +19 -161
- data/.document +0 -5
- data/.gitignore +0 -23
- data/.rspec +0 -2
- data/.travis.yml +0 -48
- data/Appraisals +0 -36
- data/Gemfile +0 -19
- data/Gemfile.lock +0 -185
- data/Rakefile +0 -10
- data/assets/loaf_logo.png +0 -0
- data/bin/appraisal +0 -16
- data/bin/rake +0 -16
- data/bin/setup +0 -7
- data/gemfiles/rails3.2.gemfile +0 -24
- data/gemfiles/rails4.0.gemfile +0 -24
- data/gemfiles/rails4.1.gemfile +0 -23
- data/gemfiles/rails4.2.gemfile +0 -23
- data/gemfiles/rails5.0.gemfile +0 -22
- data/gemfiles/rails5.1.gemfile +0 -22
- data/lib/loaf/crumb_formatter.rb +0 -24
- data/loaf.gemspec +0 -28
- data/spec/integration/breadcrumb_trail_spec.rb +0 -60
- data/spec/integration/configuration_spec.rb +0 -12
- data/spec/rails_app/Rakefile +0 -8
- data/spec/rails_app/app/controllers/application_controller.rb +0 -5
- data/spec/rails_app/app/controllers/comments_controller.rb +0 -17
- data/spec/rails_app/app/controllers/home_controller.rb +0 -4
- data/spec/rails_app/app/controllers/posts_controller.rb +0 -20
- data/spec/rails_app/app/views/comments/index.html.erb +0 -1
- data/spec/rails_app/app/views/home/index.html.erb +0 -1
- data/spec/rails_app/app/views/layouts/_breadcrumbs.html.erb +0 -12
- data/spec/rails_app/app/views/layouts/application.html.erb +0 -14
- data/spec/rails_app/app/views/posts/index.html.erb +0 -1
- data/spec/rails_app/app/views/posts/new.html.erb +0 -4
- data/spec/rails_app/app/views/posts/show.html.erb +0 -1
- data/spec/rails_app/config.ru +0 -4
- data/spec/rails_app/config/application.rb +0 -48
- data/spec/rails_app/config/boot.rb +0 -10
- data/spec/rails_app/config/database.yml +0 -25
- data/spec/rails_app/config/environment.rb +0 -5
- data/spec/rails_app/config/environments/development.rb +0 -32
- data/spec/rails_app/config/environments/production.rb +0 -62
- data/spec/rails_app/config/environments/test.rb +0 -41
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails_app/config/initializers/inflections.rb +0 -10
- data/spec/rails_app/config/initializers/mime_types.rb +0 -5
- data/spec/rails_app/config/initializers/secret_token.rb +0 -7
- data/spec/rails_app/config/initializers/session_store.rb +0 -8
- data/spec/rails_app/config/initializers/wrap_parameters.rb +0 -14
- data/spec/rails_app/config/locales/en.yml +0 -5
- data/spec/rails_app/config/locales/loaf.en.yml +0 -6
- data/spec/rails_app/config/routes.rb +0 -7
- data/spec/rails_app/config/secrets.yml +0 -22
- data/spec/rails_app/public/404.html +0 -26
- data/spec/rails_app/public/422.html +0 -26
- data/spec/rails_app/public/500.html +0 -26
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/rails_app/public/robots.txt +0 -5
- data/spec/spec_helper.rb +0 -52
- data/spec/support/capybara.rb +0 -8
- data/spec/support/dummy_controller.rb +0 -9
- data/spec/support/dummy_view.rb +0 -47
- data/spec/support/load_routes.rb +0 -4
- data/spec/unit/configuration_spec.rb +0 -39
- data/spec/unit/controller_extensions_spec.rb +0 -54
- data/spec/unit/crumb_formatter_spec.rb +0 -36
- data/spec/unit/crumb_spec.rb +0 -15
- data/spec/unit/generators/install_generator_spec.rb +0 -17
- data/spec/unit/options_validator_spec.rb +0 -15
- data/spec/unit/translation_spec.rb +0 -22
- data/spec/unit/view_extensions/breadcrumb_spec.rb +0 -22
- data/spec/unit/view_extensions/breadcrumb_trail_spec.rb +0 -232
- data/spec/unit/view_extensions/has_breadcrumbs_spec.rb +0 -10
- data/tasks/console.rake +0 -10
- data/tasks/coverage.rake +0 -11
- data/tasks/spec.rake +0 -29
@@ -1,7 +0,0 @@
|
|
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
|
-
RailsApp::Application.config.secret_token = '2bc2743124978fc50d054e09cc457b9a6de3cb8c1b7000d78a9af674e93245bf292f2f57f56ad782dc6f7da1695206251d7c9541ec3870467275e4c65447db48'
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
RailsApp::Application.config.session_store :cookie_store, key: '_rails_app_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
|
-
# RailsApp::Application.config.session_store :active_record_store
|
@@ -1,14 +0,0 @@
|
|
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
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
-
# If you change this key, all old signed cookies will become invalid!
|
5
|
-
|
6
|
-
# Make sure the secret is at least 30 characters and all random,
|
7
|
-
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
-
# You can use `rake secret` to generate a secure secret key.
|
9
|
-
|
10
|
-
# Make sure the secrets in this file are kept private
|
11
|
-
# if you're sharing your code publicly.
|
12
|
-
|
13
|
-
development:
|
14
|
-
secret_key_base: c392df63ec28b42b36b92a5b9e8603fa62d7807024d07801ab162ec7a2a165a87d27a4a8535ce09cd2bf4a82afe45e3080fb8cc56613d608e5b18335594782b3
|
15
|
-
|
16
|
-
test:
|
17
|
-
secret_key_base: 4b1fba0d12c53b8b21880fda47b603b3dcca117ccf41fcc70091351b88ede5d4c5c91371f407cd056efd66fa5f306c23add65a89d4304e06a4243289ee97be1d
|
18
|
-
|
19
|
-
# Do not keep production secrets in the repository,
|
20
|
-
# instead read values from the environment.
|
21
|
-
production:
|
22
|
-
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
@@ -1,26 +0,0 @@
|
|
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>
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</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/422.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The change you wanted was rejected.</h1>
|
23
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</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/500.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>We're sorry, but something went wrong.</h1>
|
23
|
-
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
File without changes
|
data/spec/spec_helper.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
if (ENV['COVERAGE'] || ENV['TRAVIS']) && RUBY_VERSION < '2.4.0'
|
4
|
-
require 'simplecov'
|
5
|
-
require 'coveralls'
|
6
|
-
|
7
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
8
|
-
SimpleCov::Formatter::HTMLFormatter,
|
9
|
-
Coveralls::SimpleCov::Formatter
|
10
|
-
])
|
11
|
-
|
12
|
-
SimpleCov.start do
|
13
|
-
command_name 'spec'
|
14
|
-
add_filter 'spec'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# Configure Rails Environment
|
19
|
-
ENV["RAILS_ENV"] = "test"
|
20
|
-
|
21
|
-
require 'rails_app/config/environment.rb'
|
22
|
-
require 'rspec/rails'
|
23
|
-
require 'loaf'
|
24
|
-
|
25
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
26
|
-
|
27
|
-
RSpec.configure do |config|
|
28
|
-
config.expect_with :rspec do |expectations|
|
29
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
|
-
end
|
31
|
-
|
32
|
-
config.mock_with :rspec do |mocks|
|
33
|
-
mocks.verify_partial_doubles = true
|
34
|
-
end
|
35
|
-
|
36
|
-
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
37
|
-
config.disable_monkey_patching!
|
38
|
-
|
39
|
-
# This setting enables warnings. It's recommended, but in some cases may
|
40
|
-
# be too noisy due to issues in dependencies.
|
41
|
-
config.warnings = true
|
42
|
-
|
43
|
-
if config.files_to_run.one?
|
44
|
-
config.default_formatter = 'doc'
|
45
|
-
end
|
46
|
-
|
47
|
-
config.profile_examples = 2
|
48
|
-
|
49
|
-
config.order = :random
|
50
|
-
|
51
|
-
Kernel.srand config.seed
|
52
|
-
end
|
data/spec/support/capybara.rb
DELETED
data/spec/support/dummy_view.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'action_view'
|
2
|
-
|
3
|
-
class DummyView < ActionView::Base
|
4
|
-
module FakeRequest
|
5
|
-
class Request
|
6
|
-
attr_accessor :path, :fullpath, :protocol, :host_with_port
|
7
|
-
def get?
|
8
|
-
true
|
9
|
-
end
|
10
|
-
end
|
11
|
-
def request
|
12
|
-
@request ||= Request.new
|
13
|
-
end
|
14
|
-
def params
|
15
|
-
@params ||= {}
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
include FakeRequest
|
20
|
-
include ActionView::Helpers::UrlHelper
|
21
|
-
include Loaf::ViewExtensions
|
22
|
-
|
23
|
-
attr_reader :_breadcrumbs
|
24
|
-
|
25
|
-
routes = ActionDispatch::Routing::RouteSet.new
|
26
|
-
routes.draw do
|
27
|
-
get "/" => "foo#bar", :as => :home
|
28
|
-
get "/posts" => "foo#posts"
|
29
|
-
get "/posts/:title" => "foo#posts"
|
30
|
-
get "/post/:id" => "foo#post", :as => :post
|
31
|
-
get "/post/:title" => "foo#title"
|
32
|
-
get "/post/:id/comments" => "foo#comments"
|
33
|
-
|
34
|
-
namespace :blog do
|
35
|
-
get "/" => "foo#bar"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
include routes.url_helpers
|
40
|
-
|
41
|
-
def set_path(path)
|
42
|
-
request.path = path
|
43
|
-
request.fullpath = path
|
44
|
-
request.protocol = 'http://'
|
45
|
-
request.host_with_port = 'www.example.com'
|
46
|
-
end
|
47
|
-
end
|
data/spec/support/load_routes.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
RSpec.describe Loaf::Configuration do
|
4
|
-
it "allows to set and read attributes" do
|
5
|
-
config = Loaf::Configuration.new
|
6
|
-
|
7
|
-
config.crumb_length = 4
|
8
|
-
expect(config.crumb_length).to eq(4)
|
9
|
-
|
10
|
-
config.match = :exact
|
11
|
-
expect(config.match).to eq(:exact)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "accepts attributes at initialization" do
|
15
|
-
options = { crumb_length: 12, match: :exact }
|
16
|
-
config = Loaf::Configuration.new(options)
|
17
|
-
|
18
|
-
expect(config.crumb_length).to eq(12)
|
19
|
-
expect(config.match).to eq(:exact)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "exports configuration as hash" do
|
23
|
-
config = Loaf::Configuration.new
|
24
|
-
expect(config.to_hash).to eq({
|
25
|
-
capitalize: false,
|
26
|
-
crumb_length: 30,
|
27
|
-
locales_path: '/',
|
28
|
-
match: :inclusive
|
29
|
-
})
|
30
|
-
end
|
31
|
-
|
32
|
-
it "yields configuration" do
|
33
|
-
conf = double(:conf)
|
34
|
-
allow(Loaf).to receive(:configuration).and_return(conf)
|
35
|
-
expect { |b|
|
36
|
-
Loaf.configure(&b)
|
37
|
-
}.to yield_with_args(conf)
|
38
|
-
end
|
39
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
RSpec.describe Loaf::ControllerExtensions do
|
4
|
-
|
5
|
-
context 'when classes extend controller_extensions' do
|
6
|
-
it { expect(DummyController).to respond_to(:add_breadcrumb) }
|
7
|
-
it { expect(DummyController).to respond_to(:breadcrumb) }
|
8
|
-
it { expect(DummyController.new).to respond_to(:add_breadcrumb) }
|
9
|
-
it { expect(DummyController.new).to respond_to(:breadcrumb) }
|
10
|
-
it { expect(DummyController.new).to respond_to(:clear_breadcrumbs) }
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'class methods' do
|
14
|
-
it 'invokes before_action' do
|
15
|
-
allow(DummyController).to receive(:before_action)
|
16
|
-
allow(DummyController).to receive(:respond_to?).and_return(true)
|
17
|
-
DummyController.breadcrumb('name', 'url_path')
|
18
|
-
expect(DummyController).to have_received(:before_action)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'delegates breadcrumb registration to controller instance' do
|
22
|
-
name = 'List objects'
|
23
|
-
url = :object_path
|
24
|
-
options = {force: true}
|
25
|
-
instance = double(:controller_instance).as_null_object
|
26
|
-
|
27
|
-
allow(DummyController).to receive(:new).and_return(instance)
|
28
|
-
DummyController.breadcrumb(name, url, options)
|
29
|
-
expect(instance).to have_received(:breadcrumb).with(name, url, options)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'instance methods' do
|
34
|
-
it 'instantiates breadcrumbs container' do
|
35
|
-
name = 'List objects'
|
36
|
-
url = :object_path
|
37
|
-
instance = DummyController.new
|
38
|
-
|
39
|
-
allow(Loaf::Crumb).to receive(:new)
|
40
|
-
instance.breadcrumb(name, url)
|
41
|
-
expect(Loaf::Crumb).to have_received(:new).with(name, url, {})
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'adds breadcrumb to collection' do
|
45
|
-
name = 'List objects'
|
46
|
-
url = :object_path
|
47
|
-
instance = DummyController.new
|
48
|
-
|
49
|
-
expect {
|
50
|
-
instance.breadcrumb(name, url)
|
51
|
-
}.to change { instance._breadcrumbs.size }.by(1)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
RSpec.describe Loaf::CrumbFormatter, '.format_name' do
|
4
|
-
let(:formatter) {
|
5
|
-
Class.new do
|
6
|
-
extend Loaf::CrumbFormatter
|
7
|
-
|
8
|
-
def self.truncate(name, options)
|
9
|
-
name
|
10
|
-
end
|
11
|
-
end
|
12
|
-
}
|
13
|
-
|
14
|
-
it 'returns name error if breadcrumb name is nil' do
|
15
|
-
expect(formatter.format_name('')).to eql('')
|
16
|
-
end
|
17
|
-
|
18
|
-
it "doesn't capitalize by default" do
|
19
|
-
name = 'some random name'
|
20
|
-
formatted = formatter.format_name(name)
|
21
|
-
expect(formatted).to eql(name)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'capitalizes crumb name with capitalize option' do
|
25
|
-
name = 'some random name'
|
26
|
-
formatted = formatter.format_name(name, capitalize: true)
|
27
|
-
expect(formatted).to eql('Some random name')
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'shortens crumb to provided length' do
|
31
|
-
name = 'very long name that is more that 30 characters long'
|
32
|
-
allow(formatter).to receive(:truncate).with(name, length: 30).
|
33
|
-
and_return(name[0..30])
|
34
|
-
expect(formatter.format_name(name, crumb_length: 30)).to eql(name[0..30])
|
35
|
-
end
|
36
|
-
end
|
data/spec/unit/crumb_spec.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
RSpec.describe Loaf::Crumb do
|
2
|
-
it "fails when name is nil" do
|
3
|
-
expect {
|
4
|
-
Loaf::Crumb.new(nil, 'path')
|
5
|
-
}.to raise_error(ArgumentError,
|
6
|
-
/breadcrumb first argument, `name`, cannot be nil/)
|
7
|
-
end
|
8
|
-
|
9
|
-
it "fails when url is nil" do
|
10
|
-
expect {
|
11
|
-
Loaf::Crumb.new('name', nil)
|
12
|
-
}.to raise_error(ArgumentError,
|
13
|
-
/breadcrumb second argument, `url`, cannot be nil/)
|
14
|
-
end
|
15
|
-
end
|