Sha256: 455c535449ef58b9f6ee6f9527dc27ed93254e5053183c81c7c43f6a66113fad

Contents?: true

Size: 1.29 KB

Versions: 12

Compression:

Stored size: 1.29 KB

Contents

module Cardio
  class Mod
    class LoadStrategy
      # The {TmpFiles} load strategy version for set modules
      class SetTmpFiles < LoadStrategy::TmpFiles
        private

        def generate_tmp_files
          return unless prepare_tmp_dir "tmp/set"

          mod_dirs.each_with_tmp(:set) do |mod_dir, mod_tmp_dir|
            FileUtils.mkdir_p mod_tmp_dir
            Dir.glob("#{mod_dir}/**/*.rb").each do |abs_path|
              rel_path = abs_path.sub "#{mod_dir}/", ""
              tmp_filename = File.join mod_tmp_dir, rel_path
              const_parts = parts_from_path rel_path
              # puts "write_tmp_file #{abs_path}, #{tmp_filename}, #{const_parts}"
              write_tmp_file abs_path, tmp_filename, const_parts
            end
          end
        end

        def load_tmp_files
          pattern_groups.each do |pattern_group|
            mod_dirs.each_tmp(:set) do |set_tmp_dir|
              load_tmp_files_for_pattern pattern_group, set_tmp_dir
            end
          end
        end

        def load_tmp_files_for_pattern pattern_group, set_tmp_dir
          pattern_group.each do |pattern|
            pattern_dir = "#{set_tmp_dir}/#{pattern}"
            Loader.load_dir "#{pattern_dir}/**" if Dir.exist? pattern_dir
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
card-1.108.1 lib/cardio/mod/load_strategy/set_tmp_files.rb
card-1.108.0 lib/cardio/mod/load_strategy/set_tmp_files.rb
card-1.107.0 lib/cardio/mod/load_strategy/set_tmp_files.rb
card-1.106.0 lib/cardio/mod/load_strategy/set_tmp_files.rb
card-1.105.6 lib/cardio/mod/load_strategy/set_tmp_files.rb
card-1.105.5 lib/cardio/mod/load_strategy/set_tmp_files.rb
card-1.105.4 lib/cardio/mod/load_strategy/set_tmp_files.rb
card-1.105.3 lib/cardio/mod/load_strategy/set_tmp_files.rb
card-1.105.2.pre1 lib/cardio/mod/load_strategy/set_tmp_files.rb
card-1.105.2 lib/cardio/mod/load_strategy/set_tmp_files.rb
card-1.105.1 lib/cardio/mod/load_strategy/set_tmp_files.rb
card-1.105.0 lib/cardio/mod/load_strategy/set_tmp_files.rb