Class: Gap::Copy

Inherits:
Object
  • Object
show all
Defined in:
lib/gap50/gap/copy.rb

Constant Summary collapse

DEFAULT_COPY =
Copy.new

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sam = Gap::Main) ⇒ Copy

Returns a new instance of Copy.



3
4
5
# File 'lib/gap50/gap/copy.rb', line 3

def initialize(sam = Gap::Main)
    @sam = sam
end

Class Method Details

.copy(dir, basedir, pattern) ⇒ Object



23
24
25
# File 'lib/gap50/gap/copy.rb', line 23

def self.copy(dir, basedir, pattern)
    DEFAULT_COPY.copy(dir, basedir, pattern)
end

Instance Method Details

#copy(dir, basedir, pattern) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/gap50/gap/copy.rb', line 7

def copy(dir, basedir, pattern)
    Dir.glob(basedir + "/" + pattern) do |all|
        next if !FileTest.file?(all)
        file = dir + all[basedir.length..-1]
        if @sam.need_update_file?(file, all)
            @sam.genfile file do 
                open(all, "rb") do |f|
                    f.read
                end
            end
        end
        yield if block_given?
    end
end