-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try Fix CDATA problem in android2csv.rb #104
base: master
Are you sure you want to change the base?
Changes from 3 commits
6ac906d
c7bdf9d
ea498e8
9863f90
f66672a
e1284d5
005cf5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,11 @@ def load_strings(strings_filename) | |
end | ||
parser.xpath("//string").each do |node| | ||
if !node.nil? && !node["name"].nil? | ||
strings.merge!(node["name"] => node.inner_html) | ||
if node.cdata? | ||
strings.merge!(node["name"] => '<![CDATA[' + node.inner_html + ']]>') | ||
else | ||
strings.merge!(node["name"] => node.inner_html) | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trailing whitespace detected. |
||
end | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,4 +50,24 @@ def test_special_chars | |
# clean up | ||
system("rm -rf ./" + csv_filename) | ||
end | ||
|
||
def test_cdata_are_not_removed | ||
csv_filename = "./test.csv" | ||
filename = "test/data/android_cdata.xml" | ||
headers = %w{variables german} | ||
|
||
expected_output = [["html"], {filename => {"html" => "<![CDATA[<p>Text<p>]]>"}}] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space inside { missing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space inside { missing. |
||
converter = Babelish::Android2CSV.new( | ||
:csv_filename => csv_filename, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. |
||
:headers => headers, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. |
||
:filenames => [filename]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. |
||
|
||
output = converter.convert(false) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remove a line here which check if file exists. Since the above |
||
assert File.exist?(converter.csv_filename) | ||
assert_equal expected_output, output | ||
|
||
# clean up | ||
system("rm -rf ./" + csv_filename) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="html"><![CDATA[<p>Text<p>]]></string> | ||
</resources> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Line is too long. [81/80]