Sha256: 2c81a3404ec589a544c4fa05cf85899a03c747f117c7634c7509e3dd37b75ff8

Contents?: true

Size: 1.99 KB

Versions: 4

Compression:

Stored size: 1.99 KB

Contents

# frozen_string_literal: true

##
# Usage example:
#
# result = ConvenientService::Examples::Rails::V1::Gemfile::Services::Format.result(path: "Gemfile")
# result = ConvenientService::Examples::Rails::V1::Gemfile::Services::Format.result(path: "spec/cli/gemfile/format/fixtures/Gemfile")
#
module ConvenientService
  module Examples
    module Rails
      module V1
        class Gemfile
          module Services
            class Format
              include RailsService::Config

              attribute :path, :string

              validates :path, presence: true if ConvenientService::Dependencies.support_has_j_send_result_params_validations_using_active_model_validations?

              step Services::ReadFileContent,
                in: :path,
                out: :content

              step Services::StripComments,
                in: :content,
                out: :content_without_comments

              step Services::ParseContent,
                in: {content: :content_without_comments},
                out: :parsed_content

              step Services::FormatHeader,
                in: :parsed_content,
                out: {formatted_content: :formatted_header_content}

              step Services::FormatBody,
                in: :parsed_content,
                out: {formatted_content: :formatted_body_content}

              step Services::MergeSections,
                in: [
                  {header: :formatted_header_content},
                  {body: :formatted_body_content}
                ],
                out: :merged_sections

              step Services::ReplaceFileContent,
                in: [
                  :path,
                  {content: :merged_sections}
                ]

              before :result do
                @progressbar = ::ProgressBar.create(title: "Formatting", total: steps.count)
              end

              after :step do |step|
                @progressbar.increment
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
convenient_service-0.17.0 lib/convenient_service/examples/rails/v1/gemfile/services/format.rb
convenient_service-0.16.0 lib/convenient_service/examples/rails/v1/gemfile/services/format.rb
convenient_service-0.15.0 lib/convenient_service/examples/rails/v1/gemfile/services/format.rb
convenient_service-0.14.0 lib/convenient_service/examples/rails/v1/gemfile/services/format.rb