Sha256: 62fdf494e62dc6f0e12c750d56a2d743599cff9f811eabf1e2b4b14d0913cd1f

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

# encoding: utf-8
module FeduxOrgStdlib
  module Project
    class Plan

      private

      attr_reader :main_file, :additional_files

      public

      # Create a new project plan
      #
      # @param [String] main_file
      #   The main project file
      # @param [Array] additional_files
      #   Additional files containing information about project plan
      def initialize(
        main_file: File.expand_path('plan.tjp'),
        additional_files: []
      )
        @main_file        = main_file
        @additional_files = Array(additional_files)
      end

      # Does the plan needs to be compiled
      #
      # @param [String] base_file
      #   The output file which should be used to determine if the report is
      #   older then the project plan
      # @return [true,false]
      #   Result of comparism
      def needs_to_be_compiled?(base_file)
        (Array(main_file) + additional_files).any? { |f| File.mtime(f) > File.mtime(base_file) }
      end

      # Output a textual representation of self
      #
      # @return [String]
      #   The path to the main file of the project plan
      def to_s
        main_file
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.7.21 lib/fedux_org_stdlib/project/plan.rb
fedux_org-stdlib-0.7.20 lib/fedux_org_stdlib/project/plan.rb