Skip to content

Commit 488f98c

Browse files
committed
Merge branch 'master' of github.com:wikibus/heracles
2 parents 93a0741 + 103fd1f commit 488f98c

24 files changed

Lines changed: 2446 additions & 816 deletions

.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"plugins": [
3+
["transform-runtime", {
4+
"polyfill": false,
5+
"regenerator": true
6+
}]
7+
]
8+
}

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
language: node_js
22
node_js:
33
- "node"
4+
before_install:
5+
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
6+
- sudo apt-get update
7+
- sudo apt-get install gcc-5 g++-5
8+
- sudo rm /usr/bin/g++
9+
- sudo ln -s /usr/bin/g++-5 /usr/bin/g++
410
install:
511
- npm i -g yarn
612
- yarn install

karma.conf.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ module.exports = function (config) {
4242
sl_firefox_latest: {
4343
base: 'BrowserStack',
4444
browser: 'firefox',
45-
os: 'OS X',
46-
os_version: 'Mountain Lion'
45+
os: 'Windows',
46+
os_version: '8.1'
4747
},
4848
sl_safari_9: {
4949
base: 'BrowserStack',
@@ -169,6 +169,10 @@ module.exports = function (config) {
169169
browserDisconnectTimeout : 10000, // default 2000
170170
browserDisconnectTolerance : 1, // default 0
171171
browserNoActivityTimeout : 4*60*1000, //default 10000
172-
captureTimeout : 4*60*1000 //default 60000
172+
captureTimeout : 4*60*1000, //default 60000
173+
174+
browserStack: {
175+
startTunnel: true
176+
}
173177
});
174178
};

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@
5050
"@types/isomorphic-fetch": "0.0.34",
5151
"@types/jasmine": "^2.5.53",
5252
"@types/sinon": "^2.3.3",
53+
"babel-core": "^6.26.3",
54+
"babel-loader": "^7.1.5",
55+
"babel-plugin-transform-runtime": "^6.23.0",
56+
"babel-preset-env": "^1.7.0",
57+
"babel-preset-es2015": "^6.24.1",
58+
"babel-preset-es3": "^1.0.1",
59+
"babel-preset-stage-0": "^6.24.1",
5360
"core-decorators": "^0.19.0",
5461
"core-js": "^2.5.0",
5562
"gitbook-plugin-etoc": "^1.2.2",

src/HydraResponse.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1+
import {IResourceGraph, ResourceGraph} from './ResourceGraph';
12
import {HydraResource} from './Resources';
23
import {IResource} from './Resources/Resource';
34
import {IResponseWrapper, ResponseWrapper} from './ResponseWrapper';
45
import {IRootSelector} from './RootSelectors';
56

6-
export interface IResourceGraph {
7-
[uri: string]: HydraResource;
8-
}
9-
107
export interface IHydraResponse extends Iterable<HydraResource>, IResponseWrapper {
118

129
/**
@@ -37,7 +34,7 @@ export function create(
3734
response: IResponseWrapper,
3835
resources: IResourceGraph,
3936
rootSelectors: IRootSelector[]): IHydraResponse {
40-
const safeResources = resources || {};
37+
const safeResources = resources || new ResourceGraph();
4138
const safeSelectors = rootSelectors || [];
4239

4340
class HydraResponse extends ResponseWrapper implements IHydraResponse {
@@ -48,7 +45,7 @@ export function create(
4845
}
4946

5047
public get(identifier: string) {
51-
return safeResources[identifier];
48+
return safeResources.get(identifier);
5249
}
5350

5451
get root() {

src/MediaTypeProcessors/RdfProcessor.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import * as stringToStream from 'string-to-stream';
66
import {IHydraClient} from '../alcaeus';
77
import * as Constants from '../Constants';
88
import {JsonLd} from '../Constants';
9-
import {IResourceGraph} from '../HydraResponse';
109
import {forOwn} from '../LodashUtil';
1110
import {ParserFactory} from '../ParserFactory';
1211
import {IResourceFactory} from '../ResourceFactory';
12+
import {IResourceGraph, ResourceGraph} from '../ResourceGraph';
1313
import {ApiDocumentation} from '../Resources';
1414
import {IResource} from '../Resources/Resource';
1515
import {IResponseWrapper} from '../ResponseWrapper';
@@ -105,7 +105,7 @@ async function flatten(json, url): Promise<object> {
105105
function resourcify(
106106
createResource: (obj, resources) => IResource,
107107
obj,
108-
resourcified: object) {
108+
resourcified: IResourceGraph) {
109109
if ((typeof obj === 'object') === false) {
110110
return obj;
111111
}
@@ -144,18 +144,13 @@ function resourcify(
144144
}
145145

146146
function processResources(createResource: (obj, resources) => IResource, resources): IResourceGraph {
147-
const resourcified = {};
147+
const resourcified = new ResourceGraph();
148148
resources.forEach((res) => {
149-
try {
150-
res[JsonLd.Id] = new URL(res[JsonLd.Id]).href;
151-
} catch (e) {}
152-
153149
resourcified[res[JsonLd.Id]] = res;
154150
});
155151

156-
resources.reduceRight((acc: object, val) => {
157-
const id = val[JsonLd.Id];
158-
acc[id] = createResource(val, acc);
152+
resources.reduceRight((acc: ResourceGraph, val) => {
153+
acc.add(createResource(val, acc));
159154
return acc;
160155
}, resourcified);
161156

src/ResourceGraph.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {HydraResource} from './Resources';
2+
import {IResource} from './Resources/Resource';
3+
4+
export interface IResourceGraph {
5+
get(uri: string): HydraResource;
6+
}
7+
8+
export class ResourceGraph implements IResourceGraph {
9+
public get(uri: string): HydraResource {
10+
return this[uri] || this[decodeURI(uri)];
11+
}
12+
13+
public add(resource: IResource) {
14+
this[resource.id] = resource;
15+
}
16+
}

src/RootSelectors/CanonicalLinkSelector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as li from 'parse-link-header';
22
import * as Constants from '../Constants';
3-
import {IResourceGraph} from '../HydraResponse';
3+
import {IResourceGraph} from '../ResourceGraph';
44
import {IResponseWrapper} from '../ResponseWrapper';
55

66
const CanonicalLinkRel = 'canonical';

src/RootSelectors/ExactIdMatchSelector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {IHydraResponse, IResourceGraph} from '../HydraResponse';
1+
import {IHydraResponse} from '../HydraResponse';
2+
import {IResourceGraph} from '../ResourceGraph';
23

34
export default {
45
selectRoot(resources: IResourceGraph, response: IHydraResponse) {

src/RootSelectors/PartialCollectionViewSelector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Core} from '../Constants';
22
import Vocab = Core.Vocab;
3-
import {IHydraResponse, IResourceGraph} from '../HydraResponse';
3+
import {IHydraResponse} from '../HydraResponse';
4+
import {IResourceGraph} from '../ResourceGraph';
45
import {IResponseWrapper} from '../ResponseWrapper';
56
import {IRootSelector} from './index';
67

0 commit comments

Comments
 (0)