Module: Cashflow::Config

Defined in:
lib/cashflow/config.rb

Class Method Summary collapse

Class Method Details

.capture_stdout(&block) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/cashflow/config.rb', line 27

def capture_stdout(&block)
  original_stdout = $stdout
  $stdout = fake = StringIO.new
  begin
    yield
  ensure
    $stdout = original_stdout
  end
  fake.string
end

.db_configObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cashflow/config.rb', line 13

def db_config
  {
    'production' => {
      'adapter'  => 'sqlite3',
      'database' => '~/.cashflow/cashflow.sqlite3'
    },

    'development' => {
      'adapter'  => 'sqlite3',
      'database' => File.join(Cashflow::Config.root_path, "db/#{env}.sqlite3").to_s
    }
  }
end

.envObject



5
6
7
# File 'lib/cashflow/config.rb', line 5

def env
  ENV['CASHFLOW_ENV'] || 'production'
end

.root_pathObject



9
10
11
# File 'lib/cashflow/config.rb', line 9

def root_path
  @@root_path ||= File.expand_path('../../..', __FILE__)
end