Class: REGO::App

Inherits:
Object
  • Object
show all
Defined in:
lib/rego/app.rb

Instance Method Summary collapse

Constructor Details

#initialize(src, dest, opt = {}) ⇒ App

Returns a new instance of App.



14
15
16
17
18
19
20
21
22
# File 'lib/rego/app.rb', line 14

def initialize( src, dest, opt = {} )
	@src, @dest, @opt = src, dest, opt
	@src.chop! if %r|/$| =~ @src
	@dest.chop! if %r|/$| =~ @dest
	@env = {
		:src => @src,
		:dest => @dest
	}.update( @opt )
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rego/app.rb', line 24

def run
	Pathname::glob( "#{@src}/**/{.*,*}" ) do |src|
		relative = src.to_s[@src.size, src.to_s.size]
		@env[:src_file] = relative
		@env[:dest_file] = relative.dup

		if src.directory?
			Pathname::new( @dest + relative ).mkpath
		else
			case src.to_s
			when /\.rego$/
				@env[:dest_file] = relative.sub( /\.rego$/, '' )
				begin
					next if !@opt[:force] && (src.mtime < Pathname::new( dest_file( @env ) ).mtime)
				rescue Errno::ENOENT
				end
				$stderr.puts relative if @opt[:verbose]
				processing( @env, :template )
			when /\.ignore$/
				# ignore this file
			else
				processing( @env, :symlink )
			end
		end
	end
end