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
# 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
    raise Unitsdb::Errors::InvalidFormatError,
          "Invalid format '#{@options[:format]}': must be 'yaml', 'zip', or 'all'"
  end

  puts "Release files created successfully in #{@options[:output_dir]}"
rescue Unitsdb::Errors::DatabaseError => e
  raise Unitsdb::Errors::DatabaseLoadError,
        "Failed to create release: #{e.message}"
end