Module: Hourglass
- Defined in:
- lib/hourglass.rb,
lib/hourglass/tag.rb,
lib/hourglass/runner.rb,
lib/hourglass/project.rb,
lib/hourglass/setting.rb,
lib/hourglass/activity.rb,
lib/hourglass/database.rb,
lib/hourglass/application.rb
Defined Under Namespace
Classes: Activity, Application, Project, Runner, Setting, Tag
Constant Summary
collapse
- Database =
Sequel.connect("jdbc:h2:#{Hourglass.db_path};IGNORECASE=TRUE", options)
Class Method Summary
collapse
Class Method Details
.data_path ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/hourglass.rb', line 28
def self.data_path
if !defined? @data_path
dir =
if ENV['HOURGLASS_HOME']
ENV['HOURGLASS_HOME']
else
case Config::CONFIG['host_os']
when /mswin|windows/i
File.join(ENV['APPDATA'], "hourglass")
else
if ENV['HOME']
File.join(ENV['HOME'], ".hourglass")
else
raise "Can't figure out where Hourglass lives! Try setting the HOURGLASS_HOME environment variable"
end
end
end
if !File.exist?(dir)
begin
Dir.mkdir(dir)
rescue SystemCallError
raise "Can't create Hourglass directory (#{dir})! Is the parent directory accessible?"
end
end
if !File.writable?(dir)
raise "Hourglass directory (#{dir}) is not writable!"
end
@data_path = File.expand_path(dir)
end
@data_path
end
|
.db_path ⇒ Object
24
25
26
|
# File 'lib/hourglass.rb', line 24
def self.db_path
File.join(data_path, 'db', environment.to_s)
end
|
.environment ⇒ Object
20
21
22
|
# File 'lib/hourglass.rb', line 20
def self.environment
@environment ||= ENV['HOURGLASS_ENV'] || :production
end
|
.root ⇒ Object
12
13
14
|
# File 'lib/hourglass.rb', line 12
def self.root
File.expand_path(File.join(File.dirname(__FILE__), '..'))
end
|
.root_path ⇒ Object
16
17
18
|
# File 'lib/hourglass.rb', line 16
def self.root_path
@root_path ||= Pathname.new(root)
end
|