Skip to content

Commit

Permalink
Fix rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
franklinhu committed Mar 8, 2024
1 parent af4ab91 commit da39d8a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
13 changes: 13 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
AllCops:
TargetRubyVersion: 2.6

Style/Documentation:
Enabled: false

Style/StringLiterals:
Enabled: true
EnforcedStyle: single_quotes
Expand All @@ -11,3 +14,13 @@ Style/StringLiteralsInInterpolation:

Layout/LineLength:
Max: 120

Metrics/AbcSize:
Enabled: false

Metrics/BlockLength:
Enabled: false

Metrics/MethodLength:
Enabled: false

8 changes: 4 additions & 4 deletions lib/sorbet_erb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
require_relative 'sorbet_erb/version'

module SorbetErb
USAGE = <<~END
USAGE = <<~USAGE
Usage: sorbet_erb input_dir output_dir
input_dir - where to scan for ERB files
output_dir - where to write files with Ruby extracted from ERB
END
USAGE

ERB_TEMPLATE = <<~END
ERB_TEMPLATE = <<~ERB_TEMPLATE
# typed: true
class SorbetErb<%= class_suffix %> < ApplicationController
include ApplicationController::HelperMethods
Expand All @@ -25,7 +25,7 @@ def body<%= locals %>
<% end %>
end
end
END
ERB_TEMPLATE

def self.extract_rb_from_erb(path, output_dir)
puts 'Clearing output directory'
Expand Down
20 changes: 10 additions & 10 deletions test/code_extractor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,41 @@ class CodeExtractorTest < Minitest::Spec
test_cases = [
{
name: 'normal code',
input: <<~END,
input: <<~INPUT,
<div>
<% value -%>
</div>
END
INPUT
output: [
' value '
],
locals: nil
},
{
name: 'expression',
input: <<~END,
input: <<~INPUT,
<%= @something %>
END
INPUT
output: [
' @something '
],
locals: nil
},
{
name: 'comment',
input: <<~END,
input: <<~INPUT,
<%# comment %>
END
INPUT
output: [],
locals: nil
},
{
name: 'for loop',
input: <<~END,
input: <<~INPUT,
<% collection.each do |item| %>
<%= item.name %>
<% end %>
END
INPUT
output: [
' collection.each do |item| ',
' item.name ',
Expand All @@ -51,10 +51,10 @@ class CodeExtractorTest < Minitest::Spec
},
{
name: 'strict locals - no defaults',
input: <<~END,
input: <<~INPUT,
<%# locals: (a:, b:) %>
<%= a %>
END
INPUT
output: [
' a '
],
Expand Down

0 comments on commit da39d8a

Please sign in to comment.