lib/ripper/extract_constants.rb in grape-reload-0.0.2 vs lib/ripper/extract_constants.rb in grape-reload-0.0.3

- old
+ new

@@ -100,27 +100,17 @@ result[:used] = result[:used].reject {|variants| !variants.find{|v| result[:declared].include?(v) }.nil? } - used = self.used.reject {|variants| - !variants.find{|v| result[:declared].include?(v) }.nil? - } - - if namespace - ns_variants = [namespace+'::'] - full_namespace[0..-2].reverse.each{|ns| ns_variants << ns + '::' + ns_variants.last} - used.each do |variants| - # variants = variants.reject{ |v| - # !ns_variants.find{|ns_part| v.start_with?(ns_part) }.nil? - # } - result[:used] = result[:used] << variants - end - else - result[:used] = result[:used].concat(used) + used = self.used.reject {|variants| !variants.find{|v| result[:declared].include?(v) }.nil? } + if namespace.nil? + used = used.map {|variants| variants.map{|v| (v.start_with?('::') ? '' : (namespace || '') + '::') + v }} end + result[:used] = result[:used].concat(used) + result end end class ASTEntity @@ -297,9 +287,10 @@ @body = args.find{|a| a.first == :bodystmt}[1].map{|node| ASTEntity.node_for(node) } end def collect_constants(result, context) + result.declare_const(@module_name) result = result.nest(@module_name) context.module << @module_name super(result, context) end end