Skip to content

Commit

Permalink
Merge pull request #411 from mpraglowski/res-migrator-fix
Browse files Browse the repository at this point in the history
RES migrator fix
  • Loading branch information
mostlyobvious authored Jul 31, 2018
2 parents b5383d5 + 9bde63c commit ea9afb0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@

module RubyEventStore
class DeprecatedReadAPIRewriter < ::Parser::Rewriter
DEPRECATED_READER_METHODS = [
:read_all_streams_backward,
:read_events_backward,
:read_stream_events_backward,
:read_all_streams_forward,
:read_events_forward,
:read_stream_events_forward
]
private_constant :DEPRECATED_READER_METHODS

def on_send(node)
node.each_descendant(:send) { |desc_node| on_send(desc_node) }

_, method_name, *args = node.children
return unless DEPRECATED_READER_METHODS.include?(method_name)
replace_range = node.location.selector
replace_range = replace_range.join(node.location.end) if node.location.end

Expand Down Expand Up @@ -64,4 +75,4 @@ def parse_keyword(node)
node.children[0].to_sym
end
end
end
end
4 changes: 3 additions & 1 deletion ruby_event_store/spec/deprecated_spec_api_rewriter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@ def rewrite(string)
specify { expect(rewrite('block_call{client.read_all_streams_forward}')).to eq('block_call{client.read.limit(100).each.to_a}') }

specify { expect(rewrite('client.read_stream_events_forward(name_as_variable)')).to eq('client.read.stream(name_as_variable).each.to_a') }

specify { expect(rewrite('@bus.(command)')).to eq('@bus.(command)') }
end
end
end

0 comments on commit ea9afb0

Please sign in to comment.