Sha256: 2e78859c3108281283c03b99f4355d50bb13383114d31879157e0b40931d1a76

Contents?: true

Size: 1.57 KB

Versions: 6

Compression:

Stored size: 1.57 KB

Contents

class Dependencies < Hash

  def initialize
    initialize_ruby_dependencies
	initialize_csharp_dependencies
  end

  def initialize_ruby_dependencies
    ruby_deps = Array.new
    Dir.glob("**/*.rb").each{|f|
	  text=File.read(f)
	  text.scan(/require '([\w\/]+)/).each{|r|
	   ruby_deps << r.first.to_s if !ruby_deps.include? r
	  }
	}
	if ruby_deps.length > 0
	  ruby_deps = ruby_deps.sort
	  self["ruby"]=ruby_deps
	end
  end

  def initialize_csharp_dependencies
    cs_dep_hash=Hash.new
    #includes = Array.new
	#hints = Array.new
    Dir.glob("**/*.csproj").each{|f|
	  text=File.read(f)
	  text.scan(/<Reference Include="([\w\.]+)"/).each{|r|
	   cs_dep_hash[r.first.to_s]=r.first.to_s if !cs_dep_hash.has_key? r.first.to_s
	  }
	  text.scan(/<HintPath>([\w\.\\\s]+)</).each{|r|
	   hint = r.first.to_s
	   include = hint.split('\\').last
	   cs_dep_hash.delete include.gsub(".dll","")
	   cs_dep_hash[include]=hint
	  }
	}
	cs_deps = Hash.new
	cs_dep_hash.each do |include,hint|
	  if(include==hint)
	    cs_deps[:system]=Array.new if !cs_deps.has_key?(:system)
		cs_deps[:system]<< hint
	  else
	    cs_deps[:file]=Array.new if !cs_deps.has_key?(:file)
	    cs_deps[:file] << hint
	  end
	end
	if cs_deps.length > 0
	  cs_deps[:system]=cs_deps[:system].sort# = cs_deps.sort
	  cs_deps[:file]=cs_deps[:file]
	  self["C#"]=cs_deps
	end
  end

  def show
    self.each do |key,array|
	  if(array.length > 0)
	    puts key
	    array.each {|v|
	      puts "  " + Color.green + v + Color.clear + " "
	    }
	  end
	end
	puts " "
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dev_tasks-0.0.24 lib/dependencies.rb
dev_tasks-0.0.23 lib/dependencies.rb
dev_tasks-0.0.22 lib/dependencies.rb
dev_tasks-0.0.21 lib/dependencies.rb
dev_tasks-0.0.20 lib/dependencies.rb
dev_tasks-0.0.19 lib/dependencies.rb