Class: Cocina::CLI
- Inherits:
-
Object
- Object
- Cocina::CLI
- Defined in:
- lib/cocina/cli.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#dependencies ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#instances ⇒ Object
readonly
Returns the value of attribute instances.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#primary_dependencies ⇒ Object
readonly
Returns the value of attribute primary_dependencies.
-
#primary_instance ⇒ Object
readonly
Returns the value of attribute primary_instance.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #converge_dependencies ⇒ Object
- #converge_dependency(dep) ⇒ Object
- #destroy_dependencies ⇒ Object
-
#initialize(target) ⇒ CLI
constructor
A new instance of CLI.
- #instance(id) ⇒ Object
- #log_banner(msg) ⇒ Object
- #prepare_dependencies ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(target) ⇒ CLI
Returns a new instance of CLI.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cocina/cli.rb', line 10 def initialize(target) super() @dependencies = [] @config = Cocina::Config.new('Cocinafile') @logger = Kitchen::Logger.new( stdout: STDOUT, color: :white, progname: 'Cocina' ) @primary_instance = instance(target) @primary_dependencies = primary_instance.dependencies end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
7 8 9 |
# File 'lib/cocina/cli.rb', line 7 def collection @collection end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/cocina/cli.rb', line 7 def config @config end |
#dependencies ⇒ Object (readonly)
Returns the value of attribute dependencies.
7 8 9 |
# File 'lib/cocina/cli.rb', line 7 def dependencies @dependencies end |
#instances ⇒ Object (readonly)
Returns the value of attribute instances.
7 8 9 |
# File 'lib/cocina/cli.rb', line 7 def instances @instances end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
8 9 10 |
# File 'lib/cocina/cli.rb', line 8 def logger @logger end |
#primary_dependencies ⇒ Object (readonly)
Returns the value of attribute primary_dependencies.
8 9 10 |
# File 'lib/cocina/cli.rb', line 8 def primary_dependencies @primary_dependencies end |
#primary_instance ⇒ Object (readonly)
Returns the value of attribute primary_instance.
8 9 10 |
# File 'lib/cocina/cli.rb', line 8 def primary_instance @primary_instance end |
Instance Method Details
#cleanup ⇒ Object
55 56 57 58 59 60 |
# File 'lib/cocina/cli.rb', line 55 def cleanup "Cleaning up all dependencies" destroy_dependencies primary_instance.destroy nil end |
#converge_dependencies ⇒ Object
45 46 47 48 |
# File 'lib/cocina/cli.rb', line 45 def converge_dependencies logger.info "Dependencies: #{dependencies}" dependencies.each {|dep| converge_dependency dep } end |
#converge_dependency(dep) ⇒ Object
50 51 52 53 |
# File 'lib/cocina/cli.rb', line 50 def converge_dependency(dep) "Converging <#{dep}>" instance(dep).converge end |
#destroy_dependencies ⇒ Object
62 63 64 65 66 67 |
# File 'lib/cocina/cli.rb', line 62 def destroy_dependencies dependencies.each do |dep| logger.info "Destroying #{dep}" instance(dep).destroy end end |
#instance(id) ⇒ Object
34 35 36 |
# File 'lib/cocina/cli.rb', line 34 def instance(id) @config[id] end |
#log_banner(msg) ⇒ Object
69 70 71 |
# File 'lib/cocina/cli.rb', line 69 def (msg) logger. "#{msg}" end |
#prepare_dependencies ⇒ Object
38 39 40 41 42 43 |
# File 'lib/cocina/cli.rb', line 38 def prepare_dependencies primary_dependencies.each do |dep| @dependencies.concat instance(dep).dependencies @dependencies << dep end end |
#run ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/cocina/cli.rb', line 24 def run "Running for: #{primary_instance.name}" prepare_dependencies converge_dependencies primary_instance.verify cleanup end |