Module: Edison::Helpers

Defined in:
lib/edison.rb

Class Method Summary collapse

Class Method Details

.date_from_filename(data) ⇒ Object



201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/edison.rb', line 201

def self.date_from_filename(data)
	if data.date
		raise Exception, "Date will be inferred from filename, but found in data"
	end

	if File.basename(data._fname) =~ /^(\d{4}-\d{1,2}-\d{1,2})/
		data.date = Date.parse($1)
	else
		raise Exception, "Expected filename to start with date (YYYY-M?M-D?D)"
	end

	data
end

.default_layout(data) ⇒ Object



215
216
217
218
219
220
221
# File 'lib/edison.rb', line 215

def self.default_layout(data)
	unless data.layout
		data.layout = "default"
	end

	data
end