tb_heavy_control 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/lib/tasks/tb_heavy_control_tasks.rake +4 -0
  6. data/lib/tb_heavy_control/configurable.rb +89 -0
  7. data/lib/tb_heavy_control/loader.rb +41 -0
  8. data/lib/tb_heavy_control/railtie.rb +36 -0
  9. data/lib/tb_heavy_control/version.rb +3 -0
  10. data/lib/tb_heavy_control.rb +19 -0
  11. data/lib/trailblazer/operation/controller/active_record.rb +21 -0
  12. data/lib/trailblazer/operation/model/active_model.rb +11 -0
  13. data/lib/trailblazer/operation/responder.rb +23 -0
  14. data/lib/trailblazer/operation/worker.rb +112 -0
  15. data/test/dummy/README.rdoc +28 -0
  16. data/test/dummy/Rakefile +6 -0
  17. data/test/dummy/app/assets/javascripts/application.js +13 -0
  18. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  19. data/test/dummy/app/controllers/application_controller.rb +5 -0
  20. data/test/dummy/app/helpers/application_helper.rb +2 -0
  21. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  22. data/test/dummy/bin/bundle +3 -0
  23. data/test/dummy/bin/rails +4 -0
  24. data/test/dummy/bin/rake +4 -0
  25. data/test/dummy/bin/setup +29 -0
  26. data/test/dummy/config/application.rb +26 -0
  27. data/test/dummy/config/boot.rb +5 -0
  28. data/test/dummy/config/database.yml +25 -0
  29. data/test/dummy/config/environment.rb +5 -0
  30. data/test/dummy/config/environments/development.rb +41 -0
  31. data/test/dummy/config/environments/production.rb +79 -0
  32. data/test/dummy/config/environments/test.rb +42 -0
  33. data/test/dummy/config/initializers/assets.rb +11 -0
  34. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  35. data/test/dummy/config/initializers/cookies_serializer.rb +3 -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 +4 -0
  39. data/test/dummy/config/initializers/session_store.rb +3 -0
  40. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  41. data/test/dummy/config/locales/en.yml +23 -0
  42. data/test/dummy/config/routes.rb +56 -0
  43. data/test/dummy/config/secrets.yml +22 -0
  44. data/test/dummy/config.ru +4 -0
  45. data/test/dummy/public/404.html +67 -0
  46. data/test/dummy/public/422.html +67 -0
  47. data/test/dummy/public/500.html +66 -0
  48. data/test/dummy/public/favicon.ico +0 -0
  49. data/test/tb_heavy_control_test.rb +7 -0
  50. data/test/test_helper.rb +20 -0
  51. metadata +172 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a54ae4567638a77de15d4cc8f98a30b1d7876cfa
4
+ data.tar.gz: 498f1fda13c24131e900a03486b3a118ecfb80a5
5
+ SHA512:
6
+ metadata.gz: e648b9921f00750eb394ab91362f9dcdf7feeaf8d90a274b1898a0452990018deeccc5fea61f194f2cd48c864dd63530a630bc9811a94dc1ac52d84cd6b5f1a2
7
+ data.tar.gz: a99c26d484770f5adac5f5ec5ecae2c237ae0ae52e3e417645f93954180cf49566372ce79bc011b8e1c7c9284133ec8c337ac09761316c3c91447c3e91be461d
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Roman Kolesnev
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = TbHeavyControl
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
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 = 'TbHeavyControl'
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
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :tb_heavy_control do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,89 @@
1
+ module TbHeavyControl
2
+ module Configurable
3
+ CONST_CHECK_SKIP = %w(operations views concepts).freeze
4
+
5
+ attr_reader :pipeline
6
+
7
+ def config(&block)
8
+ raise 'tb_heavy_control config cannot run without block' if block.nil?
9
+ @pipeline ||= [] # Pathname means load file, String - check constant
10
+ @context = Rails.root.join('app', 'concepts')
11
+
12
+ instance_eval(&block)
13
+ end
14
+
15
+ def debug(arg = nil)
16
+ @debug = arg unless arg.nil?
17
+ @debug
18
+ end
19
+
20
+ private
21
+
22
+ # DSL methods
23
+
24
+ def getrb(original_path)
25
+ array_form = normalize(original_path)
26
+
27
+ last = array_form.last
28
+ array_form[-1] = last + '.rb' if last[-3..-1] != '.rb'
29
+
30
+ path = @context.join(*array_form)
31
+ raise "Cannot find file: #{path}" unless path.file?
32
+
33
+ @pipeline << path unless @pipeline.include?(path)
34
+ end
35
+
36
+ def context(path)
37
+ previous_context = @context
38
+ @context = previous_context.join(*normalize(path))
39
+ raise "#{@context} isn't a directory" unless @context.directory?
40
+ check_constant_for(@context)
41
+ yield
42
+ @context = previous_context
43
+ end
44
+
45
+ def folder(original_path = '')
46
+ folder = @context.join(*normalize(original_path))
47
+ raise "#{folder} isn't a directory" unless folder.directory?
48
+
49
+ rb_files = folder.children.select { |pn| pn.extname == '.rb' }
50
+ check_constant_for(folder) if rb_files.any?
51
+ rb_files.each { |file| getrb file }
52
+ end
53
+
54
+ def recursive(original_path = '', reverse: false)
55
+ folder = @context.join(*normalize(original_path))
56
+ raise "#{folder} isn't a directory" unless folder.directory?
57
+
58
+ folder original_path unless reverse
59
+ context original_path do
60
+ # exclude '.' and '..' entries
61
+ folder.children.select(&:directory?).each do |child_folder|
62
+ next if child_folder.basename == 'views'
63
+ recursive child_folder.basename, reverse: reverse
64
+ end
65
+ end
66
+ folder original_path if reverse
67
+ end
68
+
69
+ # Helper methods
70
+
71
+ def check_constant_for(folder) # rubocop:disable Metrics/AbcSize (15.5)
72
+ return if CONST_CHECK_SKIP.include? folder.basename.to_s
73
+
74
+ subpath = []
75
+ while folder.basename.to_s != 'concepts'
76
+ subpath << folder.basename
77
+ folder = folder.parent
78
+ end
79
+
80
+ const_name = subpath.reverse.map(&:to_s).map(&:camelize).join('::')
81
+
82
+ @pipeline << const_name unless @pipeline.include? const_name
83
+ end
84
+
85
+ def normalize(arg)
86
+ Array(arg).map(&:to_s)
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,41 @@
1
+ module TbHeavyControl
2
+ module Loader
3
+ class << self
4
+ def call
5
+ @order = TbHeavyControl.pipeline
6
+ @order.each do |entry|
7
+ case entry
8
+ when Pathname then load_file(entry.to_s)
9
+ when String then check_constant(entry)
10
+ end
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def load_file(file)
17
+ Rails.logger.debug "tb_heavy_control: load file '#{file}'" if TbHeavyControl.debug
18
+ require_dependency file
19
+ end
20
+
21
+ def check_constant(const_name)
22
+ Rails.logger.debug "tb_heavy_control: check constant '#{const_name}'" if TbHeavyControl.debug
23
+ const_name.constantize
24
+ rescue NameError
25
+ parent = resolve_parent(const_name)
26
+
27
+ new_module_name = const_name.demodulize
28
+ Rails.logger.debug "tb_heavy_control: create module '#{const_name}'" if TbHeavyControl.debug
29
+ parent.const_set(new_module_name, Module.new)
30
+ end
31
+
32
+ def resolve_parent(const_name)
33
+ parent_str = const_name.deconstantize
34
+ case parent_str
35
+ when '', '::' then Object
36
+ else parent_str.constantize
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,36 @@
1
+ require 'tb_heavy_control/loader'
2
+
3
+ module TbHeavyControl
4
+ class Railtie < Rails::Railtie
5
+ def self.concepts_loader(_app)
6
+ TbHeavyControl::Loader.call
7
+ end
8
+
9
+ # initializer 'tb_heavy_control.disable_eager_loading', before: :set_load_path do |app|
10
+ # path = app.root.join('app', 'concepts').to_s
11
+ #
12
+ # app.config.eager_load_paths -= [path]
13
+ # end
14
+
15
+ # this initializer is a copy from trailblazer-rails gem
16
+ initializer 'tb_heavy_control.trailblazer-rails_stuff' do
17
+ require 'trailblazer/autoloading'
18
+
19
+ require 'trailblazer/operation/model'
20
+ require 'trailblazer/operation/model/active_model'
21
+ Trailblazer::Operation::Model::DSL.module_eval do
22
+ include Trailblazer::Operation::Model::ActiveModel # ::contract.
23
+ end
24
+
25
+ Trailblazer::Operation.class_eval do
26
+ autoload :Responder, 'trailblazer/operation/responder'
27
+ end
28
+ end
29
+
30
+ initializer 'tb_heavy_control.concepts_loader', after: :load_config_initializers do |app|
31
+ ActionDispatch::Reloader.to_prepare do
32
+ TbHeavyControl::Railtie.concepts_loader(app)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module TbHeavyControl
2
+ VERSION = '0.0.1'.freeze
3
+ end
@@ -0,0 +1,19 @@
1
+ require 'tb_heavy_control/configurable'
2
+
3
+ module TbHeavyControl
4
+ extend TbHeavyControl::Configurable
5
+ end
6
+
7
+ require 'tb_heavy_control/railtie'
8
+
9
+ # stuff below is copy from trailblazer-rails gem
10
+ # stuff inside lib/trailblazer folder too =)
11
+
12
+ require 'trailblazer/operation'
13
+ # TODO: remove that once i18n, validations etc in Reform/AM are sorted.
14
+ Trailblazer::Operation.contract_class.class_eval do
15
+ def self.name
16
+ # for whatever reason, validations climb up the inheritance tree and require _every_ class to have a name (4.1).
17
+ 'Reform::Form'
18
+ end
19
+ end
@@ -0,0 +1,21 @@
1
+ # Assigns an additional instance variable for +@model+ named after the model's table name (e.g. @comment).
2
+ #
3
+ # THIS MODULE IS DEPRECATED!
4
+ #
5
+ # Please don't use this module. Instead, use @model in your controller or pass the
6
+ # operation instance to a cell to present it.
7
+ module Trailblazer::Operation::Controller::ActiveRecord
8
+ private
9
+ def setup_operation_instance_variables!(operation, options)
10
+ super
11
+ instance_variable_set(:"@#{operation_model_name}", @model)
12
+ end
13
+
14
+ def operation_model_name
15
+ # set the right variable name if collection
16
+ if @operation.is_a?(Trailblazer::Operation::Collection)
17
+ return @model.model.table_name.split(".").last
18
+ end
19
+ @model.class.table_name.split(".").last.singularize
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ module Trailblazer
2
+ module Operation::Model
3
+ # Automatically set model_name on operation's contract.
4
+ module ActiveModel
5
+ def contract(*, &block)
6
+ super
7
+ contract_class.model(model_class) # this assumes that Form::ActiveModel is mixed in.
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ module Trailblazer::Operation::Responder
2
+ def self.included(base)
3
+ base.extend ClassMethods
4
+ end
5
+
6
+ module ClassMethods
7
+ def model_name
8
+ model_class.model_name
9
+ end
10
+ end
11
+
12
+ extend Forwardable
13
+ def_delegators :@model, :to_param, :destroyed?, :persisted?
14
+
15
+ def errors
16
+ return [] if @valid
17
+ [1]
18
+ end
19
+
20
+ def to_model
21
+ @model
22
+ end
23
+ end
@@ -0,0 +1,112 @@
1
+ require 'sidekiq/worker'
2
+ require 'active_support/core_ext/hash/indifferent_access'
3
+
4
+ #setup in initialize: when Op.run() with Worker, the policy will be run "delayed" and not with the actual permission set. this will result in many crashing sidekiq workers.
5
+
6
+ class Trailblazer::Operation
7
+ # only kicks in when Operation::run, #run will still do it real-time
8
+ # Works with Reform 2, only.
9
+ module Worker
10
+ def self.included(base)
11
+ base.send(:include, Sidekiq::Worker)
12
+ base.extend(ClassMethods)
13
+ end
14
+
15
+ module ClassMethods
16
+ def run(params)
17
+ if background?
18
+ return perform_async(serializable(params))
19
+ end
20
+
21
+ super(params)
22
+ end
23
+
24
+ def new(*args)
25
+ return super if args.any?
26
+ # sidekiq behavior: (not a big fan of this)
27
+ self
28
+ end
29
+
30
+ def perform(params) # called by Sidekiq.
31
+ build_operation(params).perform
32
+ end
33
+
34
+ def jid=(jid)
35
+ puts "@@@@@ #{jid.inspect}"
36
+ end
37
+
38
+ private
39
+ def perform_async(*args)
40
+ client_push('class' => self, 'args' => args) # calls class.new.perform(params)
41
+ end
42
+
43
+ def background? # TODO: make configurable.
44
+ true
45
+ # if Rails.env == "production" or Rails.env == "staging"
46
+ end
47
+
48
+ def serializable(params)
49
+ params # this is where we convert file uloads into Trailblazer::UploadedFile, etc. soon.
50
+ end
51
+ end
52
+
53
+
54
+ def perform#(params)
55
+ # the serialized params hash from Sidekiq contains a Op::UploadedFile hash.
56
+
57
+ # the following code is basically what happens in a controller.
58
+ # this is a bug in Rails, it doesn't work without requiring as/hash/ina
59
+ # params = ActiveSupport::HashWithIndifferentAccess.new_from_hash_copying_default(params) # TODO: this might make it ultra-slow as Reform converts it back to strings.
60
+ params = @params.with_indifferent_access
61
+ @params = deserializable(params)
62
+ run
63
+ end
64
+
65
+ private
66
+ def deserializable(params)
67
+ params # this is where we convert file uloads into Trailblazer::UploadedFile, etc. soon.
68
+ end
69
+
70
+
71
+ # Overrides ::serializable and #deserializable and handles file properties from the Contract schema.
72
+ module FileMarshaller
73
+ # NOTE: this is WIP and the implementation will be more understandable and performant soon.
74
+ def self.included(base)
75
+ base.extend ClassMethods
76
+ end
77
+
78
+
79
+ private
80
+ module ClassMethods
81
+ def file_marshaller_representer
82
+ @file_marshaller_representer ||= contract_class.schema(include: [Representable::Hash]).apply do |dfn|
83
+ dfn.merge!(
84
+ getter: lambda { |*| self[dfn.name.to_sym] },
85
+ setter: lambda { |fragment, *| self[dfn.name.to_s] = fragment }
86
+ ) # FIXME: allow both sym and str.
87
+
88
+ dfn.merge!(class: Hash) and next if dfn[:form] or dfn[:twin] # nested properties need a class for deserialization.
89
+ next unless dfn[:file]
90
+
91
+ # TODO: where do we set /tmp/uploads?
92
+ dfn.merge!(
93
+ serialize: lambda { |file, *| Trailblazer::Operation::UploadedFile.new(file, tmp_dir: "/tmp/uploads").to_hash },
94
+ deserialize: lambda { |object, hash, *| Trailblazer::Operation::UploadedFile.from_hash(hash) },
95
+ class: Hash
96
+ )
97
+ end
98
+ end
99
+
100
+ def serializable(params)
101
+ file_marshaller_representer.new(params).to_hash
102
+ end
103
+ end
104
+
105
+ # todo: do with_indifferent_access in #deserialize and call super here.
106
+ def deserializable(hash)
107
+ # self.class.file_marshaller_representer.new({}).extend(Representable::Debug).from_hash(hash)
108
+ self.class.file_marshaller_representer.new({}.with_indifferent_access).from_hash(hash)
109
+ end
110
+ end
111
+ end
112
+ end
@@ -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
+ Rails.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 any plugin's vendor/assets/javascripts directory 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/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -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,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -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,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+
7
+ Dir.chdir APP_ROOT do
8
+ # This script is a starting point to setup your application.
9
+ # Add necessary setup steps to this file:
10
+
11
+ puts "== Installing dependencies =="
12
+ system "gem install bundler --conservative"
13
+ system "bundle check || bundle install"
14
+
15
+ # puts "\n== Copying sample files =="
16
+ # unless File.exist?("config/database.yml")
17
+ # system "cp config/database.yml.sample config/database.yml"
18
+ # end
19
+
20
+ puts "\n== Preparing database =="
21
+ system "bin/rake db:setup"
22
+
23
+ puts "\n== Removing old logs and tempfiles =="
24
+ system "rm -f log/*"
25
+ system "rm -rf tmp/cache"
26
+
27
+ puts "\n== Restarting application server =="
28
+ system "touch tmp/restart.txt"
29
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "tb_heavy_control"
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
+
22
+ # Do not swallow errors in after_commit/after_rollback callbacks.
23
+ config.active_record.raise_in_transactional_callbacks = true
24
+ end
25
+ end
26
+
@@ -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.exist?(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
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: db/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/production.sqlite3
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!