Class: Producer::Core::Env

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
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.



10
11
12
13
14
15
16
17
# File 'lib/producer/core/env.rb', line 10

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.



8
9
10
# File 'lib/producer/core/env.rb', line 8

def debug
  @debug
end

#dry_runObject

Returns the value of attribute dry_run.



8
9
10
# File 'lib/producer/core/env.rb', line 8

def dry_run
  @dry_run
end

#error_outputObject (readonly)

Returns the value of attribute error_output.



7
8
9
# File 'lib/producer/core/env.rb', line 7

def error_output
  @error_output
end

#inputObject (readonly)

Returns the value of attribute input.



7
8
9
# File 'lib/producer/core/env.rb', line 7

def input
  @input
end

#loggerObject (readonly)

Returns the value of attribute logger.



7
8
9
# File 'lib/producer/core/env.rb', line 7

def logger
  @logger
end

#outputObject (readonly)

Returns the value of attribute output.



7
8
9
# File 'lib/producer/core/env.rb', line 7

def output
  @output
end

#registryObject (readonly)

Returns the value of attribute registry.



7
8
9
# File 'lib/producer/core/env.rb', line 7

def registry
  @registry
end

#targetObject

Returns the value of attribute target.



8
9
10
# File 'lib/producer/core/env.rb', line 8

def target
  @target
end

#verboseObject

Returns the value of attribute verbose.



8
9
10
# File 'lib/producer/core/env.rb', line 8

def verbose
  @verbose
end

Instance Method Details

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



23
24
25
26
27
# File 'lib/producer/core/env.rb', line 23

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

#cleanupObject



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

def cleanup
  remote.cleanup
end

#debug?Boolean

Returns:

  • (Boolean)


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

def debug?
  @debug
end

#dry_run?Boolean

Returns:

  • (Boolean)


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

def dry_run?
  @dry_run
end

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



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

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

#remoteObject



19
20
21
# File 'lib/producer/core/env.rb', line 19

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

#verbose?Boolean

Returns:

  • (Boolean)


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

def verbose?
  @verbose
end