Adrian Lang has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/172522

Change subject: Move wikibase.RepoApi{,Error} to wikibase.api
......................................................................

Move wikibase.RepoApi{,Error} to wikibase.api

Change-Id: I77e7368cf0352884b6762b16a7557480be1f4e26
---
M lib/resources/Resources.php
A lib/resources/deprecated/resources.php
A lib/resources/deprecated/wikibase.RepoApi.js
A lib/resources/deprecated/wikibase.RepoApiError.js
M lib/resources/wikibase.RepoApi/resources.php
M lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
M lib/resources/wikibase.RepoApi/wikibase.RepoApiError.js
M lib/tests/qunit/resources.php
M lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApi.tests.js
M lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApiError.tests.js
10 files changed, 102 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/22/172522/1

diff --git a/lib/resources/Resources.php b/lib/resources/Resources.php
index bd7ce2a..13cdf11 100644
--- a/lib/resources/Resources.php
+++ b/lib/resources/Resources.php
@@ -183,6 +183,7 @@
        $modules = array_merge(
                $modules,
                include( __DIR__ . '/api/resources.php' ),
+               include( __DIR__ . '/deprecated/resources.php' ),
                include( __DIR__ . '/entityChangers/resources.php' ),
                include( __DIR__ . '/experts/resources.php' ),
                include( __DIR__ . '/formatters/resources.php' ),
diff --git a/lib/resources/deprecated/resources.php 
b/lib/resources/deprecated/resources.php
new file mode 100644
index 0000000..1bb49ff
--- /dev/null
+++ b/lib/resources/deprecated/resources.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * @license GNU GPL v2+
+ * @author Adrian Lang <[email protected]>
+ */
+return call_user_func( function() {
+       preg_match(
+               '+' . preg_quote( DIRECTORY_SEPARATOR, '+' ) . 
'((?:vendor|extensions)' .
+                       preg_quote( DIRECTORY_SEPARATOR, '+' ) . '.*)$+',
+               __DIR__,
+               $remoteExtPathParts
+       );
+       $moduleTemplate = array(
+               'localBasePath' => __DIR__,
+               'remoteExtPath' => '..' . DIRECTORY_SEPARATOR . 
$remoteExtPathParts[1],
+       );
+
+       $modules = array(
+               'wikibase.RepoApi' => $moduleTemplate + array(
+                       'scripts' => array(
+                               'wikibase.RepoApi.js',
+                       ),
+                       'dependencies' => array(
+                               'wikibase',
+                               'wikibase.api.RepoApi',
+                       ),
+               ),
+               'wikibase.RepoApiError' => $moduleTemplate + array(
+                       'scripts' => array(
+                               'wikibase.RepoApiError.js',
+                       ),
+                       'dependencies' => array(
+                               'wikibase',
+                               'wikibase.api.RepoApiError',
+                       ),
+               ),
+       );
+
+       return $modules;
+
+} );
diff --git a/lib/resources/deprecated/wikibase.RepoApi.js 
b/lib/resources/deprecated/wikibase.RepoApi.js
new file mode 100644
index 0000000..8649a2e
--- /dev/null
+++ b/lib/resources/deprecated/wikibase.RepoApi.js
@@ -0,0 +1,13 @@
+/**
+ * @licence GNU GPL v2+
+ * @author Adrian Lang < [email protected] >
+ */
+
+'use strict';
+
+mediaWiki.log.deprecate(
+       wikibase,
+       'RepoApi',
+       wikibase.api.RepoApi,
+       'It has been moved from wikibase.RepoApi to wikibase.api.RepoApi.'
+);
diff --git a/lib/resources/deprecated/wikibase.RepoApiError.js 
b/lib/resources/deprecated/wikibase.RepoApiError.js
new file mode 100644
index 0000000..cdfb999
--- /dev/null
+++ b/lib/resources/deprecated/wikibase.RepoApiError.js
@@ -0,0 +1,13 @@
+/**
+ * @licence GNU GPL v2+
+ * @author Adrian Lang < [email protected] >
+ */
+
+'use strict';
+
+mediaWiki.log.deprecate(
+       wikibase,
+       'RepoApiError',
+       wikibase.api.RepoApiError,
+       'It has been moved from wikibase.RepoApiError to 
wikibase.api.RepoApiError.'
+);
diff --git a/lib/resources/wikibase.RepoApi/resources.php 
b/lib/resources/wikibase.RepoApi/resources.php
index 4cc66c8..4403ed4 100644
--- a/lib/resources/wikibase.RepoApi/resources.php
+++ b/lib/resources/wikibase.RepoApi/resources.php
@@ -19,17 +19,17 @@
 
        $modules = array(
 
-               'wikibase.RepoApi' => $moduleTemplate + array(
+               'wikibase.api.RepoApi' => $moduleTemplate + array(
                        'scripts' => array(
                                'wikibase.RepoApi.js',
                        ),
                        'dependencies' => array(
                                'json',
-                               'wikibase',
+                               'wikibase.api.__namespace',
                        ),
                ),
 
-               'wikibase.RepoApiError' => $moduleTemplate + array(
+               'wikibase.api.RepoApiError' => $moduleTemplate + array(
                        'scripts' => array(
                                'wikibase.RepoApiError.js',
                        ),
@@ -44,7 +44,7 @@
                        ),
                        'dependencies' => array(
                                'util.inherit',
-                               'wikibase',
+                               'wikibase.api.__namespace',
                        ),
                ),
 
diff --git a/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js 
b/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
index c079bea..d888df1 100644
--- a/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
+++ b/lib/resources/wikibase.RepoApi/wikibase.RepoApi.js
@@ -8,17 +8,19 @@
 ( function( wb, $ ) {
 'use strict';
 
+var MODULE = wb.api;
+
 /**
  * Constructor to create an API object for interaction with the repo Wikibase 
API.
  * @constructor
- * @since 0.5 (in 0.4 without constructor parameters, in 0.3 as wb.Api without 
support for client
- *        usage)
+ * @since 0.5 (in 0.4 without constructor parameters, in 0.3 as wikibase.Api
+ *        without support for client usage)
  *
  * @param {mediaWiki.Api} api
  *
  * @throws {Error} if parameters are not specified properly.
  */
-wb.RepoApi = function wbRepoApi( api ) {
+var SELF = MODULE.RepoApi = function wbRepoApi( api ) {
        if( api === undefined ) {
                throw new Error( 'Required parameters not specified properly' );
        }
@@ -26,7 +28,7 @@
        this._api = api;
 };
 
-$.extend( wb.RepoApi.prototype, {
+$.extend( SELF.prototype, {
        /**
         * @type mediaWiki.Api
         */
@@ -314,7 +316,7 @@
        /**
         * Removes an existing claim.
         *
-        * @param {String} claimGuid The GUID of the Claim to be removed 
(wb.datamodel.Claim.getGuid)
+        * @param {String} claimGuid The GUID of the Claim to be removed 
(wikibase.datamodel.Claim.getGuid)
         * @param {Number} [claimRevisionId]
         * @return {jQuery.Promise}
         */
@@ -354,7 +356,7 @@
        /**
         * Changes the Main Snak of an existing claim.
         *
-        * @param {string} claimGuid The GUID of the Claim to be changed 
(wb.datamodel.Claim.getGuid)
+        * @param {string} claimGuid The GUID of the Claim to be changed 
(wikibase.datamodel.Claim.getGuid)
         * @param {number} baseRevId
         * @param {string} snakType The type of the snak
         * @param {string} property Id of the snak's property
diff --git a/lib/resources/wikibase.RepoApi/wikibase.RepoApiError.js 
b/lib/resources/wikibase.RepoApi/wikibase.RepoApiError.js
index 1f26925..fe27261 100644
--- a/lib/resources/wikibase.RepoApi/wikibase.RepoApiError.js
+++ b/lib/resources/wikibase.RepoApi/wikibase.RepoApiError.js
@@ -5,6 +5,7 @@
 ( function( mw, wb, util ) {
        'use strict';
 
+       var MODULE = wb.api;
        var PARENT = Error;
 
        /**
@@ -29,7 +30,7 @@
                this.message = this.getMessage();
        };
 
-       wb.RepoApiError = util.inherit( 'WbRepoApiError', PARENT, constructor,
+       var SELF = MODULE.RepoApiError = util.inherit( 'WbRepoApiError', 
PARENT, constructor,
                {
                        /**
                         * Message keys of API related error messages.
@@ -84,7 +85,7 @@
         *        determine a specific message
         * @return {wikibase.RepoApiError}
         */
-       wb.RepoApiError.newFromApiResponse = function( details, apiAction ) {
+       SELF.newFromApiResponse = function( details, apiAction ) {
                var errorCode = '',
                        detailedMessage = '';
 
@@ -103,7 +104,7 @@
                        detailedMessage = details.exception;
                }
 
-               return new wb.RepoApiError( errorCode, detailedMessage, 
apiAction );
+               return new SELF( errorCode, detailedMessage, apiAction );
        };
 
        /**
diff --git a/lib/tests/qunit/resources.php b/lib/tests/qunit/resources.php
index 6031765..7c51283 100644
--- a/lib/tests/qunit/resources.php
+++ b/lib/tests/qunit/resources.php
@@ -72,24 +72,24 @@
                        ),
                ),
 
-               'wikibase.RepoApi.tests' => $moduleBase + array(
+               'wikibase.api.RepoApi.tests' => $moduleBase + array(
                        'scripts' => array(
                                'wikibase.RepoApi/wikibase.RepoApi.tests.js',
                        ),
                        'dependencies' => array(
                                'wikibase',
                                'wikibase.api.getLocationAgnosticMwApi',
-                               'wikibase.RepoApi',
+                               'wikibase.api.RepoApi',
                        ),
                ),
 
-               'wikibase.RepoApiError.tests' => $moduleBase + array(
+               'wikibase.api.RepoApiError.tests' => $moduleBase + array(
                        'scripts' => array(
                                
'wikibase.RepoApi/wikibase.RepoApiError.tests.js',
                        ),
                        'dependencies' => array(
                                'wikibase',
-                               'wikibase.RepoApiError',
+                               'wikibase.api.RepoApiError',
                        ),
                        'messages' => array(
                                'wikibase-error-unexpected',
diff --git a/lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApi.tests.js 
b/lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApi.tests.js
index 8931456..0ae19f5 100644
--- a/lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApi.tests.js
+++ b/lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApi.tests.js
@@ -1,5 +1,5 @@
 /**
- * QUnit tests for wikibase.RepoApi
+ * QUnit tests for wikibase.api.RepoApi
  * @see https://www.mediawiki.org/wiki/Extension:Wikibase
  *
  * @licence GNU GPL v2+
@@ -12,10 +12,10 @@
        var mwApi = new mw.Api();
 
        /**
-        * wb.RepoApi object
+        * wikibase.api.RepoApi object
         * @var {Object}
         */
-       var api = new wb.RepoApi( mwApi );
+       var api = new wb.api.RepoApi( mwApi );
 
        /**
         * Queue used run asynchronous tests synchronously.
@@ -81,7 +81,7 @@
                } ).fail( onFail );
        };
 
-       QUnit.module( 'wikibase.RepoApi', QUnit.newMwEnvironment( {
+       QUnit.module( 'wikibase.api.RepoApi', QUnit.newMwEnvironment( {
                teardown: function() {
                        entityStack = [];
                }
@@ -263,7 +263,7 @@
         *
         * @param {Object} assert
         * @param {string} type E.g. 'label' or 'description'
-        * @param {string} apiFnName The name of the wb.RepoApi function to set 
the value
+        * @param {string} apiFnName The name of the wikibase.api.RepoApi 
function to set the value
         */
        function testSetBasicMultiLingualValue( assert, type, apiFnName ) {
                var entity,
@@ -297,7 +297,7 @@
 
                        assert.ok( // promise is a plain object, so check for 
'then' function
                                $.isFunction( setTypeApiPromise.then ),
-                               'wb.RepoApi.' + apiFnName + ' returns a jQuery 
Promise'
+                               'wikibase.api.RepoApi.' + apiFnName + ' returns 
a jQuery Promise'
                        );
 
 
diff --git a/lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApiError.tests.js 
b/lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApiError.tests.js
index 74f1bc5..12a9e66 100644
--- a/lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApiError.tests.js
+++ b/lib/tests/qunit/wikibase.RepoApi/wikibase.RepoApiError.tests.js
@@ -6,10 +6,10 @@
 ( function( wb, mw, QUnit ) {
        'use strict';
 
-       QUnit.module( 'wikibase.RepoApiError' );
+       QUnit.module( 'wikibase.api.RepoApiError' );
 
        QUnit.test( 'Create and validate errors', function( assert ) {
-               var error = new wb.RepoApiError( 'error-code', 'detailed 
message' );
+               var error = new wb.api.RepoApiError( 'error-code', 'detailed 
message' );
 
                assert.equal(
                        error.code,
@@ -29,7 +29,7 @@
                        'Unknown error code: Used default generic error 
message.'
                );
 
-               error = new wb.RepoApiError( 'timeout', 'detailed message', 
'remove' );
+               error = new wb.api.RepoApiError( 'timeout', 'detailed message', 
'remove' );
 
                assert.equal(
                        error.message,
@@ -40,7 +40,7 @@
        } );
 
        QUnit.test( 'Validate errors created via factory method', function( 
assert ) {
-               var error = wb.RepoApiError.newFromApiResponse( {
+               var error = wb.api.RepoApiError.newFromApiResponse( {
                                error: { code: 'error-code', info: 'detailed 
message' }
                        } );
 
@@ -56,7 +56,7 @@
                        'Validated detailed message of error created via 
factory method.'
                );
 
-               error = wb.RepoApiError.newFromApiResponse( {
+               error = wb.api.RepoApiError.newFromApiResponse( {
                        error: { code: 'error-code', messages: { html: { '*': 
"messages.html['*']" } } }
                } );
 
@@ -66,7 +66,7 @@
                        'Non-array-like object structure kept for compatibility 
reasons'
                );
 
-               error = wb.RepoApiError.newFromApiResponse( {
+               error = wb.api.RepoApiError.newFromApiResponse( {
                        error: {
                                code: 'error-code',
                                messages: { 0: { html: { '*': 
"messages[0].html['*']" } } }
@@ -79,7 +79,7 @@
                        'Array-like object structure with a single message'
                );
 
-               error = wb.RepoApiError.newFromApiResponse( {
+               error = wb.api.RepoApiError.newFromApiResponse( {
                        error: { code: 'error-code', messages: {
                                0: { html: { '*': "messages[0].html['*']" } },
                                1: { html: { '*': "messages[1].html['*']" } }
@@ -92,7 +92,7 @@
                        'Array-like object structure with multiple messages'
                );
 
-               error = wb.RepoApiError.newFromApiResponse( {
+               error = wb.api.RepoApiError.newFromApiResponse( {
                        textStatus: 'textStatus', exception: 'exception'
                } );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/172522
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I77e7368cf0352884b6762b16a7557480be1f4e26
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to