Conversation
| converter = Babelish::Android2CSV.new( | ||
| :csv_filename => csv_filename, | ||
| :headers => headers, | ||
| :filenames => [filename]) |
There was a problem hiding this comment.
Use the new Ruby 1.9 hash syntax.
Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
| expected_output = [["html"], {filename => {"html" => "<![CDATA[<p>Text<p>]]>"}}] | ||
| converter = Babelish::Android2CSV.new( | ||
| :csv_filename => csv_filename, | ||
| :headers => headers, |
There was a problem hiding this comment.
Use the new Ruby 1.9 hash syntax.
|
|
||
| expected_output = [["html"], {filename => {"html" => "<![CDATA[<p>Text<p>]]>"}}] | ||
| converter = Babelish::Android2CSV.new( | ||
| :csv_filename => csv_filename, |
There was a problem hiding this comment.
Use the new Ruby 1.9 hash syntax.
| 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.
Space inside { missing.
Line is too long. [84/80]
Space inside } missing.
| converter = Babelish::Android2CSV.new( | ||
| :csv_filename => csv_filename, | ||
| :headers => headers, | ||
| :filenames => [filename]) |
There was a problem hiding this comment.
Use the new Ruby 1.9 hash syntax.
Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
| expected_output = [["html"], {filename => {"html" => "<![CDATA[<p>Text<p>]]>"}}] | ||
| converter = Babelish::Android2CSV.new( | ||
| :csv_filename => csv_filename, | ||
| :headers => headers, |
There was a problem hiding this comment.
Use the new Ruby 1.9 hash syntax.
|
|
||
| expected_output = [["html"], {filename => {"html" => "<![CDATA[<p>Text<p>]]>"}}] | ||
| converter = Babelish::Android2CSV.new( | ||
| :csv_filename => csv_filename, |
There was a problem hiding this comment.
Use the new Ruby 1.9 hash syntax.
| 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.
Space inside { missing.
Line is too long. [84/80]
Space inside } missing.
lib/babelish/android2csv.rb
Outdated
| strings.merge!(node["name"] => '<![CDATA[' + node.inner_html + ']]>') | ||
| else | ||
| strings.merge!(node["name"] => node.inner_html) | ||
| end |
There was a problem hiding this comment.
Trailing whitespace detected.
lib/babelish/android2csv.rb
Outdated
| if !node.nil? && !node["name"].nil? | ||
| strings.merge!(node["name"] => node.inner_html) | ||
| if node.cdata? | ||
| strings.merge!(node["name"] => '<![CDATA[' + node.inner_html + ']]>') |
There was a problem hiding this comment.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Line is too long. [81/80]
|
Looks like it's not working... I'll try something else later. |
lib/babelish/android2csv.rb
Outdated
| parser.xpath("//string").each do |node| | ||
| if !node.nil? && !node["name"].nil? | ||
| strings.merge!(node["name"] => node.inner_html) | ||
| if "#{node.children.first.class}" == "Nokogiri::XML::CDATA" |
There was a problem hiding this comment.
Prefer to_s over string interpolation.
|
@netbe Looks like it is working now Please take a look~ Thanks~ |
| :filenames => [filename]) | ||
|
|
||
| output = converter.convert(false) | ||
|
|
There was a problem hiding this comment.
I remove a line here which check if file exists.
Since the above convert has a false. I think the file will not exist?
Update:
I found that
Nodeof<string name="cdata"><![CDATA[Line number 1.<br />Line number 2.]]></string>will contain a
NodeSetand the first item of thatNodeSetwill be aCDATATried using
is_a?to check the class but still not that familiar with ruby, so I ended up using string comparison.--
Hi,
Try use following method as a workaround to fix #73 (as a newbie of ruby...)
http://www.rubydoc.info/github/sparklemotion/nokogiri/Nokogiri/XML/Node#cdata%3F-instance_method
https://github.com/sparklemotion/nokogiri/blob/master/lib/nokogiri/xml/node.rb#L454
Append the test you've written before.
Please take a look~
--
BTW I escape the string with CDATA to deal with #73 's problem for now
Turn
<string name="cdata"><![CDATA[Line number 1.<br />Line number 2.]]></string>Into
<string name="cdata">Line number 1.<br />Line number 2.</string>But it's kind of exhausted for me or my coworker to edit all our strings...