Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
ValueObject -> ObjectSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
Grzegorz Pstrucha committed May 2, 2017
1 parent 2e074c5 commit 4f57aee
Show file tree
Hide file tree
Showing 35 changed files with 845 additions and 845 deletions.
2 changes: 1 addition & 1 deletion CUSTOMIZATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The field information in the `.value` file can be used to generate other useful

To build a plugin:

* Create a js file that implements the following for [valueObjects](https://github.com/facebook/remodel/blob/master/src/value-object.ts#L44), and the following for [algebraicDataTypes](https://github.com/facebook/remodel/blob/master/src/algebraic-type.ts#L84).
* Create a js file that implements the following for [valueObjects](https://github.com/facebook/remodel/blob/master/src/object-spec.ts#L44), and the following for [algebraicDataTypes](https://github.com/facebook/remodel/blob/master/src/algebraic-type.ts#L84).
* Update your `.valueObjectConfig` or `.algebraicTypeConfig` like so:

```
Expand Down
2 changes: 1 addition & 1 deletion bin/generate
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Maybe.match(function(args) {
const Promise = require('./dist/promise');
const List = require('./dist/list');

const valueObjectsFuture = require('./dist/value-objects').generate(process.cwd(), args);
const valueObjectsFuture = require('./dist/object-specs').generate(process.cwd(), args);
const algebraicTypesFuture = require('./dist/algebraic-types').generate(process.cwd(), args);

const promise = Promise.all(List.of(valueObjectsFuture, algebraicTypesFuture));
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/plugin-inclusion-utils-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import List = require('../list');
import Maybe = require('../maybe');
import PluginInclusionUtils = require('../plugin-inclusion-utils');
import ValueObject = require('../value-object');
import ObjectSpec = require('../object-spec');

describe('PluginInclusionUtils', function() {
describe('#includesContainingDefaultIncludes', function() {
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/plugins/assume-nonnull-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import AssumeNonnull = require('../../plugins/assume-nonnull');
import FileWriter = require('../../file-writer');
import Maybe = require('../../maybe');
import ObjC = require('../../objc');
import ValueObject = require('../../value-object');
import ObjectSpec = require('../../object-spec');

const ValueObjectPlugin = AssumeNonnull.createPlugin();
const AlgebraicTypePlugin = AssumeNonnull.createAlgebraicTypePlugin();

describe('ValueObjectPlugins.AssumeNonnull', function() {
describe('#imports', function() {
it('Foundation was found', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [],
comments: [],
Expand All @@ -34,7 +34,7 @@ describe('ValueObjectPlugins.AssumeNonnull', function() {
typeName: 'Foo'
};

const imports:ObjC.Import[] = ValueObjectPlugin.imports(valueType);
const imports:ObjC.Import[] = ValueObjectPlugin.imports(objectType);
const expectedImports:ObjC.Import[] = [
{ file: 'Foundation.h', isPublic: true, library: Maybe.Just('Foundation') },
];
Expand All @@ -44,7 +44,7 @@ describe('ValueObjectPlugins.AssumeNonnull', function() {

describe('#nullability', function() {
it('AssumeNonnull macro was found', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [],
comments: [],
Expand All @@ -55,7 +55,7 @@ describe('ValueObjectPlugins.AssumeNonnull', function() {
typeName: 'Foo'
};

const nullability:Maybe.Maybe<ObjC.ClassNullability> = ValueObjectPlugin.nullability(valueType);
const nullability:Maybe.Maybe<ObjC.ClassNullability> = ValueObjectPlugin.nullability(objectType);
const expectedNullability:Maybe.Maybe<ObjC.ClassNullability> = Maybe.Just(ObjC.ClassNullability.assumeNonnull);
expect(nullability).toEqualJSON(expectedNullability);
});
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/plugins/builder-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import Code = require('../../code');
import Maybe = require('../../maybe');
import ObjC = require('../../objc');
import ObjectGeneration = require('../../object-generation');
import ValueObject = require('../../value-object');
import ObjectSpec = require('../../object-spec');

const Plugin = Builder.createPlugin();

describe('Plugins.Builder', function() {
describe('#additionalFiles', function() {
it('returns a header and an implementation for a builder when provided a ' +
'value type that has no attributes', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [],
comments: [],
Expand All @@ -34,7 +34,7 @@ describe('Plugins.Builder', function() {
typeName: 'FooBarBaz'
};

const additionalFiles:Code.File[] = Plugin.additionalFiles(valueType);
const additionalFiles:Code.File[] = Plugin.additionalFiles(objectType);

const expectedAdditionalFiles:Code.File[] = [
{
Expand Down Expand Up @@ -150,7 +150,7 @@ describe('Plugins.Builder', function() {

it('returns a header and an implementation for a builder when provided a ' +
'value type that has no attributes and a different name', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [],
comments: [],
Expand All @@ -161,7 +161,7 @@ describe('Plugins.Builder', function() {
typeName: 'RMFerr'
};

const additionalFiles:Code.File[] = Plugin.additionalFiles(valueType);
const additionalFiles:Code.File[] = Plugin.additionalFiles(objectType);

const expectedAdditionalFiles:Code.File[] = [
{
Expand Down Expand Up @@ -277,7 +277,7 @@ describe('Plugins.Builder', function() {

it('returns a header and an implementation for a builder when provided a ' +
'value type that has a bunch of attributes', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [
{
Expand Down Expand Up @@ -328,7 +328,7 @@ describe('Plugins.Builder', function() {
typeName: 'RMFerr'
};

const additionalFiles:Code.File[] = Plugin.additionalFiles(valueType);
const additionalFiles:Code.File[] = Plugin.additionalFiles(objectType);

const expectedAdditionalFiles:Code.File[] = [
{
Expand Down
46 changes: 23 additions & 23 deletions src/__tests__/plugins/coding-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import Coding = require('../../plugins/coding');
import Error = require('../../error');
import Maybe = require('../../maybe');
import ObjC = require('../../objc');
import ValueObject = require('../../value-object');
import ObjectSpec = require('../../object-spec');

const ValueObjectPlugin = Coding.createPlugin();
const AlgebraicTypePlugin = Coding.createAlgebraicTypePlugin();

describe('ValueObjectPlugins.Coding', function() {
describe('#validationErrors', function() {
it('returns no validation errors when there are no attributes on the found type', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [],
comments: [],
Expand All @@ -33,12 +33,12 @@ describe('ValueObjectPlugins.Coding', function() {
libraryName: Maybe.Nothing<string>(),
typeName: 'Foo'
};
const errors:Error.Error[] = ValueObjectPlugin.validationErrors(valueType);
const errors:Error.Error[] = ValueObjectPlugin.validationErrors(objectType);
expect(errors).toEqualJSON([]);
});

it('returns a validation error when there is an attribute with an unknown type', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [
{
Expand Down Expand Up @@ -75,15 +75,15 @@ describe('ValueObjectPlugins.Coding', function() {
libraryName: Maybe.Nothing<string>(),
typeName: 'Foo'
};
const errors:Error.Error[] = ValueObjectPlugin.validationErrors(valueType);
const errors:Error.Error[] = ValueObjectPlugin.validationErrors(objectType);
const expectedErrors:Error.Error[] = [
Error.Error('The Coding plugin does not know how to decode and encode the type "LikeStatus" from Foo.likeStatus. Did you forget to declare a backing type?')
];
expect(errors).toEqualJSON(expectedErrors);
});

it('returns two validation errors when there are two attributes with unknown types', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [
{
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('ValueObjectPlugins.Coding', function() {
libraryName: Maybe.Nothing<string>(),
typeName: 'Foo'
};
const errors:Error.Error[] = ValueObjectPlugin.validationErrors(valueType);
const errors:Error.Error[] = ValueObjectPlugin.validationErrors(objectType);
const expectedErrors:Error.Error[] = [
Error.Error('The Coding plugin does not know how to decode and encode the type "Name" from Foo.name. Did you forget to declare a backing type?'),
Error.Error('The Coding plugin does not know how to decode and encode the type "LikeStatus" from Foo.likeStatus. Did you forget to declare a backing type?')
Expand All @@ -129,7 +129,7 @@ describe('ValueObjectPlugins.Coding', function() {
});

it('returns a validation error when there is an attribute with an unknown underlying type', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [
{
Expand All @@ -153,7 +153,7 @@ describe('ValueObjectPlugins.Coding', function() {
libraryName: Maybe.Nothing<string>(),
typeName: 'Foo'
};
const errors:Error.Error[] = ValueObjectPlugin.validationErrors(valueType);
const errors:Error.Error[] = ValueObjectPlugin.validationErrors(objectType);
const expectedErrors:Error.Error[] = [
Error.Error('The Coding plugin does not know how to decode and encode the backing type "Baz" from Foo.name. Did you declare the wrong backing type?')
];
Expand All @@ -163,7 +163,7 @@ describe('ValueObjectPlugins.Coding', function() {

describe('#instanceMethods', function() {
it('returns no instance methods when there are no attributes on the found type', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [],
comments: [],
Expand All @@ -173,12 +173,12 @@ describe('ValueObjectPlugins.Coding', function() {
libraryName: Maybe.Nothing<string>(),
typeName: 'Foo'
};
const instanceMethods:ObjC.Method[] = ValueObjectPlugin.instanceMethods(valueType);
const instanceMethods:ObjC.Method[] = ValueObjectPlugin.instanceMethods(objectType);
expect(instanceMethods).toEqualJSON([]);
});

it('returns two instance methods which will encode and decode two values when called', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [
{
Expand Down Expand Up @@ -229,7 +229,7 @@ describe('ValueObjectPlugins.Coding', function() {
typeName: 'Foo'
};

const instanceMethods:ObjC.Method[] = ValueObjectPlugin.instanceMethods(valueType);
const instanceMethods:ObjC.Method[] = ValueObjectPlugin.instanceMethods(objectType);

const expectedInstanceMethods:ObjC.Method[] = [
{
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('ValueObjectPlugins.Coding', function() {

describe('#imports', function() {
it('A correct import the found type', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [
{
Expand All @@ -317,7 +317,7 @@ describe('ValueObjectPlugins.Coding', function() {
typeName: 'Foo'
};

const imports:ObjC.Import[] = ValueObjectPlugin.imports(valueType);
const imports:ObjC.Import[] = ValueObjectPlugin.imports(objectType);
const expectedImports:ObjC.Import[] = [{
file:'UIGeometry.h',
isPublic:false,
Expand All @@ -329,7 +329,7 @@ describe('ValueObjectPlugins.Coding', function() {

describe('#staticConstants', function() {
it('returns no constants when there are no attributes on the found type', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [],
comments: [],
Expand All @@ -339,13 +339,13 @@ describe('ValueObjectPlugins.Coding', function() {
libraryName: Maybe.Nothing<string>(),
typeName: 'Foo'
};
const staticConstants:ObjC.Constant[] = ValueObjectPlugin.staticConstants(valueType);
const staticConstants:ObjC.Constant[] = ValueObjectPlugin.staticConstants(objectType);
expect(staticConstants).toEqualJSON([]);
});

it('returns a constant referencing to the key for coding when the found type ' +
'has a single attribute', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [
{
Expand All @@ -370,7 +370,7 @@ describe('ValueObjectPlugins.Coding', function() {
typeName: 'Foo'
};

const staticConstants:ObjC.Constant[] = ValueObjectPlugin.staticConstants(valueType);
const staticConstants:ObjC.Constant[] = ValueObjectPlugin.staticConstants(objectType);
const expectedStaticConstants:ObjC.Constant[] = [
{
type: {
Expand All @@ -389,7 +389,7 @@ describe('ValueObjectPlugins.Coding', function() {

it('returns a constant referencing to the key for coding when the found type ' +
'has a single attribute of a different name', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [
{
Expand All @@ -414,7 +414,7 @@ describe('ValueObjectPlugins.Coding', function() {
typeName: 'Foo'
};

const staticConstants:ObjC.Constant[] = ValueObjectPlugin.staticConstants(valueType);
const staticConstants:ObjC.Constant[] = ValueObjectPlugin.staticConstants(objectType);
const expectedStaticConstants:ObjC.Constant[] = [
{
comments: [],
Expand All @@ -433,7 +433,7 @@ describe('ValueObjectPlugins.Coding', function() {

it('returns two constants referencing to the key for coding when the found type ' +
'has two attributes', function() {
const valueType:ValueObject.Type = {
const objectType:ObjectSpec.Type = {
annotations: {},
attributes: [
{
Expand Down Expand Up @@ -471,7 +471,7 @@ describe('ValueObjectPlugins.Coding', function() {
typeName: 'Foo'
};

const staticConstants:ObjC.Constant[] = ValueObjectPlugin.staticConstants(valueType);
const staticConstants:ObjC.Constant[] = ValueObjectPlugin.staticConstants(objectType);
const expectedStaticConstants:ObjC.Constant[] = [
{
comments: [],
Expand Down
Loading

0 comments on commit 4f57aee

Please sign in to comment.