diff --git a/servers/rest_server/includes/ServicesFormatter.inc b/servers/rest_server/includes/ServicesFormatter.inc index 9f3ed7d..554b1bd 100644 --- a/servers/rest_server/includes/ServicesFormatter.inc +++ b/servers/rest_server/includes/ServicesFormatter.inc @@ -90,13 +90,8 @@ class ServicesXMLFormatter implements ServicesFormatterInterface { class ServicesYAMLFormatter implements ServicesFormatterInterface { public function render($data) { - if (($library = libraries_load('spyc')) && !empty($library['loaded'])) { - return Spyc::YAMLDump($data, 4, 60); - } - else { - watchdog('REST Server', 'Spyc library not found!', array(), WATCHDOG_ERROR); - return ''; - } + module_load_include('php', 'rest_server', 'lib/spyc'); + return Spyc::YAMLDump($data, 4, 60); } } diff --git a/servers/rest_server/includes/ServicesParser.inc b/servers/rest_server/includes/ServicesParser.inc index 8716490..303130a 100644 --- a/servers/rest_server/includes/ServicesParser.inc +++ b/servers/rest_server/includes/ServicesParser.inc @@ -132,13 +132,8 @@ class ServicesParserFile implements ServicesParserInterface { class ServicesParserYAML implements ServicesParserInterface { public function parse(ServicesContextInterface $context) { - if (($library = libraries_load('spyc')) && !empty($library['loaded'])) { - return Spyc::YAMLLoadString($context->getPostData()); - } - else { - watchdog('REST Server', 'Spyc library not found!', array(), WATCHDOG_ERROR); - return array(); - } + module_load_include('php', 'rest_server', 'lib/spyc'); + return Spyc::YAMLLoadString($context->getPostData()); } } diff --git a/servers/rest_server/rest_server.info b/servers/rest_server/rest_server.info index f67f9db..8085664 100644 --- a/servers/rest_server/rest_server.info +++ b/servers/rest_server/rest_server.info @@ -3,7 +3,6 @@ description = Provides a REST server. package = Services - servers dependencies[] = services -dependencies[] = libraries backdrop = 1.x type = module diff --git a/servers/rest_server/rest_server.install b/servers/rest_server/rest_server.install index 95b6bc3..b2f8966 100644 --- a/servers/rest_server/rest_server.install +++ b/servers/rest_server/rest_server.install @@ -4,29 +4,6 @@ * Install, uninstall and update the rest server module. */ -/** - * Implements hook_requirements(). - */ -function rest_server_requirements($phase) { - $requirements = array(); - - // Report the version of libraries. - if ($phase == 'runtime') { - backdrop_load('module', 'libraries'); - $libraries = rest_server_libraries_info(); - foreach ($libraries as $name => $info) { - $library = libraries_detect($name); - $requirements[$name] = array( - 'title' => $library['name'], - 'severity' => $library['installed'] ? REQUIREMENT_OK : REQUIREMENT_WARNING, - 'value' => $library['installed'] ? l($library['version'], $library['vendor url']) : $library['error message'], - ); - } - } - - return $requirements; -} - /** * Implements hook_uninstall(). */ diff --git a/servers/rest_server/rest_server.module b/servers/rest_server/rest_server.module old mode 100755 new mode 100644 index 0090afc..df28c15 --- a/servers/rest_server/rest_server.module +++ b/servers/rest_server/rest_server.module @@ -60,9 +60,8 @@ function rest_server_request_parsers() { 'text/xml' => 'ServicesParserXML', ); - if (($library = libraries_load('spyc')) && !empty($library['loaded'])) { - $parsers['application/x-yaml'] = 'ServicesParserYAML'; - } + module_load_include('php', 'rest_server', 'lib/spyc'); + $parsers['application/x-yaml'] = 'ServicesParserYAML'; backdrop_alter('rest_server_request_parsers', $parsers); } @@ -104,12 +103,11 @@ function rest_server_response_formatters() { ), ); - if (($library = libraries_load('spyc')) && !empty($library['loaded'])) { - $formatters['yaml'] = array( - 'mime types' => array('text/plain', 'application/x-yaml', 'text/yaml'), - 'formatter class' => 'ServicesYAMLFormatter', - ); - } + module_load_include('php', 'rest_server', 'lib/spyc'); + $formatters['yaml'] = array( + 'mime types' => array('text/plain', 'application/x-yaml', 'text/yaml'), + 'formatter class' => 'ServicesYAMLFormatter', + ); backdrop_alter('rest_server_response_formatters', $formatters); } @@ -172,26 +170,6 @@ function _rest_server_add_default_and_remove_unknown(&$array, $keys, $default) { } } -/** - * Implements hook_libraries_info(). - */ -function rest_server_libraries_info() { - $libraries['spyc'] = array( - 'name' => 'Spyc', - 'vendor url' => 'https://github.com/mustangostang/spyc', - 'download url' => 'https://raw.githubusercontent.com/mustangostang/spyc/0.6.3/Spyc.php', - 'version arguments' => array( - 'file' => 'Spyc.php', - 'pattern' => '@version\s+([0-9a-zA-Z\.-]+)@', - ), - 'files' => array( - 'php' => array('Spyc.php'), - ), - ); - - return $libraries; -} - /** * Implements hook_autoload_info(). */ diff --git a/services.make.example b/services.make.example deleted file mode 100644 index c5ed13a..0000000 --- a/services.make.example +++ /dev/null @@ -1,8 +0,0 @@ -api = 2 -core = 7.x - -; Libraries -libraries[spyc][directory_name] = spyc -libraries[spyc][download][type] = file -libraries[spyc][download][url] = https://raw.github.com/mustangostang/spyc/0.6.3/Spyc.php -libraries[spyc][type] = library diff --git a/tests/services.tests.info b/tests/services.tests.info index d74bfa9..955a3ea 100644 --- a/tests/services.tests.info +++ b/tests/services.tests.info @@ -88,12 +88,6 @@ description = TBD group = Services file = functional/ServicesSecurityTests.test -[ServicesSpycLibraryTests] -name = ServicesSpycLibraryTests -description = TBD -group = Services -file = unit/ServicesSpycLibraryTests.test - [ServicesUITest] name = ServicesUITests description = TBD diff --git a/tests/unit/ServicesSpycLibraryTests.test b/tests/unit/ServicesSpycLibraryTests.test deleted file mode 100644 index 7d723bd..0000000 --- a/tests/unit/ServicesSpycLibraryTests.test +++ /dev/null @@ -1,40 +0,0 @@ - 'Spyc Library', - 'description' => 'Test if we can download Spyc library.', - 'group' => 'Services', - ); - } - - /** - * Testing whether link in make file is valid. - */ - public function testMakeFileLinkValid() { - $makefile_path = backdrop_get_path('module', 'services') . '/services.make.example'; - $makefile_content = file_get_contents($makefile_path); - // libraries[spyc][download][url] = "https://raw.github.com/mustangostang/spyc/79f61969f63ee77e0d9460bc254a27a671b445f3/spyc.php" - $matches = array(); - preg_match('/libraries\[spyc\]\[download\]\[url\] = (.*)/', $makefile_content, $matches); - $spyc_library_url = $matches[1]; - $spyc_library_content = file_get_contents($spyc_library_url); - - $search_keywords = array('assertTrue($spyc_library_valid, 'Spyc library can be downloaded from make file.'); - } -}