Class: Synvert::Core::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/synvert/core/configuration.rb

Overview

Synvert global configuration.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.number_of_workersInteger

Number of workers

Returns:

  • (Integer)

    default is 1



66
67
68
# File 'lib/synvert/core/configuration.rb', line 66

def number_of_workers
  @number_of_workers || 1
end

.only_pathsArray<String>

Get a list of only paths.

Returns:

  • (Array<String>)

    default is [].



45
46
47
# File 'lib/synvert/core/configuration.rb', line 45

def only_paths
  @only_paths || []
end

.respect_gitignoreBoolean

Check if respect .gitignore

Returns:

  • (Boolean)

    default is true



52
53
54
# File 'lib/synvert/core/configuration.rb', line 52

def respect_gitignore
  @respect_gitignore.nil? ? true : @respect_gitignore
end

.root_pathString

Get the path.

Returns:

  • (String)

    default is '.'



31
32
33
# File 'lib/synvert/core/configuration.rb', line 31

def root_path
  @root_path || '.'
end

.show_run_processBoolean

Check if show run process.

Returns:

  • (Boolean)

    default is false



59
60
61
# File 'lib/synvert/core/configuration.rb', line 59

def show_run_process
  @show_run_process || false
end

.single_quoteBoolean

Use single quote or double quote.

Returns:

  • (Boolean)

    true if use single quote, default is true



73
74
75
# File 'lib/synvert/core/configuration.rb', line 73

def single_quote
  @single_quote.nil? ? true : @single_quote
end

.skip_pathsArray<String>

Get a list of skip paths.

Returns:

  • (Array<String>)

    default is [].



38
39
40
# File 'lib/synvert/core/configuration.rb', line 38

def skip_paths
  @skip_paths || []
end

.strictBoolean

Returns the value of the strict flag.

If the strict flag is not set, it returns true by default.

Returns:

  • (Boolean)

    the value of the strict flag



91
92
93
# File 'lib/synvert/core/configuration.rb', line 91

def strict
  @strict.nil? ? true : @strict
end

.strict, if strict is false, it will ignore ruby version and gem version check.=(value) ⇒ Object (writeonly)



17
18
19
20
21
22
23
24
25
26
# File 'lib/synvert/core/configuration.rb', line 17

attr_writer :root_path,
:skip_paths,
:only_paths,
:respect_gitignore,
:show_run_process,
:number_of_workers,
:single_quote,
:tab_width,
:strict,
:test_result

.tab_widthInteger

Returns the tab width used for indentation.

If the tab width is not explicitly set, it defaults to 2.

Returns:

  • (Integer)

    The tab width.



82
83
84
# File 'lib/synvert/core/configuration.rb', line 82

def tab_width
  @tab_width || 2
end

.test_resultString

Returns the value of the test_result flag.

If the test_result flag is not set, it returns 'actions' by default.

Returns:

  • (String)

    the value of the test_result flag



100
101
102
# File 'lib/synvert/core/configuration.rb', line 100

def test_result
  @test_result || 'actions'
end

.test_result, default is 'actions', it can be 'actions' or 'new_source'.=(value) ⇒ Object (writeonly)



17
18
19
20
21
22
23
24
25
26
# File 'lib/synvert/core/configuration.rb', line 17

attr_writer :root_path,
:skip_paths,
:only_paths,
:respect_gitignore,
:show_run_process,
:number_of_workers,
:single_quote,
:tab_width,
:strict,
:test_result

Class Method Details

.with_temporary_configurations(configurations) { ... } ⇒ Object

Temporarily sets the specified configurations, executes the given block, and then restores the original configurations.

Examples:

with_temporary_configurations({ number_of_workers: 1 }) do
  # Code to be executed with temporary configurations
end

Parameters:

  • configurations (Hash)

    The configurations to be set temporarily.

Yields:

  • The block of code to be executed.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/synvert/core/configuration.rb', line 113

def with_temporary_configurations(configurations, &block)
  old_instance_variables =
    instance_variables.reduce({}) do |hash, var|
      hash[var] = instance_variable_get(var)
      hash
    end

  configurations.each do |variable, value|
    instance_variable_set("@#{variable}", value)
  end

  block.call

  old_instance_variables.each do |var, value|
    instance_variable_set(var, value)
  end
end