Sha256: 2944080fa7d36656b12ffbb70f90a91632923d1e6871d4efe643b13700c36521

Contents?: true

Size: 1.4 KB

Versions: 96

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require 'eac_cli/runner'
require 'eac_fs/traversable'
require 'eac_ruby_utils/core_ext'
require 'eac_ruby_utils/settings_provider'

module Avm
  module Files
    module RunnerWith
      module FilesystemTraverser
        DEFAULT_DEFAULT_TRAVERSER_RECURSIVE = false

        common_concern do
          include ::EacCli::Runner
          include ::EacFs::Traversable
          enable_settings_provider
          include TopMethods
          runner_definition do
            bool_opt '-R', '--recursive', 'Recursive.'
            bool_opt '--no-recursive', 'No recursive.'
            pos_arg :paths, optional: true, repeat: true
          end
        end

        module TopMethods
          def on_none_path_informed
            infom 'Warning: none path informed'
          end

          def paths
            parsed.paths.map(&:to_pathname)
          end

          def run_filesystem_traverser
            if parsed.paths.any?
              parsed.paths.each { |path| traverser_check_path(path) }
            else
              on_none_path_informed
            end
          end

          def traverser_recursive
            return false if parsed.no_recursive?
            return true if parsed.recursive?

            setting_value(:default_traverser_recursive, required: false)
              .if_not_nil(DEFAULT_DEFAULT_TRAVERSER_RECURSIVE)
          end
        end
      end
    end
  end
end

Version data entries

96 entries across 96 versions & 2 rubygems

Version Path
avm-files-0.8.0 lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.93.0 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
avm-files-0.7.0 lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.85.0 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.84.2 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.84.1 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.84.0 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.83.0 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.82.0 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.81.0 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.80.0 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.79.0 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.78.0 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.77.1 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.77.0 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.76.1 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.76.0 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.75.2 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.75.1 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb
eac_tools-0.75.0 sub/avm-files/lib/avm/files/runner_with/filesystem_traverser.rb