Module: Konstant

Defined in:
lib/konstant.rb,
lib/konstant/version.rb

Defined Under Namespace

Classes: Build, Builder, Cli, Project, Runner, Scheduler, Web

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.configObject



17
18
19
# File 'lib/konstant.rb', line 17

def self.config
  @config ||= {}
end

.configure(new_config) ⇒ Object



21
22
23
24
25
26
# File 'lib/konstant.rb', line 21

def self.configure(new_config)
  case new_config
    when Hash then config.merge! new_config
    when String then config.merge! JSON.parse(File.read new_config)
  end
end

.copy_fixture_projectsObject



36
37
38
39
# File 'lib/konstant.rb', line 36

def self.copy_fixture_projects
  system "cp -a #{root}/data/templates/data_dir #{config['data_dir']}/"
  system "cp -a #{root}/spec/fixtures/projects/* #{config['data_dir']}/projects/"
end

.envObject



41
42
43
# File 'lib/konstant.rb', line 41

def self.env
  ENV["RUBY_ENV"] || "production"
end

.loggerObject



63
64
65
66
67
68
69
# File 'lib/konstant.rb', line 63

def self.logger
  @logger ||= begin
    result = Logger.new(STDOUT)
    result.level = Logger::INFO
    result
  end
end

.logger=(value) ⇒ Object



71
72
73
# File 'lib/konstant.rb', line 71

def self.logger=(value)
  @logger = value
end

.measureObject



75
76
77
78
79
# File 'lib/konstant.rb', line 75

def self.measure
  started_at = Time.now
  yield
  Time.now - started_at
end

.reset_configObject



28
29
30
# File 'lib/konstant.rb', line 28

def self.reset_config
  @config = nil
end

.reset_data_dirObject



32
33
34
# File 'lib/konstant.rb', line 32

def self.reset_data_dir
  system "rm -rf #{config['data_dir']}"
end

.rootObject



45
46
47
# File 'lib/konstant.rb', line 45

def self.root
  File.expand_path(File.dirname(__FILE__) + "/..")
end

.shutdown!Object



49
50
51
# File 'lib/konstant.rb', line 49

def self.shutdown!
  @shutdown = true
end

.shutdown?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/konstant.rb', line 53

def self.shutdown?
  @shutdown
end

.shutdown_handlersObject



57
58
59
60
61
# File 'lib/konstant.rb', line 57

def self.shutdown_handlers
  @shutdown_handlers ||= [
    Proc.new { Konstant.shutdown! }
  ]
end