Skip to content
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

Implemented having comments in CSV #99

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Dchau95
Copy link

@Dchau95 Dchau95 commented Aug 9, 2017

Android XML load strings does not load comments, whereas iOS Strings loads comments. Merely trying to mirror both platform strings conversion.

expected_output = [{"app_name" => "android2csv", "action_greetings" => "Hello", "ANOTHER_STRING" => "testEN", "empty" => ""},
{"app_name" => "This is the app name", "action_greetings" => "This is a greeting",
"ANOTHER_STRING" => "This is another string", "empty" => "This is an empty string"}]
output = Babelish::Android2CSV.new.load_strings "test/data/android-comments.xml"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [84/80]

def test_load_strings_with_comments
expected_output = [{"app_name" => "android2csv", "action_greetings" => "Hello", "ANOTHER_STRING" => "testEN", "empty" => ""},
{"app_name" => "This is the app name", "action_greetings" => "This is a greeting",
"ANOTHER_STRING" => "This is another string", "empty" => "This is an empty string"}]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the elements of a hash literal if they span more than one line.
Line is too long. [92/80]
Space inside } missing.

@@ -27,6 +27,14 @@ def test_initialize
assert_equal filenames, converter.filenames
end

def test_load_strings_with_comments
expected_output = [{"app_name" => "android2csv", "action_greetings" => "Hello", "ANOTHER_STRING" => "testEN", "empty" => ""},
{"app_name" => "This is the app name", "action_greetings" => "This is a greeting",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the elements of an array literal if they span more than one line.
Space inside { missing.
Line is too long. [89/80]
Trailing whitespace detected.

@@ -27,6 +27,14 @@ def test_initialize
assert_equal filenames, converter.filenames
end

def test_load_strings_with_comments
expected_output = [{"app_name" => "android2csv", "action_greetings" => "Hello", "ANOTHER_STRING" => "testEN", "empty" => ""},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside { missing.
Line is too long. [130/80]
Space inside } missing.
Trailing whitespace detected.

comments[node["name"]] = previous_comment if previous_comment
previous_comment = nil
end
if node.comment?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use next to skip iteration.

def parse_comment_line(line)
line.strip!
if line[0] != ?# && line[0] != ?=
m = line.match(/^\/\*(.*)\*\/\s*$/)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use %r around regular expression.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@netbe This function I copied from strings2csv.rb, so unsure if I should still change this according to houndci-bot.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dchau95 yes please make any change @houndci-bot mention and add tests to check comments on android

@@ -6,22 +6,40 @@ def initialize(args = {:filenames => []})
super(args)
end

def parse_comment_line(line)
line.strip!
if line[0] != ?# && line[0] != ?=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use the character literal - use string literal instead.

"empty" => "This is an empty string"
}
]
output = Babelish::Android2CSV.new.load_strings "test/data/android-comments.xml"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [84/80]

"ANOTHER_STRING" => "This is another string",
"empty" => "This is an empty string"
}
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the right bracket the same as the start of the line where the left bracket is.

"action_greetings" => "This is a greeting",
"ANOTHER_STRING" => "This is another string",
"empty" => "This is an empty string"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the right brace the same as the start of the line where the left brace is.

"app_name" => "This is the app name",
"action_greetings" => "This is a greeting",
"ANOTHER_STRING" => "This is another string",
"empty" => "This is an empty string"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

{
"app_name" => "This is the app name",
"action_greetings" => "This is a greeting",
"ANOTHER_STRING" => "This is another string",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

"action_greetings" => "Hello",
"ANOTHER_STRING" => "testEN",
"empty" => ""
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the right brace the same as the start of the line where the left brace is.
Trailing whitespace detected.

"app_name" => "android2csv",
"action_greetings" => "Hello",
"ANOTHER_STRING" => "testEN",
"empty" => ""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

{
"app_name" => "android2csv",
"action_greetings" => "Hello",
"ANOTHER_STRING" => "testEN",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

expected_output = [
{
"app_name" => "android2csv",
"action_greetings" => "Hello",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

def test_load_strings_with_comments
expected_output = [
{
"app_name" => "android2csv",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

@netbe
Copy link
Owner

netbe commented Sep 18, 2017

@Dchau95 Thks for the contrib, just getting back from vacation, I ll have a look soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants