Module: SequelTools
- Defined in:
- lib/sequel_tools.rb,
lib/sequel_tools/version.rb,
lib/sequel_tools/actions_manager.rb,
lib/sequel_tools/sequel_tools_logger.rb
Defined Under Namespace
Classes: ActionsManager, MissingConfigError, SequelToolsLogger
Constant Summary
collapse
- DEFAULT_CONFIG =
{
project_root: nil,
pg_dump: 'pg_dump', psql: 'psql', maintenancedb: :default, migrations_location: 'db/migrations',
schema_location: 'db/migrations/schema.sql',
seeds_location: 'db/seeds.rb',
dbname: nil,
dbhost: 'localhost',
dbadapter: 'postgres',
dbport: nil,
username: nil,
password: nil,
dump_schema_on_migrate: false,
log_level: nil,
sql_log_level: :debug,
}
- REQUIRED_KEYS =
unfrozen on purpose so that one might want to update the defaults
[ :project_root, :dbadapter, :dbname, :username ]
- VERSION =
'0.1.6'
Class Method Summary
collapse
Class Method Details
.base_config(extra_config = {}) ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/sequel_tools.rb', line 27
def self.base_config( = {})
config = DEFAULT_CONFIG.merge
REQUIRED_KEYS.each do |key|
raise MissingConfigError, "Expected value for #{key} config is missing" if config[key].nil?
end
[:migrations_location, :schema_location, :seeds_location].each do |k|
config[k] = File.expand_path config[k], config[:project_root]
end
config
end
|
.inject_rake_tasks(config = {}, rake_context) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/sequel_tools.rb', line 38
def self.inject_rake_tasks(config = {}, rake_context)
require_relative 'sequel_tools/actions_manager'
require_relative 'sequel_tools/all_actions'
actions_manager = ActionsManager.new config
actions_manager.load_all
actions_manager.export_as_rake_tasks rake_context
end
|
.suppress_java_output ⇒ Object
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/sequel_tools.rb', line 46
def self.suppress_java_output
return yield unless RUBY_PLATFORM == 'java'
require 'java'
require 'stringio'
old_err = java.lang.System.err
java.lang.System.err = java.io.PrintStream.new(StringIO.new.to_outputstream)
yield
ensure
java.lang.System.err = old_err if RUBY_PLATFORM == 'java'
end
|