Module: AstroboaCLI::Util

Included in:
Command, Command::Base
Defined in:
lib/astroboa-cli/util.rb

Defined Under Namespace

Classes: TemplateError

Instance Method Summary collapse

Instance Method Details

#askObject



91
92
93
# File 'lib/astroboa-cli/util.rb', line 91

def ask
  STDIN.gets.strip
end

#astroboa_running?Boolean

Returns:

  • (Boolean)


269
270
271
272
273
# File 'lib/astroboa-cli/util.rb', line 269

def astroboa_running?
  server_config = get_server_configuration
  jboss_dir = File.join(server_config['install_dir'], 'torquebox', 'jboss')
  system %(ps -ef | grep "org.jboss.as.standalone -Djboss.home.dir=#{jboss_dir}" | grep -vq grep)
end

#check_if_running_with_sudoObject



239
240
241
242
243
244
245
246
247
248
249
# File 'lib/astroboa-cli/util.rb', line 239

def check_if_running_with_sudo
  display "You need sudo privileges to run this command. Checking..."
  error <<-MSG.gsub(/^ {6}/, '') unless running_with_sudo?
  You are not running with sudo privileges. Please run astroboa-cli with sudo
  If you installed ruby with 'rbenv' you need to install 'rbenv-sudo' plugin and then run 'rbenv sudo astroboa-cli <COMMAND>'
  For 'rbenv-sudo' installation check ruby installation instructions at https://github.com/betaconcept/astroboa-cli
  If you manage your rubies with 'rvm' the you should use the 'rvmsudo' command: 'rvmsudo astroboa-cli <COMMAND>'
  MSG
  
  display "Running with sudo privileges: OK"
end

#create_postgresql_db(server_configuration, database_name) ⇒ Object



466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'lib/astroboa-cli/util.rb', line 466

def create_postgresql_db(server_configuration, database_name)
  database_admin, database_admin_password, database_server = get_postgresql_config(server_configuration)
  begin
    conn = PG.connect(
      host:     database_server, 
      port:     '5432', 
      dbname:   'postgres', 
      user:     database_admin, 
      password: database_admin_password)

    # check if db exists
    res = conn.exec("SELECT COUNT(*) FROM pg_database WHERE datname=$1",[database_name])
    unless res.entries[0]['count'].to_i == 0
      display "Database #{database_name} exists. You may run the command with --db_name repo_db_name to specify a different database name" 
      raise
    end

    res = conn.exec("CREATE DATABASE #{database_name} ENCODING 'UNICODE'")
    if res.result_status == PG::Result::PGRES_COMMAND_OK
      display %(Create Postges database "#{database_name}" : OK)
    else
      display "Failed to create postgres database #{database_name}. The error is #{res.error_message}"
      raise 
    end
  rescue PG::Error => e
    display %(An error has occured during the creation of postgres database "#{database_name}")
    display "The error is: #{res.error_message}" 
    display %(The error trace is \n #{e.backtrace.join("\n")})
    raise
  else
    display %(An error has occured during the creation of postgres database "#{database_name}")
    display %(The error trace is \n #{e.backtrace.join("\n")})
  ensure
    conn.finish if conn && !conn.finished?
  end
end

#create_postgresql_db_with_jdbc(server_configuration, database_name, repo_dir) ⇒ Object

Not used because only works in jruby, TO BE REMOVED



565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
# File 'lib/astroboa-cli/util.rb', line 565

def create_postgresql_db_with_jdbc(server_configuration, database_name, repo_dir)
  database_admin, database_admin_password, database_server = get_postgresql_config(server_configuration)
  begin
    ActiveRecord::Base.establish_connection(
      :adapter    => 'jdbcpostgresql',
      :database   => "postgres", 
      :username   => database_admin,
      :password   => database_admin_password,
      :host       => database_server, 
      :port       => 5432)
    ActiveRecord::Base.connection.create_database database_name, :encoding => 'unicode'
    ActiveRecord::Base.connection.disconnect!
    ActiveRecord::Base.remove_connection

    display %(Create Postges database "#{database_name}" : OK)
  rescue ActiveRecord::StatementInvalid => e
    if e.message =~ /database "#{database_name}" already exists/
      display "Database #{database_name} exists. You may run the command with --db_name repo_db_name to specify a different database name"
    else
      display %(An error has occured during the creation of postgres database "#{database_name}")
      display %(The error trace is \n #{e.backtrace.join("\n")})
    end

    raise
  end
end

#delete_file_content_between_regex(filename, from_regex, to_regex) ⇒ Object

Delete file lines between two regular expressions, /foo/ and /bar/, including the lines that match the regular expressions, e.g. delete file lines between two comments, including the comments from_regex and to_regex should be specified without leading and trailing slashes i.e. “string_to_match” and not “/string_to_match/”



193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/astroboa-cli/util.rb', line 193

def delete_file_content_between_regex(filename, from_regex, to_regex)
  from_regex_obj = %r{#{from_regex}}
  to_regex_obj = %r{#{to_regex}}
  found_boundary = false
  file_lines = File.readlines(filename)
  File.open(filename, "w") do |f|
    file_lines.each do |line|
      found_boundary = true if line =~ from_regex_obj
      f.puts line unless found_boundary
      found_boundary = false if line =~ to_regex_obj
    end
  end
end

#delete_file_lines(filename, lines_to_delete) ⇒ Object



208
209
210
211
212
213
214
215
216
# File 'lib/astroboa-cli/util.rb', line 208

def delete_file_lines(filename, lines_to_delete)
  file_lines = File.readlines(filename)
  lines_to_delete.each do |index|
    file_lines.delete_at(index)
  end 
  File.open(filename, "w") do |f| 
    f.write lines_to_delete.join
  end
end

#dir_writable?(dir) ⇒ Boolean

Returns:

  • (Boolean)


252
253
254
255
256
257
# File 'lib/astroboa-cli/util.rb', line 252

def dir_writable?(dir)
  until FileTest.directory?(dir)
    dir = File.dirname(dir)
  end
  File.writable? dir
end

#display(msg = "", new_line = true, add_to_log = true) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/astroboa-cli/util.rb', line 56

def display(msg="", new_line=true, add_to_log=true)
  if new_line
    puts(msg)
  else
    print(msg)
    STDOUT.flush
  end
  log.info msg if add_to_log
end

#drop_postgresql_db(server_configuration, database_name) ⇒ Object



504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
# File 'lib/astroboa-cli/util.rb', line 504

def drop_postgresql_db(server_configuration, database_name)
  database_admin, database_admin_password, database_server = get_postgresql_config(server_configuration)
  begin
    conn = PG.connect(
      :host     => database_server, 
      :port     => '5432', 
      :dbname   => 'postgres', 
      :user     => database_admin, 
      :password => database_admin_password)

    # check if db exists
    res = conn.exec("SELECT COUNT(*) FROM pg_database WHERE datname=$1",[database_name])
    unless res.entries[0]['count'] == 0 
      display "Cannot remove database #{database_name} because it does not exist"
      raise
    end

    res = conn.exec("DROP DATABASE $1", [database_name])
    if res.result_status == PG::Result::PGRES_COMMAND_OK
      display %(Delete Postges database "#{database_name}" : OK)
    else
      display "Failed to delete postgres database #{database_name}. The error is #{res.error_message}"
      raise 
    end

  rescue PG::Error => e
    display %(An error has occured during the deletion of postgres database "#{database_name}")
    display "The error is: #{res.error_message}" 
    display %(The error trace is \n #{e.backtrace.join("\n")})
    raise
  else
    display %(An error has occured during the deletion of postgres database "#{database_name}")
    display %(The error trace is \n #{e.backtrace.join("\n")})
  ensure
    conn.finish if conn && !conn.finished?
  end
end

#drop_postgresql_db_with_jdbc(server_configuration, database_name) ⇒ Object

Not used because only works in jruby, TO BE REMOVED



594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
# File 'lib/astroboa-cli/util.rb', line 594

def drop_postgresql_db_with_jdbc(server_configuration, database_name)
  database_admin, database_admin_password, database_server = get_postgresql_config(server_configuration)
  begin
    ActiveRecord::Base.establish_connection(
      :adapter    => 'jdbcpostgresql',
      :database   => "postgres", 
      :username   => database_admin,
      :password   => database_admin_password,
      :host       => database_server, 
      :port       => 5432)
    ActiveRecord::Base.connection.drop_database database_name
    ActiveRecord::Base.connection.disconnect!
    ActiveRecord::Base.remove_connection

    display %(Delete Postges database "#{database_name}" : OK)
  rescue ActiveRecord::StatementInvalid => e
    display %(An error has occured during the deletion of postgres database "#{database_name}")
    display %(The error trace is \n #{e.backtrace.join("\n")})
    raise
  end
end

#error(msg, add_to_log = true) ⇒ Object



67
68
69
70
71
# File 'lib/astroboa-cli/util.rb', line 67

def error(msg, add_to_log=true)
  STDERR.puts(format_with_bang(msg))
  log.error msg if add_to_log   
  exit 1
end

#extract_archive_command(archive_name) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/astroboa-cli/util.rb', line 146

def extract_archive_command(archive_name)
  case archive_name
  when /(tar.gz)|(tgz)$/
    'tar xzf'
  when /(tar.bz2)|(tb2)$/
    'tar xjf'
  when /tar$/
    'tar xf'
  when /zip$/
    'unzip -o -q'
  else
    fail "Unknown binary archive format: #{archive_name}"
  end
end

#fail(message) ⇒ Object



74
75
76
# File 'lib/astroboa-cli/util.rb', line 74

def fail(message)
  raise AstroboaCLI::Command::CommandFailed, message
end

#format_with_bang(message) ⇒ Object



79
80
81
82
# File 'lib/astroboa-cli/util.rb', line 79

def format_with_bang(message)
  return '' if message.to_s.strip == ""
  " !    " + message.split("\n").join("\n !    ")
end

#gem_available?(name) ⇒ Boolean

Returns:

  • (Boolean)


260
261
262
263
264
265
266
# File 'lib/astroboa-cli/util.rb', line 260

def gem_available?(name)
   Gem::Specification.find_by_name(name)
rescue Gem::LoadError
   false
rescue
   Gem.available?(name)
end

#get_postgresql_config(server_configuration) ⇒ Object



458
459
460
461
462
463
# File 'lib/astroboa-cli/util.rb', line 458

def get_postgresql_config(server_configuration)
  database_admin = server_configuration['database_admin']
  database_admin_password = server_configuration['database_admin_password']
  database_server = server_configuration['database_server']
  return database_admin, database_admin_password, database_server
end

#get_server_conf_fileObject



276
277
278
279
# File 'lib/astroboa-cli/util.rb', line 276

def get_server_conf_file
  return File.expand_path(File.join("~", ".astroboa-conf.yml")) if mac_os_x?
  return File.join(File::SEPARATOR, 'etc', 'astroboa', 'astroboa-conf.yml')
end

#get_server_configurationObject



289
290
291
292
293
# File 'lib/astroboa-cli/util.rb', line 289

def get_server_configuration
  server_conf_file = get_server_conf_file
  return YAML.load(File.read(server_conf_file)) if File.exists? server_conf_file
  error "Server configuration file: '#{server_conf_file}' does not exist"
end

#has_executable(path) ⇒ Object



106
107
108
109
110
111
112
113
114
115
# File 'lib/astroboa-cli/util.rb', line 106

def has_executable(path)
  # If the path includes a forward slash, we're checking
  # an absolute path. Otherwise, we're checking a global executable
  if path.include?('/')
    commands = "test -x #{path}"
  else
    command = "[ -n \"`echo \\`which #{path}\\``\" ]"
  end
  process_os_command command
end

#has_executable_with_version(path, version, get_version = '-v') ⇒ Object

Same as has_executable but with checking for e certain version number. If version number contains dots it, they should be escaped, e.g. “1\.6” Last option is the parameter to append for getting the version (which defaults to “-v”).



122
123
124
125
126
127
128
129
# File 'lib/astroboa-cli/util.rb', line 122

def has_executable_with_version(path, version, get_version = '-v')
  if path.include?('/')
    command = "[ -x #{path} -a -n \"`#{path} #{get_version} 2>&1 | egrep -e \\\"#{version}\\\"`\" ]"
  else
    command = "[ -n \"`echo \\`which #{path}\\``\" -a -n \"`\\`which #{path}\\` #{get_version} 2>&1 | egrep -e \\\"#{version}\\\"`\" ]"
  end
  process_os_command command
end

#has_version_in_grep(cmd, version) ⇒ Object

Same as has_executable but checking output of a certain command with grep.



134
135
136
# File 'lib/astroboa-cli/util.rb', line 134

def has_version_in_grep(cmd, version)
   process_os_command "[ -n \"`#{cmd} 2> /dev/null | egrep -e \\\"#{version}\\\"`\" ]"
end

#jruby_ok?Boolean

Returns:

  • (Boolean)


410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
# File 'lib/astroboa-cli/util.rb', line 410

def jruby_ok?
  install_jruby_with_rvm_message =<<-RVM_INSTALL_MESSAGE
  We recommend to install jruby using the "RVM" utility command
  To install "rvm" for a single user (i.e. the user that will run astroboa-cli) login as the user and run the following command:

  user$ curl -L get.rvm.io | bash -s stable 

  For multi-user installation and detailed rvm installation instructions check: https://rvm.io/rvm/install/    

  After RVM has been installed run the following commands to install jruby:
  rvm install jruby-1.6.7
  rvm use jruby-1.6.7
  RVM_INSTALL_MESSAGE

  jruby_not_running_message =<<-JRUBY_MESSAGE
  It seems that you are not running jruby.
  Astroboa requires jruby version 1.6.7 or above. 
  Please install jruby version 1.6.7 or above and run the astroboa-cli command again

  #{install_jruby_with_rvm_message}
  JRUBY_MESSAGE

  jruby_wrong_version_message =<<-JRUBY_VERSION_MESSAGE
  It seems that you are not running the required jruby version
  Your jruby version is: #{JRUBY_VERSION}
  Astroboa requires jruby version 1.6.7 or above. 
  Please install jruby version 1.6.7 or above and run the astroboa-cli command again

  #{install_jruby_with_rvm_message}
  JRUBY_VERSION_MESSAGE

  ruby_wrong_version_message =<<-RUBY_VERSION_MESSAGE
  It seems that you are not running jruby in 1.9 mode.
  Your current Ruby Version is: #{RUBY_VERSION} 
  Astroboa requires your jruby to run in 1.9 mode. 
  To make jruby run in 1.9 mode add the following to your .bash_profile
  export JRUBY_OPTS=--1.9 

  You need to logout and login or run "source ~/.bash_profile" in order to activate this setting
  RUBY_VERSION_MESSAGE

  error jruby_not_running_message unless runs_with_jruby?
  error jruby_wrong_version_message unless jruby_version_ok?
  error ruby_wrong_version_message unless ruby_version_ok?
  display "Checking if you are running jruby version 1.6.7 or above in 1.9 mode: OK"
end

#jruby_version_ok?Boolean

Returns:

  • (Boolean)


339
340
341
342
343
344
345
346
347
# File 'lib/astroboa-cli/util.rb', line 339

def jruby_version_ok?
  return false unless defined? JRUBY_VERSION

  jruby_version_numbers = JRUBY_VERSION.split(".")

  return false unless jruby_version_numbers[0].to_i == 1 && 
    ((jruby_version_numbers[1].to_i == 6 && jruby_version_numbers[2].to_i >= 7) || jruby_version_numbers[1].to_i == 7)
  return true
end

#linux?Boolean

Returns:

  • (Boolean)


229
230
231
# File 'lib/astroboa-cli/util.rb', line 229

def linux?
  RbConfig::CONFIG['host_os'] =~ /linux/i
end

#longest(items) ⇒ Object



101
102
103
# File 'lib/astroboa-cli/util.rb', line 101

def longest(items)
  items.map { |i| i.to_s.length }.sort.last
end

#mac_os_x?Boolean

Returns:

  • (Boolean)


224
225
226
# File 'lib/astroboa-cli/util.rb', line 224

def mac_os_x?
  RbConfig::CONFIG['host_os'] =~ /darwin/i
end

#output_with_bang(message = "", new_line = true) ⇒ Object



85
86
87
88
# File 'lib/astroboa-cli/util.rb', line 85

def output_with_bang(message="", new_line=true)
  return if message.to_s.strip == ""
  display(format_with_bang(message), new_line)
end

#process_os_command(command) ⇒ Object



139
140
141
142
143
# File 'lib/astroboa-cli/util.rb', line 139

def process_os_command(command)
  system command
  return false if $?.to_i != 0
  return true
end

#render_template_to_file(template_path, context, file_path) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/astroboa-cli/util.rb', line 174

def render_template_to_file(template_path, context, file_path)
  require 'erubis'

  begin
    template = File.read template_path
    eruby = Erubis::Eruby.new(template)
    File.open file_path, "w" do |f|
      f << eruby.evaluate(context)
    end
  rescue Object => e
    raise TemplateError.new(e, template, context)
  end

end

#repository?(server_configuration, repository_name) ⇒ Boolean

check that repo is consistently configured, i.e Its directory exists AND it is specified in server configuration AND its repo config file exists

Returns:

  • (Boolean)


323
324
325
326
327
328
329
330
331
# File 'lib/astroboa-cli/util.rb', line 323

def repository?(server_configuration, repository_name)
  repos_dir = server_configuration['repos_dir']
  astroboa_dir = server_configuration['install_dir']
  repo_dir = File.join(repos_dir, repository_name)
  
  return true if File.exists?(repo_dir) && repository_in_repos_config?(repos_dir, repository_name) && repository_in_server_config?(server_configuration, repository_name)
  
  return false;
end

#repository_in_repos_config?(repos_dir, repository_name) ⇒ Boolean

Returns:

  • (Boolean)


301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/astroboa-cli/util.rb', line 301

def repository_in_repos_config?(repos_dir, repository_name)
  astroboa_repos_config = File.join(repos_dir, "repositories-conf.xml")

  repo_conf = nil

  if File.exists? astroboa_repos_config
    File.open(astroboa_repos_config, 'r') do |f|
      repo_conf = Nokogiri::XML(f) do |config|
        config.noblanks
      end
    end
    
    repo_nodes = repo_conf.xpath(%(//repository[@id="#{repository_name}"]))
    return true if !repo_nodes.empty?
  end

  return false
end

#repository_in_server_config?(server_config, repo_name) ⇒ Boolean

Returns:

  • (Boolean)


296
297
298
# File 'lib/astroboa-cli/util.rb', line 296

def repository_in_server_config?(server_config, repo_name)
  return server_config.has_key?('repositories') && server_config['repositories'].has_key?(repo_name)
end

#ruby_ok?Boolean

Returns:

  • (Boolean)


360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/astroboa-cli/util.rb', line 360

def ruby_ok?
  ruby_installation_instructions_message =<<-RUBY_INSTALL_MESSAGE
  You can easily install ruby with 'rbenv' or 'rvm' utility programs.

  ----------------------------------
  We recommend to install ruby using the 'rbenv' and 'ruby-build' utility commands.
  On Mac OS X  to install 'rbenv' and 'ruby-build' using the Homebrew (http://mxcl.github.com/homebrew/) package manager do:
    $ brew update
    $ brew install rbenv
    $ brew install ruby-build

  To install ruby version 1.9.3-p194 do:
    $ rbenv install 1.9.3-p194

  To set the global version of Ruby to be used in all your shells do:
    $ rbenv global 1.9.3-p194

  To set ruby 1.9.3-p194 as a local per-project ruby version by writing the version name to an .rbenv-version file in the current directory do:

    $ rbenv local 1.9.3-p194

  To set ruby 1.9.3-p194 as the version to be used only in the current shell (sets the RBENV_VERSION environment variable in your shell) do:

    $ rbenv shell 1.9.3-p194

  ------------------------------- 
  If you prefer to use 'rvm' as your ruby management utility use the following command to install it for a single user:

  user$ curl -L get.rvm.io | bash -s stable 

  For multi-user installation and detailed rvm installation instructions check: https://rvm.io/rvm/install/    

  After 'rvm' has been installed run the following commands to install ruby 1.9.3-p194:
  rvm install 1.9.3-p194
  rvm use 1.9.3-p194
  RUBY_INSTALL_MESSAGE

  ruby_wrong_version_message =<<-RUBY_VERSION_MESSAGE
  It seems that you are not running ruby 1.9.x.
  Your current Ruby Version is: #{RUBY_VERSION} 
  Astroboa CLI requires your ruby version to be 1.9.x (e.g. 1.9.2 or 1.9.3).

  #{ruby_installation_instructions_message}
  RUBY_VERSION_MESSAGE

  error ruby_wrong_version_message unless ruby_version_ok?
  #display "Checking if your ruby version is 1.9.x: OK"
end

#ruby_version_ok?Boolean

Returns:

  • (Boolean)


350
351
352
353
354
355
356
357
# File 'lib/astroboa-cli/util.rb', line 350

def ruby_version_ok?
  return false unless defined? RUBY_VERSION

  ruby_version_numbers = RUBY_VERSION.split(".")

  return false unless ruby_version_numbers[0].to_i == 1 && ruby_version_numbers[1].to_i >= 9
  return true
end

#running_with_sudo?Boolean

Returns:

  • (Boolean)


234
235
236
# File 'lib/astroboa-cli/util.rb', line 234

def running_with_sudo?
  Process.uid == 0
end

#runs_with_jruby?Boolean

Returns:

  • (Boolean)


334
335
336
# File 'lib/astroboa-cli/util.rb', line 334

def runs_with_jruby?
  (defined? RUBY_ENGINE && RUBY_ENGINE == 'jruby') || RUBY_PLATFORM == "java"
end

#save_server_configuration(server_configuration) ⇒ Object



282
283
284
285
286
# File 'lib/astroboa-cli/util.rb', line 282

def save_server_configuration(server_configuration)
  File.open(get_server_conf_file, "w") do |f|
    f.write(YAML.dump(server_configuration))
  end
end

#shell(cmd) ⇒ Object



96
97
98
# File 'lib/astroboa-cli/util.rb', line 96

def shell(cmd)
  FileUtils.cd(Dir.pwd) {|d| return `#{cmd}`}
end

#strip_text_nodes(xml_doc) ⇒ Object

remove leading and trailing white space from XML Document text nodes xml_doc should be a Nokogiri::XML:Document or Nokogiri::XML::Node



545
546
547
548
549
550
551
# File 'lib/astroboa-cli/util.rb', line 545

def strip_text_nodes xml_doc
  xml_doc.traverse do |node|
    if node.text?
      node.content = node.content.strip
    end
  end
end

#unzip_file(file, destination) ⇒ Object



162
163
164
165
166
167
168
169
170
171
# File 'lib/astroboa-cli/util.rb', line 162

def unzip_file (file, destination)
  Zip::ZipFile.open(file) { |zip_file|
   zip_file.each { |f|
     next unless f.file?
     f_path=File.join(destination, f.name)
     FileUtils.mkdir_p(File.dirname(f_path))
     zip_file.extract(f, f_path) unless File.exist?(f_path)
   }
  }
end

#windows?Boolean

Returns:

  • (Boolean)


219
220
221
# File 'lib/astroboa-cli/util.rb', line 219

def windows?
  RbConfig::CONFIG['host_os'] =~ /mswin/i
end

#write_xml(document, file_full_path) ⇒ Object

write XML document to a file document should be a Nokogiri::XML:Document or Nokogiri::XML::Node



555
556
557
558
559
560
561
# File 'lib/astroboa-cli/util.rb', line 555

def write_xml document, file_full_path
  strip_text_nodes document

  File.open(file_full_path, 'w') do |f|
    document.write_xml_to(f, :indent => 1, :indent_text => "\t", :encoding => 'UTF-8')
  end
end