Sha256: 43e8b47e160753c089153d52ef6b9307f72bc767f86ad6e03f584721900ecdc5

Contents?: true

Size: 844 Bytes

Versions: 5

Compression:

Stored size: 844 Bytes

Contents

# frozen_string_literal: true

require_relative "../../app/command"
require_relative "structure/dump"

module Hanami
  module CLI
    module Commands
      module App
        module DB
          class SampleData < App::Command
            FILE_PATH = "db/sample_data.rb"

            desc "Load sample data"

            def call(**)
              if has_file?
                measure "sample data loaded from #{FILE_PATH}" do
                  load full_file_path
                end
              else
                out.puts "=> #{FILE_PATH} not found"
              end
            end

            private

            def full_file_path
              File.join(app.root, FILE_PATH)
            end

            def has_file?
              File.exist?(full_file_path)
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hanami-cli-2.0.0.rc1 lib/hanami/cli/commands/app/db/sample_data.rb
hanami-cli-2.0.0.beta4 lib/hanami/cli/commands/app/db/sample_data.rb
hanami-cli-2.0.0.beta3 lib/hanami/cli/commands/app/db/sample_data.rb
hanami-cli-2.0.0.beta2 lib/hanami/cli/commands/app/db/sample_data.rb
hanami-cli-2.0.0.beta1 lib/hanami/cli/commands/app/db/sample_data.rb