Sha256: 9c84a278d884ed909af66cbccef0b25e334efd8ca7f1241d0d365ba41a422e31

Contents?: true

Size: 907 Bytes

Versions: 14

Compression:

Stored size: 907 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      module Gemfile
        module Services
          class ReadFileContent
            include ConvenientService::Standard::Config

            attr_reader :path

            step :validate_path
            step Services::AssertFileExists, in: :path
            step Services::AssertFileNotEmpty, in: :path
            step :result, in: :path, out: :content

            def initialize(path:)
              @path = path
            end

            def result
              success(data: {content: ::File.read(path)})
            end

            private

            def validate_path
              return failure(path: "Path is `nil`") if path.nil?
              return failure(path: "Path is empty") if path.empty?

              success
            end
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
convenient_service-0.12.0 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.10.1 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.10.0 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.9.0 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.8.0 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.7.0 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.6.0 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.5.0 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.4.0 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.3.1 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.3.0 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.2.1 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.2.0 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb
convenient_service-0.1.0 lib/convenient_service/examples/standard/gemfile/services/read_file_content.rb