Skip to content

Implemented csv2yaml convertor#103

Open
moskvin wants to merge 11 commits intonetbe:masterfrom
sibext:master
Open

Implemented csv2yaml convertor#103
moskvin wants to merge 11 commits intonetbe:masterfrom
sibext:master

Conversation

@moskvin
Copy link
Copy Markdown
Contributor

@moskvin moskvin commented Feb 27, 2018

Added

  • csv2yaml convertor

Comment thread lib/babelish/version.rb Outdated
@@ -1,3 +1,3 @@
module Babelish
VERSION = "0.5.3"
VERSION = "0.6.0"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Freeze mutable objects assigned to constants.

Comment thread lib/babelish/csv2yaml.rb Outdated
end
end
end

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

1 trailing blank lines detected.

Comment thread lib/babelish/csv2yaml.rb Outdated
end
indent = ' '
entry += comment.to_s.empty? ? "" : "#{indent}# #{comment}\n"
entry += "#{indent}#{row_key}: \"#{row_value}\"\n"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Useless assignment to variable - entry. Use + instead of +=.

Comment thread lib/babelish/csv2yaml.rb Outdated
entry += "#{@language.code}:\n"
@is_first_row = false
end
indent = ' '
Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not agree with the bot

Comment thread lib/babelish/csv2yaml.rb Outdated
return filepath ? [filepath] : []
end

def get_row_format(row_key, row_value, comment = nil, indentation = 0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Unused method argument - indentation. If it's necessary, use _ or _indentation as an argument name to indicate that it won't be used.

Comment thread lib/babelish/csv2yaml.rb Outdated
filename = @output_basename || language.code
filepath = Pathname.new("#{@output_dir}/#{filename}.#{extension}")
@language = language
return filepath ? [filepath] : []
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Redundant return detected.

Comment thread lib/babelish/csv2yaml.rb
end

def language_filepaths(language)
require 'pathname'
Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not agree with the bot

Comment thread lib/babelish/csv2yaml.rb
@@ -0,0 +1,34 @@
module Babelish
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Missing magic comment # frozen_string_literal: true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

rubocop | grep frozen_string_literal does not have it.

@netbe
Copy link
Copy Markdown
Owner

netbe commented Feb 27, 2018

@moskvin thanks for the contribution,

Please add some unit tests and have you look at the @houndci-bot comments.

  • Also did you look athttps://github.com/netbe/Babelish/tree/feature/yaml?
  • Also would be cool to have yaml2csv?

Comment thread lib/babelish/csv2yaml.rb Outdated
end

def extension
'yaml'
Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will not fix it!

Comment thread lib/babelish/csv2yaml.rb
end

def get_row_format(row_key, row_value, comment = nil, _indentation = 0)
entry = ''
Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will not fix it!

@moskvin
Copy link
Copy Markdown
Contributor Author

moskvin commented Mar 24, 2018

Also did you look athttps://github.com/netbe/Babelish/tree/feature/yaml?

no, I was surprised :)

@moskvin
Copy link
Copy Markdown
Contributor Author

moskvin commented Mar 24, 2018

Also would be cool to have yaml2csv?

not required right now for me, but I think we should add it

@moskvin
Copy link
Copy Markdown
Contributor Author

moskvin commented Mar 24, 2018

@netbe If you want to achieve clean code for the project I suggest use rubocop

Comment thread lib/babelish/csv2yaml.rb Outdated
end

def extension
'yaml'
Copy link
Copy Markdown
Collaborator

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.

Comment thread lib/babelish/csv2yaml.rb Outdated
@is_first_row = false
end
entry << "#{indent*2}# #{comment}\n" unless comment.to_s.empty?
entry << "#{indent*2}#{row_key}: \"#{row_value}\"\n"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Surrounding space missing for operator *.

Comment thread lib/babelish/csv2yaml.rb Outdated
entry << "#{indent}#{filename}:\n"
@is_first_row = false
end
entry << "#{indent*2}# #{comment}\n" unless comment.to_s.empty?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Surrounding space missing for operator *.

Comment thread lib/babelish/csv2yaml.rb

def get_row_format(row_key, row_value, comment = nil, _indentation = 0)
entry = ''
indent = ' '
Copy link
Copy Markdown
Collaborator

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.

Comment thread lib/babelish/csv2yaml.rb Outdated
def language_filepaths(language)
require 'pathname'
filename = @output_basename || language.code
filepath = Pathname.new("#{@output_dir}/#{filename}.#{language.code}.#{extension}")
Copy link
Copy Markdown
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. [89/80]

Comment thread lib/babelish/csv2yaml.rb Outdated
def extension
'yaml'
end

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Extra empty line detected at class body end.

Comment thread lib/babelish/csv2yaml.rb Outdated
end

def extension
'yaml'
Copy link
Copy Markdown
Collaborator

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.

Comment thread lib/babelish/csv2yaml.rb Outdated
@is_first_row = false
end
entry << "#{indent*@deep}# #{comment}\n" unless comment.to_s.empty?
entry << "#{indent*@deep}#{row_key}: \"#{row_value}\"\n"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Surrounding space missing for operator *.

Comment thread lib/babelish/csv2yaml.rb Outdated
end
@is_first_row = false
end
entry << "#{indent*@deep}# #{comment}\n" unless comment.to_s.empty?
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Surrounding space missing for operator *.

Comment thread lib/babelish/csv2yaml.rb

def get_row_format(row_key, row_value, comment = nil, indentation = 0)
entry = ''
indent = ' '
Copy link
Copy Markdown
Collaborator

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.

Comment thread lib/babelish/csv2yaml.rb
end

def get_row_format(row_key, row_value, comment = nil, indentation = 0)
entry = ''
Copy link
Copy Markdown
Collaborator

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.

Comment thread lib/babelish/csv2yaml.rb Outdated
filepath ? [filepath] : []
end

def get_row_format(row_key, row_value, comment = nil, indentation = 0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Unused method argument - indentation. If it's necessary, use _ or _indentation as an argument name to indicate that it won't be used.

Comment thread lib/babelish/csv2yaml.rb
end

def language_filepaths(language)
require 'pathname'
Copy link
Copy Markdown
Collaborator

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.


def to_camel_case underscope_text
enumerator = underscope_text.split('_').each_with_index
enumerator.map{|word, index| index == 0 ? word : word.capitalize}.join
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Space missing to the left of {.
Space between { and | missing.
Use index.zero? instead of index == 0.
Space missing inside }.

end

def to_camel_case underscope_text
enumerator = underscope_text.split('_').each_with_index
Copy link
Copy Markdown
Collaborator

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.

Comment thread lib/babelish/csv2strings.rb Outdated
@output_basename || 'Localizable'
end

def to_camel_case underscope_text
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use def with parentheses when there are parameters.

Comment thread lib/babelish/csv2strings.rb Outdated
def get_row_format(row_key, row_value, comment = nil, indentation = 0)
entry = comment.to_s.empty? ? "" : "\n/* #{comment} */\n"
entry + "\"#{row_key}\"" + " " * indentation + " = \"#{row_value}\";\n"
entry + "\"#{to_camel_case(row_key)}\"" + " " * indentation + " = \"#{row_value}\";\n"
Copy link
Copy Markdown
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. [92/80]

end

def filename_to_camel_case underscope_text
underscope_text.split('_').map{|word| word.capitalize}.join
Copy link
Copy Markdown
Collaborator

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.
Space missing to the left of {.
Space between { and | missing.
Pass &:capitalize as an argument to map instead of a block.
Space missing inside }.

Comment thread lib/babelish/csv2strings.rb Outdated
enumerator.map{|word, index| index == 0 ? word : word.capitalize}.join
end

def filename_to_camel_case underscope_text
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use def with parentheses when there are parameters.


def row_to_camel_case underscope_text
enumerator = underscope_text.split('_').each_with_index
enumerator.map{|word, index| index == 0 ? word : word.capitalize}.join
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Space missing to the left of {.
Space between { and | missing.
Use index.zero? instead of index == 0.
Space missing inside }.

end

def row_to_camel_case underscope_text
enumerator = underscope_text.split('_').each_with_index
Copy link
Copy Markdown
Collaborator

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.

Comment thread lib/babelish/csv2strings.rb Outdated
@output_basename || 'Localizable'
end

def row_to_camel_case underscope_text
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use def with parentheses when there are parameters.

Comment thread lib/babelish/csv2strings.rb Outdated
def get_row_format(row_key, row_value, comment = nil, indentation = 0)
entry = comment.to_s.empty? ? "" : "\n/* #{comment} */\n"
entry + "\"#{row_key}\"" + " " * indentation + " = \"#{row_value}\";\n"
entry + "\"#{row_to_camel_case(row_key)}\"" + " " * indentation + " = \"#{row_value}\";\n"
Copy link
Copy Markdown
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. [96/80]

…mel case

[csv2strings] Added convertor for filename from underscore case to camel case
Copy link
Copy Markdown
Collaborator

@houndci-bot houndci-bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

.rubocop.yml: Style/FileName has the wrong namespace - should be Naming
.rubocop.yml: Style/FileName has the wrong namespace - should be Naming
.rubocop.yml: Style/PredicateName has the wrong namespace - should be Naming
.rubocop.yml: Style/AccessorMethodName has the wrong namespace - should be Naming
Error: The `Style/TrailingCommaInLiteral` cop no longer exists. Please use `Style/TrailingCommaInArrayLiteral` and/or `Style/TrailingCommaInHashLiteral` instead.
(obsolete configuration found in .rubocop.yml, please update it)
obsolete parameter MaxLineLength (for Style/IfUnlessModifier) found in .rubocop.yml
`Style/IfUnlessModifier: MaxLineLength` has been removed. Use `Metrics/LineLength: Max` instead

Comment thread lib/babelish/version.rb
@@ -1,3 +1,3 @@
module Babelish
VERSION = "0.5.4"
VERSION = '0.6.0'.freeze
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Comment thread lib/babelish/csv2yaml.rb Outdated
end

def extension
'yaml'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Comment thread lib/babelish/csv2yaml.rb

def get_row_format(row_key, row_value, comment = nil, _indentation = 0)
entry = ''
indent = ' '
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Comment thread lib/babelish/csv2yaml.rb
end

def get_row_format(row_key, row_value, comment = nil, _indentation = 0)
entry = ''
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Comment thread lib/babelish/csv2yaml.rb
end

def language_filepaths(language)
require 'pathname'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.


def row_to_camel_case(underscope_text)
enumerator = underscope_text.split('_').each_with_index
enumerator.map{|word, index| index == 0 ? word : word.capitalize}.join
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Layout/SpaceBeforeBlockBraces: Space missing to the left of {.
Layout/SpaceInsideBlockBraces: Space between { and | missing.
Style/NumericPredicate: Use index.zero? instead of index == 0.
Layout/SpaceInsideBlockBraces: Space missing inside }.

end

def row_to_camel_case(underscope_text)
enumerator = underscope_text.split('_').each_with_index
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

else
language.regions.each do |region|
filepaths << Pathname.new(@output_dir) + "#{language.code}-#{region}.lproj/#{output_basename}.#{extension}"
filepaths << Pathname.new(@output_dir) + "#{language.code}-#{region}.lproj/#{basename}.#{extension}"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [110/80]

basename = filename_to_camel_case(output_basename)
if language.regions.empty?
filepaths << Pathname.new(@output_dir) + "#{language.code}.lproj/#{output_basename}.#{extension}"
filepaths << Pathname.new(@output_dir) + "#{language.code}.lproj/#{basename}.#{extension}"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [98/80]

Comment thread lib/babelish/csv2base.rb
output += get_row_format(key, value, comment, indentation - key.length)
key_out = key_to_output(key)
value_out = value_to_output(value)
output += get_row_format(key_out, value_out, comment, indentation - key_out.length)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [93/80]

Comment thread lib/babelish/csv2json.rb
require 'pathname'
filename = @output_basename || language.code
filepath = Pathname.new("#{@output_dir}#{filename}.#{extension}")
filepath = Pathname.new("#{@output_dir}/#{filename}.#{language.code}.#{extension}")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [89/80]

stolyarov and others added 2 commits August 20, 2021 14:26
Comment thread Gemfile
group :test do
gem 'coveralls', :require => false, :platforms => [:ruby_19, :ruby_20]
gem 'coveralls', require: false, platforms: %i[ruby_19 ruby_20]
gem 'rubocop'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Comment thread Gemfile

group :test do
gem 'coveralls', :require => false, :platforms => [:ruby_19, :ruby_20]
gem 'coveralls', require: false, platforms: %i[ruby_19 ruby_20]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Comment thread Gemfile
@@ -1,8 +1,9 @@
source "http://rubygems.org"
source 'http://rubygems.org'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Comment thread Rakefile

Rake::TestTask.new do |t|
t.libs << "test"
t.libs << 'test'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Comment thread Rakefile
@@ -1,9 +1,9 @@
require "bundler/gem_tasks"
require 'bundler/gem_tasks'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

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