Class: Project

Inherits:
Object
  • Object
show all
Defined in:
lib/teuton/utils/project.rb

Overview

Class is used to store global parameters of the running project

Class Method Summary collapse

Class Method Details

.add_input_params(projectpath, options) ⇒ Object

Preprocess input options:

  • Convert input case options String to an Array of integers

  • Read color input option



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/teuton/utils/project.rb', line 45

def self.add_input_params(projectpath, options)
  value[:options].merge! options
  Rainbow.enabled = value[:options]["color"]

  finder = NameFileFinder.new(value[:options])
  finder.find_filenames_for(projectpath)
  value[:project_path] = finder.project_path
  value[:script_path] = finder.script_path
  value[:config_path] = finder.config_path
  value[:test_name] = finder.test_name

  return if value[:options]["case"].nil?

  numbers = value[:options]["case"].split(",")
  value[:options]["case"] = numbers.collect!(&:to_i)
end

.initObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/teuton/utils/project.rb', line 6

def self.init
  @project = {}
  @project[:running_basedir] = Dir.getwd
  @project[:output_basedir] = "var"
  @project[:name] = "teuton"
  @project[:format] = :txt # Default export format
  @project[:debug] = false # Disable/enable local executions
  @project[:options] = { # Default input options
    "color" => true,
    "lang" => "en",
    "panel" => false,
    "quiet" => false
  }
  @project[:verbose] = true # Enable/disable screen outputs
  @project[:global] = {}
  @project[:ialias] = {} # Hash of Internal alias
  @project[:macros] = {}
  @project[:groups] = []
  @project[:uses] = []
  @project[:hall_of_fame] = [] # Hall of fame content
end

.quiet?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
# File 'lib/teuton/utils/project.rb', line 34

def self.quiet?
  return true if value[:options]["quiet"]
  return true unless value[:verbose]

  false
end

.relative_path(filepath) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/teuton/utils/project.rb', line 62

def self.relative_path(filepath)
  if filepath.start_with?(Dir.pwd)
    filepath[Dir.pwd.length + 1, filepath.length]
  else
    filepath
  end
end

.valueObject



28
29
30
# File 'lib/teuton/utils/project.rb', line 28

def self.value
  @project
end