Class: Dependencies

Inherits:
Hash
  • Object
show all
Defined in:
lib/dependencies.rb

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Dependencies

Returns a new instance of Dependencies.



3
4
5
6
# File 'lib/dependencies.rb', line 3

def initialize
  initialize_ruby_dependencies
	initialize_csharp_dependencies
end

Instance Method Details

#initialize_csharp_dependencies ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dependencies.rb', line 22

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 = Array.new
	cs_dep_hash.each do |include,hint|
 cs_deps << hint
	end
	if cs_deps.length > 0
 cs_deps = cs_deps.sort
 self["C#"]=cs_deps
	end
end

#initialize_ruby_dependencies ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dependencies.rb', line 8

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

#show ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/dependencies.rb', line 48

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