Sha256: 4a4e80f98b2fc406a7a807c371625e3d811338b1892b182435fb85ef8590b1d7

Contents?: true

Size: 850 Bytes

Versions: 18

Compression:

Stored size: 850 Bytes

Contents

class OutputType
	class Default
		# File name is for checking the existence of outputs
		def file_name(rule_name, scope = '')
			scope.to_s + (scope.empty? ? '' : '/') + rule_name
		end

		# Real name is for further processing, like schema.table_name in database
		# defaultly the file is the output, but when the file is merely a placeholder
		# the two will differ
		def real_name(rule_name, scope = '')
			file_name
		end

		def ext
			res = self.class.to_s
			res[0] = res[0].downcase
			res
		end
	end

	class Table < Default
		def real_name(file_name, scope = '')
			stem = file_name.gsub(/\.table$/, '')
			scope.to_s + (scope.empty? ? '' : '.') + stem
		end
	end

	def create(sym)
		self.class.const_get(sym.capitalize).new || Default.new
	end

	def self.parse_option(opt)
		opt.map { |obj| obj.class == Symbol ? create(obj) : obj }
	end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
raka-0.3.18 lib/raka/output_type.rb
raka-0.3.17 lib/raka/output_type.rb
raka-0.3.16 lib/raka/output_type.rb
raka-0.3.15 lib/raka/output_type.rb
raka-0.3.14 lib/raka/output_type.rb
raka-0.3.13 lib/raka/output_type.rb
raka-0.3.12 lib/raka/output_type.rb
raka-0.3.11 lib/raka/output_type.rb
raka-0.3.10 lib/raka/output_type.rb
raka-0.3.9 lib/raka/output_type.rb
raka-0.3.8 lib/raka/output_type.rb
raka-0.3.7 lib/raka/output_type.rb
raka-0.3.6 lib/raka/output_type.rb
raka-0.3.4 lib/raka/output_type.rb
raka-0.3.3 lib/output_type.rb
raka-0.3.2 lib/output_type.rb
raka-0.3.1 lib/output_type.rb
raka-0.2.3 lib/output_type.rb