mariner 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.autotest +10 -0
- data/.gitignore +18 -0
- data/.pairs +6 -0
- data/.rspec +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +12 -0
- data/LICENSE +22 -0
- data/README.md +59 -0
- data/Rakefile +13 -0
- data/lib/mariner.rb +49 -0
- data/lib/mariner/errors.rb +26 -0
- data/lib/mariner/helper.rb +96 -0
- data/lib/mariner/railtie.rb +21 -0
- data/lib/mariner/renderer/base.rb +42 -0
- data/lib/mariner/store.rb +76 -0
- data/lib/mariner/unordered_list_renderer.rb +202 -0
- data/lib/mariner/url.rb +54 -0
- data/lib/mariner/version.rb +3 -0
- data/mariner.gemspec +20 -0
- data/spec/integrations/unordered_list_renderer_spec.rb +90 -0
- data/spec/mariner_spec.rb +29 -0
- data/spec/navigation/helper_spec.rb +131 -0
- data/spec/navigation/railtie_spec.rb +17 -0
- data/spec/navigation/renderer/base_spec.rb +25 -0
- data/spec/navigation/store_spec.rb +80 -0
- data/spec/navigation/unordered_list_render_spec.rb +93 -0
- data/spec/navigation/url_spec.rb +45 -0
- data/spec/rails_app/.gitignore +15 -0
- data/spec/rails_app/Rakefile +7 -0
- data/spec/rails_app/app/assets/javascripts/application.js +15 -0
- data/spec/rails_app/app/assets/stylesheets/application.css +13 -0
- data/spec/rails_app/app/controllers/application_controller.rb +6 -0
- data/spec/rails_app/app/helpers/application_helper.rb +2 -0
- data/spec/rails_app/app/mailers/.gitkeep +0 -0
- data/spec/rails_app/app/models/.gitkeep +0 -0
- data/spec/rails_app/app/views/application/condensed.html.erb +1 -0
- data/spec/rails_app/app/views/application/normal.html.erb +1 -0
- data/spec/rails_app/app/views/layouts/application.html.erb +12 -0
- data/spec/rails_app/config.ru +4 -0
- data/spec/rails_app/config/application.rb +64 -0
- data/spec/rails_app/config/boot.rb +3 -0
- data/spec/rails_app/config/database.yml +3 -0
- data/spec/rails_app/config/environment.rb +5 -0
- data/spec/rails_app/config/environments/test.rb +37 -0
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_app/config/initializers/inflections.rb +15 -0
- data/spec/rails_app/config/initializers/mime_types.rb +5 -0
- data/spec/rails_app/config/initializers/secret_token.rb +7 -0
- data/spec/rails_app/config/initializers/session_store.rb +8 -0
- data/spec/rails_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/rails_app/config/locales/en.yml +5 -0
- data/spec/rails_app/config/routes.rb +9 -0
- data/spec/rails_app/db/.gitkeep +0 -0
- data/spec/rails_app/lib/assets/.gitkeep +0 -0
- data/spec/rails_app/lib/tasks/.gitkeep +0 -0
- data/spec/rails_app/log/.gitkeep +0 -0
- data/spec/rails_app/script/rails +6 -0
- data/spec/rails_app/vendor/assets/javascripts/.gitkeep +0 -0
- data/spec/rails_app/vendor/assets/stylesheets/.gitkeep +0 -0
- data/spec/rails_app/vendor/plugins/.gitkeep +0 -0
- data/spec/spec_helper.rb +8 -0
- metadata +175 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Mariner
|
4
|
+
|
5
|
+
describe Railtie do
|
6
|
+
|
7
|
+
it "mixes the Rails routes helper into Url" do
|
8
|
+
Url.new(nil, nil).should respond_to :root_path
|
9
|
+
end
|
10
|
+
|
11
|
+
it "mixes Helper into ActionController helpers" do
|
12
|
+
ActionController::Base.ancestors.should include ::Mariner::Helper
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Mariner
|
4
|
+
|
5
|
+
module Renderer
|
6
|
+
|
7
|
+
describe Base do
|
8
|
+
|
9
|
+
describe "#initialize" do
|
10
|
+
|
11
|
+
let(:fake_renderer) { stub(UnorderedListRenderer) }
|
12
|
+
let(:fake_entity) { stub }
|
13
|
+
|
14
|
+
subject { Base.new(fake_entity, fake_renderer) }
|
15
|
+
|
16
|
+
its(:subject) { should == fake_entity }
|
17
|
+
its(:rendering_strategy) { should == fake_renderer }
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Mariner
|
4
|
+
|
5
|
+
describe Store do
|
6
|
+
|
7
|
+
it "is a subclass of Abyss::DeepStore" do
|
8
|
+
subject.should be_a ::Abyss::DeepStore
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#virtual?" do
|
12
|
+
|
13
|
+
it "aliases the attribute reader" do
|
14
|
+
subject.method(:virtual).should == subject.method(:virtual?)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#initialize" do
|
20
|
+
|
21
|
+
subject { Store.new }
|
22
|
+
|
23
|
+
its(:virtual?) { should be_false }
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#assign" do
|
28
|
+
|
29
|
+
context "by default" do
|
30
|
+
|
31
|
+
it "stores a new Url with a method_name, title, and link_options" do
|
32
|
+
url_stub = stub
|
33
|
+
Url.should_receive(:new).with(:some_undefined_method, 'A Title', { :option => 'value' }).and_return(url_stub)
|
34
|
+
subject.assign(:some_undefined_method, ['A Title', { :option => 'value' }])
|
35
|
+
subject.configurations[:some_undefined_method].should == url_stub
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when given an incorrect number of values" do
|
41
|
+
|
42
|
+
it "raises an argument error" do
|
43
|
+
expect {
|
44
|
+
subject.assign(:some_undefined_method, ['One', 'Two', 'Three'])
|
45
|
+
}.to raise_error ArgumentError, /wrong number of values specified \(3 for <= 2\)/i
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#render" do
|
53
|
+
|
54
|
+
let(:renderer_stub) { stub }
|
55
|
+
|
56
|
+
context "by default" do
|
57
|
+
|
58
|
+
it "uses a default rendering strategy" do
|
59
|
+
UnorderedListRenderer.any_instance.stub(:factory).with(:group, subject).and_return(renderer_stub)
|
60
|
+
|
61
|
+
renderer_stub.should_receive(:render)
|
62
|
+
subject.render
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
it "renders through a specified strategy when given" do
|
68
|
+
class FakeRenderingStrategy #:nodoc:
|
69
|
+
end
|
70
|
+
FakeRenderingStrategy.any_instance.stub(:factory).with(:group, subject).and_return(renderer_stub)
|
71
|
+
|
72
|
+
renderer_stub.should_receive(:render)
|
73
|
+
subject.render(FakeRenderingStrategy.new)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Mariner
|
4
|
+
|
5
|
+
describe UnorderedListRenderer do
|
6
|
+
|
7
|
+
describe "#initialize" do
|
8
|
+
|
9
|
+
describe "option_assignment" do
|
10
|
+
|
11
|
+
subject { UnorderedListRenderer.new(:render_titles => "PHONE") }
|
12
|
+
|
13
|
+
its(:render_titles) { should == "PHONE" }
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#render_titles?" do
|
20
|
+
|
21
|
+
it "aliases the attrbiute_reader" do
|
22
|
+
subject.method(:render_titles).should == subject.method(:render_titles?)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#factory" do
|
28
|
+
|
29
|
+
it "can factory a GroupRenderer" do
|
30
|
+
subject.factory(:group, stub(Store)).should be_instance_of UnorderedListRenderer::GroupRenderer
|
31
|
+
end
|
32
|
+
|
33
|
+
it "can factory an ItemRenderer" do
|
34
|
+
subject.factory(:item, stub(Url)).should be_instance_of UnorderedListRenderer::ItemRenderer
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
describe UnorderedListRenderer::ItemRenderer do
|
42
|
+
|
43
|
+
# Method #render is not tested here. See
|
44
|
+
# spec/integrations/unordered_list_renderer_spec
|
45
|
+
|
46
|
+
describe "#render_options" do
|
47
|
+
|
48
|
+
subject { UnorderedListRenderer::ItemRenderer.new(url, UnorderedListRenderer.new) }
|
49
|
+
|
50
|
+
before { url.stub(:root_path).and_return("/") }
|
51
|
+
|
52
|
+
context 'when no additional class is specified in render_options' do
|
53
|
+
|
54
|
+
let(:url) { Url.new(:root_path, "Title", {}) }
|
55
|
+
|
56
|
+
it 'returns the correct attributes' do
|
57
|
+
subject.render_options.should == { :href => "/", :class => "root_path" }
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when an additional class is specified' do
|
63
|
+
|
64
|
+
let(:url) { Url.new(:root_path, "Title", {:class => 'additional'}) }
|
65
|
+
|
66
|
+
it 'returns the correct attributes' do
|
67
|
+
subject.render_options.should == { :href => "/", :class => "additional root_path" }
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when an additional options are specified' do
|
73
|
+
|
74
|
+
let(:url) { Url.new(:root_path, "Title", {:placeholder => 'foo'}) }
|
75
|
+
|
76
|
+
it 'returns the correct attributes' do
|
77
|
+
subject.render_options.should == { :href => "/", :class => "root_path", :placeholder => 'foo' }
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
describe UnorderedListRenderer::GroupRenderer do
|
87
|
+
|
88
|
+
# Method #render is not tested here. See
|
89
|
+
# spec/integrations/unordered_list_renderer_spec
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Mariner
|
4
|
+
|
5
|
+
describe Url do
|
6
|
+
|
7
|
+
subject { Url.new(:foo_path, "Thing", {:option => 'bar'}) }
|
8
|
+
|
9
|
+
describe "#initialize" do
|
10
|
+
|
11
|
+
its(:name) { should == :foo_path }
|
12
|
+
its(:title) { should == "Thing" }
|
13
|
+
its(:options) { should == {:option => 'bar'} }
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#render" do
|
18
|
+
|
19
|
+
let(:renderer_stub) { stub }
|
20
|
+
|
21
|
+
context "by default" do
|
22
|
+
|
23
|
+
it "uses a default rendering strategy" do
|
24
|
+
UnorderedListRenderer.any_instance.stub(:factory).with(:item, subject).and_return(renderer_stub)
|
25
|
+
|
26
|
+
renderer_stub.should_receive(:render)
|
27
|
+
subject.render
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
it "renders through a specified strategy when given" do
|
33
|
+
class FakeRenderingStrategy #:nodoc:
|
34
|
+
end
|
35
|
+
FakeRenderingStrategy.any_instance.stub(:factory).with(:item, subject).and_return(renderer_stub)
|
36
|
+
|
37
|
+
renderer_stub.should_receive(:render)
|
38
|
+
subject.render(FakeRenderingStrategy.new)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# See http://help.github.com/ignore-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 the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
|
13
|
+
# Ignore all logfiles and tempfiles.
|
14
|
+
/log/*.log
|
15
|
+
/tmp
|
@@ -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
|
+
RailsApp::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 @@
|
|
1
|
+
<%= raw Mariner.configuration.condensed_nav.render %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= raw Mariner.configuration.normal_nav.render %>
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "action_controller/railtie"
|
4
|
+
require "action_mailer/railtie"
|
5
|
+
require "active_resource/railtie"
|
6
|
+
require "sprockets/railtie"
|
7
|
+
|
8
|
+
require "mariner"
|
9
|
+
|
10
|
+
if defined?(Bundler)
|
11
|
+
# If you precompile assets before deploying to production, use this line
|
12
|
+
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
13
|
+
# If you want your assets lazily compiled in production, use this line
|
14
|
+
# Bundler.require(:default, :assets, Rails.env)
|
15
|
+
end
|
16
|
+
|
17
|
+
module RailsApp
|
18
|
+
class Application < Rails::Application
|
19
|
+
# Settings in config/environments/* take precedence over those specified here.
|
20
|
+
# Application configuration should go into files in config/initializers
|
21
|
+
# -- all .rb files in that directory are automatically loaded.
|
22
|
+
|
23
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
24
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
25
|
+
|
26
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
27
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
28
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
29
|
+
|
30
|
+
# Activate observers that should always be running.
|
31
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
32
|
+
|
33
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
34
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
35
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
36
|
+
|
37
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
38
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
39
|
+
# config.i18n.default_locale = :de
|
40
|
+
|
41
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
42
|
+
config.encoding = "utf-8"
|
43
|
+
|
44
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
45
|
+
config.filter_parameters += [:password]
|
46
|
+
|
47
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
48
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
49
|
+
# like if you have constraints or database-specific column types
|
50
|
+
# config.active_record.schema_format = :sql
|
51
|
+
|
52
|
+
# Enforce whitelist mode for mass assignment.
|
53
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
54
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
55
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
56
|
+
# config.active_record.whitelist_attributes = true
|
57
|
+
|
58
|
+
# Enable the asset pipeline
|
59
|
+
config.assets.enabled = true
|
60
|
+
|
61
|
+
# Version of your assets, change this if you want to expire all your assets
|
62
|
+
config.assets.version = '1.0'
|
63
|
+
end
|
64
|
+
end
|