Class: Producer::Core::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/producer/core/env.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input: $stdin, output: $stdout, error_output: $stderr, remote: nil, registry: {}) ⇒ Env

Returns a new instance of Env.



7
8
9
10
11
12
13
14
# File 'lib/producer/core/env.rb', line 7

def initialize(input: $stdin, output: $stdout, error_output: $stderr, remote: nil, registry: {})
  @verbose = @debug = @dry_run = false
  @input        = input
  @output       = output
  @error_output = error_output
  @remote       = remote
  @registry     = registry
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



5
6
7
# File 'lib/producer/core/env.rb', line 5

def debug
  @debug
end

#dry_runObject

Returns the value of attribute dry_run.



5
6
7
# File 'lib/producer/core/env.rb', line 5

def dry_run
  @dry_run
end

#error_outputObject (readonly)

Returns the value of attribute error_output.



4
5
6
# File 'lib/producer/core/env.rb', line 4

def error_output
  @error_output
end

#inputObject (readonly)

Returns the value of attribute input.



4
5
6
# File 'lib/producer/core/env.rb', line 4

def input
  @input
end

#loggerObject (readonly)

Returns the value of attribute logger.



4
5
6
# File 'lib/producer/core/env.rb', line 4

def logger
  @logger
end

#outputObject (readonly)

Returns the value of attribute output.



4
5
6
# File 'lib/producer/core/env.rb', line 4

def output
  @output
end

#registryObject (readonly)

Returns the value of attribute registry.



4
5
6
# File 'lib/producer/core/env.rb', line 4

def registry
  @registry
end

#targetObject

Returns the value of attribute target.



5
6
7
# File 'lib/producer/core/env.rb', line 5

def target
  @target
end

#verboseObject

Returns the value of attribute verbose.



5
6
7
# File 'lib/producer/core/env.rb', line 5

def verbose
  @verbose
end

Instance Method Details

#[](key) ⇒ Object Also known as: get



20
21
22
23
24
# File 'lib/producer/core/env.rb', line 20

def [](key)
  @registry.fetch key
rescue KeyError
  fail RegistryKeyError, key.inspect
end

#[]=(key, value) ⇒ Object



27
28
29
# File 'lib/producer/core/env.rb', line 27

def []=(key, value)
  @registry[key] = value
end

#cleanupObject



56
57
58
# File 'lib/producer/core/env.rb', line 56

def cleanup
  remote.cleanup
end

#debug?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/producer/core/env.rb', line 48

def debug?
  @debug
end

#dry_run?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/producer/core/env.rb', line 52

def dry_run?
  @dry_run
end

#log(message, severity = :info) ⇒ Object



40
41
42
# File 'lib/producer/core/env.rb', line 40

def log(message, severity = :info)
  logger.send severity, message
end

#remoteObject



16
17
18
# File 'lib/producer/core/env.rb', line 16

def remote
  @remote ||= Remote.new(target)
end

#verbose?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/producer/core/env.rb', line 44

def verbose?
  @verbose
end