Class: CPEE::ModelManagement::RenameDir
- Inherits:
-
Riddl::Implementation
- Object
- Riddl::Implementation
- CPEE::ModelManagement::RenameDir
- Defined in:
- lib/cpee-model-management/implementation.rb
Overview
}}}
Instance Method Summary collapse
-
#response ⇒ Object
{{{.
Instance Method Details
#response ⇒ Object
{{{
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/cpee-model-management/implementation.rb', line 308 def response where = @r[0..-2].map{ |d| Riddl::Protocols::Utils::unescape(d) }.join('/') conns = @a[0] models = @a[1] name = File.join(where,File.basename(@r.last,'.dir')) nname = File.join(where,@p[0].value) fname = File.join(models,name + '.dir') fnname = File.join(models,nname + '.dir') counter = 0 while File.exist?(fnname) counter += 1 fnname = File.join(models,nname + counter.to_s + '.dir') end dn = CPEE::ModelManagement::get_dn @h['DN'] = dn['GN'] + ' ' + dn['SN'] attrs = JSON::load File.open(fname + '.attrs') attrs['author'] = File.write(fname + '.attrs',JSON::pretty_generate(attrs)) Dir.glob(File.join(fname + '/*.xml')).each do |f| XML::Smart::modify(f) do |doc| doc.register_namespace 'p', 'http://cpee.org/ns/properties/2.0' doc.find('/p:testset/p:attributes/p:design_dir').each do |ele| ele.text = nname + '.dir' end attrs = doc.find('/p:testset/p:attributes/*').map do |e| [e.qname.name,e.text] end.to_h end File.write(f + '.attrs',JSON::pretty_generate(attrs)) end CPEE::ModelManagement::op , 'mv', models, File.join(nname + '.dir'), File.join(name + '.dir') CPEE::ModelManagement::notify conns, 'rename', models, fnname, fname nil end |