Sha256: d351c5697edac3f2b620e507c5778f707a28ee292d9e801e56a5c93b170f4cbb

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

require "platina_world/path_builder"

module PlatinaWorld
  module Runner
    class Base
      def initialize(loaded_file)
        @loaded_file = loaded_file
      end

      def run
        paths.each do |path|
          file_path = path.to_s

          if path.exist?
            PlatinaWorld::FileStatus.skip(file_path)
          else
            generate(path)
            PlatinaWorld::FileStatus.create(file_path)
          end
        end
      end

      private

      def paths
        @paths ||= PlatinaWorld::PathBuilder.new(@loaded_file).build
      end

      def generate(path)
        case
        when path.directory?
          generate_directory(path)
        when path.has_directory?
          generate_file_with_dir(path)
        else
          generate_file(path)
        end
      end

      def generate_directory(path)
        raise NotImplementedError
      end

      def generate_file_with_dir(path)
        raise NotImplementedError
      end

      def generate_file(path)
        raise NotImplementedError
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
platina_world-0.1.5 lib/platina_world/runners/base.rb