Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added rubocop and fixed most offenses
- Loading branch information
Showing
18 changed files
with
301 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
inherit_from: .rubocop_todo.yml | ||
|
||
AllCops: | ||
TargetRubyVersion: 2.0 | ||
|
||
Documentation: | ||
Enabled: false | ||
|
||
Lint/EndAlignment: | ||
EnforcedStyleAlignWith: variable | ||
|
||
Lint/LiteralInInterpolation: | ||
Enabled: true | ||
|
||
Metrics/AbcSize: | ||
Exclude: | ||
- test/**/* | ||
|
||
Metrics/ClassLength: | ||
Exclude: | ||
- test/**/* | ||
|
||
Metrics/LineLength: | ||
Max: 120 | ||
Exclude: | ||
- test/**/* | ||
|
||
Metrics/MethodLength: | ||
Exclude: | ||
- test/**/* | ||
|
||
Layout/AlignParameters: | ||
EnforcedStyle: with_fixed_indentation | ||
|
||
Layout/CaseIndentation: | ||
EnforcedStyle: end | ||
|
||
Layout/DotPosition: | ||
EnforcedStyle: trailing | ||
|
||
Layout/EmptyLinesAroundBlockBody: | ||
Enabled: false | ||
|
||
Layout/EmptyLinesAroundClassBody: | ||
EnforcedStyle: empty_lines | ||
|
||
Layout/EmptyLinesAroundModuleBody: | ||
EnforcedStyle: empty_lines | ||
|
||
Layout/FirstParameterIndentation: | ||
EnforcedStyle: special_for_inner_method_call | ||
|
||
Layout/IndentArray: | ||
EnforcedStyle: consistent | ||
|
||
Layout/IndentHash: | ||
EnforcedStyle: consistent | ||
|
||
Layout/MultilineMethodCallIndentation: | ||
EnforcedStyle: indented | ||
IndentationWidth: 2 | ||
|
||
Layout/MultilineOperationIndentation: | ||
EnforcedStyle: indented | ||
IndentationWidth: 2 | ||
|
||
Style/AutoResourceCleanup: | ||
Enabled: true | ||
|
||
Style/DoubleNegation: | ||
Enabled: false | ||
|
||
Style/FrozenStringLiteralComment: | ||
Enabled: false | ||
|
||
Style/MethodCalledOnDoEndBlock: | ||
Enabled: true | ||
|
||
Style/MethodCalledOnDoEndBlock: | ||
Exclude: | ||
- test/**/* | ||
|
||
Style/Send: | ||
Enabled: true | ||
|
||
Style/StringLiterals: | ||
EnforcedStyle: double_quotes | ||
|
||
Style/StringLiteralsInInterpolation: | ||
EnforcedStyle: double_quotes | ||
|
||
Style/StringMethods: | ||
Enabled: true | ||
|
||
Style/SymbolArray: | ||
Enabled: true | ||
|
||
Style/TrailingCommaInArguments: | ||
EnforcedStyleForMultiline: comma | ||
|
||
Style/TrailingCommaInLiteral: | ||
EnforcedStyleForMultiline: comma |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config` | ||
# on 2017-10-02 15:24:21 +0000 using RuboCop version 0.50.0. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
# Offense count: 4 | ||
Metrics/AbcSize: | ||
Max: 35 | ||
|
||
# Offense count: 16 | ||
# Configuration parameters: CountComments, ExcludedMethods. | ||
Metrics/BlockLength: | ||
Max: 265 | ||
|
||
# Offense count: 2 | ||
Metrics/CyclomaticComplexity: | ||
Max: 13 | ||
|
||
# Offense count: 4 | ||
# Configuration parameters: CountComments. | ||
Metrics/MethodLength: | ||
Max: 17 | ||
|
||
# Offense count: 2 | ||
Metrics/PerceivedComplexity: | ||
Max: 11 | ||
|
||
# Offense count: 27 | ||
Style/Send: | ||
Exclude: | ||
- 'bin/tm' | ||
- 'lib/textmagic/api.rb' | ||
- 'lib/textmagic/response.rb' | ||
- 'test/test_api.rb' | ||
- 'test/test_response.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
|
||
gem "minitest", require: "minitest/autorun" | ||
gem "mocha", require: "mocha/mini_test" | ||
gem "rubocop" | ||
gem "webmock" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,35 @@ | ||
# encoding: utf-8 | ||
|
||
module TextMagic | ||
|
||
class API | ||
|
||
module Charset | ||
|
||
GSM_CHARSET = "@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞ\e\f^{}\\[~]|€ÆæßÉ !\"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà".scan(/./u) | ||
ESCAPED_CHARS = "{}\\~[]|€" | ||
GSM_CHARSET = | ||
"@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞ\e\f^{}\\[~]|€ÆæßÉ !\"#¤%&'()*+,-./0123456789:;<=>?¡"\ | ||
"ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà".scan(/./u).freeze | ||
ESCAPED_CHARS = "{}\\~[]|€".freeze | ||
|
||
# Returns +true+ if the supplied text contains only characters from | ||
# GSM 03.38 charset, otherwise it returns +false+. | ||
def is_gsm(text) | ||
def gsm?(text) | ||
text.scan(/./u).each { |c| return false unless GSM_CHARSET.include?(c) } | ||
true | ||
end | ||
alias is_gsm gsm? | ||
|
||
# Returns +true+ if the supplied text contains characters outside of | ||
# GSM 03.38 charset, otherwise it returns +false+. | ||
def is_unicode(text) | ||
def unicode?(text) | ||
!is_gsm(text) | ||
end | ||
alias is_unicode unicode? | ||
|
||
def real_length(text, unicode) | ||
text.size + (unicode ? 0 : text.scan(/[\{\}\\~\[\]\|€]/).size) | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |
Oops, something went wrong.