xmlconv 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/History.txt +10 -0
- data/bin/migrate_xmlconv_to_utf_8 +0 -0
- data/bin/xmlconv_admin +0 -0
- data/lib/xmlconv/util/transaction.rb +21 -1
- data/lib/xmlconv/version.rb +1 -1
- data/lib/xmlconv/view/preformatted.rb +63 -40
- data/lib/xmlconv/view/template.rb +16 -9
- data/test/test_custom/lookandfeel.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 853b6b5baf72454d6fdf78f7377a6d94e4129a31
|
4
|
+
data.tar.gz: 05873a7b6ff4476bbf1c9564d8c9a06a4c5c3ab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9c8addf5d4a2efbd5660b0b15b8d68278e3fa22d588a4317059a089f2a8d68afc6c9a6bae14a6b9d1289de22d99e19889fbb54d0be0ad2a727cffc3edba40ab
|
7
|
+
data.tar.gz: bacc37b66f1ae54143cdf0dc6f3aff102013c8fd823bccb50ac486d8cb5d1f8c82d172c768dfc342cc8e6637ea4908cb3177eea857fd6961177d56903cd8ea19
|
data/.gitignore
ADDED
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 1.0.9 / 25.07.2016
|
2
|
+
|
3
|
+
* Fix encoding issue for incoming request
|
4
|
+
* Fix encoding issue on preformatted view
|
5
|
+
* Add charset in http response header and meta tag (UI)
|
6
|
+
|
7
|
+
=== 1.0.8 / 13.07.2016
|
8
|
+
|
9
|
+
* Fix base_url as non-flavoerd url
|
10
|
+
|
1
11
|
=== 1.0.7 / 21.06.2016
|
2
12
|
|
3
13
|
* Made it work running via mod_ruby with Ruby 1.8.6
|
File without changes
|
data/bin/xmlconv_admin
CHANGED
File without changes
|
@@ -26,7 +26,9 @@ module XmlConv
|
|
26
26
|
reader_instance = Conversion.const_get(@reader)
|
27
27
|
writer_instance = Conversion.const_get(@writer)
|
28
28
|
@start_time = Time.now
|
29
|
-
|
29
|
+
@input = encode(@input)
|
30
|
+
@input.gsub!(/\t+|\s+/, ' ')
|
31
|
+
input_model = reader_instance.parse(@input)
|
30
32
|
@arguments ||= []
|
31
33
|
@model = reader_instance.convert(input_model, *@arguments)
|
32
34
|
output_model = writer_instance.convert(@model, *@arguments)
|
@@ -37,6 +39,24 @@ module XmlConv
|
|
37
39
|
ensure
|
38
40
|
@destination.forget_credentials!
|
39
41
|
end
|
42
|
+
|
43
|
+
# Assumes its encoding once as ISO-8859-1 (latin1) at here,
|
44
|
+
# Because input_body is passed from ruby 1.8.6
|
45
|
+
def encode(input_body)
|
46
|
+
src = input_body.to_s
|
47
|
+
begin
|
48
|
+
# ISO-8859-1 (latin1) and WINDOWS-1252
|
49
|
+
src.encode('ISO-8859-1').force_encoding('UTF-8')
|
50
|
+
rescue Encoding::InvalidByteSequenceError,
|
51
|
+
Encoding::UndefinedConversionError
|
52
|
+
begin
|
53
|
+
src.force_encoding('ISO-8859-1').encode('UTF-8')
|
54
|
+
rescue
|
55
|
+
src
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
40
60
|
def invoice_ids
|
41
61
|
@model.invoices.collect do |inv|
|
42
62
|
inv.invoice_id.last.to_s.gsub /^0+/, ''
|
data/lib/xmlconv/version.rb
CHANGED
@@ -4,51 +4,74 @@
|
|
4
4
|
require 'htmlgrid/value'
|
5
5
|
|
6
6
|
module XmlConv
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
module View
|
8
|
+
class Preformatted < HtmlGrid::Value
|
9
|
+
BREAK_WIDTH = 65
|
10
|
+
|
10
11
|
def init
|
11
12
|
super
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rescue
|
18
|
-
pretty = raw
|
13
|
+
if @value
|
14
|
+
raw = @value.gsub(/>\s+</, '><').gsub(/\t|\r\n?/, '')
|
15
|
+
# fix encoding
|
16
|
+
if raw =~ /ISO\-8859\-1|WINDOWS\-1252/i
|
17
|
+
raw.force_encoding(Encoding::ISO_8859_1)
|
19
18
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
parts = []
|
29
|
-
tmpparts.each { |part|
|
30
|
-
if(part.length > BREAK_WIDTH)
|
31
|
-
parts.concat(part.split(/ /))
|
32
|
-
else
|
33
|
-
parts.push(part)
|
34
|
-
end
|
19
|
+
raw.encode!(Encoding::UTF_8).force_encoding(Encoding::UTF_8)
|
20
|
+
@value = <<~PRE
|
21
|
+
<pre>#{
|
22
|
+
cgi_with_utf8 {
|
23
|
+
# prettify (indent)
|
24
|
+
pretty = begin CGI.pretty(raw); rescue raw; end
|
25
|
+
# omit tags
|
26
|
+
CGI.escapeHTML(wrap(pretty))
|
35
27
|
}
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
}</pre>
|
29
|
+
PRE
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def wrap(pretty)
|
36
|
+
wrapped = ''
|
37
|
+
pretty.each_line { |line|
|
38
|
+
if line.length < BREAK_WIDTH
|
39
|
+
wrapped << line
|
40
|
+
else
|
41
|
+
indent = line[/^ +/].to_s
|
42
|
+
indent = indent[0,indent.length % (BREAK_WIDTH / 3)]
|
43
|
+
tmpparts = line.split(/(?<=") +(?=")/)
|
44
|
+
parts = []
|
45
|
+
tmpparts.each { |part|
|
46
|
+
if part.length > BREAK_WIDTH
|
47
|
+
parts.concat(part.split(/ /))
|
48
|
+
else
|
49
|
+
parts.push(part)
|
50
|
+
end
|
51
|
+
}
|
52
|
+
wrapline = parts.shift
|
53
|
+
while part = parts.shift
|
54
|
+
if (wrapline.length + part.length) >= BREAK_WIDTH
|
55
|
+
wrapped << wrapline
|
56
|
+
wrapped << "\n"
|
57
|
+
wrapline = indent.dup << (' ' * 5) << part
|
58
|
+
else
|
59
|
+
wrapline << ' ' << part
|
45
60
|
end
|
46
|
-
wrap << wrapline
|
47
61
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
62
|
+
wrapped << wrapline
|
63
|
+
end
|
64
|
+
}
|
65
|
+
wrapped
|
66
|
+
end
|
67
|
+
|
68
|
+
def cgi_with_utf8
|
69
|
+
orig_verbose = $VERBOSE
|
70
|
+
$VERBOSE = nil
|
71
|
+
result = yield
|
72
|
+
$VERBOSE = orig_verbose
|
73
|
+
result
|
51
74
|
end
|
52
|
-
|
53
|
-
|
75
|
+
end
|
76
|
+
end
|
54
77
|
end
|
@@ -5,13 +5,20 @@ require 'htmlgrid/divtemplate'
|
|
5
5
|
require 'xmlconv/view/foot'
|
6
6
|
|
7
7
|
module XmlConv
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
module View
|
9
|
+
class Template < HtmlGrid::DivTemplate
|
10
|
+
HTTP_HEADERS = {
|
11
|
+
'Content-Type' => 'text/html;charset=UTF-8'
|
12
|
+
}
|
13
|
+
META_TAGS = [{
|
14
|
+
'http-equiv' => 'content-type',
|
15
|
+
'content' => 'tex/html;charset=UTF-8'
|
16
|
+
}]
|
17
|
+
COMPONENTS = {
|
18
|
+
[0, 0] => :content,
|
19
|
+
[0, 1] => :foot,
|
20
|
+
}
|
21
|
+
FOOT = Foot
|
22
|
+
end
|
23
|
+
end
|
17
24
|
end
|
@@ -23,7 +23,8 @@ module XmlConv
|
|
23
23
|
def test_base_url_does_not_include_flavor
|
24
24
|
lookandfeel = Lookandfeel.new(@session)
|
25
25
|
assert_equal('sbsm', lookandfeel.flavor)
|
26
|
-
|
26
|
+
assert_equal('sbsm', @session.flavor)
|
27
|
+
refute_match(@session.flavor, lookandfeel.base_url)
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmlconv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaomi Hatakeyama, Zeno R.R. Davatz, Niklaus Giger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: odba
|
@@ -313,6 +313,7 @@ executables:
|
|
313
313
|
extensions: []
|
314
314
|
extra_rdoc_files: []
|
315
315
|
files:
|
316
|
+
- ".gitignore"
|
316
317
|
- Gemfile
|
317
318
|
- History.txt
|
318
319
|
- LICENSE
|