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-1.6.1 lib/ruboto/util/asset_copier.rb
ruboto-1.6.0 lib/ruboto/util/asset_copier.rb
ruboto-1.5.0 lib/ruboto/util/asset_copier.rb
ruboto-1.4.1 lib/ruboto/util/asset_copier.rb
ruboto-1.4.0 lib/ruboto/util/asset_copier.rb
ruboto-1.3.1 lib/ruboto/util/asset_copier.rb
ruboto-1.3.0 lib/ruboto/util/asset_copier.rb
ruboto-1.2.0 lib/ruboto/util/asset_copier.rb
ruboto-1.1.2 lib/ruboto/util/asset_copier.rb
ruboto-1.1.1 lib/ruboto/util/asset_copier.rb
ruboto-1.1.0 lib/ruboto/util/asset_copier.rb
ruboto-1.0.3 lib/ruboto/util/asset_copier.rb
ruboto-1.0.2 lib/ruboto/util/asset_copier.rb
ruboto-1.0.1 lib/ruboto/util/asset_copier.rb
ruboto-1.0.0 lib/ruboto/util/asset_copier.rb
ruboto-0.16.0 lib/ruboto/util/asset_copier.rb
ruboto-0.15.0 lib/ruboto/util/asset_copier.rb
ruboto-0.14.0 lib/ruboto/util/asset_copier.rb
ruboto-0.13.0 lib/ruboto/util/asset_copier.rb
ruboto-0.12.0 lib/ruboto/util/asset_copier.rb