Class: Archimate::Cli::Cleanup
- Inherits:
-
Object
- Object
- Archimate::Cli::Cleanup
- Defined in:
- lib/archimate/cli/cleanup.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Class Method Summary collapse
Instance Method Summary collapse
- #clean ⇒ Object
-
#initialize(model, output, options) ⇒ Cleanup
constructor
A new instance of Cleanup.
- #remove_unreferenced_nodes ⇒ Object
- #write_trash ⇒ Object
Constructor Details
#initialize(model, output, options) ⇒ Cleanup
Returns a new instance of Cleanup.
18 19 20 21 22 23 24 25 |
# File 'lib/archimate/cli/cleanup.rb', line 18 def initialize(model, output, ) @model = model @output = output @options = @trash = Nokogiri::XML::Document.new("<deleted></deleted>") @model_set = nil @progressbar = ProgressIndicator.new(total: model.unreferenced_nodes.size, title: "Elements") end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
11 12 13 |
# File 'lib/archimate/cli/cleanup.rb', line 11 def model @model end |
Class Method Details
Instance Method Details
#clean ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/archimate/cli/cleanup.rb', line 43 def clean return unless model remove_unreferenced_nodes puts "Found #{unref_set.size} model items unreferenced by diagram or relationships" Archimate::ArchiFileWriter.write(model, output) write_trash end |
#remove_unreferenced_nodes ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/archimate/cli/cleanup.rb', line 27 def remove_unreferenced_nodes model.unreferenced_nodes.each do |unreferenced_node| raise "This functionality is not implemeted yet" # TODO: this needs to be the XML serialization of the node trash.root.add_child unreferenced_node.dup # TODO: implement this # model.delete(unreferenced_node) @progressbar.increment end end |
#write_trash ⇒ Object
39 40 41 |
# File 'lib/archimate/cli/cleanup.rb', line 39 def write_trash [:saveremoved].write(trash) end |