Class: Wlog::Helpers
- Inherits:
-
Object
- Object
- Wlog::Helpers
- Includes:
- StaticConfigurations
- Defined in:
- lib/wlog/domain/helpers.rb
Overview
Constant Summary
Constants included from StaticConfigurations
StaticConfigurations::AppDirectory, StaticConfigurations::AppName, StaticConfigurations::ConfigDirectory, StaticConfigurations::ConfigFile, StaticConfigurations::DataDirectory, StaticConfigurations::DefaultDb, StaticConfigurations::TaintFile, StaticConfigurations::TemplateDir, StaticConfigurations::TemplateOutputDir, StaticConfigurations::TemplateSampleFile
Class Method Summary collapse
-
.break_string(string, numchars) ⇒ Object
Break the string to a different line.
-
.database_exits? ⇒ Boolean
Check to see if the database exists in the DataDirectory.
-
.first_setup? ⇒ Boolean
Check if the application directory exists.
-
.make_dirs! ⇒ Object
Check to see if DataDirectory exists Create the data directory if it does not exist.
Class Method Details
.break_string(string, numchars) ⇒ Object
Break the string to a different line
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/wlog/domain/helpers.rb', line 12 def self.break_string(string,numchars) return unless string desc , cl = "", 0 string.split.each do |word| wlength = word.length if cl + wlength + 1 > numchars cl = 0 desc.concat($/) end desc.concat(word).concat(" ") cl += wlength + 1 end desc.chomp! desc end |
.database_exits? ⇒ Boolean
Check to see if the database exists in the DataDirectory
29 30 31 |
# File 'lib/wlog/domain/helpers.rb', line 29 def self.database_exits? File.exists? "#{DataDirectory}#{ARGV[0] || DefaultDb}" end |
.first_setup? ⇒ Boolean
Check if the application directory exists. If it does not, it’s a first time system run.
44 |
# File 'lib/wlog/domain/helpers.rb', line 44 def self.first_setup?; !File.exists? TaintFile end |
.make_dirs! ⇒ Object
Check to see if DataDirectory exists Create the data directory if it does not exist.
35 36 37 38 39 40 |
# File 'lib/wlog/domain/helpers.rb', line 35 def self.make_dirs! # Does the data dir path not exist? unless File.exists? DataDirectory FileUtils.mkdir_p DataDirectory end nil end |