diff --git a/lib/synvert/core.rb b/lib/synvert/core.rb index e1cecdb6..fe8fe6ab 100644 --- a/lib/synvert/core.rb +++ b/lib/synvert/core.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require "synvert/core/version" +require 'synvert/core/version' require 'bundler' require 'parser' require 'parser/current' diff --git a/lib/synvert/core/engine/erb.rb b/lib/synvert/core/engine/erb.rb index 34dcadf7..68b0a972 100644 --- a/lib/synvert/core/engine/erb.rb +++ b/lib/synvert/core/engine/erb.rb @@ -4,17 +4,17 @@ module Synvert::Core module Engine - ERUBY_EXPR_SPLITTER = "; ;" - ERUBY_STMT_SPLITTER = "; ;" + ERUBY_EXPR_SPLITTER = '; ;' + ERUBY_STMT_SPLITTER = '; ;' class ERB - class <", "%>"), :escape => false, :trim => false).src + Erubis.new(source.gsub('-%>', '%>'), escape: false, trim: false).src end # convert ruby code to erb. @@ -28,25 +28,30 @@ def decode(source) source = remove_erubis_buf(source) end - private + private def decode_ruby_stmt(source) source.gsub(/#{ERUBY_STMT_SPLITTER}(.+?)#{ERUBY_STMT_SPLITTER}/m) { "<%#{$1}%>" } end def decode_ruby_output(source) - source.gsub(/@output_buffer.append=\((.+?)\);#{ERUBY_EXPR_SPLITTER}/m) { "<%=#{$1}%>" } - .gsub(/@output_buffer.append= (.+?)\s+(do|\{)(\s*\|[^|]*\|)?\s*#{ERUBY_EXPR_SPLITTER}/m) { |m| "<%=#{m.sub("@output_buffer.append= ", "").sub(ERUBY_EXPR_SPLITTER, "")}%>" } + source.gsub(/@output_buffer.append=\((.+?)\);#{ERUBY_EXPR_SPLITTER}/m) { "<%=#{$1}%>" }.gsub( + /@output_buffer.append= (.+?)\s+(do|\{)(\s*\|[^|]*\|)?\s*#{ERUBY_EXPR_SPLITTER}/m + ) { |m| "<%=#{m.sub('@output_buffer.append= ', '').sub(ERUBY_EXPR_SPLITTER, '')}%>" } end def decode_html_output(source) - source.gsub(/@output_buffer.safe_append='(.+?)'.freeze;/m) { reverse_escape_text($1) } - .gsub(/@output_buffer.safe_append=\((.+?)\);#{ERUBY_EXPR_SPLITTER}/m) { reverse_escape_text($1) } - .gsub(/@output_buffer.safe_append=(.+?)\s+(do|\{)(\s*\|[^|]*\|)?\s*#{ERUBY_EXPR_SPLITTER}/m) { reverse_escape_text($1) } + source.gsub(/@output_buffer.safe_append='(.+?)'.freeze;/m) { reverse_escape_text($1) }.gsub( + /@output_buffer.safe_append=\((.+?)\);#{ERUBY_EXPR_SPLITTER}/m + ) { reverse_escape_text($1) }.gsub( + /@output_buffer.safe_append=(.+?)\s+(do|\{)(\s*\|[^|]*\|)?\s*#{ERUBY_EXPR_SPLITTER}/m + ) { reverse_escape_text($1) } end def remove_erubis_buf(source) - source.sub("@output_buffer = output_buffer || ActionView::OutputBuffer.new;", "").sub("@output_buffer.to_s", "") + source + .sub('@output_buffer = output_buffer || ActionView::OutputBuffer.new;', '') + .sub('@output_buffer.to_s', '') end def reverse_escape_text(source) @@ -59,7 +64,7 @@ def reverse_escape_text(source) class Erubis < ::Erubis::Eruby def add_preamble(src) @newline_pending = 0 - src << "@output_buffer = output_buffer || ActionView::OutputBuffer.new;" + src << '@output_buffer = output_buffer || ActionView::OutputBuffer.new;' end def add_text(src, text) @@ -102,22 +107,23 @@ def add_expr_literal(src, code) def add_expr_escaped(src, code) flush_newline_if_pending(src) if code =~ BLOCK_EXPR - src << "@output_buffer.safe_append= " << code << ERUBY_EXPR_SPLITTER + src << '@output_buffer.safe_append= ' << code << ERUBY_EXPR_SPLITTER else - src << "@output_buffer.safe_append=(" << code << ");" << ERUBY_EXPR_SPLITTER + src << '@output_buffer.safe_append=(' << code << ');' << ERUBY_EXPR_SPLITTER end end def add_stmt(src, code) flush_newline_if_pending(src) - if code != "\n" && code != "" - index = if code =~ /\A(\s*)\r?\n/ - $1.length - elsif code =~ /\A(\s+)/ - $1.end_with?(' ') ? $1.length - 1 : $1.length - else - 0 - end + if code != "\n" && code != '' + index = + if code =~ /\A(\s*)\r?\n/ + $1.length + elsif code =~ /\A(\s+)/ + $1.end_with?(' ') ? $1.length - 1 : $1.length + else + 0 + end code.insert(index, ERUBY_STMT_SPLITTER) code.insert(-1, ERUBY_STMT_SPLITTER[0...-1]) end diff --git a/lib/synvert/core/exceptions.rb b/lib/synvert/core/exceptions.rb index 8e1867f6..97926644 100644 --- a/lib/synvert/core/exceptions.rb +++ b/lib/synvert/core/exceptions.rb @@ -2,14 +2,11 @@ module Synvert::Core # Rewriter not found exception. - class RewriterNotFound < RuntimeError - end + class RewriterNotFound < RuntimeError; end # Gemfile.lock not found exception. - class GemfileLockNotFound < RuntimeError - end + class GemfileLockNotFound < RuntimeError; end # Method not supported exception. - class MethodNotSupported < RuntimeError - end + class MethodNotSupported < RuntimeError; end end diff --git a/lib/synvert/core/node_ext.rb b/lib/synvert/core/node_ext.rb index 046adbfb..5c2262f5 100644 --- a/lib/synvert/core/node_ext.rb +++ b/lib/synvert/core/node_ext.rb @@ -281,27 +281,24 @@ def to_value end def to_s - if :mlhs == self.type - "(#{self.children.map(&:name).join(', ')})" - end + "(#{self.children.map(&:name).join(', ')})" if :mlhs == self.type end def debug_info - "\n" + [ - "file: #{self.loc.expression.source_buffer.name}", - "line: #{self.loc.expression.line}", - "source: #{self.to_source}", - "node: #{self.inspect}" - ].join("\n") + "\n" + + [ + "file: #{self.loc.expression.source_buffer.name}", + "line: #{self.loc.expression.line}", + "source: #{self.to_source}", + "node: #{self.inspect}" + ].join("\n") end # Get the source code of current node. # # @return [String] source code. def to_source - if self.loc.expression - self.loc.expression.source - end + self.loc.expression.source if self.loc.expression end # Get the indent of current node. @@ -336,21 +333,23 @@ def recursive_children # @param rules [Hash] rules to match. # @return true if matches. def match?(rules) - flat_hash(rules).keys.all? do |multi_keys| - if multi_keys.last == :any - actual_values = actual_value(self, multi_keys[0...-1]) - expected = expected_value(rules, multi_keys) - actual_values.any? { |actual| match_value?(actual, expected) } - elsif multi_keys.last == :not - actual = actual_value(self, multi_keys[0...-1]) - expected = expected_value(rules, multi_keys) - !match_value?(actual, expected) - else - actual = actual_value(self, multi_keys) - expected = expected_value(rules, multi_keys) - match_value?(actual, expected) + flat_hash(rules) + .keys + .all? do |multi_keys| + if multi_keys.last == :any + actual_values = actual_value(self, multi_keys[0...-1]) + expected = expected_value(rules, multi_keys) + actual_values.any? { |actual| match_value?(actual, expected) } + elsif multi_keys.last == :not + actual = actual_value(self, multi_keys[0...-1]) + expected = expected_value(rules, multi_keys) + !match_value?(actual, expected) + else + actual = actual_value(self, multi_keys) + expected = expected_value(rules, multi_keys) + match_value?(actual, expected) + end end - end end # Get rewritten source code. @@ -376,9 +375,9 @@ def rewritten_source(code) lines_count = lines.length if lines_count > 1 && lines_count == evaluated.size new_code = [] - lines.each_with_index { |line, index| - new_code << (index == 0 ? line : line[evaluated.first.indent-2..-1]) - } + lines.each_with_index do |line, index| + new_code << (index == 0 ? line : line[evaluated.first.indent - 2..-1]) + end new_code.join("\n") else source @@ -397,7 +396,7 @@ def rewritten_source(code) end end - private + private # Compare actual value with expected value. # @@ -408,15 +407,10 @@ def rewritten_source(code) def match_value?(actual, expected) case expected when Symbol - if Parser::AST::Node === actual - actual.to_source == ":#{expected}" - else - actual.to_sym == expected - end + Parser::AST::Node === actual ? actual.to_source == ":#{expected}" : actual.to_sym == expected when String if Parser::AST::Node === actual - actual.to_source == expected || - (actual.to_source[0] == ':' && actual.to_source[1..-1] == expected) || + actual.to_source == expected || (actual.to_source[0] == ':' && actual.to_source[1..-1] == expected) || actual.to_source[1...-1] == expected else actual.to_s == expected @@ -434,11 +428,7 @@ def match_value?(actual, expected) when NilClass actual.nil? when Numeric - if Parser::AST::Node === actual - actual.children[0] == expected - else - actual == expected - end + Parser::AST::Node === actual ? actual.children[0] == expected : actual == expected when TrueClass :true == actual.type when FalseClass @@ -475,11 +465,7 @@ def flat_hash(h, k = []) # @param multi_keys [Array] # @return [Object] actual value. def actual_value(node, multi_keys) - multi_keys.inject(node) { |n, key| - if n - key == :source ? n.send(key) : n.send(key) - end - } + multi_keys.inject(node) { |n, key| key == :source ? n.send(key) : n.send(key) if n } end # Get expected value from rules. diff --git a/lib/synvert/core/rewriter.rb b/lib/synvert/core/rewriter.rb index f436d843..01b8ffc7 100644 --- a/lib/synvert/core/rewriter.rb +++ b/lib/synvert/core/rewriter.rb @@ -42,7 +42,7 @@ class Rewriter autoload :RubyVersion, 'synvert/core/rewriter/ruby_version' autoload :GemSpec, 'synvert/core/rewriter/gem_spec' - class < 1 - "\n\n" + rewritten_source.split("\n").map { |line| - indent(@node) + line - }.join("\n") + "\n\n" + rewritten_source.split("\n").map { |line| indent(@node) + line }.join("\n") else "\n" + indent(@node) + rewritten_source end diff --git a/lib/synvert/core/rewriter/action/append_action.rb b/lib/synvert/core/rewriter/action/append_action.rb index a3dc820d..e2e94659 100644 --- a/lib/synvert/core/rewriter/action/append_action.rb +++ b/lib/synvert/core/rewriter/action/append_action.rb @@ -9,11 +9,7 @@ class Rewriter::AppendAction < Rewriter::Action # # @return [Integer] begin position. def begin_pos - if :begin == @node.type - @node.loc.expression.end_pos - else - @node.loc.expression.end_pos - @node.indent - END_LENGTH - end + :begin == @node.type ? @node.loc.expression.end_pos : @node.loc.expression.end_pos - @node.indent - END_LENGTH end # End position, always same to begin position. @@ -23,7 +19,7 @@ def end_pos begin_pos end - private + private # Indent of the node. # diff --git a/lib/synvert/core/rewriter/action/insert_action.rb b/lib/synvert/core/rewriter/action/insert_action.rb index 56edad63..f1de8981 100644 --- a/lib/synvert/core/rewriter/action/insert_action.rb +++ b/lib/synvert/core/rewriter/action/insert_action.rb @@ -3,7 +3,7 @@ module Synvert::Core # InsertAction to insert code to the top of node body. class Rewriter::InsertAction < Rewriter::Action - DO_LENGTH = " do".length + DO_LENGTH = ' do'.length # Begin position to insert code. # @@ -11,7 +11,11 @@ class Rewriter::InsertAction < Rewriter::Action def begin_pos case @node.type when :block - @node.children[1].children.empty? ? @node.children[0].loc.expression.end_pos + DO_LENGTH : @node.children[1].loc.expression.end_pos + if @node.children[1].children.empty? + @node.children[0].loc.expression.end_pos + DO_LENGTH + else + @node.children[1].loc.expression.end_pos + end when :class @node.children[1] ? @node.children[1].loc.expression.end_pos : @node.children[0].loc.expression.end_pos else @@ -26,7 +30,7 @@ def end_pos begin_pos end - private + private # Indent of the node. # diff --git a/lib/synvert/core/rewriter/action/insert_after_action.rb b/lib/synvert/core/rewriter/action/insert_after_action.rb index 10d73ed8..8737d1b4 100644 --- a/lib/synvert/core/rewriter/action/insert_after_action.rb +++ b/lib/synvert/core/rewriter/action/insert_after_action.rb @@ -17,7 +17,7 @@ def end_pos begin_pos end - private + private # Indent of the node. # diff --git a/lib/synvert/core/rewriter/action/remove_action.rb b/lib/synvert/core/rewriter/action/remove_action.rb index 36eb8744..cda308aa 100644 --- a/lib/synvert/core/rewriter/action/remove_action.rb +++ b/lib/synvert/core/rewriter/action/remove_action.rb @@ -3,7 +3,7 @@ module Synvert::Core # RemoveAction to remove code. class Rewriter::RemoveAction < Rewriter::Action - def initialize(instance, code=nil) + def initialize(instance, code = nil) super end diff --git a/lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb b/lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb index 84489277..4ad5330f 100644 --- a/lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb +++ b/lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb @@ -4,7 +4,7 @@ module Synvert::Core # ReplaceErbStmtWithExprAction to replace erb stmt code to expr, # e.g. <% form_for ... %> => <%= form_for ... %>. class Rewriter::ReplaceErbStmtWithExprAction < Rewriter::Action - def initialize(instance, code=nil) + def initialize(instance, code = nil) super end @@ -13,8 +13,7 @@ def initialize(instance, code=nil) # @return [Integer] begin position. def begin_pos node_begin_pos = @node.loc.expression.begin_pos - while @node.loc.expression.source_buffer.source[node_begin_pos -= 1] == ' ' - end + while @node.loc.expression.source_buffer.source[node_begin_pos -= 1] == ' '; end node_begin_pos - Engine::ERUBY_STMT_SPLITTER.length + 1 end @@ -23,9 +22,8 @@ def begin_pos # @return [Integer] end position. def end_pos node_begin_pos = @node.loc.expression.begin_pos - node_begin_pos += @node.loc.expression.source.index "do" - while @node.loc.expression.source_buffer.source[node_begin_pos += 1] != '@' - end + node_begin_pos += @node.loc.expression.source.index 'do' + while @node.loc.expression.source_buffer.source[node_begin_pos += 1] != '@'; end node_begin_pos end @@ -33,7 +31,8 @@ def end_pos # # @return [String] rewritten code. def rewritten_code - @node.loc.expression.source_buffer.source[begin_pos...end_pos].sub(Engine::ERUBY_STMT_SPLITTER, "@output_buffer.append= ") + @node.loc.expression.source_buffer.source[begin_pos...end_pos] + .sub(Engine::ERUBY_STMT_SPLITTER, '@output_buffer.append= ') .sub(Engine::ERUBY_STMT_SPLITTER, Engine::ERUBY_EXPR_SPLITTER) end end diff --git a/lib/synvert/core/rewriter/action/replace_with_action.rb b/lib/synvert/core/rewriter/action/replace_with_action.rb index f40a4e71..ad7f755e 100644 --- a/lib/synvert/core/rewriter/action/replace_with_action.rb +++ b/lib/synvert/core/rewriter/action/replace_with_action.rb @@ -23,16 +23,18 @@ def end_pos def rewritten_code if rewritten_source.split("\n").length > 1 new_code = [] - rewritten_source.split("\n").each_with_index { |line, index| - new_code << (index == 0 || !@options[:autoindent] ? line : indent(@node) + line) - } + rewritten_source + .split("\n") + .each_with_index do |line, index| + new_code << (index == 0 || !@options[:autoindent] ? line : indent(@node) + line) + end new_code.join("\n") else rewritten_source end end - private + private # Indent of the node # diff --git a/lib/synvert/core/rewriter/condition/if_only_exist_condition.rb b/lib/synvert/core/rewriter/condition/if_only_exist_condition.rb index 1407d623..22a9a7b7 100644 --- a/lib/synvert/core/rewriter/condition/if_only_exist_condition.rb +++ b/lib/synvert/core/rewriter/condition/if_only_exist_condition.rb @@ -5,8 +5,7 @@ module Synvert::Core class Rewriter::IfOnlyExistCondition < Rewriter::Condition # check if only have one child node and the child node matches rules. def match? - @instance.current_node.body.size == 1 && - @instance.current_node.body.first.match?(@rules) + @instance.current_node.body.size == 1 && @instance.current_node.body.first.match?(@rules) end end end diff --git a/lib/synvert/core/rewriter/gem_spec.rb b/lib/synvert/core/rewriter/gem_spec.rb index 6d5ad45c..da96abf7 100644 --- a/lib/synvert/core/rewriter/gem_spec.rb +++ b/lib/synvert/core/rewriter/gem_spec.rb @@ -3,7 +3,7 @@ module Synvert::Core # GemSpec checks and compares gem version. class Rewriter::GemSpec - OPERATORS = {eq: '==', lt: '<', gt: '>', lte: '<=', gte: '>=', ne: '!='} + OPERATORS = { eq: '==', lt: '<', gt: '>', lte: '<=', gte: '>=', ne: '!=' } # Initialize a gem_spec. # diff --git a/lib/synvert/core/rewriter/helper.rb b/lib/synvert/core/rewriter/helper.rb index 98da9e68..a9e96e7c 100644 --- a/lib/synvert/core/rewriter/helper.rb +++ b/lib/synvert/core/rewriter/helper.rb @@ -15,11 +15,7 @@ module Rewriter::Helper # if current_node doesn't have a receiver, it returns "{{message}} {{arguments}}" # if current_node has a receiver, it returns "{{receiver}}.{{message}} {{arguments}}" def add_receiver_if_necessary(code) - if node.receiver - "{{receiver}}.#{code}" - else - code - end + node.receiver ? "{{receiver}}.#{code}" : code end # Add arguments with parenthesis if necessary. @@ -33,11 +29,7 @@ def add_receiver_if_necessary(code) # if current_node doesn't have an argument, it returns "" # if current_node has argument, it returns "({{arguments}})" def add_arguments_with_parenthesis_if_necessary - if node.arguments.size > 0 - "({{arguments}})" - else - "" - end + node.arguments.size > 0 ? '({{arguments}})' : '' end # Add curly brackets to code if necessary. @@ -49,11 +41,7 @@ def add_arguments_with_parenthesis_if_necessary # # add_curly_brackets_if_necessary("{{arguments}}") def add_curly_brackets_if_necessary(code) - if code.start_with?('{') && code.end_with?('}') - code - else - "{ #{code} }" - end + code.start_with?('{') && code.end_with?('}') ? code : "{ #{code} }" end # Remove leading and trailing brackets. @@ -65,9 +53,7 @@ def add_curly_brackets_if_necessary(code) # # strip_brackets("(1..100)") #=> "1..100" def strip_brackets(code) - code.sub(/^\((.*)\)$/) { $1 } - .sub(/^\[(.*)\]$/) { $1 } - .sub(/^{(.*)}$/) { $1 } + code.sub(/^\((.*)\)$/) { $1 }.sub(/^\[(.*)\]$/) { $1 }.sub(/^{(.*)}$/) { $1 } end end end diff --git a/lib/synvert/core/rewriter/instance.rb b/lib/synvert/core/rewriter/instance.rb index 9125b72c..986088d2 100644 --- a/lib/synvert/core/rewriter/instance.rb +++ b/lib/synvert/core/rewriter/instance.rb @@ -8,7 +8,7 @@ module Synvert::Core class Rewriter::Instance include Rewriter::Helper - class < 0 - @actions.sort_by! { |action| action.send(@options[:sort_by]) } - conflict_actions = get_conflict_actions - @actions.reverse_each do |action| - source[action.begin_pos...action.end_pos] = action.rewritten_code - source = remove_code_or_whole_line(source, action.line) + + if @actions.length > 0 + @actions.sort_by! { |action| action.send(@options[:sort_by]) } + conflict_actions = get_conflict_actions + @actions.reverse_each do |action| + source[action.begin_pos...action.end_pos] = action.rewritten_code + source = remove_code_or_whole_line(source, action.line) + end + @actions = [] + + self.class.write_file(file_path, source) end - @actions = [] - - self.class.write_file(file_path, source) - end - rescue Parser::SyntaxError - puts "[Warn] file #{file_path} was not parsed correctly." - # do nothing, iterate next file - end while !conflict_actions.empty? + rescue Parser::SyntaxError + puts "[Warn] file #{file_path} was not parsed correctly." + # do nothing, iterate next file + end while !conflict_actions.empty? + end end - end end # Gets current node, it allows to get current node in block code. @@ -220,7 +222,7 @@ def if_only_exist_node(rules, &block) # # @param code [String] code need to be appended. # @param options [Hash] action options. - def append(code, options={}) + def append(code, options = {}) @actions << Rewriter::AppendAction.new(self, code, options) end @@ -229,7 +231,7 @@ def append(code, options={}) # # @param code [String] code need to be inserted. # @param options [Hash] action options. - def insert(code, options={}) + def insert(code, options = {}) @actions << Rewriter::InsertAction.new(self, code, options) end @@ -238,7 +240,7 @@ def insert(code, options={}) # # @param code [String] code need to be inserted. # @param options [Hash] action options. - def insert_after(node, options={}) + def insert_after(node, options = {}) @actions << Rewriter::InsertAfterAction.new(self, node, options) end @@ -247,7 +249,7 @@ def insert_after(node, options={}) # # @param code [String] code need to be replaced with. # @param options [Hash] action options. - def replace_with(code, options={}) + def replace_with(code, options = {}) @actions << Rewriter::ReplaceWithAction.new(self, code, options) end @@ -269,7 +271,7 @@ def warn(message) @rewriter.add_warning Rewriter::Warning.new(self, message) end - private + private # It changes source code from bottom to top, and it can change source code twice at the same time, # So if there is an overlap between two actions, it removes the conflict actions and operate them in the next loop. @@ -301,7 +303,8 @@ def remove_code_or_whole_line(source, line) source_arr = source.split("\n") if source_arr[line - 1] && source_arr[line - 1].strip.empty? source_arr.delete_at(line - 1) - if source_arr[line - 2] && source_arr[line - 2].strip.empty? && source_arr[line - 1] && source_arr[line - 1].strip.empty? + if source_arr[line - 2] && source_arr[line - 2].strip.empty? && source_arr[line - 1] && + source_arr[line - 1].strip.empty? source_arr.delete_at(line - 1) end source_arr.join("\n") + (newline_at_end_of_line ? "\n" : '') diff --git a/lib/synvert/core/rewriter/scope.rb b/lib/synvert/core/rewriter/scope.rb index 493975f0..e26a4a50 100644 --- a/lib/synvert/core/rewriter/scope.rb +++ b/lib/synvert/core/rewriter/scope.rb @@ -2,6 +2,5 @@ module Synvert::Core # Scope finds out nodes which match rules. - class Rewriter::Scope - end + class Rewriter::Scope; end end diff --git a/lib/synvert/core/rewriter/scope/within_scope.rb b/lib/synvert/core/rewriter/scope/within_scope.rb index fec5703e..8e40a170 100644 --- a/lib/synvert/core/rewriter/scope/within_scope.rb +++ b/lib/synvert/core/rewriter/scope/within_scope.rb @@ -38,13 +38,9 @@ def find_matching_nodes(current_node) matching_nodes = [] if @options[:recursive] matching_nodes << current_node if current_node.match? @rules - current_node.recursive_children do |child_node| - matching_nodes << child_node if child_node.match? @rules - end + current_node.recursive_children { |child_node| matching_nodes << child_node if child_node.match? @rules } else - current_node.each do |child_node| - matching_nodes << child_node if child_node.match? @rules - end + current_node.each { |child_node| matching_nodes << child_node if child_node.match? @rules } end matching_nodes end diff --git a/lib/synvert/core/version.rb b/lib/synvert/core/version.rb index a695ba58..8dc9f166 100644 --- a/lib/synvert/core/version.rb +++ b/lib/synvert/core/version.rb @@ -2,6 +2,6 @@ module Synvert module Core - VERSION = "0.16.1" + VERSION = '0.16.1' end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d0fda429..4e6ce400 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,15 +1,13 @@ # frozen_string_literal: true -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib")) +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'synvert/core' require 'coveralls' Coveralls.wear! -Dir[File.join(File.dirname(__FILE__), 'support', '*')].each do |path| - require path -end +Dir[File.join(File.dirname(__FILE__), 'support', '*')].each { |path| require path } RSpec.configure do |config| config.include ParserHelper diff --git a/spec/synvert/core/engine/erb_spec.rb b/spec/synvert/core/engine/erb_spec.rb index ddcde4bf..1ff8304d 100644 --- a/spec/synvert/core/engine/erb_spec.rb +++ b/spec/synvert/core/engine/erb_spec.rb @@ -4,8 +4,8 @@ module Synvert::Core describe Engine::ERB do - it "encodes / decodes" do - source =<<-EOF + it 'encodes / decodes' do + source = <<-EOF <%content_for :head do%>