Skip to content
This repository has been archived by the owner on Sep 19, 2020. It is now read-only.

Commit

Permalink
Subscription support, refs #31.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Crump committed Jun 5, 2012
1 parent 109bd03 commit 008b1d1
Show file tree
Hide file tree
Showing 2 changed files with 310 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/foodcritic/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ def match(node)
# @return [Array] A flat array of notifications.
def notifications(ast)
return [] unless ast.respond_to?(:xpath)
ast.xpath('//command[ident/@value="notifies"]').map do |notifies|
ast.xpath('//command[ident/@value="notifies" or
ident/@value="subscribes"]').map do |notifies|

params = notifies.xpath('descendant::method_add_arg[fcall/ident/
@value="resources"]/descendant::assoc_new')
timing = notifies.xpath('args_add_block/args_add/symbol_literal[last()]/
Expand All @@ -203,14 +205,15 @@ def notifications(ast)
end
{
:type =>
:notifies,
notifies.xpath('ident/@value[1]').to_s.to_sym,
:resource_type => resource_type,
:resource_name => resource_name,
:action =>
notifies.xpath('descendant::symbol[1]/ident/@value').to_s.to_sym,
:notification_timing =>
timing.empty? ? :delayed : timing.first.to_s.to_sym
}

end.compact
end

Expand Down
Loading

0 comments on commit 008b1d1

Please sign in to comment.