Sha256: 14a1735d9f878d60a16c803e9570f3e3df9218212690a98499b592ceaa834eb6

Contents?: true

Size: 922 Bytes

Versions: 30

Compression:

Stored size: 922 Bytes

Contents

module Ruboto
  module Util
    class AssetCopier
      def initialize(from, to, force = true)
        @from = from
        @to = to
        @force = force
      end

      def copy(from, to='')
        target_dir = File.join(@to, to)
        file_pattern = File.directory?(File.join(@from, from)) ? File.join(from, '**/*') : from
        existing_files = @force ? [] : Dir.chdir(target_dir){Dir[file_pattern].select{|f| !File.directory?(f)}}
        files_to_copy = Dir.chdir(@from){Dir[file_pattern].select{|f| !File.directory?(f)}} - existing_files
        files_to_copy.each do |f|
          FileUtils.mkdir_p(File.join(target_dir, File.dirname(f)))
          FileUtils.cp(File.join(@from, f), File.join(target_dir, f))
        end
      end

      def copy_from_absolute_path(from, to='')
        FileUtils.mkdir_p(File.join(@to, to))
        FileUtils.cp_r(Dir[from], File.join(@to, to))
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
ruboto-0.13.0.rc.0 lib/ruboto/util/asset_copier.rb
ruboto-0.12.0.rc.0 lib/ruboto/util/asset_copier.rb
ruboto-0.11.0 lib/ruboto/util/asset_copier.rb
ruboto-0.11.0.rc.1 lib/ruboto/util/asset_copier.rb
ruboto-0.11.0.rc.0 lib/ruboto/util/asset_copier.rb
ruboto-0.10.2 lib/ruboto/util/asset_copier.rb
ruboto-0.10.2.rc.0 lib/ruboto/util/asset_copier.rb
ruboto-0.10.1 lib/ruboto/util/asset_copier.rb
ruboto-0.10.0 lib/ruboto/util/asset_copier.rb
ruboto-0.10.0.rc.1 lib/ruboto/util/asset_copier.rb