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 csv2yaml convertor #103

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

Implemented csv2yaml convertor #103

wants to merge 11 commits into from

Conversation

moskvin
Copy link
Contributor

@moskvin moskvin commented Feb 27, 2018

Added

  • csv2yaml convertor

@@ -1,3 +1,3 @@
module Babelish
VERSION = "0.5.3"
VERSION = "0.6.0"
Copy link
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.

end
end
end

Copy link
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.

end
indent = ' '
entry += comment.to_s.empty? ? "" : "#{indent}# #{comment}\n"
entry += "#{indent}#{row_key}: \"#{row_value}\"\n"
Copy link
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 +=.

entry += "#{@language.code}:\n"
@is_first_row = false
end
indent = ' '
Copy link
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
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

return filepath ? [filepath] : []
end

def get_row_format(row_key, row_value, comment = nil, indentation = 0)
Copy link
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.

filename = @output_basename || language.code
filepath = Pathname.new("#{@output_dir}/#{filename}.#{extension}")
@language = language
return filepath ? [filepath] : []
Copy link
Collaborator

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'
Copy link
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
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

@@ -0,0 +1,34 @@
module Babelish
Copy link
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
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
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?

end

def extension
'yaml'
Copy link
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
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!

end

def get_row_format(row_key, row_value, comment = nil, _indentation = 0)
entry = ''
Copy link
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
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
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
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
Contributor Author

moskvin commented Mar 24, 2018

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

end

def extension
'yaml'
Copy link
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.

@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
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 *.

entry << "#{indent}#{filename}:\n"
@is_first_row = false
end
entry << "#{indent*2}# #{comment}\n" unless comment.to_s.empty?
Copy link
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 *.


def get_row_format(row_key, row_value, comment = nil, _indentation = 0)
entry = ''
indent = ' '
Copy link
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 language_filepaths(language)
require 'pathname'
filename = @output_basename || language.code
filepath = Pathname.new("#{@output_dir}/#{filename}.#{language.code}.#{extension}")
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. [89/80]

def extension
'yaml'
end

Copy link
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.

end

def extension
'yaml'
Copy link
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.

@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
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 *.

end
@is_first_row = false
end
entry << "#{indent*@deep}# #{comment}\n" unless comment.to_s.empty?
Copy link
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 *.


def get_row_format(row_key, row_value, comment = nil, indentation = 0)
entry = ''
indent = ' '
Copy link
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.

end

def get_row_format(row_key, row_value, comment = nil, indentation = 0)
entry = ''
Copy link
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.

filepath ? [filepath] : []
end

def get_row_format(row_key, row_value, comment = nil, indentation = 0)
Copy link
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.

end

def language_filepaths(language)
require 'pathname'
Copy link
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
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 }.

@@ -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
Copy link
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.

@@ -27,5 +27,10 @@ def extension
def output_basename
@output_basename || 'Localizable'
end

def to_camel_case underscope_text
Copy link
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.

@@ -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"
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. [92/80]

end

def filename_to_camel_case underscope_text
underscope_text.split('_').map{|word| word.capitalize}.join
Copy link
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 }.

enumerator.map{|word, index| index == 0 ? word : word.capitalize}.join
end

def filename_to_camel_case underscope_text
Copy link
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
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 }.

@@ -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
Copy link
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.

@@ -27,5 +28,14 @@ def extension
def output_basename
@output_basename || 'Localizable'
end

def row_to_camel_case underscope_text
Copy link
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.

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"
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. [96/80]

…mel case

[csv2strings] Added convertor for filename from underscore case to camel case
Copy link
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

@@ -1,3 +1,3 @@
module Babelish
VERSION = "0.5.4"
VERSION = '0.6.0'.freeze
Copy link
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.

end

def extension
'yaml'
Copy link
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 get_row_format(row_key, row_value, comment = nil, _indentation = 0)
entry = ''
indent = ' '
Copy link
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.

end

def get_row_format(row_key, row_value, comment = nil, _indentation = 0)
entry = ''
Copy link
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.

end

def language_filepaths(language)
require 'pathname'
Copy link
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
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 }.

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
Copy link
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
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]

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
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]

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
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]

@@ -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}")
Copy link
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

# 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'
Copy link
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.


# 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]
Copy link
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.

@@ -1,8 +1,9 @@
source "http://rubygems.org"
source 'http://rubygems.org'
Copy link
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.

require 'rake/testtask'
require 'yard'

Rake::TestTask.new do |t|
t.libs << "test"
t.libs << 'test'
Copy link
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.

@@ -1,9 +1,9 @@
require "bundler/gem_tasks"
require 'bundler/gem_tasks'
Copy link
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