-
Notifications
You must be signed in to change notification settings - Fork 83
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 csv2yaml convertor #103
base: master
Are you sure you want to change the base?
Conversation
lib/babelish/version.rb
Outdated
@@ -1,3 +1,3 @@ | |||
module Babelish | |||
VERSION = "0.5.3" | |||
VERSION = "0.6.0" |
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.
Freeze mutable objects assigned to constants.
lib/babelish/csv2yaml.rb
Outdated
end | ||
end | ||
end | ||
|
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.
1 trailing blank lines detected.
lib/babelish/csv2yaml.rb
Outdated
end | ||
indent = ' ' | ||
entry += comment.to_s.empty? ? "" : "#{indent}# #{comment}\n" | ||
entry += "#{indent}#{row_key}: \"#{row_value}\"\n" |
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.
Useless assignment to variable - entry. Use + instead of +=.
lib/babelish/csv2yaml.rb
Outdated
entry += "#{@language.code}:\n" | ||
@is_first_row = false | ||
end | ||
indent = ' ' |
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.
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.
not agree with the bot
lib/babelish/csv2yaml.rb
Outdated
return filepath ? [filepath] : [] | ||
end | ||
|
||
def get_row_format(row_key, row_value, comment = nil, indentation = 0) |
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.
Unused method argument - indentation. If it's necessary, use _ or _indentation as an argument name to indicate that it won't be used.
lib/babelish/csv2yaml.rb
Outdated
filename = @output_basename || language.code | ||
filepath = Pathname.new("#{@output_dir}/#{filename}.#{extension}") | ||
@language = language | ||
return filepath ? [filepath] : [] |
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.
Redundant return detected.
end | ||
|
||
def language_filepaths(language) | ||
require 'pathname' |
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.
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.
not agree with the bot
@@ -0,0 +1,34 @@ | |||
module Babelish |
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.
Missing magic comment # frozen_string_literal: true.
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.
rubocop | grep frozen_string_literal
does not have it.
@moskvin thanks for the contribution, Please add some unit tests and have you look at the @houndci-bot comments.
|
lib/babelish/csv2yaml.rb
Outdated
end | ||
|
||
def extension | ||
'yaml' |
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.
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.
I will not fix it!
end | ||
|
||
def get_row_format(row_key, row_value, comment = nil, _indentation = 0) | ||
entry = '' |
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.
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.
I will not fix it!
no, I was surprised :) |
not required right now for me, but I think we should add it |
@netbe If you want to achieve clean code for the project I suggest use |
lib/babelish/csv2yaml.rb
Outdated
end | ||
|
||
def extension | ||
'yaml' |
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.
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" |
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.
Surrounding space missing for operator *.
lib/babelish/csv2yaml.rb
Outdated
entry << "#{indent}#{filename}:\n" | ||
@is_first_row = false | ||
end | ||
entry << "#{indent*2}# #{comment}\n" unless comment.to_s.empty? |
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.
Surrounding space missing for operator *.
|
||
def get_row_format(row_key, row_value, comment = nil, _indentation = 0) | ||
entry = '' | ||
indent = ' ' |
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.
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}") |
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.
Line is too long. [89/80]
lib/babelish/csv2yaml.rb
Outdated
def extension | ||
'yaml' | ||
end | ||
|
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.
Extra empty line detected at class body end.
lib/babelish/csv2yaml.rb
Outdated
end | ||
|
||
def extension | ||
'yaml' |
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.
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" |
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.
Surrounding space missing for operator *.
lib/babelish/csv2yaml.rb
Outdated
end | ||
@is_first_row = false | ||
end | ||
entry << "#{indent*@deep}# #{comment}\n" unless comment.to_s.empty? |
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.
Surrounding space missing for operator *.
|
||
def get_row_format(row_key, row_value, comment = nil, indentation = 0) | ||
entry = '' | ||
indent = ' ' |
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.
end | ||
|
||
def get_row_format(row_key, row_value, comment = nil, indentation = 0) | ||
entry = '' |
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.
lib/babelish/csv2yaml.rb
Outdated
filepath ? [filepath] : [] | ||
end | ||
|
||
def get_row_format(row_key, row_value, comment = nil, indentation = 0) |
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.
Unused method argument - indentation. If it's necessary, use _ or _indentation as an argument name to indicate that it won't be used.
end | ||
|
||
def language_filepaths(language) | ||
require 'pathname' |
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.
|
||
def to_camel_case underscope_text | ||
enumerator = underscope_text.split('_').each_with_index | ||
enumerator.map{|word, index| index == 0 ? word : word.capitalize}.join |
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.
Space missing to the left of {.
Space between { and | missing.
Use index.zero? instead of index == 0.
Space missing inside }.
@@ -27,5 +27,10 @@ def extension | |||
def output_basename | |||
@output_basename || 'Localizable' | |||
end | |||
|
|||
def to_camel_case underscope_text | |||
enumerator = underscope_text.split('_').each_with_index |
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.
lib/babelish/csv2strings.rb
Outdated
@@ -27,5 +27,10 @@ def extension | |||
def output_basename | |||
@output_basename || 'Localizable' | |||
end | |||
|
|||
def to_camel_case underscope_text |
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.
Use def with parentheses when there are parameters.
lib/babelish/csv2strings.rb
Outdated
@@ -17,7 +17,7 @@ def language_filepaths(language) | |||
|
|||
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" |
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.
Line is too long. [92/80]
end | ||
|
||
def filename_to_camel_case underscope_text | ||
underscope_text.split('_').map{|word| word.capitalize}.join |
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.
Space missing to the left of {.
Space between { and | missing.
Pass &:capitalize as an argument to map instead of a block.
Space missing inside }.
lib/babelish/csv2strings.rb
Outdated
enumerator.map{|word, index| index == 0 ? word : word.capitalize}.join | ||
end | ||
|
||
def filename_to_camel_case underscope_text |
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.
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 |
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.
Space missing to the left of {.
Space between { and | missing.
Use index.zero? instead of index == 0.
Space missing inside }.
@@ -27,5 +28,14 @@ def extension | |||
def output_basename | |||
@output_basename || 'Localizable' | |||
end | |||
|
|||
def row_to_camel_case underscope_text | |||
enumerator = underscope_text.split('_').each_with_index |
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.
lib/babelish/csv2strings.rb
Outdated
@@ -27,5 +28,14 @@ def extension | |||
def output_basename | |||
@output_basename || 'Localizable' | |||
end | |||
|
|||
def row_to_camel_case underscope_text |
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.
Use def with parentheses when there are parameters.
lib/babelish/csv2strings.rb
Outdated
end | ||
end | ||
filepaths | ||
end | ||
|
||
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" |
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.
Line is too long. [96/80]
…mel case [csv2strings] Added convertor for filename from underscore case to camel case
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.
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
@@ -1,3 +1,3 @@ | |||
module Babelish | |||
VERSION = "0.5.4" | |||
VERSION = '0.6.0'.freeze |
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.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
lib/babelish/csv2yaml.rb
Outdated
end | ||
|
||
def extension | ||
'yaml' |
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.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
|
||
def get_row_format(row_key, row_value, comment = nil, _indentation = 0) | ||
entry = '' | ||
indent = ' ' |
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.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end | ||
|
||
def get_row_format(row_key, row_value, comment = nil, _indentation = 0) | ||
entry = '' |
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.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
end | ||
|
||
def language_filepaths(language) | ||
require 'pathname' |
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.
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 |
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.
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 }.
def extension | ||
"strings" | ||
end | ||
|
||
def output_basename | ||
@output_basename || 'Localizable' | ||
end | ||
|
||
def row_to_camel_case(underscope_text) | ||
enumerator = underscope_text.split('_').each_with_index |
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.
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}" |
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.
Metrics/LineLength: Line is too long. [110/80]
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}" |
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.
Metrics/LineLength: Line is too long. [98/80]
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) |
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.
Metrics/LineLength: Line is too long. [93/80]
@@ -5,7 +5,7 @@ class CSV2JSON < Csv2Base | |||
def language_filepaths(language) | |||
require 'pathname' | |||
filename = @output_basename || language.code | |||
filepath = Pathname.new("#{@output_dir}#{filename}.#{extension}") | |||
filepath = Pathname.new("#{@output_dir}/#{filename}.#{language.code}.#{extension}") |
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.
Metrics/LineLength: Line is too long. [89/80]
[gems] updated gems
|
||
# Specify your gem's dependencies in teachmehowtomakearubygem.gemspec | ||
gemspec | ||
|
||
group :test do | ||
gem 'coveralls', :require => false, :platforms => [:ruby_19, :ruby_20] | ||
gem 'coveralls', require: false, platforms: %i[ruby_19 ruby_20] | ||
gem 'rubocop' |
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.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
|
||
# Specify your gem's dependencies in teachmehowtomakearubygem.gemspec | ||
gemspec | ||
|
||
group :test do | ||
gem 'coveralls', :require => false, :platforms => [:ruby_19, :ruby_20] | ||
gem 'coveralls', require: false, platforms: %i[ruby_19 ruby_20] |
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.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -1,8 +1,9 @@ | |||
source "http://rubygems.org" | |||
source 'http://rubygems.org' |
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.
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.
require 'rake/testtask' | ||
require 'yard' | ||
|
||
Rake::TestTask.new do |t| | ||
t.libs << "test" | ||
t.libs << 'test' |
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.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
@@ -1,9 +1,9 @@ | |||
require "bundler/gem_tasks" | |||
require 'bundler/gem_tasks' |
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.
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.
Added