Added CruxUtils::Port.find. Patch by Rene Lengwinat. master
authorTilman Sauerbeck <tilman@code-monkey.de>
Fri, 29 Sep 2006 15:44:43 +0000 (17:44 +0200)
committerTilman Sauerbeck <tilman@code-monkey.de>
Fri, 29 Sep 2006 15:44:43 +0000 (17:44 +0200)
lib/cruxutils.rb
lib/cruxutils/port.rb

index 5e54bb2a416fc3892d33a3d79cc826ddc0daba60..8670fc948aae5476405bdf0ac60579a0decab366 100644 (file)
@@ -1,5 +1,7 @@
 module CruxUtils
        class CruxUtilsError < StandardError; end
+
+       PORTDIRS = Dir["/usr/ports/{core,opt,contrib}"]
 end
 
 require "cruxutils/port.rb"
index ecc111334e176af841b283efe5fcd8ada0033f0f..a1e839f66bcd3273ea8c72838ff52d8507c98191 100644 (file)
@@ -20,6 +20,13 @@ class Port
                tmp
        end
 
+       def Port.find(pattern)
+               PORTDIRS.inject([]) do |memo, pd|
+                       tmp = Dir["#{pd}/#{pattern}"].map { |d| Port.new(d) }
+                       memo.concat(tmp)
+               end
+       end
+
        def initialize(dir)
                @dir = dir