Class: Cuboid::OptionGroups::Paths
Overview
Holds paths to the directories of various system components.
Constant Summary
collapse
- TMPDIR_SUFFIX =
'Cuboid_'
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#==, attr_accessor, attributes, #attributes, defaults, #defaults, #hash, inherited, #merge, set_defaults, #to_h, #to_hash, #to_rpc_data, #update, #validate
Constructor Details
#initialize ⇒ Paths
Returns a new instance of Paths.
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/cuboid/option_groups/paths.rb', line 75
def initialize
@root = self.root_path
FileUtils.mkdir_p home_path
@snapshots = self.config['snapshots'] || home_path + 'snapshots/'
FileUtils.mkdir_p @snapshots
@reports = self.config['reports'] || home_path + 'reports/'
FileUtils.mkdir_p @reports
if ENV['CUBOID_LOGDIR'].to_s != ''
@logs = "#{ENV['CUBOID_LOGDIR']}/"
elsif self.config['logs']
@logs = self.config['logs']
else
@logs = "#{home_path}logs/"
FileUtils.mkdir_p @logs
end
@lib = @root + 'lib/cuboid/'
@executables = @lib + 'processes/executables/'
@support = @lib + 'support/'
@mixins = @support + 'mixins/'
instance_variables.each do |iv|
defaults[iv.to_s.sub( '@', '' ).to_sym] = instance_variable_get( iv )
end
tmpdir
end
|
Instance Attribute Details
#application ⇒ Object
43
44
45
|
# File 'lib/cuboid/option_groups/paths.rb', line 43
def application
@application
end
|
#components ⇒ String
|
# File 'lib/cuboid/option_groups/paths.rb', line 57
|
#executables ⇒ String
Returns System processes (instance, agent, browser, etc.).
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/cuboid/option_groups/paths.rb', line 75
def initialize
@root = self.root_path
FileUtils.mkdir_p home_path
@snapshots = self.config['snapshots'] || home_path + 'snapshots/'
FileUtils.mkdir_p @snapshots
@reports = self.config['reports'] || home_path + 'reports/'
FileUtils.mkdir_p @reports
if ENV['CUBOID_LOGDIR'].to_s != ''
@logs = "#{ENV['CUBOID_LOGDIR']}/"
elsif self.config['logs']
@logs = self.config['logs']
else
@logs = "#{home_path}logs/"
FileUtils.mkdir_p @logs
end
@lib = @root + 'lib/cuboid/'
@executables = @lib + 'processes/executables/'
@support = @lib + 'support/'
@mixins = @support + 'mixins/'
instance_variables.each do |iv|
defaults[iv.to_s.sub( '@', '' ).to_sym] = instance_variable_get( iv )
end
tmpdir
end
|
#lib ⇒ String
|
# File 'lib/cuboid/option_groups/paths.rb', line 48
|
#mixins ⇒ String
|
# File 'lib/cuboid/option_groups/paths.rb', line 54
|
#reports ⇒ String
|
# File 'lib/cuboid/option_groups/paths.rb', line 63
|
#root ⇒ String
|
# File 'lib/cuboid/option_groups/paths.rb', line 45
|
#services ⇒ String
|
# File 'lib/cuboid/option_groups/paths.rb', line 60
|
#snapshots ⇒ String
Returns Snapshot storage.
|
# File 'lib/cuboid/option_groups/paths.rb', line 67
|
#support ⇒ String
|
# File 'lib/cuboid/option_groups/paths.rb', line 51
|
Class Method Details
.clear_config_cache ⇒ Object
157
158
159
|
# File 'lib/cuboid/option_groups/paths.rb', line 157
def self.clear_config_cache
@config = nil
end
|
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/cuboid/option_groups/paths.rb', line 161
def self.config
return @config if @config
if !File.exist?( paths_config_file )
@config = {}
else
@config = YAML.load( IO.read( paths_config_file ) )
end
@config.dup.each do |category, dir|
if dir.to_s.empty?
@config.delete( category )
next
end
dir = Cuboid.get_long_win32_filename( dir )
if !Cuboid.windows?
dir.gsub!( '~', ENV['HOME'] )
end
dir << '/' if !dir.end_with?( '/' )
@config[category] = dir
FileUtils.mkdir_p dir
end
@config
end
|
.paths_config_file ⇒ Object
153
154
155
|
# File 'lib/cuboid/option_groups/paths.rb', line 153
def self.paths_config_file
Cuboid.get_long_win32_filename "#{root_path}config/paths.yml"
end
|
.root_path ⇒ String
Returns Root path of the engine.
116
117
118
|
# File 'lib/cuboid/option_groups/paths.rb', line 116
def self.root_path
File.expand_path( File.dirname( __FILE__ ) + '/../../..' ) + '/'
end
|
Instance Method Details
149
150
151
|
# File 'lib/cuboid/option_groups/paths.rb', line 149
def config
self.class.config
end
|
#home_path ⇒ Object
106
107
108
|
# File 'lib/cuboid/option_groups/paths.rb', line 106
def home_path
@home_path ||= "#{ENV['HOME']}/.cuboid/"
end
|
#os_tmpdir ⇒ Object
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/cuboid/option_groups/paths.rb', line 120
def os_tmpdir
return @os_tmpdir if @os_tmpdir
if config['tmpdir'].to_s.empty?
@os_tmpdir = Cuboid.get_long_win32_filename( Dir.tmpdir )
else
@os_tmpdir = Cuboid.get_long_win32_filename( config['tmpdir'] )
end
end
|
#root_path ⇒ Object
110
111
112
|
# File 'lib/cuboid/option_groups/paths.rb', line 110
def root_path
self.class.root_path
end
|
#tmp_dir_for(pid) ⇒ Object
145
146
147
|
# File 'lib/cuboid/option_groups/paths.rb', line 145
def tmp_dir_for( pid )
"#{os_tmpdir}/#{TMPDIR_SUFFIX}#{pid}"
end
|
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/cuboid/option_groups/paths.rb', line 132
def tmpdir
return @tmpdir if @tmpdir
dir = tmp_dir_for( Process.pid )
FileUtils.mkdir_p dir
at_exit do
FileUtils.rm_rf dir
end
@tmpdir = dir
end
|