strong_presenter 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -2
  3. data/.rspec +2 -0
  4. data/.travis.yml +18 -0
  5. data/.yardopts +1 -0
  6. data/CHANGELOG.md +31 -0
  7. data/Gemfile +22 -2
  8. data/Guardfile +26 -0
  9. data/README.md +210 -52
  10. data/Rakefile +77 -1
  11. data/gemfiles/3.0.gemfile +2 -0
  12. data/gemfiles/3.1.gemfile +2 -0
  13. data/gemfiles/3.2.gemfile +2 -0
  14. data/gemfiles/4.0.gemfile +2 -0
  15. data/gemfiles/4.1.gemfile +2 -0
  16. data/lib/generators/controller_override.rb +15 -0
  17. data/lib/generators/mini_test/presenter_generator.rb +20 -0
  18. data/lib/generators/mini_test/templates/presenter_spec.rb +4 -0
  19. data/lib/generators/mini_test/templates/presenter_test.rb +4 -0
  20. data/lib/generators/rails/presenter_generator.rb +36 -0
  21. data/lib/generators/rails/templates/presenter.rb +19 -0
  22. data/lib/generators/rspec/presenter_generator.rb +9 -0
  23. data/lib/generators/rspec/templates/presenter_spec.rb +4 -0
  24. data/lib/generators/test_unit/presenter_generator.rb +9 -0
  25. data/lib/generators/test_unit/templates/presenter_test.rb +4 -0
  26. data/lib/strong_presenter/associable.rb +78 -0
  27. data/lib/strong_presenter/collection_presenter.rb +90 -0
  28. data/lib/strong_presenter/controller_additions.rb +50 -0
  29. data/lib/strong_presenter/delegation.rb +18 -0
  30. data/lib/strong_presenter/factory.rb +74 -0
  31. data/lib/strong_presenter/helper_proxy.rb +29 -11
  32. data/lib/strong_presenter/inferrer.rb +54 -0
  33. data/lib/strong_presenter/permissible.rb +73 -0
  34. data/lib/strong_presenter/permissions.rb +138 -0
  35. data/lib/strong_presenter/presenter.rb +191 -0
  36. data/lib/strong_presenter/presenter_association.rb +29 -0
  37. data/lib/strong_presenter/presenter_helper_constructor.rb +60 -0
  38. data/lib/strong_presenter/railtie.rb +27 -3
  39. data/lib/strong_presenter/tasks/test.rake +22 -0
  40. data/lib/strong_presenter/test/devise_helper.rb +30 -0
  41. data/lib/strong_presenter/test/minitest_integration.rb +6 -0
  42. data/lib/strong_presenter/test/rspec_integration.rb +16 -0
  43. data/lib/strong_presenter/test_case.rb +53 -0
  44. data/lib/strong_presenter/version.rb +1 -1
  45. data/lib/strong_presenter/view_context/build_strategy.rb +48 -0
  46. data/lib/strong_presenter/view_context.rb +84 -0
  47. data/lib/strong_presenter/view_helpers.rb +39 -0
  48. data/lib/strong_presenter.rb +64 -2
  49. data/spec/dummy/.rspec +2 -0
  50. data/spec/dummy/Rakefile +7 -0
  51. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  52. data/spec/dummy/app/controllers/localized_urls.rb +5 -0
  53. data/spec/dummy/app/controllers/posts_controller.rb +25 -0
  54. data/spec/dummy/app/helpers/application_helper.rb +5 -0
  55. data/spec/dummy/app/mailers/application_mailer.rb +3 -0
  56. data/spec/dummy/app/mailers/post_mailer.rb +19 -0
  57. data/spec/dummy/app/models/admin.rb +5 -0
  58. data/spec/dummy/app/models/post.rb +3 -0
  59. data/spec/dummy/app/models/user.rb +5 -0
  60. data/spec/dummy/app/presenters/post_presenter.rb +69 -0
  61. data/spec/dummy/app/presenters/special_post_presenter.rb +5 -0
  62. data/spec/dummy/app/presenters/special_posts_presenter.rb +5 -0
  63. data/spec/dummy/app/views/layouts/application.html.erb +11 -0
  64. data/spec/dummy/app/views/post_mailer/presented_email.html.erb +1 -0
  65. data/spec/dummy/app/views/posts/_post.html.erb +50 -0
  66. data/spec/dummy/app/views/posts/show.html.erb +1 -0
  67. data/spec/dummy/bin/rails +4 -0
  68. data/spec/dummy/config/application.rb +70 -0
  69. data/spec/dummy/config/boot.rb +5 -0
  70. data/spec/dummy/config/database.yml +25 -0
  71. data/spec/dummy/config/environment.rb +5 -0
  72. data/spec/dummy/config/environments/development.rb +33 -0
  73. data/spec/dummy/config/environments/production.rb +57 -0
  74. data/spec/dummy/config/environments/test.rb +31 -0
  75. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  76. data/spec/dummy/config/initializers/inflections.rb +15 -0
  77. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  78. data/spec/dummy/config/initializers/secret_token.rb +8 -0
  79. data/spec/dummy/config/initializers/session_store.rb +8 -0
  80. data/spec/dummy/config/locales/en.yml +5 -0
  81. data/spec/dummy/config/routes.rb +9 -0
  82. data/spec/dummy/config.ru +4 -0
  83. data/spec/dummy/db/migrate/20121019115657_create_posts.rb +8 -0
  84. data/spec/dummy/db/schema.rb +21 -0
  85. data/spec/dummy/db/seeds.rb +2 -0
  86. data/spec/dummy/fast_spec/post_presenter_spec.rb +37 -0
  87. data/spec/dummy/lib/tasks/test.rake +16 -0
  88. data/spec/dummy/log/.gitkeep +0 -0
  89. data/spec/dummy/public/404.html +26 -0
  90. data/spec/dummy/public/422.html +26 -0
  91. data/spec/dummy/public/500.html +25 -0
  92. data/spec/dummy/public/favicon.ico +0 -0
  93. data/spec/dummy/script/rails +6 -0
  94. data/spec/dummy/spec/fast_spec_helper.rb +13 -0
  95. data/spec/dummy/spec/mailers/post_mailer_spec.rb +33 -0
  96. data/spec/dummy/spec/models/post_spec.rb +4 -0
  97. data/spec/dummy/spec/presenters/active_model_serializers_spec.rb +11 -0
  98. data/spec/dummy/spec/presenters/devise_spec.rb +64 -0
  99. data/spec/dummy/spec/presenters/helpers_spec.rb +21 -0
  100. data/spec/dummy/spec/presenters/post_presenter_spec.rb +66 -0
  101. data/spec/dummy/spec/presenters/spec_type_spec.rb +7 -0
  102. data/spec/dummy/spec/presenters/special_post_presenter_spec.rb +11 -0
  103. data/spec/dummy/spec/presenters/view_context_spec.rb +22 -0
  104. data/spec/dummy/spec/spec_helper.rb +19 -0
  105. data/spec/dummy/test/minitest_helper.rb +2 -0
  106. data/spec/dummy/test/presenters/minitest/devise_test.rb +64 -0
  107. data/spec/dummy/test/presenters/minitest/helpers_test.rb +21 -0
  108. data/spec/dummy/test/presenters/minitest/spec_type_test.rb +52 -0
  109. data/spec/dummy/test/presenters/minitest/view_context_test.rb +24 -0
  110. data/spec/dummy/test/presenters/test_unit/devise_test.rb +64 -0
  111. data/spec/dummy/test/presenters/test_unit/helpers_test.rb +21 -0
  112. data/spec/dummy/test/presenters/test_unit/view_context_test.rb +24 -0
  113. data/spec/dummy/test/test_helper.rb +13 -0
  114. data/spec/generators/presenters/presenter_generator_spec.rb +131 -0
  115. data/spec/generators/simplecov_spec.rb +5 -0
  116. data/spec/integration/integration_spec.rb +81 -0
  117. data/spec/integration/simplecov_spec.rb +4 -0
  118. data/spec/spec_helper.rb +47 -0
  119. data/spec/strong_presenter/associable_spec.rb +122 -0
  120. data/spec/strong_presenter/collection_presenter_spec.rb +34 -0
  121. data/spec/strong_presenter/delegation_spec.rb +20 -0
  122. data/spec/strong_presenter/permissible_spec.rb +24 -0
  123. data/spec/strong_presenter/permissions_spec.rb +188 -0
  124. data/spec/strong_presenter/presenter_spec.rb +43 -0
  125. data/spec/strong_presenter/simplecov_spec.rb +4 -0
  126. data/spec/support/dummy_app.rb +85 -0
  127. data/spec/support/matchers/have_text.rb +50 -0
  128. data/spec/support/models.rb +14 -0
  129. data/spec/support/schema.rb +12 -0
  130. data/strong_presenter.gemspec +15 -0
  131. metadata +392 -13
  132. data/lib/strong_presenter/base.rb +0 -217
@@ -0,0 +1,84 @@
1
+ require 'strong_presenter/view_context/build_strategy'
2
+ require 'request_store'
3
+
4
+ module StrongPresenter
5
+
6
+ # Copied from Draper::ViewContext
7
+ module ViewContext
8
+ # Hooks into a controller or mailer to save the view context in {current}.
9
+ def view_context
10
+ super.tap do |context|
11
+ StrongPresenter::ViewContext.current = context
12
+ end
13
+ end
14
+
15
+ # Returns the current controller.
16
+ def self.controller
17
+ RequestStore.store[:current_controller]
18
+ end
19
+
20
+ # Sets the current controller.
21
+ def self.controller=(controller)
22
+ RequestStore.store[:current_controller] = controller
23
+ end
24
+
25
+ # Returns the current view context, or builds one if none is saved.
26
+ #
27
+ # @return [HelperProxy]
28
+ def self.current
29
+ RequestStore.store.fetch(:current_view_context) { build! }
30
+ end
31
+
32
+ # Sets the current view context.
33
+ def self.current=(view_context)
34
+ RequestStore.store[:current_view_context] = StrongPresenter::HelperProxy.new(view_context)
35
+ end
36
+
37
+ # Clears the saved controller and view context.
38
+ def self.clear!
39
+ RequestStore.store.delete :current_controller
40
+ RequestStore.store.delete :current_view_context
41
+ end
42
+
43
+ # Builds a new view context for usage in tests. See {test_strategy} for
44
+ # details of how the view context is built.
45
+ def self.build
46
+ build_strategy.call
47
+ end
48
+
49
+ # Builds a new view context and sets it as the current view context.
50
+ #
51
+ # @return [HelperProxy]
52
+ def self.build!
53
+ # send because we want to return the HelperProxy returned from #current=
54
+ send :current=, build
55
+ end
56
+
57
+ # Configures the strategy used to build view contexts in tests, which
58
+ # defaults to `:full` if `test_strategy` has not been called. Evaluates
59
+ # the block, if given, in the context of the view context's class.
60
+ #
61
+ # @example Pass a block to add helper methods to the view context:
62
+ # StrongPresenter::ViewContext.test_strategy :fast do
63
+ # include ApplicationHelper
64
+ # end
65
+ #
66
+ # @param [:full, :fast] name
67
+ # the strategy to use:
68
+ #
69
+ # `:full` - build a fully-working view context. Your Rails environment
70
+ # must be loaded, including your `ApplicationController`.
71
+ #
72
+ # `:fast` - build a minimal view context in tests, with no dependencies
73
+ # on other components of your application.
74
+ def self.test_strategy(name, &block)
75
+ @build_strategy = StrongPresenter::ViewContext::BuildStrategy.new(name, &block)
76
+ end
77
+
78
+ # @private
79
+ def self.build_strategy
80
+ @build_strategy ||= StrongPresenter::ViewContext::BuildStrategy.new(:full)
81
+ end
82
+
83
+ end
84
+ end
@@ -0,0 +1,39 @@
1
+ module StrongPresenter
2
+ # Provides the {#helpers} method used in {Presenter} and {CollectionPresenter}
3
+ # to call the Rails helpers.
4
+
5
+ # Copy of Draper::ViewHelpers
6
+ module ViewHelpers
7
+ extend ActiveSupport::Concern
8
+
9
+ module ClassMethods
10
+
11
+ # Access the helpers proxy to call built-in and user-defined
12
+ # Rails helpers from a class context.
13
+ #
14
+ # @return [HelperProxy] the helpers proxy
15
+ def helpers
16
+ StrongPresenter::ViewContext.current
17
+ end
18
+ alias_method :h, :helpers
19
+
20
+ end
21
+
22
+ # Access the helpers proxy to call built-in and user-defined
23
+ # Rails helpers. Aliased to `h` for convenience.
24
+ #
25
+ # @return [HelperProxy] the helpers proxy
26
+ def helpers
27
+ StrongPresenter::ViewContext.current
28
+ end
29
+ alias_method :h, :helpers
30
+
31
+ # Alias for `helpers.localize`, since localize is something that's used
32
+ # quite often. Further aliased to `l` for convenience.
33
+ def localize(*args)
34
+ helpers.localize(*args)
35
+ end
36
+ alias_method :l, :localize
37
+
38
+ end
39
+ end
@@ -1,7 +1,69 @@
1
+ require 'action_view'
2
+ require 'active_model/naming'
3
+ require 'active_model/serialization'
4
+ require 'active_model/serializers/json'
5
+ require 'active_model/serializers/xml'
6
+ require 'active_support/concern'
7
+ require 'active_support/inflector'
8
+ require 'active_support/core_ext/array/extract_options'
9
+ require 'active_support/core_ext/module/delegation'
10
+ require 'active_support/core_ext/hash/keys'
11
+ require 'active_support/core_ext/hash/reverse_merge'
12
+ require 'active_support/core_ext/name_error'
13
+
1
14
  require "strong_presenter/version"
2
- require "strong_presenter/base"
15
+ require "strong_presenter/view_helpers"
16
+ require "strong_presenter/helper_proxy"
17
+ require "strong_presenter/view_context"
18
+ require "strong_presenter/delegation"
19
+ require "strong_presenter/permissions"
20
+ require "strong_presenter/permissible"
21
+ require "strong_presenter/associable"
22
+ require "strong_presenter/inferrer"
23
+ require "strong_presenter/presenter"
24
+ require "strong_presenter/collection_presenter"
25
+ require "strong_presenter/factory"
26
+ require "strong_presenter/presenter_association"
27
+ require "strong_presenter/presenter_helper_constructor"
28
+ require "strong_presenter/controller_additions"
3
29
  require "strong_presenter/railtie" if defined? Rails
4
30
 
5
31
  module StrongPresenter
6
- # Your code goes here...
32
+ def self.setup_action_controller(base)
33
+ base.class_eval do
34
+ include StrongPresenter::ViewContext
35
+ include StrongPresenter::ControllerAdditions
36
+
37
+ before_filter do |controller|
38
+ StrongPresenter::ViewContext.clear!
39
+ StrongPresenter::ViewContext.controller = controller
40
+ end
41
+ end
42
+ end
43
+
44
+ def self.setup_action_mailer(base)
45
+ base.class_eval do
46
+ include StrongPresenter::ViewContext
47
+ end
48
+ end
49
+
50
+ def self.setup_active_model_serializers(base)
51
+ StrongPresenter::CollectionPresenter.class_eval do
52
+ include ActiveModel::ArraySerializerSupport
53
+ end
54
+ end
55
+
56
+ # Note: we do not want to patch ActiveRecord
57
+
58
+ class UninferrablePresenterError < NameError
59
+ def initialize(klass)
60
+ super("Could not infer a presenter for #{klass}.")
61
+ end
62
+ end
63
+
64
+ class UninferrableSourceError < NameError
65
+ def initialize(klass)
66
+ super("Could not infer a source for #{klass}.")
67
+ end
68
+ end
7
69
  end
data/spec/dummy/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -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,4 @@
1
+ class ApplicationController < ActionController::Base
2
+ include LocalizedUrls
3
+ protect_from_forgery
4
+ end
@@ -0,0 +1,5 @@
1
+ module LocalizedUrls
2
+ def default_url_options(options = {})
3
+ {locale: I18n.locale, host: "www.example.com", port: 12345}
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ class PostsController < ApplicationController
2
+ presents :post, :with => StrongPresenter::Presenter, :only => :show
3
+ presents :post, :with => PostPresenter, :only => :show do |presenter|
4
+ presenter.permit(:permit_to_present, :peek_a_boo)
5
+ end
6
+ presents :post, :with => StrongPresenter::Presenter, :only => [:index]
7
+ presents :post, :with => StrongPresenter::Presenter, :except => [:show, :new]
8
+
9
+ def show
10
+ @post = Post.find(params[:id])
11
+ end
12
+
13
+ def mail
14
+ post = Post.find(params[:id])
15
+ email = PostMailer.presented_email(post).deliver
16
+ render text: email.body
17
+ end
18
+
19
+ private
20
+
21
+ def goodnight_moon
22
+ "Goodnight, moon!"
23
+ end
24
+ helper_method :goodnight_moon
25
+ end
@@ -0,0 +1,5 @@
1
+ module ApplicationHelper
2
+ def hello_world
3
+ "Hello, world!"
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ include LocalizedUrls
3
+ end
@@ -0,0 +1,19 @@
1
+ class PostMailer < ApplicationMailer
2
+ default from: "from@example.com"
3
+ layout "application"
4
+
5
+ # Mailers don't import app/helpers automatically
6
+ helper :application
7
+
8
+ def presented_email(post)
9
+ @post = PostPresenter.new(post).permit!
10
+ mail to: "to@example.com", subject: "A presented post"
11
+ end
12
+
13
+ private
14
+
15
+ def goodnight_moon
16
+ "Goodnight, moon!"
17
+ end
18
+ helper_method :goodnight_moon
19
+ end
@@ -0,0 +1,5 @@
1
+ if defined?(Devise)
2
+ class Admin
3
+ extend Devise::Models
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ class Post < ActiveRecord::Base
2
+ # attr_accessible :title, :body
3
+ end
@@ -0,0 +1,5 @@
1
+ if defined?(Devise)
2
+ class User
3
+ extend Devise::Models
4
+ end
5
+ end
@@ -0,0 +1,69 @@
1
+ class PostPresenter < StrongPresenter::Presenter
2
+ # don't delegate_all here because it helps to identify things we
3
+ # have to delegate for ActiveModel compatibility
4
+
5
+ # need to delegate attribute methods for AM::Serialization
6
+ # need to delegate id and new_record? for AR::Base#== (Rails 3.0 only)
7
+ delegate :id, :created_at, :new_record?
8
+
9
+ def posted_date
10
+ if created_at.to_date == DateTime.now.utc.to_date
11
+ "Today"
12
+ else
13
+ "Not Today"
14
+ end
15
+ end
16
+
17
+ def path_with_model
18
+ h.post_path(object)
19
+ end
20
+
21
+ def path_with_id
22
+ h.post_path(id: id)
23
+ end
24
+
25
+ def url_with_model
26
+ h.post_url(object)
27
+ end
28
+
29
+ def url_with_id
30
+ h.post_url(id: id)
31
+ end
32
+
33
+ def link
34
+ h.link_to id.to_s, self
35
+ end
36
+
37
+ def truncated
38
+ h.truncate("Once upon a time in a world far far away", length: 17, separator: ' ')
39
+ end
40
+
41
+ def html_escaped
42
+ h.html_escape("<script>danger</script>")
43
+ end
44
+
45
+ def hello_world
46
+ h.hello_world
47
+ end
48
+
49
+ def goodnight_moon
50
+ h.goodnight_moon
51
+ end
52
+
53
+ def updated_at
54
+ :overridden
55
+ end
56
+
57
+ def permit_to_present
58
+ "I am permitted"
59
+ end
60
+
61
+ def peek_a_boo
62
+ "BOO!"
63
+ end
64
+
65
+ def unpermitted
66
+ "Top Secret"
67
+ end
68
+
69
+ end
@@ -0,0 +1,5 @@
1
+ class SpecialPostPresenter < StrongPresenter::Presenter
2
+ presents :post
3
+
4
+ delegate :id, :title
5
+ end
@@ -0,0 +1,5 @@
1
+ class SpecialPostsPresenter < StrongPresenter::CollectionPresenter
2
+ def collection_special?
3
+ true
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ </head>
6
+ <body>
7
+
8
+ <%= yield %>
9
+
10
+ </body>
11
+ </html>
@@ -0,0 +1 @@
1
+ <%= render @post %>
@@ -0,0 +1,50 @@
1
+ <dl>
2
+ <dt>Environment:</dt>
3
+ <dd id="environment"><%= Rails.env %></dd>
4
+
5
+ <dt>StrongPresenter view context controller:</dt>
6
+ <dd id="controller"><%= StrongPresenter::ViewContext.current.controller.class %></dd>
7
+
8
+ <dt>Posted:</dt>
9
+ <dd id="posted_date"><%= post.posted_date %></dd>
10
+
11
+ <dt>Built-in helpers:</dt>
12
+ <dd id="truncated"><%= post.truncated %></dd>
13
+
14
+ <dt>Built-in private helpers:</dt>
15
+ <dd id="html_escaped"><%= post.html_escaped %></dd>
16
+
17
+ <dt>Helpers from app/helpers:</dt>
18
+ <dd id="hello_world"><%= post.hello_world %></dd>
19
+
20
+ <dt>Helpers from the controller:</dt>
21
+ <dd id="goodnight_moon"><%= post.goodnight_moon %></dd>
22
+
23
+ <dt>Path with presenter:</dt>
24
+ <dd id="path_with_presenter"><%= post_path(post) %></dd>
25
+
26
+ <dt>Path with model:</dt>
27
+ <dd id="path_with_model"><%= post.path_with_model %></dd>
28
+
29
+ <dt>Path with id:</dt>
30
+ <dd id="path_with_id"><%= post.path_with_id %></dd>
31
+
32
+ <dt>URL with presenter:</dt>
33
+ <dd id="url_with_presenter"><%= post_url(post) %></dd>
34
+
35
+ <dt>URL with model:</dt>
36
+ <dd id="url_with_model"><%= post.url_with_model %></dd>
37
+
38
+ <dt>URL with id:</dt>
39
+ <dd id="url_with_id"><%= post.url_with_id %></dd>
40
+
41
+ <% post.presents :permit_to_present, :unpermitted do |key, value| %>
42
+ <dt><%= key.to_s.humanize %>:</dt>
43
+ <dd id="<%= key.to_s %>"><%= value %></dd>
44
+ <% end %>
45
+
46
+ <% post.present :peek_a_boo do |value| %>
47
+ <dt>Peek A Boo:</dt>
48
+ <dd id="peekaboo"><%= value %></dd>
49
+ <% end %>
50
+ </dl>
@@ -0,0 +1 @@
1
+ <%= render post %>
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,70 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ def attempt_require(file)
4
+ require file
5
+ rescue LoadError
6
+ end
7
+
8
+ require 'rails/all'
9
+ require 'strong_presenter'
10
+ attempt_require 'devise'
11
+ require 'active_model_serializers'
12
+
13
+ module Dummy
14
+ class Application < Rails::Application
15
+ # Settings in config/environments/* take precedence over those specified here.
16
+ # Application configuration should go into files in config/initializers
17
+ # -- all .rb files in that directory are automatically loaded.
18
+
19
+ # Custom directories with classes and modules you want to be autoloadable.
20
+ # config.autoload_paths += %W(#{config.root}/extras)
21
+
22
+ # Only load the plugins named here, in the order given (default is alphabetical).
23
+ # :all can be used as a placeholder for all plugins not explicitly named.
24
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
25
+
26
+ # Activate observers that should always be running.
27
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
28
+
29
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
30
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
31
+ # config.time_zone = 'Central Time (US & Canada)'
32
+
33
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
34
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
35
+ # config.i18n.default_locale = :de
36
+
37
+ # Configure the default encoding used in templates for Ruby 1.9.
38
+ config.encoding = "utf-8"
39
+
40
+ # Configure sensitive parameters which will be filtered from the log file.
41
+ config.filter_parameters += [:password]
42
+
43
+ # Enable escaping HTML in JSON.
44
+ config.active_support.escape_html_entities_in_json = true
45
+
46
+ # Use SQL instead of Active Record's schema dumper when creating the database.
47
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
48
+ # like if you have constraints or database-specific column types
49
+ # config.active_record.schema_format = :sql
50
+
51
+ # Enforce whitelist mode for mass assignment.
52
+ # This will create an empty whitelist of attributes available for mass-assignment for all models
53
+ # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
54
+ # parameters by using an attr_accessible or attr_protected declaration.
55
+ # config.active_record.whitelist_attributes = true
56
+
57
+ # Enable the asset pipeline
58
+ # config.assets.enabled = true
59
+
60
+ # Version of your assets, change this if you want to expire all your assets
61
+ # config.assets.version = '1.0'
62
+
63
+ # Tell Action Mailer not to deliver emails to the real world.
64
+ # The :test delivery method accumulates sent emails in the
65
+ # ActionMailer::Base.deliveries array.
66
+ config.action_mailer.delivery_method = :test
67
+ end
68
+ end
69
+
70
+ ActiveRecord::Migration.verbose = false
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
4
+
5
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -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,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,33 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Show full error reports and disable caching
10
+ config.consider_all_requests_local = true
11
+ config.action_controller.perform_caching = false
12
+
13
+ # Print deprecation notices to the Rails logger
14
+ config.active_support.deprecation = :log
15
+
16
+ # Only use best-standards-support built into browsers
17
+ config.action_dispatch.best_standards_support = :builtin
18
+
19
+ config.eager_load = false
20
+
21
+ # Raise exception on mass assignment protection for Active Record models
22
+ # config.active_record.mass_assignment_sanitizer = :strict
23
+
24
+ # Log the query plan for queries taking more than this (works
25
+ # with SQLite, MySQL, and PostgreSQL)
26
+ # config.active_record.auto_explain_threshold_in_seconds = 0.5
27
+
28
+ # Do not compress assets
29
+ # config.assets.compress = false
30
+
31
+ # Expands the lines which load the assets
32
+ # config.assets.debug = true
33
+ end
@@ -0,0 +1,57 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ config.eager_load = true
15
+
16
+ # Defaults to nil and saved in location specified by config.assets.prefix
17
+ # config.assets.manifest = YOUR_PATH
18
+
19
+ # Specifies the header that your server uses for sending files
20
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
21
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
22
+
23
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
24
+ # config.force_ssl = true
25
+
26
+ # See everything in the log (default is :info)
27
+ # config.log_level = :debug
28
+
29
+ # Prepend all log lines with the following tags
30
+ # config.log_tags = [ :subdomain, :uuid ]
31
+
32
+ # Use a different logger for distributed setups
33
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
34
+
35
+ # Use a different cache store in production
36
+ # config.cache_store = :mem_cache_store
37
+
38
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
39
+ # config.action_controller.asset_host = "http://assets.example.com"
40
+
41
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
42
+ # config.assets.precompile += %w( search.js )
43
+
44
+ # Enable threaded mode
45
+ # config.threadsafe!
46
+
47
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
48
+ # the I18n.default_locale when a translation can not be found)
49
+ config.i18n.fallbacks = true
50
+
51
+ # Send deprecation notices to registered listeners
52
+ config.active_support.deprecation = :notify
53
+
54
+ # Log the query plan for queries taking more than this (works
55
+ # with SQLite, MySQL, and PostgreSQL)
56
+ # config.active_record.auto_explain_threshold_in_seconds = 0.5
57
+ end