Class: Unitsdb::Commands::Release

Inherits:
Base
  • Object
show all
Defined in:
lib/unitsdb/commands/release.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Unitsdb::Commands::Base

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/unitsdb/commands/release.rb', line 10

def run
  # Load the database
  db = load_database(@options[:database])
  db.version = @options[:version]

  # Create output directory if it doesn't exist
  FileUtils.mkdir_p(@options[:output_dir])

  # Generate release files based on format option
  format = (@options[:format] || "all").downcase
  case format
  when "yaml"
    create_unified_yaml(db)
  when "zip"
    create_zip_archive(db)
  when "all"
    create_unified_yaml(db)
    create_zip_archive(db)
  else
    puts "Invalid format option: #{@options[:format]}"
    puts "Valid options are: 'yaml', 'zip', or 'all'"
    exit(1)
  end

  puts "Release files created successfully in #{@options[:output_dir]}"
rescue Unitsdb::Errors::DatabaseError => e
  puts "Error: #{e.message}"
  exit(1)
end