Index: libraries.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/libraries.module,v
retrieving revision 1.8
diff -u -p -r1.8 libraries.module
--- libraries.module	10 Oct 2010 03:55:16 -0000	1.8
+++ libraries.module	11 Oct 2010 13:32:55 -0000
@@ -126,7 +126,7 @@ function libraries_get_libraries() {
  *   An array of info files, keyed by library name. The values are the paths of
  *   the files.
  */
-function libraries_info_files() {
+function libraries_scan_info_files() {
   global $profile;
   if (!isset($profile)) {
     $profile = variable_get('install_profile', 'default');
@@ -143,18 +143,17 @@ function libraries_info_files() {
   // Scan for info files.
   $files = array();
   foreach ($directories as $dir) {
-    $files += file_scan_directory($dir, '/[a-z[a-z0-9_]+.info/', array(
-      'key' => 'name',
-      'recurse' => FALSE,
-    ));
-  }
-
-  foreach ($files as &$file) {
-    $file = $file->uri;
+    if (file_exists($dir)) {
+      $files = array_merge($files, file_scan_directory($dir, '@^[a-z0-9._-]+\.info$@', array(
+        'key' => 'name',
+        'recurse' => FALSE,
+      )));
+    }
   }
 
   return $files;
 }
+
 /**
  * Returns information about registered libraries.
  *
@@ -179,22 +178,27 @@ function libraries_info($library = NULL)
 
   if (!isset($libraries)) {
     $libraries = array();
+    // Gather information from hook_libraries_info().
     foreach (module_implements('libraries_info') as $module) {
       foreach (module_invoke($module, 'libraries_info') as $name => $properties) {
         $properties['module'] = $module;
-        $properties['name'] = $name;
         $libraries[$name] = $properties;
       }
     }
+
     // Gather information from .info files.
-    foreach (libraries_info_files() as $name => $path) {
-      $file = "$path/$name.info";
-      $libraries[$name] = drupal_parse_info_file($file);
+    // .info files override module definitions.
+    foreach (libraries_scan_info_files() as $name => $file) {
+      $filepath = DRUPAL_ROOT . '/' . $file->uri;
+      $properties = drupal_parse_info_file($filepath);
+      $properties['info file'] = $filepath;
+      $libraries[$name] = $properties;
     }
 
     // Provide defaults.
     foreach ($libraries as $name => &$properties) {
       $properties += array(
+        'name' => $name,
         'title' => $name,
         'vendor url' => '',
         'download url' => '',
Index: tests/libraries.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries.test,v
retrieving revision 1.6
diff -u -p -r1.6 libraries.test
--- tests/libraries.test	10 Oct 2010 14:17:55 -0000	1.6
+++ tests/libraries.test	11 Oct 2010 13:32:56 -0000
@@ -26,10 +26,34 @@ class LibrariesTestCase extends DrupalWe
    * @todo Better method name(s); split into detection/loading/overloading/etc.
    */
   public function testLibraries() {
-    // Test a library specified with an .info file gets detected.
-    $library = libraries_info('example');
+    // Test that library information is found correctly.
+    $library = libraries_info('example_simple');
+    $expected = array(
+      'name' => 'example_simple',
+      'title' => 'Example simple',
+      'vendor url' => '',
+      'download url' => '',
+      'path' => '',
+      'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
+      'version callback' => '_libraries_test_return_version',
+      'version arguments' => array('1'),
+      'files' => array(
+        'js' => array('example_1.js'),
+        'css' => array('example_1.css'),
+        'php' => array('example_1.php'),
+      ),
+      'variants' => array(),
+      'versions' => array(),
+      'integration files' => array(),
+      'module' => 'libraries_test',
+    );
+    $this->assertEqual($library, $expected, 'Library information is correctly gathered.');
+
+    // Test that a library specified with an .info file gets detected.
+    $library = libraries_info('example_info_file');
     $expected = array(
-      'title' => 'example',
+      'name' => 'example_info_file',
+      'title' => 'Example info file',
       'vendor url' => '',
       'download url' => '',
       'path' => '',
@@ -39,6 +63,7 @@ class LibrariesTestCase extends DrupalWe
       'variants' => array(),
       'versions' => array(),
       'integration files' => array(),
+      'info file' => DRUPAL_ROOT . '/' . drupal_get_path('module', 'libraries_test') . '/example/example_info_file.info',
     );
     $this->assertEqual($library, $expected, 'Library specified with an .info file found');
 
Index: tests/libraries_test.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/tests/libraries_test.module,v
retrieving revision 1.5
diff -u -p -r1.5 libraries_test.module
--- tests/libraries_test.module	10 Oct 2010 03:55:16 -0000	1.5
+++ tests/libraries_test.module	11 Oct 2010 13:32:56 -0000
@@ -12,18 +12,21 @@
 function libraries_test_libraries_info() {
   // Test library detection.
   $libraries['example_missing'] = array(
+    'title' => 'Example missing',
     // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/missing',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array('1'),
   );
   $libraries['example_undetected_version'] = array(
+    'title' => 'Example untedected version',
     // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests',
     'version callback' => '_libraries_test_return_version',
     'version arguments' => array(FALSE),
   );
   $libraries['example_unsupported_version'] = array(
+    'title' => 'Example unsupported version',
     // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests',
     'version callback' => '_libraries_test_return_version',
@@ -34,6 +37,7 @@ function libraries_test_libraries_info()
   );
 
   $libraries['example_supported_version'] = array(
+    'title' => 'Example supported version',
     // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests',
     'version callback' => '_libraries_test_return_version',
@@ -45,6 +49,7 @@ function libraries_test_libraries_info()
 
   // Test the default version callback.
   $libraries['example_default_version_callback'] = array(
+    'title' => 'Example default version callback',
     // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version arguments' => array(
@@ -57,6 +62,7 @@ function libraries_test_libraries_info()
 
   // Test a multiple-parameter version callback.
   $libraries['example_multiple_parameter_version_callback'] = array(
+    'title' => 'Example multiple parameter version callback',
     // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     // Version 2
@@ -66,6 +72,7 @@ function libraries_test_libraries_info()
 
   // Test a top-level files property.
   $libraries['example_simple'] = array(
+    'title' => 'Example simple',
     // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
@@ -87,6 +94,7 @@ function libraries_test_libraries_info()
   // Normally added by the corresponding module via hook_libraries_info_alter(),
   // these files should be automatically loaded when the library is loaded.
   $libraries['example_integration_files'] = array(
+    'title' => 'Example integration files',
     // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
@@ -108,6 +116,7 @@ function libraries_test_libraries_info()
 
   // Test version overloading.
   $libraries['example_versions'] = array(
+    'title' => 'Example versions',
     // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
@@ -144,6 +153,7 @@ function libraries_test_libraries_info()
 
   // Test variant detection.
   $libraries['example_variant_missing'] = array(
+    'title' => 'Example variant missing',
     // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
@@ -168,6 +178,7 @@ function libraries_test_libraries_info()
   );
 
   $libraries['example_variant'] = array(
+    'title' => 'Example variant',
     // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
@@ -193,6 +204,7 @@ function libraries_test_libraries_info()
 
   // Test correct behaviour with multiple versions and multiple variants.
   $libraries['example_versions_and_variants'] = array(
+    'title' => 'Example versions and variants',
     // Never declare library path manually. It is detected automatically.
     'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
     'version callback' => '_libraries_test_return_version',
Index: tests/example/example_info_file.info
===================================================================
RCS file: tests/example/example_info_file.info
diff -N tests/example/example_info_file.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/example/example_info_file.info	11 Oct 2010 13:32:56 -0000
@@ -0,0 +1,5 @@
+; $Id: example.info,v 1.1 2010/10/09 22:26:03 tstoeckler Exp $
+title = Example info file
+
+; This is an example info file for a library used for testing purposes.
+
