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
18
# 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

#recipe_argvObject

Returns the value of attribute recipe_argv.



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

def recipe_argv
  @recipe_argv
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



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

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

#cleanupObject



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

def cleanup
  remote.cleanup
end

#debug?Boolean

Returns:

  • (Boolean)


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

def debug?
  @debug
end

#dry_run?Boolean

Returns:

  • (Boolean)


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

def dry_run?
  @dry_run
end

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



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

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

#remoteObject



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

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

#verbose?Boolean

Returns:

  • (Boolean)


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

def verbose?
  @verbose
end