delegated_presenter 1.0.0 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/.travis.yml +0 -3
  2. data/README.md +31 -1
  3. data/Rakefile +7 -0
  4. data/delegated_presenter.gemspec +1 -0
  5. data/lib/delegated_presenter/base.rb +6 -3
  6. data/lib/delegated_presenter/presents_before_rendering.rb +9 -6
  7. data/lib/delegated_presenter/version.rb +1 -1
  8. data/lib/delegated_presenter.rb +5 -0
  9. data/spec/dummy/app/controllers/sample_objects_controller.rb +8 -0
  10. data/spec/dummy/config/database.yml +1 -21
  11. data/spec/dummy/config/routes.rb +3 -1
  12. data/spec/factories/sample_object.rb +1 -0
  13. data/spec/presenter_spec.rb +104 -0
  14. data/spec/presents_before_rendering_spec.rb +24 -7
  15. metadata +20 -56
  16. data/spec/dummy/.rspec +0 -1
  17. data/spec/dummy/Rakefile +0 -7
  18. data/spec/dummy/app/assets/javascripts/application.js +0 -15
  19. data/spec/dummy/app/assets/javascripts/sample_objects.js +0 -2
  20. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  21. data/spec/dummy/app/assets/stylesheets/sample_objects.css +0 -4
  22. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  23. data/spec/dummy/app/helpers/sample_objects_helper.rb +0 -2
  24. data/spec/dummy/app/mailers/.gitkeep +0 -0
  25. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  26. data/spec/dummy/app/views/sample_objects/index.html.erb +0 -0
  27. data/spec/dummy/app/views/sample_objects/show.html.erb +0 -0
  28. data/spec/dummy/config/environments/development.rb +0 -37
  29. data/spec/dummy/config/environments/production.rb +0 -67
  30. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  31. data/spec/dummy/config/initializers/inflections.rb +0 -15
  32. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  33. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  34. data/spec/dummy/config/initializers/session_store.rb +0 -8
  35. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  36. data/spec/dummy/config/locales/en.yml +0 -5
  37. data/spec/dummy/lib/assets/.gitkeep +0 -0
  38. data/spec/dummy/public/404.html +0 -26
  39. data/spec/dummy/public/422.html +0 -26
  40. data/spec/dummy/public/500.html +0 -25
  41. data/spec/dummy/public/favicon.ico +0 -0
  42. data/spec/presenter_spec_spec.rb +0 -17
data/.travis.yml CHANGED
@@ -1,7 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
- - 1.9.2
5
- - 1.9.1
6
- - jruby-19mode
7
4
  - rbx-19mode
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # DelegatedPresenter
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/jwaldrip/delegated_presenter.png)](http://travis-ci.org/jwaldrip/delegated_presenter)
4
+
3
5
  DelegatedPresenter gives you an easy way to present objects and collections to your models. It uses ruby's Delegate model so it is lightweight and functional!
4
6
 
5
7
  ## Installation
@@ -47,6 +49,32 @@ class ContactPresenter < DelegatedPresenter::Base
47
49
  end
48
50
  ```
49
51
 
52
+ ### Hide or expose methods from the presented model:
53
+
54
+ There are two helper methods in the presenter.
55
+
56
+ * ```expose: :method_name, :another_method_name``` will hide all methods except the ones you specify.
57
+ * ```hide: :method_name, :another_method_name``` will only hide the methods you specify.
58
+
59
+ ```ruby
60
+ class ContactPresenter < DelegatedPresenter::Base
61
+
62
+ hide :id, :crypted_password
63
+
64
+ end
65
+ ```
66
+
67
+ or:
68
+
69
+ ```ruby
70
+ class ContactPresenter < DelegatedPresenter::Base
71
+
72
+ expose :first_name, :last_name
73
+
74
+ end
75
+ ```
76
+
77
+
50
78
  ### Use the controller helper
51
79
  See: {DelegatedPresenter::PresentsBeforeRendering}
52
80
 
@@ -60,6 +88,7 @@ class ContactsController < ApplicationController
60
88
  end
61
89
  ```
62
90
 
91
+
63
92
  If you for any reason need to explicitly define the presenter you may define a ```with: :presenter_name``` option, like so.
64
93
 
65
94
  ```ruby
@@ -70,7 +99,8 @@ class UsersController < ApplicationController
70
99
  end
71
100
  ```
72
101
 
73
- Or if you like you can just manually initialize the presenter in your actions.
102
+
103
+ ### Using the Presenter without the controller helper:
74
104
 
75
105
  ```ruby
76
106
  class ContactsController < ApplicationController
data/Rakefile CHANGED
@@ -20,8 +20,15 @@ RDoc::Task.new(:rdoc) do |rdoc|
20
20
  rdoc.rdoc_files.include('lib/**/*.rb')
21
21
  end
22
22
 
23
+ require 'rspec/core/rake_task'
24
+ RSpec::Core::RakeTask.new('spec')
23
25
 
26
+ ENV["RAILS_ENV"] ||= 'test'
24
27
 
28
+ task :default => ['db:migrate', 'db:test:prepare', :spec]
29
+
30
+ require File.expand_path('../spec/dummy/config/application', __FILE__)
31
+ Dummy::Application.load_tasks
25
32
 
26
33
  Bundler::GemHelper.install_tasks
27
34
 
@@ -24,5 +24,6 @@ Gem::Specification.new do |gem|
24
24
  gem.add_development_dependency "rails"
25
25
  gem.add_development_dependency "factory_girl"
26
26
  gem.add_development_dependency "database_cleaner"
27
+ gem.add_development_dependency "pry"
27
28
 
28
29
  end
@@ -25,11 +25,13 @@ class DelegatedPresenter::Base < SimpleDelegator
25
25
  else
26
26
  raise DelegatedPresenter::Error::NotPresentable, "#{self.presenter_class} cannot present a #{object.class}" unless object_is_presentable?(object)
27
27
  __setobj__(object)
28
+
28
29
  if exposed_methods
29
30
  expose_methods
30
31
  elsif hidden_methods
31
32
  hide_methods
32
33
  end
34
+
33
35
  end
34
36
  end
35
37
 
@@ -59,8 +61,8 @@ class DelegatedPresenter::Base < SimpleDelegator
59
61
  # @example Hide methods:
60
62
  # hide :id, :crypted_password, :password_salt
61
63
  def self.hide(*hidden_methods)
62
- self.hidden_methods[name] ||= []
63
- self.hidden_methods[name] += hidden_methods
64
+ HIDDEN_METHODS[name] ||= []
65
+ HIDDEN_METHODS[name] += hidden_methods
64
66
  end
65
67
 
66
68
  # @!visibility public
@@ -131,7 +133,8 @@ class DelegatedPresenter::Base < SimpleDelegator
131
133
  # Extracts the the models unique methods from the superclass
132
134
  # @api private
133
135
  def unique_model_methods
134
- presented_model.methods - presented_model.class.superclass.instance_methods
136
+ attributes = presented_model.respond_to?(:attributes) ? presented_model.attributes.keys.map(&:to_sym) : []
137
+ attributes + (presented_model.methods - presented_model.class.superclass.instance_methods)
135
138
  end
136
139
 
137
140
  # Maps an array of instances to delegated presented instances
@@ -3,22 +3,23 @@ module DelegatedPresenter::PresentsBeforeRendering
3
3
 
4
4
  included do
5
5
  class_attribute :presents_before_rendering
6
- self.presents_before_rendering = []
6
+ self.presents_before_rendering = {}
7
7
  end
8
8
 
9
9
  private
10
10
 
11
11
  # Presents specified instance variables before rendering.
12
- def render
13
- presents_before_rendering.each do |var|
12
+ def render(*args)
13
+ presents_before_rendering.each do |var, presenter|
14
14
  ivar = instance_variable_get("@#{var}")
15
15
  if ivar.present?
16
16
  object_class = [ivar].flatten.collect(&:class).first.to_s
17
- instance_variable_set("@#{var}", (object_class + 'Presenter').constantize.new(ivar))
17
+ presenter = (object_class + 'Presenter') if presenter.empty?
18
+ instance_variable_set("@#{var}", presenter.constantize.new(ivar))
18
19
  end
19
20
  end
20
21
 
21
- super
22
+ super(*args)
22
23
  end
23
24
 
24
25
  module ClassMethods
@@ -36,7 +37,9 @@ module DelegatedPresenter::PresentsBeforeRendering
36
37
  # @option options [Symbol] :with The presenter to use.
37
38
  def presents(*instance_vars)
38
39
  options = instance_vars.extract_options!
39
- self.presents_before_rendering += instance_vars.flatten.map(&:to_s)
40
+ instance_vars.flatten.each do |instance_var|
41
+ self.presents_before_rendering.merge!({ instance_var.to_sym => options[:with].to_s })
42
+ end
40
43
  end
41
44
 
42
45
  alias :present :presents
@@ -1,3 +1,3 @@
1
1
  module DelegatedPresenter
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -1,4 +1,9 @@
1
1
  require "delegated_presenter/version"
2
+ require 'delegate'
3
+ require "active_support/concern"
4
+ require "active_support/dependencies/autoload"
5
+ require "active_support/core_ext/module/delegation"
6
+ require "active_support/inflector"
2
7
 
3
8
  module DelegatedPresenter
4
9
  extend ActiveSupport::Autoload
@@ -1,13 +1,21 @@
1
1
  class SampleObjectsController < ApplicationController
2
2
 
3
3
  presents :instance, :collection
4
+ presents :inherited_instance, with: SampleObjectPresenter
4
5
 
5
6
  def index
6
7
  @collection = SampleObject.all
8
+ render text: true
7
9
  end
8
10
 
9
11
  def show
10
12
  @instance = SampleObject.find(params[:id])
13
+ render text: true
14
+ end
15
+
16
+ def show_inherited
17
+ @inherited_instance = InheritedSampleObject.find(params[:id])
18
+ render text: true
11
19
  end
12
20
 
13
21
  end
@@ -1,25 +1,5 @@
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
1
  test:
16
2
  adapter: sqlite3
17
3
  database: db/test.sqlite3
18
4
  pool: 5
19
- timeout: 5000
20
-
21
- production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
24
- pool: 5
25
- timeout: 5000
5
+ timeout: 5000
@@ -1,3 +1,5 @@
1
1
  Dummy::Application.routes.draw do
2
- resources :sample_objects
2
+ resources :sample_objects do
3
+ match 'inherited/:id' => 'sample_objects#show_inherited', on: :collection
4
+ end
3
5
  end
@@ -1,4 +1,5 @@
1
1
  FactoryGirl.define do
2
+
2
3
  factory :sample_object do
3
4
  prefix "Dr."
4
5
  first_name "John"
@@ -0,0 +1,104 @@
1
+ require 'spec_helper'
2
+
3
+ class SpecObject
4
+
5
+ attr_accessor :exposed_attr, :hidden_attr, :model_instance_method
6
+
7
+ end
8
+
9
+ class SpecObjectPresenter < DelegatedPresenter::Base
10
+
11
+ def presenter_method
12
+ end
13
+
14
+ end
15
+
16
+ class SpecObjectWithHiddenPresenter < DelegatedPresenter::Base
17
+
18
+ presents SpecObject
19
+ hide :hidden_attr
20
+
21
+ end
22
+
23
+ class SpecObjectWithExposedPresenter < DelegatedPresenter::Base
24
+
25
+ presents SpecObject
26
+ expose :exposed_attr
27
+
28
+ end
29
+
30
+ describe SpecObjectPresenter do
31
+
32
+ let(:object) { SpecObject.new }
33
+ subject{ SpecObjectPresenter.new(object) }
34
+
35
+ context "presenter method" do
36
+ it '#presenter_method' do
37
+ subject.respond_to?(:presenter_method).should == true
38
+ end
39
+ end
40
+
41
+ context "model instance method" do
42
+ it '#model_instance_method' do
43
+ subject.respond_to?(:model_instance_method).should == true
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ describe SpecObjectWithHiddenPresenter do
50
+
51
+ describe '.hide' do
52
+ it "should hide methods" do
53
+ SpecObjectWithHiddenPresenter.hidden_methods.include?(:hidden_attr).should == true
54
+ end
55
+ end
56
+
57
+ context 'hides methods' do
58
+ let(:object) { SpecObject.new }
59
+ subject { SpecObjectWithHiddenPresenter.new(object) }
60
+
61
+ describe '#hidden_attr' do
62
+ it "should raise an error" do
63
+ expect{ subject.hidden_attr }.to raise_error(DelegatedPresenter::Error::MethodHidden)
64
+ end
65
+ end
66
+
67
+ describe '#model_instance_method' do
68
+ it "should not raise an error" do
69
+ expect{ subject.model_instance_method }.to_not raise_error(DelegatedPresenter::Error::MethodHidden)
70
+ end
71
+ end
72
+
73
+ end
74
+
75
+ end
76
+
77
+
78
+ describe SpecObjectWithExposedPresenter do
79
+
80
+ describe '.expose' do
81
+ it "should expose methods" do
82
+ SpecObjectWithExposedPresenter.exposed_methods.include?(:exposed_attr).should == true
83
+ end
84
+ end
85
+
86
+ context 'exposes methods' do
87
+ let(:object) { SpecObject.new }
88
+ subject { SpecObjectWithExposedPresenter.new(object) }
89
+
90
+ describe '#exposed_attr' do
91
+ it "should not raise an error" do
92
+ expect{ subject.exposed_attr }.to_not raise_error(DelegatedPresenter::Error::MethodNotExposed)
93
+ end
94
+ end
95
+
96
+ describe '#model_instance_method' do
97
+ it "should raise an error" do
98
+ expect{ subject.model_instance_method }.to raise_error(DelegatedPresenter::Error::MethodNotExposed)
99
+ end
100
+ end
101
+
102
+ end
103
+
104
+ end
@@ -4,16 +4,33 @@ describe SampleObjectsController, type: :controller do
4
4
 
5
5
  before do
6
6
  10.times { FactoryGirl.create(:sample_object) }
7
+ 10.times { FactoryGirl.create(:inherited_sample_object) }
7
8
  end
8
9
 
9
- it 'presents @collection' do
10
- get :index
11
- expect(assigns(:collection).presenter_class).to eq(SampleObjectPresenter)
12
- end
10
+ context "presents before rendering" do
11
+
12
+ describe "#render (collection)" do
13
+ it 'presents @collection' do
14
+ get :index
15
+ assigns(:collection).presenter_class.should eq(SampleObjectPresenter)
16
+ end
17
+ end
18
+
19
+ describe "#render (instance)" do
20
+ it 'presents @instance' do
21
+ get :show, { id: SampleObject.first.id }
22
+ assigns(:instance).presenter_class.should eq(SampleObjectPresenter)
23
+ end
24
+ end
25
+
26
+ describe "#render (instance with specified presenter)" do
27
+ it 'presents @with_presenter' do
28
+ get :show_inherited, { id: InheritedSampleObject.first.id }
29
+ assigns(:inherited_instance).presenter_class.should eq(SampleObjectPresenter)
30
+ end
31
+ end
32
+
13
33
 
14
- it 'presents @instance' do
15
- get :show, { id: 1 }
16
- expect(assigns(:instance).presenter_class).to eq(SampleObjectPresenter)
17
34
  end
18
35
 
19
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delegated_presenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-06 00:00:00.000000000 Z
12
+ date: 2012-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -123,6 +123,22 @@ dependencies:
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: pry
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
126
142
  description: Simple presenter allows for a simple way for you to present a model to
127
143
  your views without cluttering up the original model.
128
144
  email:
@@ -150,52 +166,26 @@ files:
150
166
  - lib/generators/delegated_presenter_generator.rb
151
167
  - lib/generators/templates/presenter.rb.erb
152
168
  - lib/tasks/delegated_presenter_tasks.rake
153
- - spec/dummy/.rspec
154
169
  - spec/dummy/README.rdoc
155
- - spec/dummy/Rakefile
156
- - spec/dummy/app/assets/javascripts/application.js
157
- - spec/dummy/app/assets/javascripts/sample_objects.js
158
- - spec/dummy/app/assets/stylesheets/application.css
159
- - spec/dummy/app/assets/stylesheets/sample_objects.css
160
170
  - spec/dummy/app/controllers/application_controller.rb
161
171
  - spec/dummy/app/controllers/sample_objects_controller.rb
162
- - spec/dummy/app/helpers/application_helper.rb
163
- - spec/dummy/app/helpers/sample_objects_helper.rb
164
- - spec/dummy/app/mailers/.gitkeep
165
172
  - spec/dummy/app/models/.gitkeep
166
173
  - spec/dummy/app/models/inherited_sample_object.rb
167
174
  - spec/dummy/app/models/sample_object.rb
168
175
  - spec/dummy/app/presenters/sample_object_presenter.rb
169
- - spec/dummy/app/views/layouts/application.html.erb
170
- - spec/dummy/app/views/sample_objects/index.html.erb
171
- - spec/dummy/app/views/sample_objects/show.html.erb
172
176
  - spec/dummy/config.ru
173
177
  - spec/dummy/config/application.rb
174
178
  - spec/dummy/config/boot.rb
175
179
  - spec/dummy/config/database.yml
176
180
  - spec/dummy/config/environment.rb
177
- - spec/dummy/config/environments/development.rb
178
- - spec/dummy/config/environments/production.rb
179
181
  - spec/dummy/config/environments/test.rb
180
- - spec/dummy/config/initializers/backtrace_silencers.rb
181
- - spec/dummy/config/initializers/inflections.rb
182
- - spec/dummy/config/initializers/mime_types.rb
183
- - spec/dummy/config/initializers/secret_token.rb
184
- - spec/dummy/config/initializers/session_store.rb
185
- - spec/dummy/config/initializers/wrap_parameters.rb
186
- - spec/dummy/config/locales/en.yml
187
182
  - spec/dummy/config/routes.rb
188
183
  - spec/dummy/db/migrate/20121006185000_create_sample_objects.rb
189
184
  - spec/dummy/db/schema.rb
190
- - spec/dummy/lib/assets/.gitkeep
191
185
  - spec/dummy/log/.gitkeep
192
- - spec/dummy/public/404.html
193
- - spec/dummy/public/422.html
194
- - spec/dummy/public/500.html
195
- - spec/dummy/public/favicon.ico
196
186
  - spec/dummy/script/rails
197
187
  - spec/factories/sample_object.rb
198
- - spec/presenter_spec_spec.rb
188
+ - spec/presenter_spec.rb
199
189
  - spec/presents_before_rendering_spec.rb
200
190
  - spec/spec_helper.rb
201
191
  homepage: http://github.com/jwaldrip/delegated_presenter
@@ -224,52 +214,26 @@ specification_version: 3
224
214
  summary: Simple presenter allows for a simple way for you to present a model to your
225
215
  views without cluttering up the original model.
226
216
  test_files:
227
- - spec/dummy/.rspec
228
217
  - spec/dummy/README.rdoc
229
- - spec/dummy/Rakefile
230
- - spec/dummy/app/assets/javascripts/application.js
231
- - spec/dummy/app/assets/javascripts/sample_objects.js
232
- - spec/dummy/app/assets/stylesheets/application.css
233
- - spec/dummy/app/assets/stylesheets/sample_objects.css
234
218
  - spec/dummy/app/controllers/application_controller.rb
235
219
  - spec/dummy/app/controllers/sample_objects_controller.rb
236
- - spec/dummy/app/helpers/application_helper.rb
237
- - spec/dummy/app/helpers/sample_objects_helper.rb
238
- - spec/dummy/app/mailers/.gitkeep
239
220
  - spec/dummy/app/models/.gitkeep
240
221
  - spec/dummy/app/models/inherited_sample_object.rb
241
222
  - spec/dummy/app/models/sample_object.rb
242
223
  - spec/dummy/app/presenters/sample_object_presenter.rb
243
- - spec/dummy/app/views/layouts/application.html.erb
244
- - spec/dummy/app/views/sample_objects/index.html.erb
245
- - spec/dummy/app/views/sample_objects/show.html.erb
246
224
  - spec/dummy/config.ru
247
225
  - spec/dummy/config/application.rb
248
226
  - spec/dummy/config/boot.rb
249
227
  - spec/dummy/config/database.yml
250
228
  - spec/dummy/config/environment.rb
251
- - spec/dummy/config/environments/development.rb
252
- - spec/dummy/config/environments/production.rb
253
229
  - spec/dummy/config/environments/test.rb
254
- - spec/dummy/config/initializers/backtrace_silencers.rb
255
- - spec/dummy/config/initializers/inflections.rb
256
- - spec/dummy/config/initializers/mime_types.rb
257
- - spec/dummy/config/initializers/secret_token.rb
258
- - spec/dummy/config/initializers/session_store.rb
259
- - spec/dummy/config/initializers/wrap_parameters.rb
260
- - spec/dummy/config/locales/en.yml
261
230
  - spec/dummy/config/routes.rb
262
231
  - spec/dummy/db/migrate/20121006185000_create_sample_objects.rb
263
232
  - spec/dummy/db/schema.rb
264
- - spec/dummy/lib/assets/.gitkeep
265
233
  - spec/dummy/log/.gitkeep
266
- - spec/dummy/public/404.html
267
- - spec/dummy/public/422.html
268
- - spec/dummy/public/500.html
269
- - spec/dummy/public/favicon.ico
270
234
  - spec/dummy/script/rails
271
235
  - spec/factories/sample_object.rb
272
- - spec/presenter_spec_spec.rb
236
+ - spec/presenter_spec.rb
273
237
  - spec/presents_before_rendering_spec.rb
274
238
  - spec/spec_helper.rb
275
239
  has_rdoc:
data/spec/dummy/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
data/spec/dummy/Rakefile DELETED
@@ -1,7 +0,0 @@
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
@@ -1,15 +0,0 @@
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 .
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
@@ -1,13 +0,0 @@
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
- */
@@ -1,4 +0,0 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,2 +0,0 @@
1
- module SampleObjectsHelper
2
- end
File without changes
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", :media => "all" %>
6
- <%= javascript_include_tag "application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
File without changes
File without changes
@@ -1,37 +0,0 @@
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
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- # Print deprecation notices to the Rails logger
20
- config.active_support.deprecation = :log
21
-
22
- # Only use best-standards-support built into browsers
23
- config.action_dispatch.best_standards_support = :builtin
24
-
25
- # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
27
-
28
- # Log the query plan for queries taking more than this (works
29
- # with SQLite, MySQL, and PostgreSQL)
30
- config.active_record.auto_explain_threshold_in_seconds = 0.5
31
-
32
- # Do not compress assets
33
- config.assets.compress = false
34
-
35
- # Expands the lines which load the assets
36
- config.assets.debug = true
37
- end
@@ -1,67 +0,0 @@
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
- # Compress JavaScripts and CSS
15
- config.assets.compress = true
16
-
17
- # Don't fallback to assets pipeline if a precompiled asset is missed
18
- config.assets.compile = false
19
-
20
- # Generate digests for assets URLs
21
- config.assets.digest = true
22
-
23
- # Defaults to nil and saved in location specified by config.assets.prefix
24
- # config.assets.manifest = YOUR_PATH
25
-
26
- # Specifies the header that your server uses for sending files
27
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
-
30
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
- # config.force_ssl = true
32
-
33
- # See everything in the log (default is :info)
34
- # config.log_level = :debug
35
-
36
- # Prepend all log lines with the following tags
37
- # config.log_tags = [ :subdomain, :uuid ]
38
-
39
- # Use a different logger for distributed setups
40
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41
-
42
- # Use a different cache store in production
43
- # config.cache_store = :mem_cache_store
44
-
45
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
46
- # config.action_controller.asset_host = "http://assets.example.com"
47
-
48
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
49
- # config.assets.precompile += %w( search.js )
50
-
51
- # Disable delivery errors, bad email addresses will be ignored
52
- # config.action_mailer.raise_delivery_errors = false
53
-
54
- # Enable threaded mode
55
- # config.threadsafe!
56
-
57
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58
- # the I18n.default_locale when a translation can not be found)
59
- config.i18n.fallbacks = true
60
-
61
- # Send deprecation notices to registered listeners
62
- config.active_support.deprecation = :notify
63
-
64
- # Log the query plan for queries taking more than this (works
65
- # with SQLite, MySQL, and PostgreSQL)
66
- # config.active_record.auto_explain_threshold_in_seconds = 0.5
67
- end
@@ -1,7 +0,0 @@
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!
@@ -1,15 +0,0 @@
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
@@ -1,5 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new mime types for use in respond_to blocks:
4
- # Mime::Type.register "text/richtext", :rtf
5
- # Mime::Type.register_alias "text/html", :iphone
@@ -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
- Dummy::Application.config.secret_token = 'c47a06a3fcf2da19af049e07da314dc501bc5eb5d68cab3ed276191cac61ce9985fafa944e664f47b5fd96f313abc4d5c79f7ede34d98fd60ea4e52e10408d5b'
@@ -1,8 +0,0 @@
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
@@ -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,5 +0,0 @@
1
- # Sample localization file for English. Add more files in this directory for other locales.
2
- # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
-
4
- en:
5
- hello: "Hello world"
File without changes
@@ -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,25 +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
- </div>
24
- </body>
25
- </html>
File without changes
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe SampleObjectPresenter do
4
-
5
- it '.presenter_method (full_name)' do
6
- object = FactoryGirl.create(:sample_object)
7
- presented_object = SampleObjectPresenter.new(object)
8
- expect(presented_object.full_name).to be_present
9
- end
10
-
11
- it '.model_instance_method (first_name)' do
12
- object = FactoryGirl.create(:sample_object)
13
- presented_object = SampleObjectPresenter.new(object)
14
- expect(presented_object.first_name).to be_present
15
- end
16
-
17
- end