Top Level Namespace

Defined Under Namespace

Modules: AccountHelper, ApplicationHelper, LiveTree, Localization, Localizer, LoginSystem, PersonHelper, SubscriberHelper, UserSystem Classes: AccountController, Choice, Elt, EltController, Mail, MailNotify, Mailman, Notifier, Person, PersonController, SubscriberController, User, UserNotify

Constant Summary collapse

ICONV =
Iconv.new('UTF-8', 'ISO-8859-15')

Instance Method Summary collapse

Instance Method Details

#inputDir(directory) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/data_import.rb', line 10

def inputDir(directory)
	Dir.glob(directory+'/*.txt') do |file|
		dir = directory+'/'+file
		inputFile File.basename(directory), file
	end

	Dir.foreach(directory) do |d|
		if (d != '.' and d != '..' and d != '.svn')
		dir = directory+'/'+d
			if (File.directory?(dir) or File.symlink?(dir))
				#puts 'dir: '+dir
				inputDir dir
			end
		end
	end
end

#inputFile(d, fileName) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/data_import.rb', line 27

def inputFile(d, fileName)
	puts 'Loading: '+fileName

	elt = Elt.find_by_id(File.basename(fileName).gsub(/.txt/, ''))

	file = File.new(fileName)

	if elt == nil
		elt = Elt.new
		elt.id = File.basename(fileName).gsub(/.txt/, '')
		elt.created_on = nil
	end

	if elt.created_on == nil or elt.created_on < file.mtime
		elt.mail = nil

		elt.parent_id = d
		elt.created_on = file.mtime
		puts elt.created_on.class
		elt.subject = ICONV.iconv(file.gets.strip)
		elt.body = format(ICONV.iconv(file.gets('\n')))
		print "subject: "+elt.subject
		#puts "body: "+elt.body
		puts " (created_on: "+elt.created_on.to_s+")"
		elt.save
	end
end