mariner 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.autotest +10 -0
  2. data/.gitignore +18 -0
  3. data/.pairs +6 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +5 -0
  6. data/Gemfile +12 -0
  7. data/LICENSE +22 -0
  8. data/README.md +59 -0
  9. data/Rakefile +13 -0
  10. data/lib/mariner.rb +49 -0
  11. data/lib/mariner/errors.rb +26 -0
  12. data/lib/mariner/helper.rb +96 -0
  13. data/lib/mariner/railtie.rb +21 -0
  14. data/lib/mariner/renderer/base.rb +42 -0
  15. data/lib/mariner/store.rb +76 -0
  16. data/lib/mariner/unordered_list_renderer.rb +202 -0
  17. data/lib/mariner/url.rb +54 -0
  18. data/lib/mariner/version.rb +3 -0
  19. data/mariner.gemspec +20 -0
  20. data/spec/integrations/unordered_list_renderer_spec.rb +90 -0
  21. data/spec/mariner_spec.rb +29 -0
  22. data/spec/navigation/helper_spec.rb +131 -0
  23. data/spec/navigation/railtie_spec.rb +17 -0
  24. data/spec/navigation/renderer/base_spec.rb +25 -0
  25. data/spec/navigation/store_spec.rb +80 -0
  26. data/spec/navigation/unordered_list_render_spec.rb +93 -0
  27. data/spec/navigation/url_spec.rb +45 -0
  28. data/spec/rails_app/.gitignore +15 -0
  29. data/spec/rails_app/Rakefile +7 -0
  30. data/spec/rails_app/app/assets/javascripts/application.js +15 -0
  31. data/spec/rails_app/app/assets/stylesheets/application.css +13 -0
  32. data/spec/rails_app/app/controllers/application_controller.rb +6 -0
  33. data/spec/rails_app/app/helpers/application_helper.rb +2 -0
  34. data/spec/rails_app/app/mailers/.gitkeep +0 -0
  35. data/spec/rails_app/app/models/.gitkeep +0 -0
  36. data/spec/rails_app/app/views/application/condensed.html.erb +1 -0
  37. data/spec/rails_app/app/views/application/normal.html.erb +1 -0
  38. data/spec/rails_app/app/views/layouts/application.html.erb +12 -0
  39. data/spec/rails_app/config.ru +4 -0
  40. data/spec/rails_app/config/application.rb +64 -0
  41. data/spec/rails_app/config/boot.rb +3 -0
  42. data/spec/rails_app/config/database.yml +3 -0
  43. data/spec/rails_app/config/environment.rb +5 -0
  44. data/spec/rails_app/config/environments/test.rb +37 -0
  45. data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  46. data/spec/rails_app/config/initializers/inflections.rb +15 -0
  47. data/spec/rails_app/config/initializers/mime_types.rb +5 -0
  48. data/spec/rails_app/config/initializers/secret_token.rb +7 -0
  49. data/spec/rails_app/config/initializers/session_store.rb +8 -0
  50. data/spec/rails_app/config/initializers/wrap_parameters.rb +14 -0
  51. data/spec/rails_app/config/locales/en.yml +5 -0
  52. data/spec/rails_app/config/routes.rb +9 -0
  53. data/spec/rails_app/db/.gitkeep +0 -0
  54. data/spec/rails_app/lib/assets/.gitkeep +0 -0
  55. data/spec/rails_app/lib/tasks/.gitkeep +0 -0
  56. data/spec/rails_app/log/.gitkeep +0 -0
  57. data/spec/rails_app/script/rails +6 -0
  58. data/spec/rails_app/vendor/assets/javascripts/.gitkeep +0 -0
  59. data/spec/rails_app/vendor/assets/stylesheets/.gitkeep +0 -0
  60. data/spec/rails_app/vendor/plugins/.gitkeep +0 -0
  61. data/spec/spec_helper.rb +8 -0
  62. 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
+ */
@@ -0,0 +1,6 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ def normal; end
5
+ def condensed; end
6
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
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,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>RailsApp</title>
5
+ <%= csrf_meta_tags %>
6
+ </head>
7
+ <body>
8
+
9
+ <%= yield %>
10
+
11
+ </body>
12
+ </html>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run RailsApp::Application
@@ -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
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../../../Gemfile', __FILE__)
3
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/test.sqlite3
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RailsApp::Application.initialize!