api_client_bulk_loader 0.1.3

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.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +32 -0
  3. data/lib/api_client_bulk_loader/api_client_bulk_loader.rb +14 -0
  4. data/lib/api_client_bulk_loader/client/association_adapter.rb +31 -0
  5. data/lib/api_client_bulk_loader/client/association_helper.rb +60 -0
  6. data/lib/api_client_bulk_loader/client/bulk_load_helper.rb +46 -0
  7. data/lib/api_client_bulk_loader/client/loader.rb +79 -0
  8. data/lib/api_client_bulk_loader/client/polymorphic_association_adapter.rb +32 -0
  9. data/lib/api_client_bulk_loader/client/polymorphic_association_helper.rb +63 -0
  10. data/lib/api_client_bulk_loader/version.rb +3 -0
  11. data/lib/api_client_bulk_loader.rb +4 -0
  12. data/test/dummy/README.rdoc +28 -0
  13. data/test/dummy/Rakefile +6 -0
  14. data/test/dummy/app/assets/javascripts/application.js +13 -0
  15. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  16. data/test/dummy/app/controllers/application_controller.rb +5 -0
  17. data/test/dummy/app/controllers/variant_objects_controller.rb +10 -0
  18. data/test/dummy/app/helpers/application_helper.rb +2 -0
  19. data/test/dummy/app/models/variant_object.rb +2 -0
  20. data/test/dummy/app/views/layouts/application.html.erb +11 -0
  21. data/test/dummy/app/views/variant_objects/_variant_object.html.erb +1 -0
  22. data/test/dummy/app/views/variant_objects/_variant_object_medium.html.erb +1 -0
  23. data/test/dummy/app/views/variant_objects/_variant_object_small.html.erb +1 -0
  24. data/test/dummy/app/views/variant_objects/index.html.erb +24 -0
  25. data/test/dummy/bin/bundle +3 -0
  26. data/test/dummy/bin/rails +4 -0
  27. data/test/dummy/bin/rake +4 -0
  28. data/test/dummy/config/application.rb +23 -0
  29. data/test/dummy/config/boot.rb +5 -0
  30. data/test/dummy/config/database.yml +25 -0
  31. data/test/dummy/config/environment.rb +5 -0
  32. data/test/dummy/config/environments/development.rb +29 -0
  33. data/test/dummy/config/environments/production.rb +80 -0
  34. data/test/dummy/config/environments/test.rb +36 -0
  35. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  36. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  37. data/test/dummy/config/initializers/inflections.rb +16 -0
  38. data/test/dummy/config/initializers/mime_types.rb +5 -0
  39. data/test/dummy/config/initializers/secret_token.rb +12 -0
  40. data/test/dummy/config/initializers/session_store.rb +3 -0
  41. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  42. data/test/dummy/config/locales/en.yml +23 -0
  43. data/test/dummy/config/routes.rb +58 -0
  44. data/test/dummy/config.ru +4 -0
  45. data/test/dummy/db/development.sqlite3 +0 -0
  46. data/test/dummy/db/migrate/20131206162427_create_variant_objects.rb +9 -0
  47. data/test/dummy/db/schema.rb +23 -0
  48. data/test/dummy/db/test.sqlite3 +0 -0
  49. data/test/dummy/log/development.log +40 -0
  50. data/test/dummy/log/test.log +521 -0
  51. data/test/dummy/public/404.html +58 -0
  52. data/test/dummy/public/422.html +58 -0
  53. data/test/dummy/public/500.html +57 -0
  54. data/test/dummy/public/favicon.ico +0 -0
  55. data/test/dummy/test/fixtures/variant_objects.yml +14 -0
  56. data/test/integration/variant_object_controller_test.rb +25 -0
  57. data/test/test_helper.rb +26 -0
  58. metadata +188 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9b52e169fa4d30699f1d05bccb728bb24da39004
4
+ data.tar.gz: 5a7605677dd52caa27ef85a544187807bce9b2d1
5
+ SHA512:
6
+ metadata.gz: 5b91c1a5b5648d0724356c39c1ca130576c723af4c44acb607680849c743022f3255c6c9db3be6c5429c3bf6c79e63da323aaaa47917a545b9955f066fa80828
7
+ data.tar.gz: 9665e5686d9b9bf1aebdfa1b7d98f36da80ad7c60c13ca60c174d11616eb7dfbdb9d91b07c9dfc49134349d97263fa68bbd92c4e898713cd60a58950619cca16
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'ApiClientBulkLoader'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
@@ -0,0 +1,14 @@
1
+
2
+ module ApiClientBulkLoader
3
+ module Client
4
+ autoload :AssociationHelper, 'api_client_bulk_loader/client/association_helper'
5
+ autoload :AssociationAdapter, 'api_client_bulk_loader/client/association_adapter'
6
+ autoload :PolymorphicAssociationHelper, 'api_client_bulk_loader/client/polymorphic_association_helper'
7
+ autoload :PolymorphicAssociationAdapter, 'api_client_bulk_loader/client/polymorphic_association_adapter'
8
+ autoload :BulkLoadHelper, 'api_client_bulk_loader/client/bulk_load_helper'
9
+ autoload :Loader, 'api_client_bulk_loader/client/loader'
10
+ end
11
+
12
+ end
13
+
14
+ JsonApiClient::Resource.send(:include, ApiClientBulkLoader::Client::BulkLoadHelper)
@@ -0,0 +1,31 @@
1
+ module ApiClientBulkLoader
2
+ module Client
3
+ #Adapts into the bulk loader. Mainly useful for storing the details of the bulk call.
4
+ class AssociationAdapter
5
+ attr_reader :resource_model, :attribute, :autoload, :values_from, :limit
6
+
7
+ def initialize(res_model, attribute = nil, values_from = nil, autoload = false, is_has_one = false, limit = nil)
8
+ @resource_model = res_model
9
+ @attribute = attribute
10
+ @autoload = autoload
11
+ @values_from = values_from
12
+ @has_one = is_has_one
13
+ @limit = limit
14
+
15
+ Thread.current[:bulk_loader] ||= ApiClientBulkLoader::Client::Loader.new
16
+ @bulk_loader = Thread.current[:bulk_loader]
17
+ end
18
+
19
+ #Fetch.
20
+ def fetch(values)
21
+ results = @bulk_loader.fetch(@resource_model, values, @attribute)
22
+ return @has_one ? results.first : results
23
+ end
24
+
25
+ #Push.
26
+ def push(values)
27
+ @bulk_loader.push(@resource_model, values, @attribute)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,60 @@
1
+ module ApiClientBulkLoader
2
+ module Client
3
+ #Included in the client base models
4
+ module AssociationHelper
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ #manually push values into the queue.
9
+ def self.bulk_queue_values_for_association(values, association)
10
+ raise Exception.new("Cannot find bulk-enabled association #{association} in class.") unless @bulk_queued_associations[association]
11
+ @bulk_queued_associations[association].push(values)
12
+ end
13
+
14
+ #Register an association as one to be batch loaded
15
+ #Required:
16
+ # association - the association that is being bulk loaded.
17
+ # api_client_model - the model to fetch the association with (what you call .find on)
18
+ #Optional
19
+ # attribute - The attribute of the associated model to search by. Defults to id. This could be used to query by an FK - If you have a User class and a user has many Cars, then under User you could do
20
+ # bulk_load :cars, Client::Cars, attribute: user_id
21
+ # This would cause user.cars to trigger a query of cars.json?user_id=<the users id> instead of the default cars.json?ids=[user.car_ids]
22
+ # Use this when the length of .<>_ids exceeds the uri length limit.
23
+ # from - The attribute of the client model to use to fetch values. eg. :assoc_ids
24
+ # autoload - if the ids for the association will be queued on the item's initialization. Else, you call obj.queue_association(:assoc_to_load) manually.
25
+ # is_has_one - Overrides the default of returning an array for the association, instead it returns the first item.
26
+
27
+ def self.bulk_load(association, api_client_model, attribute: :id, autoload: false, from: :id, is_has_one: false, limit: nil)
28
+ @bulk_queued_associations ||= {}
29
+ @bulk_queued_associations[association] = ApiClientBulkLoader::Client::AssociationAdapter.new(api_client_model, attribute, from, autoload, is_has_one, limit)
30
+
31
+ define_bulk_method(association)
32
+ end
33
+
34
+ #Shorthand to the above, but automatically sets 'is_has_one' to true.
35
+ def self.bulk_load_has_one(*args, **kwargs)
36
+ self.bulk_load(*args,**kwargs.merge({is_has_one: true}))
37
+ end
38
+
39
+ def queue_association(association, limit = nil)
40
+ adapter = self.class.bulk_queued_associations[association]
41
+ #Probably just raise an exception if it doesnt respond to the target.
42
+ values = Array(self.send(adapter.values_from))
43
+ limit = limit || adapter.limit
44
+
45
+ values = values.first(limit) if limit.present?
46
+
47
+
48
+ if !values.nil?
49
+ adapter.push(values)
50
+ self.instance_variable_set("@#{association}", ->{
51
+ adapter.fetch(values)
52
+ })
53
+ end
54
+ end
55
+
56
+ end
57
+
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,46 @@
1
+ module ApiClientBulkLoader
2
+ module Client
3
+ #Included in the client base models
4
+ module BulkLoadHelper
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+
9
+ include AssociationHelper
10
+ include PolymorphicAssociationHelper
11
+
12
+ #Getter for registered association load queues
13
+ def self.bulk_queued_associations
14
+ @bulk_queued_associations
15
+ end
16
+
17
+ def self.define_bulk_method(association)
18
+ #define new getter for assoc that uses the proc
19
+ define_method association.to_s do
20
+ ivar = self.instance_variable_get("@#{association}")
21
+ if (ivar.is_a? Proc)
22
+ self.instance_variable_set("@#{association}", ivar.call)
23
+ else
24
+ ivar
25
+ end
26
+ end
27
+ end
28
+
29
+ def initialize(*args)
30
+ super(*args)
31
+ #Skip em unless we got em
32
+ return self unless self.class.bulk_queued_associations
33
+ self.class.bulk_queued_associations.each do |assoc, adapter|
34
+ if adapter.class == ApiClientBulkLoader::Client::PolymorphicAssociationAdapter
35
+ self.queue_poly_association(assoc) if adapter.autoload
36
+ else
37
+ self.queue_association(assoc) if adapter.autoload
38
+ end
39
+ end
40
+
41
+ return self
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,79 @@
1
+ module ApiClientBulkLoader
2
+ module Client
3
+ #Storage class for our bulk loading. Is one per thread.
4
+ class Loader
5
+ def initialize()
6
+ #Hash with keys being a client model, pointing to hashes with id's as keys and loaded objects as values.
7
+ @model_store = {}
8
+
9
+ #Contains each bulk stored model, then containing the attribute to be queried by which then holds an array of values that have yet to be fetched
10
+ @queued_model_store = {}
11
+
12
+ #Contains a structure similar to queued model store, but stores which values have already been queried.
13
+ @checked_model_store = {}
14
+ end
15
+
16
+ #Push the values into the appropriate queue store, only if they haven't been run.
17
+ def push(model, values, attribute = :id)
18
+ # Idempotent.
19
+ create_model_attribute_store(model, attribute)
20
+
21
+ # Eliminate those that have already been checked
22
+ values -= @checked_model_store[model][attribute] if(@checked_model_store[model][attribute])
23
+
24
+ # or in those values to the queue store.
25
+ @queued_model_store[model][attribute] |= values
26
+ end
27
+
28
+ #Fetch the values, given the adapter that pertains to those values.
29
+ def fetch(model, values, attribute = :id)
30
+ #If any of these values are in the queue, we have to retrieve it.
31
+ retrieve_model_by_attribute!(model, attribute) unless (values & @queued_model_store[model][attribute]).empty?
32
+
33
+ #Return all values for keys matching our value(s)
34
+ return @model_store[model].values_at(*values).compact || []
35
+ end
36
+
37
+ private
38
+
39
+ #For a model's attribute, fetch all records matching the values in the queue.
40
+ def retrieve_model_by_attribute!(model, attribute)
41
+ return [] unless @queued_model_store[model][attribute]
42
+ #Get our values from the queue and make the call to the client model
43
+
44
+ values = @queued_model_store[model][attribute]
45
+
46
+ results = if attribute != :id #Index the returned results by the attribute used to query by
47
+
48
+ Array(model.find(attribute => values)).group_by{|obj| obj.send(attribute) }
49
+
50
+ else #Index the results by their ids.
51
+
52
+ Hash[ Array(model.find(values)).map{|obj| [obj.id, obj]} ]
53
+
54
+ end
55
+
56
+ #Merge the results in with what we may already have.
57
+ @model_store[model] = @model_store[model].merge(results)
58
+
59
+ #Register these values as being checked
60
+ @checked_model_store[model][attribute] |= values
61
+ #Clear the queue
62
+ @queued_model_store[model][attribute] = []
63
+ end
64
+
65
+ def create_model_attribute_store(model, attribute)
66
+ #base hash for the model
67
+ @queued_model_store[model] ||= {}
68
+ @checked_model_store[model] ||= {}
69
+
70
+ #For criteria to be loaded by an attribute
71
+ @queued_model_store[model][attribute] ||= []
72
+ #For checking if criteria has already been run.
73
+ @checked_model_store[model][attribute] ||= []
74
+ #For storing by id.
75
+ @model_store[model] ||= {}
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,32 @@
1
+ module ApiClientBulkLoader
2
+ module Client
3
+ #Adapts into the bulk loader. Mainly useful for storing the details of the bulk call.
4
+ class PolymorphicAssociationAdapter
5
+ attr_reader :resource_translation, :attribute, :autoload, :type_from, :values_from, :limit
6
+
7
+ def initialize(resource_translation, attribute = nil, type_from = nil, values_from = nil, autoload = false, is_has_one = false, limit = nil)
8
+ @resource_translation = resource_translation
9
+ @attribute = attribute
10
+ @autoload = autoload
11
+ @values_from = values_from
12
+ @type_from = type_from
13
+ @has_one = is_has_one
14
+ @limit = limit
15
+
16
+ Thread.current[:bulk_loader] ||= ApiClientBulkLoader::Client::Loader.new
17
+ @bulk_loader = Thread.current[:bulk_loader]
18
+ end
19
+
20
+ #Fetch.
21
+ def fetch(values, resource_type)
22
+ results = @bulk_loader.fetch(@resource_translation[resource_type], values, @attribute)
23
+ return @has_one ? results.first : results
24
+ end
25
+
26
+ #Push.
27
+ def push(values, resource_type)
28
+ @bulk_loader.push(@resource_translation[resource_type], values, @attribute)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,63 @@
1
+ module ApiClientBulkLoader
2
+ module Client
3
+ #Included in the client base models
4
+ module PolymorphicAssociationHelper
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+
9
+ #manually push values into the queue.
10
+ def self.bulk_queue_poly_values_for_association(resource_model, values, association)
11
+ raise Exception.new("Cannot find bulk-enabled association #{association} in class.") unless @bulk_queued_associations[association]
12
+ @bulk_queued_associations[association].push(values,resource_model)
13
+ end
14
+
15
+ #Register a polymorphic association as one to be batch loaded
16
+ #Required:
17
+ # association - the association that is being bulk loaded.
18
+ # type_model_hash - a hash mapping the possible values for type to their respective client endpoints
19
+ #Optional
20
+ # attribute - The attribute of the associated model to search by. Defults to id. This could be used to query by an FK - If you have a User class and a user has many Cars, then under User you could do
21
+ # bulk_load :cars, Client::Cars, attribute: user_id
22
+ # This would cause user.cars to trigger a query of cars.json?user_id=<the users id> instead of the default cars.json?ids=[user.car_ids]
23
+ # Use this when the length of .<>_ids exceeds the uri length limit.
24
+ # from - The attribute of the client model to use to fetch values. eg. :assoc_ids
25
+ # type_from - The attribute of the client model to use to fetch the polymorphic type
26
+ # autoload - if the ids for the association will be queued on the item's initialization. Else, you call obj.queue_association(:assoc_to_load) manually.
27
+ # is_has_one - Overrides the default of returning an array for the association, instead it returns the first item.
28
+
29
+
30
+ def self.bulk_load_poly(association, type_model_hash, attribute: :id, autoload: false, type_from: :document_type, from: :document_id, is_has_one: false, limit: nil)
31
+ @bulk_queued_associations ||= {}
32
+ @bulk_queued_associations[association] = ApiClientBulkLoader::Client::PolymorphicAssociationAdapter.new(type_model_hash, attribute,type_from, from, autoload, is_has_one, limit)
33
+
34
+ define_bulk_method(association)
35
+ end
36
+
37
+ def self.bulk_load_poly_has_one(*args, **kwargs)
38
+ self.bulk_load_poly(*args,**kwargs.merge({is_has_one: true}))
39
+ end
40
+
41
+ def queue_poly_association(association, limit = nil)
42
+ adapter = self.class.bulk_queued_associations[association]
43
+ #Probably just raise an exception if it doesnt respond to the target.
44
+ values = Array(self.send(adapter.values_from))
45
+ resource_type = self.send(adapter.type_from)
46
+ limit = limit || adapter.limit
47
+
48
+ values = values.first(limit) if limit.present?
49
+
50
+
51
+ if !values.nil?
52
+ adapter.push(values, resource_type)
53
+ self.instance_variable_set("@#{association}", ->{
54
+ adapter.fetch(values, resource_type)
55
+ })
56
+ end
57
+ end
58
+
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,3 @@
1
+ module ApiClientBulkLoader
2
+ VERSION = "0.1.3"
3
+ end
@@ -0,0 +1,4 @@
1
+ require 'rails'
2
+ require 'json_api_client'
3
+
4
+ require "api_client_bulk_loader/api_client_bulk_loader"
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,13 @@
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
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= 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,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,10 @@
1
+ class VariantObjectsController < ApplicationController
2
+
3
+ def index
4
+ @variant_objects = VariantObject.all
5
+
6
+ if(params[:variant])
7
+ @variant = params[:variant]
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class VariantObject < ActiveRecord::Base
2
+ 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
+ <h1 class="default_template"><%= variant_object.name %></h1>
@@ -0,0 +1 @@
1
+ <h2 class="medium_template"><%= variant_object.name %></h2>
@@ -0,0 +1 @@
1
+ <h3 class="small_template"><%= variant_object.name %></h3>
@@ -0,0 +1,24 @@
1
+ <div id="test_disp_container">
2
+ <% if @variant %>
3
+
4
+ <%= render @variant_objects, :variant => @variant %>
5
+ <hr/>
6
+ <% @variant_objects.each do |variant_object| %>
7
+ <%= render :partial=> variant_object, :variant => @variant %>
8
+ <br/>
9
+ <%= render variant_object, :variant => @variant %>
10
+ <% end %>
11
+
12
+ <% else %>
13
+ <%= render @variant_objects %>
14
+ <hr/>
15
+ <% @variant_objects.each do |variant_object| %>
16
+ <%= render :partial=> variant_object %>
17
+ <br/>
18
+ <%= render variant_object %>
19
+ <% end %>
20
+ <% end %>
21
+ <% if params[:test_nil_path] %>
22
+ <%= render %>
23
+ <% end %>
24
+ </div>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -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,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "render_variant"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+ end
22
+ end
23
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -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,29 @@
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
+ # Do not eager load code on boot.
10
+ config.eager_load = false
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
+ # Raise an error on page load if there are pending migrations
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+ end