class ActiveResourceInspector::Base
Attributes
dirname[RW]
resources[R]
Public Class Methods
detailed_print()
click to toggle source
# File lib/active_resource_inspector.rb, line 31 def self.detailed_print factory(dirpath).defaul_print do |res| ["\t"*5, res.prefix_source, res.collection_name, res.format_extension, " (", res, ") \n\n"].join('') end end
print(dirpath)
click to toggle source
# File lib/active_resource_inspector.rb, line 27 def self.print(dirpath) factory(dirpath).defaul_print end
Private Class Methods
factory(dirname)
click to toggle source
# File lib/active_resource_inspector.rb, line 61 def self.factory(dirname) Base.new.tap do |obj| if defined?(Rails::Railtie) obj.dirname = File.join(Rails.root,'app', 'models') else obj.dirname = dirname || '.' end end end
Public Instance Methods
defaul_print(&block)
click to toggle source
# File lib/active_resource_inspector.rb, line 37 def defaul_print(&block) puts "Location: #{dirname}" puts "\n" resources.group_by{|e| e.site.to_s }.each do |endpoint, rs| rs.group_by{|e| e.auth_type }.each do |auth_type, rs2| if auth_type.nil? puts "#{endpoint} #{rs2[0].headers.empty? ? '(no auth)' : 'with headers auth '+rs2[0].headers.to_s }" else puts "#{endpoint} wiht auth #{auth_type.capitalize}" end t = rs2.map do |res| if block_given? block.call(res) else ["\t"*5, res.prefix_source, res.collection_name, res.format_extension].join('') end end puts t.sort end end end
files()
click to toggle source
# File lib/active_resource_inspector.rb, line 23 def files Dir[File.join(dirname, '**/*.rb')] end