forked from maxrossello/redmine_glossary
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglossary_import_info.rb
69 lines (56 loc) · 1.37 KB
/
glossary_import_info.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#
# glossary_import_info.rb
#
# Author : Mitsuyoshi Yoshida
# This program is freely distributable under the terms of an MIT-style license.
#
require 'i18n'
class GlossaryImportInfo
attr_accessor :import_file
attr_accessor :err_string
def initialize(tbl)
@import_file = tbl[:import_file]
end
def success?
(err_string) ? false : true
end
end
class CsvGlossaryImportInfo < GlossaryImportInfo
attr_accessor :is_first_comment
attr_reader :col_max
attr_accessor :cat_num, :newterm_num, :upterm_num
attr_writer :in_encoding
def initialize(tbl)
super(tbl)
@is_first_comment = tbl[:is_first_comment]
@in_encoding = tbl[:in_encoding]
@colno_tbl = {}
Term.import_params.each {|prm|
prmcol = tbl["colno_#{prm}"]
if (prmcol and !prmcol.empty?)
@colno_tbl[prmcol.to_i] = prm
end
}
@col_max = @colno_tbl.keys.max
@cat_num = 0
@newterm_num = 0
@upterm_num = 0
end
def in_encoding
(@in_encoding) ? @in_encoding : 'UTF-8'
end
def col_param(colno)
@colno_tbl[colno]
end
def param_col(prm)
@colno_tbl.each {|key, val|
return key if (val == prm)
}
nil
end
def self.default_param_cols(&blk)
Term.import_params.each {|prm|
yield prm, (Term.export_params.index(prm))
}
end
end