index
int64 0
0
| repo_id
stringlengths 16
145
| file_path
stringlengths 27
196
| content
stringlengths 1
16.7M
|
---|---|---|---|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/tree/TreeChartBasic.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict'
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Tree } from 'react-native-pathjs-charts'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class TreeChartBasic extends Component {
static navigationOptions = ({ navigation }) => ({
title: `Tree - Basic`,
});
render() {
let data = {
"name": "Root",
"children": [{
"name": "Santa Catarina",
"children": [{
"name": "Tromp"
}, {
"name": "Thompson"
}, {
"name": "Ryan"
}]
}, {
"name": "Acre",
"children": [{
"name": "Dicki"
}, {
"name": "Armstrong"
}, {
"name": "Nitzsche"
}]
}]
}
let options = {
margin: {
top: 20,
left: 50,
right: 80,
bottom: 20
},
width: 200,
height: 200,
fill: "#2980B9",
stroke: "#3E90F0",
r: 2,
animate: {
type: 'oneByOne',
duration: 200,
fillTransition: 3
},
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
return (
<View style={styles.container}>
<Tree data={data} options={options} />
</View>
)
}
}
export default TreeChartBasic;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/bar/BarChartColumnBasic.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict'
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Bar } from 'react-native-pathjs-charts'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class BarChartColumnBasic extends Component {
static navigationOptions = ({ navigation }) => ({
title: `Bar (Column) - Basic`,
});
render() {
let data = [
[{
"v": 49,
"name": "apple"
}, {
"v": 42,
"name": "apple"
}],
[{
"v": 69,
"name": "banana"
}, {
"v": 62,
"name": "banana"
}],
[{
"v": 29,
"name": "grape"
}, {
"v": 15,
"name": "grape"
}]
]
let options = {
width: 300,
height: 300,
margin: {
top: 20,
left: 25,
bottom: 50,
right: 20
},
color: '#2980B9',
gutter: 20,
animate: {
type: 'oneByOne',
duration: 200,
fillTransition: 3
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E',
rotate: 45
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
}
return (
<View style={styles.container}>
<Bar data={data} options={options} accessorKey='v'/>
</View>
)
}
}
export default BarChartColumnBasic;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/scatterplot/ScatterplotChartBasic.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict'
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Scatterplot } from 'react-native-pathjs-charts'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class ScatterplotChartBasic extends Component {
static navigationOptions = ({ navigation }) => ({
title: `Scatterplot - Basic`,
});
render() {
let data = [
[{
"title": "Amapá",
"rating": 4.47,
"episode": 0
}, {
"title": "Santa Catarina",
"rating": 3.3,
"episode": 1
}, {
"title": "Minas Gerais",
"rating": 6.46,
"episode": 2
}, {
"title": "Amazonas",
"rating": 3.87,
"episode": 3
}, {
"title": "Mato Grosso do Sul",
"rating": 2.8,
"episode": 4
}, {
"title": "Mato Grosso do Sul",
"rating": 2.05,
"episode": 5
}, {
"title": "Tocantins",
"rating": 7.28,
"episode": 6
}, {
"title": "Roraima",
"rating": 5.23,
"episode": 7
}, {
"title": "Roraima",
"rating": 7.76,
"episode": 8
}, {
"title": "Amazonas",
"rating": 2.26,
"episode": 9
}, {
"title": "Mato Grosso do Sul",
"rating": 2.46,
"episode": 10
}, {
"title": "Santa Catarina",
"rating": 7.59,
"episode": 11
}, {
"title": "Acre",
"rating": 3.74,
"episode": 12
}, {
"title": "Amapá",
"rating": 5.03,
"episode": 13
}, {
"title": "Paraíba",
"rating": 4.16,
"episode": 14
}, {
"title": "Mato Grosso",
"rating": 0.81,
"episode": 15
}, {
"title": "Rio de Janeiro",
"rating": 3.01,
"episode": 16
}, {
"title": "Rio de Janeiro",
"rating": 0,
"episode": 17
}, {
"title": "Distrito Federal",
"rating": 5.46,
"episode": 18
}, {
"title": "São Paulo",
"rating": 9.71,
"episode": 19
}, {
"title": "Mato Grosso",
"rating": 7.9,
"episode": 20
}, {
"title": "Tocantins",
"rating": 4.2,
"episode": 21
}, {
"title": "Amapá",
"rating": 6,
"episode": 22
}, {
"title": "Paraná",
"rating": 7.99,
"episode": 23
}, {
"title": "Mato Grosso do Sul",
"rating": 1.07,
"episode": 24
}, {
"title": "Tocantins",
"rating": 1.42,
"episode": 25
}, {
"title": "Paraná",
"rating": 5.94,
"episode": 26
}, {
"title": "Maranhão",
"rating": 3.17,
"episode": 27
}, {
"title": "Maranhão",
"rating": 1.58,
"episode": 28
}, {
"title": "Rondônia",
"rating": 6.12,
"episode": 29
}, {
"title": "Roraima",
"rating": 7.28,
"episode": 30
}, {
"title": "Mato Grosso",
"rating": 4.74,
"episode": 31
}, {
"title": "Roraima",
"rating": 1.47,
"episode": 32
}, {
"title": "Alagoas",
"rating": 9,
"episode": 33
}, {
"title": "Amazonas",
"rating": 0.43,
"episode": 34
}, {
"title": "Mato Grosso do Sul",
"rating": 8.61,
"episode": 35
}, {
"title": "Tocantins",
"rating": 0.6,
"episode": 36
}, {
"title": "Maranhão",
"rating": 9.62,
"episode": 37
}, {
"title": "Rio de Janeiro",
"rating": 4.79,
"episode": 38
}, {
"title": "Santa Catarina",
"rating": 7.71,
"episode": 39
}, {
"title": "Piauí",
"rating": 3.83,
"episode": 40
}, {
"title": "Pernambuco",
"rating": 8.19,
"episode": 41
}, {
"title": "Bahia",
"rating": 6.98,
"episode": 42
}, {
"title": "Minas Gerais",
"rating": 4.52,
"episode": 43
}]
]
let options = {
width: 290,
height: 290,
r: 2,
margin: {
top: 20,
left: 40,
bottom: 30,
right: 30
},
fill: "#2980B9",
stroke: "#3E90F0",
animate: {
type: 'delayed',
duration: 200
},
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
}
return (
<View style={styles.container}>
<Scatterplot data={data} options={options} xKey="episode" yKey="rating" />
</View>
)
}
}
export default ScatterplotChartBasic;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/pie/PieChartBasicAnimation.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict'
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Pie } from 'react-native-pathjs-charts'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class PieChartBasicAnimation extends Component {
static navigationOptions = ({ navigation }) => ({
title: `Pie - Basic - Animation`,
});
render() {
let data = [{
"name": "Washington",
"population": 7694980
},
{
"name": "Oregon",
"population": 2584160
}, {
"name": "Minnesota",
"population": 6590667,
"color": {'r':223,'g':154,'b':20}
}, {
"name": "Alaska",
"population": 7284698
}
]
let options = {
margin: {
top: 20,
left: 20,
right: 20,
bottom: 20
},
width: 350,
height: 350,
color: '#2980B9',
r: 50,
R: 150,
legendPosition: 'topLeft',
animate: {
enabled: true,
type: 'oneByOne',
duration: 200,
fillTransition: 3
},
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
color: '#ECF0F1'
}
}
return (
<View style={styles.container}>
<Pie data={data}
options={options}
accessorKey="population"
margin={{ top: 20, left: 20, right: 20, bottom: 20 }}
color="#2980B9"
pallete={
[
{ 'r': 25, 'g': 99, 'b': 201 },
{ 'r': 24, 'g': 175, 'b': 35 },
{ 'r': 190, 'g': 31, 'b': 69 },
{ 'r': 100, 'g': 36, 'b': 199 },
{ 'r': 214, 'g': 207, 'b': 32 },
{ 'r': 198, 'g': 84, 'b': 45 }
]
}
r={50}
R={150}
legendPosition="topLeft"
label={{
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
color: '#ECF0F1'
}}
/>
</View>
)
}
}
export default PieChartBasicAnimation;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/pie/PieChartBasic.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict'
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Pie } from 'react-native-pathjs-charts'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class PieChartBasic extends Component {
static navigationOptions = ({ navigation }) => ({
title: `Pie - Basic`,
});
render() {
let data = [{
"name": "Washington",
"population": 7694980
}, {
"name": "Oregon",
"population": 2584160
}, {
"name": "Minnesota",
"population": 6590667,
"color": {'r':223,'g':154,'b':20}
}, {
"name": "Alaska",
"population": 7284698
}]
let options = {
margin: {
top: 20,
left: 20,
right: 20,
bottom: 20
},
width: 350,
height: 350,
color: '#2980B9',
r: 50,
R: 150,
legendPosition: 'topLeft',
animate: {
type: 'oneByOne',
duration: 200,
fillTransition: 3
},
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
color: '#ECF0F1'
}
}
return (
<View style={styles.container}>
<Pie data={data}
options={options}
accessorKey="population"
margin={{top: 20, left: 20, right: 20, bottom: 20}}
color="#2980B9"
pallete={
[
{'r':25,'g':99,'b':201},
{'r':24,'g':175,'b':35},
{'r':190,'g':31,'b':69},
{'r':100,'g':36,'b':199},
{'r':214,'g':207,'b':32},
{'r':198,'g':84,'b':45}
]
}
r={50}
R={150}
legendPosition="topLeft"
label={{
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
color: '#ECF0F1'
}}
/>
</View>
)
}
}
export default PieChartBasic;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/radar/RadarChartBasic.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict'
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { Radar } from 'react-native-pathjs-charts'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class RadarChartBasic extends Component {
static navigationOptions = ({ navigation }) => ({
title: `Radar - Basic`,
});
onLabelPress = (label, value) => {
alert(label + ':' + value);
}
render() {
let data = [{
"speed": 74,
"balance": 29,
"explosives": 40,
"energy": 40,
"flexibility": 30,
"agility": 25,
"endurance": 44
}]
let options = {
width: 290,
height: 290,
margin: {
top: 20,
left: 20,
right: 30,
bottom: 20
},
r: 150,
max: 100,
fill: "#2980B9",
stroke: "#2980B9",
animate: {
type: 'oneByOne',
duration: 200
},
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E',
onLabelPress: this.onLabelPress
}
}
return (
<View style={styles.container}>
<Radar data={data} options={options} />
</View>
)
}
}
export default RadarChartBasic;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/stockline/StockLineChartBasic.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
import React, { Component } from 'react';
import { View, StyleSheet } from 'react-native';
import { StockLine } from 'react-native-pathjs-charts';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class StockLineChartBasic extends Component {
static navigationOptions = ({ navigation }) => ({
title: `StockLine - Basic`,
});
render() {
const data = [
[{
"x": 0,
"y": 47782
}, {
"x": 1,
"y": 48497
}, {
"x": 2,
"y": 77128
}, {
"x": 3,
"y": 73413
}, {
"x": 4,
"y": 58257
}, {
"x": 5,
"y": 40579
}, {
"x": 6,
"y": 72893
}, {
"x": 7,
"y": 60663
}, {
"x": 8,
"y": 15715
}, {
"x": 9,
"y": 40305
}, {
"x": 10,
"y": 68592
}, {
"x": 11,
"y": 95664
}, {
"x": 12,
"y": 17908
}, {
"x": 13,
"y": 22838
}, {
"x": 14,
"y": 32153
}, {
"x": 15,
"y": 56594
}, {
"x": 16,
"y": 76348
}, {
"x": 17,
"y": 46222
}, {
"x": 18,
"y": 59304
}],
[{
"x": 0,
"y": 132189
}, {
"x": 1,
"y": 61705
}, {
"x": 2,
"y": 154976
}, {
"x": 3,
"y": 81304
}, {
"x": 4,
"y": 172572
}, {
"x": 5,
"y": 140656
}, {
"x": 6,
"y": 148606
}, {
"x": 7,
"y": 53010
}, {
"x": 8,
"y": 110783
}, {
"x": 9,
"y": 196446
}, {
"x": 10,
"y": 117057
}, {
"x": 11,
"y": 186765
}, {
"x": 12,
"y": 174908
}, {
"x": 13,
"y": 75247
}, {
"x": 14,
"y": 192894
}, {
"x": 15,
"y": 150356
}, {
"x": 16,
"y": 180360
}, {
"x": 17,
"y": 175697
}, {
"x": 18,
"y": 114967
}],
[{
"x": 0,
"y": 125797
}, {
"x": 1,
"y": 256656
}, {
"x": 2,
"y": 222260
}, {
"x": 3,
"y": 265642
}, {
"x": 4,
"y": 263902
}, {
"x": 5,
"y": 113453
}, {
"x": 6,
"y": 289461
}, {
"x": 7,
"y": 293850
}, {
"x": 8,
"y": 206079
}, {
"x": 9,
"y": 240859
}, {
"x": 10,
"y": 152776
}, {
"x": 11,
"y": 297282
}, {
"x": 12,
"y": 175177
}, {
"x": 13,
"y": 169233
}, {
"x": 14,
"y": 237827
}, {
"x": 15,
"y": 242429
}, {
"x": 16,
"y": 218230
}, {
"x": 17,
"y": 161511
}, {
"x": 18,
"y": 153227
}]
];
const options = {
width: 250,
height: 250,
color: '#2980B9',
margin: {
top: 10,
left: 35,
bottom: 30,
right: 10
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
};
return (
<View style={styles.container}>
<StockLine data={data} options={options} xKey='x' yKey='y' />
</View>
);
}
}
export default StockLineChartBasic;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/stockline/StockLineChartDynamicLineRendering.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
import React, { Component } from 'react';
import { View, StyleSheet } from 'react-native';
import { Text, Circle } from 'react-native-svg';
import { StockLine } from 'react-native-pathjs-charts';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class StockLineChartDynamicLineRendering extends Component {
static navigationOptions = ({ navigation }) => ({
title: `StockLine - Dynamic Line Rendering`,
});
render() {
const data = [
[{
"x": 0,
"y": 47782
}, {
"x": 1,
"y": 48497
}, {
"x": 2,
"y": 77128
}, {
"x": 3,
"y": 73413
}, {
"x": 4,
"y": 58257
}, {
"x": 5,
"y": 40579
}, {
"x": 6,
"y": 72893
}, {
"x": 7,
"y": 60663
}, {
"x": 8,
"y": 15715
}, {
"x": 9,
"y": 40305
}, {
"x": 10,
"y": 68592
}, {
"x": 11,
"y": 95664
}, {
"x": 12,
"y": 17908
}, {
"x": 13,
"y": 22838
}],
[{
"x": 0,
"y": 132189
}, {
"x": 1,
"y": 61705
}, {
"x": 2,
"y": 154976
}, {
"x": 3,
"y": 81304
}, {
"x": 4,
"y": 172572
}, {
"x": 5,
"y": 140656
}, {
"x": 6,
"y": 148606
}, {
"x": 7,
"y": 53010
}, {
"x": 8,
"y": 110783
}, {
"x": 9,
"y": 196446
}, {
"x": 10,
"y": 117057
}, {
"x": 11,
"y": 186765
}, {
"x": 12,
"y": 174908
}, {
"x": 13,
"y": 75247
}, {
"x": 14,
"y": 192894
}, {
"x": 15,
"y": 150356
}],
[{
"x": 0,
"y": 125797
}, {
"x": 1,
"y": 256656
}, {
"x": 2,
"y": 222260
}, {
"x": 3,
"y": 265642
}, {
"x": 4,
"y": 263902
}, {
"x": 5,
"y": 113453
}, {
"x": 6,
"y": 289461
}, {
"x": 7,
"y": 293850
}, {
"x": 8,
"y": 206079
}, {
"x": 9,
"y": 240859
}, {
"x": 10,
"y": 152776
}, {
"x": 11,
"y": 297282
}, {
"x": 12,
"y": 175177
}, {
"x": 13,
"y": 169233
}, {
"x": 14,
"y": 237827
}, {
"x": 15,
"y": 242429
}, {
"x": 16,
"y": 218230
}, {
"x": 17,
"y": 161511
}, {
"x": 18,
"y": 153227
}]
];
let options = {
width: 250,
height: 250,
color: '#2980B9',
margin: {
top: 10,
left: 35,
bottom: 30,
right: 10
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
strokeWidth: 2,
showAreas: (curve: number, index: number) => index === 0,
showPoints: (graphIndex: number, pointIndex: number) =>
graphIndex === 1 && pointIndex === data[1].length - 1,
renderPoint: () => [
<Text
key="valueLegend"
fontFamily="Arial"
fontSize={14}
fontWeight="normal"
fill="#101010"
textAnchor="middle"
x={0}
y={20}
>
{data[1][data[1].length - 1].y}
</Text>,
<Circle key="light" fill='#34495E' cx={0} cy={0} r={10} fillOpacity={0.5} />,
<Circle key="full" fill='#34495E' cx={0} cy={0} r={7} fillOpacity={1} />,
],
strokeDasharray: (curve: number, index: number) => (index === 2 ? [5] : []),
strokeOpacity: (curve: number, index: number) => (index === 2 ? 0.3 : 1),
};
return (
<View style={styles.container}>
<StockLine data={data} options={options} xKey='x' yKey='y' />
</View>
);
}
}
export default StockLineChartDynamicLineRendering;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/stockline/StockLineChartStaticTickLabels.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict'
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { StockLine } from 'react-native-pathjs-charts'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class StockLineChartStaticTickLabels extends Component {
static navigationOptions = ({ navigation }) => ({
title: `StockLine - Static Labels`,
});
render() {
let data = [
[{
"x": 0,
"y": 47782
}, {
"x": 1,
"y": 48497
}, {
"x": 2,
"y": 77128
}, {
"x": 3,
"y": 73413
}, {
"x": 4,
"y": 58257
}, {
"x": 5,
"y": 40579
}, {
"x": 6,
"y": 72893
}]
]
let options = {
width: 250,
height: 250,
color: '#2980B9',
margin: {
top: 10,
left: 35,
bottom: 30,
right: 10
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
tickValues: [
{value:'name1'},
{value:'name2'},
{value:'name3'},
{value:'name4'},
{value:'name5'},
{value:'name6'},
{value:'name7'}
],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
}
return (
<View style={styles.container}>
<StockLine data={data} options={options} xKey='x' yKey='y' />
</View>
)
}
}
export default StockLineChartStaticTickLabels;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/stockline/StockLineChartGesture.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
import React, { Component } from 'react';
import { View, StyleSheet, Text } from 'react-native';
import { StockLine } from 'react-native-pathjs-charts';
const data = [
[{
"x": 0,
"y": 47782
}, {
"x": 1,
"y": 48497
}, {
"x": 2,
"y": 77128
}, {
"x": 3,
"y": 73413
}, {
"x": 4,
"y": 58257
}, {
"x": 5,
"y": 40579
}, {
"x": 6,
"y": 72893
}, {
"x": 7,
"y": 60663
}, {
"x": 8,
"y": 15715
}, {
"x": 9,
"y": 40305
}, {
"x": 10,
"y": 68592
}, {
"x": 11,
"y": 95664
}, {
"x": 12,
"y": 17908
}, {
"x": 13,
"y": 22838
}, {
"x": 14,
"y": 32153
}, {
"x": 15,
"y": 56594
}, {
"x": 16,
"y": 76348
}, {
"x": 17,
"y": 46222
}, {
"x": 18,
"y": 59304
}],
[{
"x": 0,
"y": 132189
}, {
"x": 1,
"y": 61705
}, {
"x": 2,
"y": 154976
}, {
"x": 3,
"y": 81304
}, {
"x": 4,
"y": 172572
}, {
"x": 5,
"y": 140656
}, {
"x": 6,
"y": 148606
}, {
"x": 7,
"y": 53010
}, {
"x": 8,
"y": 110783
}, {
"x": 9,
"y": 196446
}, {
"x": 10,
"y": 117057
}, {
"x": 11,
"y": 186765
}, {
"x": 12,
"y": 174908
}, {
"x": 13,
"y": 75247
}, {
"x": 14,
"y": 192894
}, {
"x": 15,
"y": 150356
}, {
"x": 16,
"y": 180360
}, {
"x": 17,
"y": 175697
}, {
"x": 18,
"y": 114967
}],
[{
"x": 0,
"y": 125797
}, {
"x": 1,
"y": 256656
}, {
"x": 2,
"y": 222260
}, {
"x": 3,
"y": 265642
}, {
"x": 4,
"y": 263902
}, {
"x": 5,
"y": 113453
}, {
"x": 6,
"y": 289461
}, {
"x": 7,
"y": 293850
}, {
"x": 8,
"y": 206079
}, {
"x": 9,
"y": 240859
}, {
"x": 10,
"y": 152776
}, {
"x": 11,
"y": 297282
}, {
"x": 12,
"y": 175177
}, {
"x": 13,
"y": 169233
}, {
"x": 14,
"y": 237827
}, {
"x": 15,
"y": 242429
}, {
"x": 16,
"y": 218230
}, {
"x": 17,
"y": 161511
}, {
"x": 18,
"y": 153227
}]
];
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class StockLineChartBasic extends Component {
constructor(props) {
super(props);
this.state = {};
}
componentWillMount () {
this._panHandlerStart = this._panHandlerStart.bind(this);
this._panHandlerMove = this._panHandlerStart.bind(this);
this._panHandlerEnd = this._panHandlerEnd.bind(this);
}
static navigationOptions = ({ navigation }) => ({
title: `StockLine - Gesture`,
});
_panHandlerStart(cursorPositionX) {
this.setState({
selectedDataPointPosition: String(Math.floor(cursorPositionX * (data[0].length - 1)))
});
}
_panHandlerMove(cursorPositionX) {
this.setState({
selectedDataPointPosition: String(Math.floor(cursorPositionX * (data[0].length - 1)))
});
}
_panHandlerEnd(cursorPositionX) {
this.setState({
selectedDataPointPosition: ""
});
}
render() {
const options = {
width: 250,
height: 250,
color: '#2980B9',
margin: {
top: 10,
left: 35,
bottom: 30,
right: 10
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
interaction: true,
cursorLine: {
stroke: 'white',
strokeWidth: 2
}
};
return (
<View style={styles.container}>
<Text> Data point index: { this.state.selectedDataPointPosition }</Text>
<StockLine
panHandlerStart={this._panHandlerStart}
panHandlerMove={this._panHandlerMove}
panHandlerEnd={this._panHandlerEnd}
data={data}
options={options}
xKey='x'
yKey='y' />
</View>
);
}
}
export default StockLineChartBasic;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/stockline/StockLineChartDynamicTickLabels.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
import React, { Component } from 'react';
import { View, StyleSheet } from 'react-native';
import { StockLine } from 'react-native-pathjs-charts';
import moment from 'moment';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class StockLineChartDynamicTickLabels extends Component {
static navigationOptions = ({ navigation }) => ({
title: `StockLine - Dynamic Labels`,
});
render() {
const data = [
[{
"x": 0,
"y": 47782
}, {
"x": 1,
"y": 48497
}, {
"x": 2,
"y": 77128
}, {
"x": 3,
"y": 73413
}]
]
const options = {
width: 250,
height: 250,
color: '#2980B9',
margin: {
top: 10,
left: 35,
bottom: 30,
right: 10
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
tickValues: [],
labelFunction: ((v) => {
let d = moment('2016-10-08 14:00','YYYY-MM-DD HH:mm')
return d.add((v * 2),'hours').format('h:mm A')
}),
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
};
return (
<View style={styles.container}>
<StockLine data={data} options={options} xKey='x' yKey='y' />
</View>
);
}
}
export default StockLineChartDynamicTickLabels;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/smoothline/SmoothLineChartBasic.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict'
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { SmoothLine } from 'react-native-pathjs-charts'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class SmoothLineChartBasic extends Component {
static navigationOptions = ({ navigation }) => ({
title: `SmoothLine - Basic`,
});
render() {
let data = [
[{
"x": -10,
"y": -1000
}, {
"x": -9,
"y": -729
}, {
"x": -8,
"y": -512
}, {
"x": -7,
"y": -343
}, {
"x": -6,
"y": -216
}, {
"x": -5,
"y": -125
}, {
"x": -4,
"y": -64
}, {
"x": -3,
"y": -27
}, {
"x": -2,
"y": -8
}, {
"x": -1,
"y": -1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 8
}, {
"x": 3,
"y": 27
}, {
"x": 4,
"y": 64
}, {
"x": 5,
"y": 125
}, {
"x": 6,
"y": 216
}, {
"x": 7,
"y": 343
}, {
"x": 8,
"y": 512
}, {
"x": 9,
"y": 729
}, {
"x": 10,
"y": 1000
}],
[{
"x": -10,
"y": 100
}, {
"x": -9,
"y": 81
}, {
"x": -8,
"y": 64
}, {
"x": -7,
"y": 49
}, {
"x": -6,
"y": 36
}, {
"x": -5,
"y": 25
}, {
"x": -4,
"y": 16
}, {
"x": -3,
"y": 9
}, {
"x": -2,
"y": 4
}, {
"x": -1,
"y": 1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 4
}, {
"x": 3,
"y": 9
}, {
"x": 4,
"y": 16
}, {
"x": 5,
"y": 25
}, {
"x": 6,
"y": 36
}, {
"x": 7,
"y": 49
}, {
"x": 8,
"y": 64
}, {
"x": 9,
"y": 81
}, {
"x": 10,
"y": 100
}]
]
let options = {
width: 280,
height: 280,
color: '#2980B9',
margin: {
top: 20,
left: 45,
bottom: 25,
right: 20
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
}
}
return (
<View style={styles.container}>
<SmoothLine data={data} options={options} xKey='x' yKey='y' />
</View>
)
}
}
export default SmoothLineChartBasic;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/smoothline/SmoothLineChartRegionsExtended.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict'
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { SmoothLine } from 'react-native-pathjs-charts'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class SmoothLineChartRegionsExtended extends Component {
static navigationOptions = ({ navigation }) => ({
title: `SmoothLine - Regions Extended`,
});
render() {
let data = [
[{
"x": -10,
"y": -1000
}, {
"x": -9,
"y": -729
}, {
"x": -8,
"y": -512
}, {
"x": -7,
"y": -343
}, {
"x": -6,
"y": -216
}, {
"x": -5,
"y": -125
}, {
"x": -4,
"y": -64
}, {
"x": -3,
"y": -27
}, {
"x": -2,
"y": -8
}, {
"x": -1,
"y": -1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 8
}, {
"x": 3,
"y": 27
}, {
"x": 4,
"y": 64
}, {
"x": 5,
"y": 125
}, {
"x": 6,
"y": 216
}, {
"x": 7,
"y": 343
}, {
"x": 8,
"y": 512
}, {
"x": 9,
"y": 729
}, {
"x": 10,
"y": 1000
}],
[{
"x": -10,
"y": 100
}, {
"x": -9,
"y": 81
}, {
"x": -8,
"y": 64
}, {
"x": -7,
"y": 49
}, {
"x": -6,
"y": 36
}, {
"x": -5,
"y": 25
}, {
"x": -4,
"y": 16
}, {
"x": -3,
"y": 9
}, {
"x": -2,
"y": 4
}, {
"x": -1,
"y": 1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 4
}, {
"x": 3,
"y": 9
}, {
"x": 4,
"y": 16
}, {
"x": 5,
"y": 25
}, {
"x": 6,
"y": 36
}, {
"x": 7,
"y": 49
}, {
"x": 8,
"y": 64
}, {
"x": 9,
"y": 81
}, {
"x": 10,
"y": 100
}]
]
let regions = [{
label: 'Level1',
from: 1,
to: 500,
fill: '#c81212'
}, {
label: 'Level2',
from: 500,
to: 1000,
fill: '#2d8023'
}, {
label: 'Level3',
from: 1000,
to: 1500,
fill: '#6a2380'
}, {
label: 'Level4',
from: 1500,
to: 2000,
fill: '#807623'
}, {
label: 'Level-1',
from: -500,
to: -1,
fill: '#8fb9b3'
}, {
label: 'Level-2',
from: -1000,
to: -501,
fill: '#e2d7c3'
}]
let regionStyling = {
labelOffset: {
left: 25,
top: 5,
},
fillOpacity: 0.5
}
let options = {
width: 280,
height: 280,
color: '#2980B9',
margin: {
top: 20,
left: 45,
bottom: 25,
right: 20
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
},
min: -1000,
max: 2000,
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
}
}
return (
<View style={styles.container}>
<SmoothLine data={data}
options={options} regions={regions} regionStyling={regionStyling} xKey='x' yKey='y' />
</View>
)
}
}
export default SmoothLineChartRegionsExtended;
|
0 | capitalone_repos/react-native-pathjs-charts/example/src | capitalone_repos/react-native-pathjs-charts/example/src/smoothline/SmoothLineChartRegions.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
'use strict'
import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { SmoothLine } from 'react-native-pathjs-charts'
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#f7f7f7',
},
});
class SmoothLineChartRegions extends Component {
static navigationOptions = ({ navigation }) => ({
title: `SmoothLine - Regions`,
});
render() {
let data = [
[{
"x": -10,
"y": -1000
}, {
"x": -9,
"y": -729
}, {
"x": -8,
"y": -512
}, {
"x": -7,
"y": -343
}, {
"x": -6,
"y": -216
}, {
"x": -5,
"y": -125
}, {
"x": -4,
"y": -64
}, {
"x": -3,
"y": -27
}, {
"x": -2,
"y": -8
}, {
"x": -1,
"y": -1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 8
}, {
"x": 3,
"y": 27
}, {
"x": 4,
"y": 64
}, {
"x": 5,
"y": 125
}, {
"x": 6,
"y": 216
}, {
"x": 7,
"y": 343
}, {
"x": 8,
"y": 512
}, {
"x": 9,
"y": 729
}, {
"x": 10,
"y": 1000
}],
[{
"x": -10,
"y": 100
}, {
"x": -9,
"y": 81
}, {
"x": -8,
"y": 64
}, {
"x": -7,
"y": 49
}, {
"x": -6,
"y": 36
}, {
"x": -5,
"y": 25
}, {
"x": -4,
"y": 16
}, {
"x": -3,
"y": 9
}, {
"x": -2,
"y": 4
}, {
"x": -1,
"y": 1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 4
}, {
"x": 3,
"y": 9
}, {
"x": 4,
"y": 16
}, {
"x": 5,
"y": 25
}, {
"x": 6,
"y": 36
}, {
"x": 7,
"y": 49
}, {
"x": 8,
"y": 64
}, {
"x": 9,
"y": 81
}, {
"x": 10,
"y": 100
}]
]
let regions = [{
label: 'Level1',
from: 1,
to: 500,
fill: '#c81212'
}, {
label: 'Level2',
from: 500,
to: 1000,
fill: '#2d8023'
}, {
label: 'Level3',
labelOffset: {
left: 25,
top: 50,
},
from: 1000,
to: 1500,
fill: '#6a2380'
}, {
label: 'Level4',
from: 1500,
to: 2000,
fill: '#807623'
}, {
label: 'Level-1',
from: -500,
to: -1,
fill: '#8fb9b3'
}, {
label: 'Level-2',
from: -1000,
to: -501,
fill: '#e2d7c3'
}]
let regionStyling = {
labelOffset: {
left: 25,
top: 5,
},
fillOpacity: 0.5
}
let options = {
width: 280,
height: 280,
color: '#2980B9',
margin: {
top: 20,
left: 45,
bottom: 25,
right: 20
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
}
}
return (
<View style={styles.container}>
<SmoothLine data={data}
options={options} regions={regions} regionStyling={regionStyling} xKey='x' yKey='y' />
</View>
)
}
}
export default SmoothLineChartRegions;
|
0 | capitalone_repos/react-native-pathjs-charts/example | capitalone_repos/react-native-pathjs-charts/example/ios/project.pbxproj | // !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; };
00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; };
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; };
00E356F31AD99517003FC87E /* exampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* exampleTests.m */; };
133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; };
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; };
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; };
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
AB5B765A3FED40CB9182AA04 /* libRNSVG.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9F8C672FD8DF4C0B9C215ABC /* libRNSVG.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTActionSheet;
};
00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTGeolocation;
};
00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B5115D1A9E6B3D00147676;
remoteInfo = RCTImage;
};
00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B511DB1A9E6C8500147676;
remoteInfo = RCTNetwork;
};
00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 832C81801AAF6DEF007FA2F7;
remoteInfo = RCTVibration;
};
00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 13B07F861A680F5B00A75B9A;
remoteInfo = example;
};
139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTSettings;
};
139FDEF31B06529B00C62182 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 3C86DF461ADF2C930047B81A;
remoteInfo = RCTWebSocket;
};
146834031AC3E56700842450 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192;
remoteInfo = React;
};
78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = RCTLinking;
};
832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 58B5119B1A9E6C1200147676;
remoteInfo = RCTText;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.jsbundle; path = main.jsbundle; sourceTree = "<group>"; };
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = ../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = "<group>"; };
00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = ../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj; sourceTree = "<group>"; };
00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = ../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj; sourceTree = "<group>"; };
00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = ../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj; sourceTree = "<group>"; };
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = ../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj; sourceTree = "<group>"; };
00E356EE1AD99517003FC87E /* exampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = exampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
00E356F21AD99517003FC87E /* exampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = exampleTests.m; sourceTree = "<group>"; };
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = ../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj; sourceTree = "<group>"; };
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = ../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj; sourceTree = "<group>"; };
13B07F961A680F5B00A75B9A /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example.app; sourceTree = BUILT_PRODUCTS_DIR; };
13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = example/AppDelegate.h; sourceTree = "<group>"; };
13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = example/AppDelegate.m; sourceTree = "<group>"; };
13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = example/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = example/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = example/main.m; sourceTree = "<group>"; };
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = ../node_modules/react-native/React/React.xcodeproj; sourceTree = "<group>"; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = ../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj; sourceTree = "<group>"; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = ../node_modules/react-native/Libraries/Text/RCTText.xcodeproj; sourceTree = "<group>"; };
8FA03AA51746438FB72D95C5 /* RNSVG.xcodeproj */ = {isa = PBXFileReference; name = "RNSVG.xcodeproj"; path = "../node_modules/react-native-svg/ios/RNSVG.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
9F8C672FD8DF4C0B9C215ABC /* libRNSVG.a */ = {isa = PBXFileReference; name = "libRNSVG.a"; path = "libRNSVG.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
00E356EB1AD99517003FC87E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
13B07F8C1A680F5B00A75B9A /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
146834051AC3E58100842450 /* libReact.a in Frameworks */,
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */,
00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */,
133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */,
00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
AB5B765A3FED40CB9182AA04 /* libRNSVG.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
00C302A81ABCB8CE00DB3ED1 /* Products */ = {
isa = PBXGroup;
children = (
00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */,
);
name = Products;
sourceTree = "<group>";
};
00C302B61ABCB90400DB3ED1 /* Products */ = {
isa = PBXGroup;
children = (
00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */,
);
name = Products;
sourceTree = "<group>";
};
00C302BC1ABCB91800DB3ED1 /* Products */ = {
isa = PBXGroup;
children = (
00C302C01ABCB91800DB3ED1 /* libRCTImage.a */,
);
name = Products;
sourceTree = "<group>";
};
00C302D41ABCB9D200DB3ED1 /* Products */ = {
isa = PBXGroup;
children = (
00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */,
);
name = Products;
sourceTree = "<group>";
};
00C302E01ABCB9EE00DB3ED1 /* Products */ = {
isa = PBXGroup;
children = (
00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */,
);
name = Products;
sourceTree = "<group>";
};
00E356EF1AD99517003FC87E /* exampleTests */ = {
isa = PBXGroup;
children = (
00E356F21AD99517003FC87E /* exampleTests.m */,
00E356F01AD99517003FC87E /* Supporting Files */,
);
path = exampleTests;
sourceTree = "<group>";
};
00E356F01AD99517003FC87E /* Supporting Files */ = {
isa = PBXGroup;
children = (
00E356F11AD99517003FC87E /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
139105B71AF99BAD00B5F7CC /* Products */ = {
isa = PBXGroup;
children = (
139105C11AF99BAD00B5F7CC /* libRCTSettings.a */,
);
name = Products;
sourceTree = "<group>";
};
139FDEE71B06529A00C62182 /* Products */ = {
isa = PBXGroup;
children = (
139FDEF41B06529B00C62182 /* libRCTWebSocket.a */,
);
name = Products;
sourceTree = "<group>";
};
13B07FAE1A68108700A75B9A /* example */ = {
isa = PBXGroup;
children = (
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
13B07FB01A68108700A75B9A /* AppDelegate.m */,
13B07FB51A68108700A75B9A /* Images.xcassets */,
13B07FB61A68108700A75B9A /* Info.plist */,
13B07FB11A68108700A75B9A /* LaunchScreen.xib */,
13B07FB71A68108700A75B9A /* main.m */,
);
name = example;
sourceTree = "<group>";
};
146834001AC3E56700842450 /* Products */ = {
isa = PBXGroup;
children = (
146834041AC3E56700842450 /* libReact.a */,
);
name = Products;
sourceTree = "<group>";
};
78C398B11ACF4ADC00677621 /* Products */ = {
isa = PBXGroup;
children = (
78C398B91ACF4ADC00677621 /* libRCTLinking.a */,
);
name = Products;
sourceTree = "<group>";
};
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
146833FF1AC3E56700842450 /* React.xcodeproj */,
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */,
00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */,
00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */,
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */,
00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */,
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */,
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
8FA03AA51746438FB72D95C5 /* RNSVG.xcodeproj */,
);
name = Libraries;
sourceTree = "<group>";
};
832341B11AAA6A8300B99B32 /* Products */ = {
isa = PBXGroup;
children = (
832341B51AAA6A8300B99B32 /* libRCTText.a */,
);
name = Products;
sourceTree = "<group>";
};
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
13B07FAE1A68108700A75B9A /* example */,
832341AE1AAA6A7D00B99B32 /* Libraries */,
00E356EF1AD99517003FC87E /* exampleTests */,
83CBBA001A601CBA00E9B192 /* Products */,
);
indentWidth = 2;
sourceTree = "<group>";
tabWidth = 2;
};
83CBBA001A601CBA00E9B192 /* Products */ = {
isa = PBXGroup;
children = (
13B07F961A680F5B00A75B9A /* example.app */,
00E356EE1AD99517003FC87E /* exampleTests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
00E356ED1AD99517003FC87E /* exampleTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "exampleTests" */;
buildPhases = (
00E356EA1AD99517003FC87E /* Sources */,
00E356EB1AD99517003FC87E /* Frameworks */,
00E356EC1AD99517003FC87E /* Resources */,
);
buildRules = (
);
dependencies = (
00E356F51AD99517003FC87E /* PBXTargetDependency */,
);
name = exampleTests;
productName = exampleTests;
productReference = 00E356EE1AD99517003FC87E /* exampleTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
13B07F861A680F5B00A75B9A /* example */ = {
isa = PBXNativeTarget;
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "example" */;
buildPhases = (
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
);
buildRules = (
);
dependencies = (
);
name = example;
productName = "Hello World";
productReference = 13B07F961A680F5B00A75B9A /* example.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
83CBB9F71A601CBA00E9B192 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 610;
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
00E356ED1AD99517003FC87E = {
CreatedOnToolsVersion = 6.2;
TestTargetID = 13B07F861A680F5B00A75B9A;
};
};
};
buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "example" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 83CBB9F61A601CBA00E9B192;
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */;
ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;
},
{
ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */;
ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */;
},
{
ProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */;
ProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */;
},
{
ProductGroup = 78C398B11ACF4ADC00677621 /* Products */;
ProjectRef = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */;
},
{
ProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */;
ProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */;
},
{
ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */;
ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;
},
{
ProductGroup = 832341B11AAA6A8300B99B32 /* Products */;
ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */;
},
{
ProductGroup = 00C302E01ABCB9EE00DB3ED1 /* Products */;
ProjectRef = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */;
},
{
ProductGroup = 139FDEE71B06529A00C62182 /* Products */;
ProjectRef = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
},
{
ProductGroup = 146834001AC3E56700842450 /* Products */;
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
},
);
projectRoot = "";
targets = (
13B07F861A680F5B00A75B9A /* example */,
00E356ED1AD99517003FC87E /* exampleTests */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTActionSheet.a;
remoteRef = 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTGeolocation.a;
remoteRef = 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
00C302C01ABCB91800DB3ED1 /* libRCTImage.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTImage.a;
remoteRef = 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTNetwork.a;
remoteRef = 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTVibration.a;
remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTSettings.a;
remoteRef = 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
139FDEF41B06529B00C62182 /* libRCTWebSocket.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTWebSocket.a;
remoteRef = 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
146834041AC3E56700842450 /* libReact.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libReact.a;
remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTLinking.a;
remoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
832341B51AAA6A8300B99B32 /* libRCTText.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRCTText.a;
remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
00E356EC1AD99517003FC87E /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
13B07F8E1A680F5B00A75B9A /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Bundle React Native code and images";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
showEnvVarsInLog = 1;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
00E356EA1AD99517003FC87E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
00E356F31AD99517003FC87E /* exampleTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
13B07F871A680F5B00A75B9A /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
13B07FC11A68108700A75B9A /* main.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
00E356F51AD99517003FC87E /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 13B07F861A680F5B00A75B9A /* example */;
targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = {
isa = PBXVariantGroup;
children = (
13B07FB21A68108700A75B9A /* Base */,
);
name = LaunchScreen.xib;
path = example;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
00E356F61AD99517003FC87E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = exampleTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/example.app/example";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
};
name = Debug;
};
00E356F71AD99517003FC87E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
INFOPLIST_FILE = exampleTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/example.app/example";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/$(TARGET_NAME)\"",
);
};
name = Release;
};
13B07F941A680F5B00A75B9A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
);
INFOPLIST_FILE = "example/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
"-lc++",
);
PRODUCT_NAME = example;
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
};
13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
);
INFOPLIST_FILE = "example/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
"-lc++",
);
PRODUCT_NAME = example;
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
};
83CBBA201A601CBA00E9B192 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
83CBBA211A601CBA00E9B192 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**",
"$(SRCROOT)/../node_modules/react-native-svg/ios/**",
);
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "exampleTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
00E356F61AD99517003FC87E /* Debug */,
00E356F71AD99517003FC87E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "example" */ = {
isa = XCConfigurationList;
buildConfigurations = (
13B07F941A680F5B00A75B9A /* Debug */,
13B07F951A680F5B00A75B9A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "example" */ = {
isa = XCConfigurationList;
buildConfigurations = (
83CBBA201A601CBA00E9B192 /* Debug */,
83CBBA211A601CBA00E9B192 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */;
}
|
0 | capitalone_repos/react-native-pathjs-charts/example/ios | capitalone_repos/react-native-pathjs-charts/example/ios/example/AppDelegate.h | /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (nonatomic, strong) UIWindow *window;
@end
|
0 | capitalone_repos/react-native-pathjs-charts/example/ios | capitalone_repos/react-native-pathjs-charts/example/ios/example/AppDelegate.m | /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"example"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
return YES;
}
@end
|
0 | capitalone_repos/react-native-pathjs-charts/example/ios | capitalone_repos/react-native-pathjs-charts/example/ios/example/Info.plist | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>example</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSAppTransportSecurity</key>
<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
|
0 | capitalone_repos/react-native-pathjs-charts/example/ios | capitalone_repos/react-native-pathjs-charts/example/ios/example/main.m | /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
|
0 | capitalone_repos/react-native-pathjs-charts/example/ios/example | capitalone_repos/react-native-pathjs-charts/example/ios/example/Images.xcassets/Contents.json | {
"info" : {
"version" : 1,
"author" : "xcode"
}
}
|
0 | capitalone_repos/react-native-pathjs-charts/example/ios/example/Images.xcassets | capitalone_repos/react-native-pathjs-charts/example/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json | {
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
} |
0 | capitalone_repos/react-native-pathjs-charts/example/ios/example | capitalone_repos/react-native-pathjs-charts/example/ios/example/Base.lproj/LaunchScreen.xib | <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7702" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Powered by React Native" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="example" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="548" y="455"/>
</view>
</objects>
</document>
|
0 | capitalone_repos/react-native-pathjs-charts/example/ios | capitalone_repos/react-native-pathjs-charts/example/ios/example-tvOS/Info.plist | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSAppTransportSecurity</key>
<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
|
0 | capitalone_repos/react-native-pathjs-charts/example/ios | capitalone_repos/react-native-pathjs-charts/example/ios/example-tvOSTests/Info.plist | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
|
0 | capitalone_repos/react-native-pathjs-charts/example/ios | capitalone_repos/react-native-pathjs-charts/example/ios/exampleTests/Info.plist | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
|
0 | capitalone_repos/react-native-pathjs-charts/example/ios | capitalone_repos/react-native-pathjs-charts/example/ios/exampleTests/exampleTests.m | /**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import <React/RCTLog.h>
#import <React/RCTRootView.h>
#define TIMEOUT_SECONDS 600
#define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
@interface exampleTests : XCTestCase
@end
@implementation exampleTests
- (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
{
if (test(view)) {
return YES;
}
for (UIView *subview in [view subviews]) {
if ([self findSubviewInView:subview matching:test]) {
return YES;
}
}
return NO;
}
- (void)testRendersWelcomeScreen
{
UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
BOOL foundElement = NO;
__block NSString *redboxError = nil;
RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
if (level >= RCTLogLevelError) {
redboxError = message;
}
});
while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
return YES;
}
return NO;
}];
}
RCTSetLogFunction(RCTDefaultLogFunction);
XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
}
@end
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/docs/index.md | ![]({{ site.baseurl }}{% link images/chart-screenshots.png %})
Chart Types
- [Bar Charts]({{ site.baseurl }}{% link bar/index.md %})
- [Pie Charts]({{ site.baseurl }}{% link pie/index.md %})
- [Radar Charts]({{ site.baseurl }}{% link radar/index.md %})
- [Scatterplot Charts]({{ site.baseurl }}{% link scatterplot/index.md %})
- [SmoothLine Charts]({{ site.baseurl }}{% link smoothline/index.md %})
- [StockLine Charts]({{ site.baseurl }}{% link stockline/index.md %})
- [Tree Charts]({{ site.baseurl }}{% link tree/index.md %})
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/docs/_config.yml | theme: jekyll-theme-minimal |
0 | capitalone_repos/react-native-pathjs-charts/docs | capitalone_repos/react-native-pathjs-charts/docs/tree/index.md | # Tree Charts
Basic Tree Chart
```javascript
render() {
let data = {
"name": "Root",
"children": [{
"name": "Santa Catarina",
"children": [{
"name": "Tromp"
}, {
"name": "Thompson"
}, {
"name": "Ryan"
}]
}, {
"name": "Acre",
"children": [{
"name": "Dicki"
}, {
"name": "Armstrong"
}, {
"name": "Nitzsche"
}]
}]
}
let options = {
margin: {
top: 20,
left: 50,
right: 80,
bottom: 20
},
width: 200,
height: 200,
fill: "#2980B9",
stroke: "#3E90F0",
r: 2,
animate: {
type: 'oneByOne',
duration: 200,
fillTransition: 3
},
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
return (
<View>
<Tree data={data} options={options} />
</View>
)
}
```
|
0 | capitalone_repos/react-native-pathjs-charts/docs | capitalone_repos/react-native-pathjs-charts/docs/bar/index.md | # Bar Charts
Basic Column Chart
```javascript
render() {
let data = [
[{
"v": 49,
"name": "apple"
}, {
"v": 42,
"name": "apple"
}],
[{
"v": 69,
"name": "banana"
}, {
"v": 62,
"name": "banana"
}],
[{
"v": 29,
"name": "grape"
}, {
"v": 15,
"name": "grape"
}]
]
let options = {
width: 300,
height: 300,
margin: {
top: 20,
left: 25,
bottom: 50,
right: 20
},
color: '#2980B9',
gutter: 20,
animate: {
type: 'oneByOne',
duration: 200,
fillTransition: 3
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
}
return (
<View>
<Bar data={data} options={options} accessorKey='v'/>
</View>
)
}
```
|
0 | capitalone_repos/react-native-pathjs-charts/docs | capitalone_repos/react-native-pathjs-charts/docs/scatterplot/index.md | # Scatterplot Charts
Basic Scatterplot Chart
```javascript
render() {
let data = [
[{
"title": "Amapá",
"rating": 4.47,
"episode": 0
}, {
"title": "Santa Catarina",
"rating": 3.3,
"episode": 1
}, {
"title": "Minas Gerais",
"rating": 6.46,
"episode": 2
}, {
"title": "Amazonas",
"rating": 3.87,
"episode": 3
}, {
"title": "Mato Grosso do Sul",
"rating": 2.8,
"episode": 4
}, {
"title": "Mato Grosso do Sul",
"rating": 2.05,
"episode": 5
}, {
"title": "Tocantins",
"rating": 7.28,
"episode": 6
}, {
"title": "Roraima",
"rating": 5.23,
"episode": 7
}, {
"title": "Roraima",
"rating": 7.76,
"episode": 8
}, {
"title": "Amazonas",
"rating": 2.26,
"episode": 9
}, {
"title": "Mato Grosso do Sul",
"rating": 2.46,
"episode": 10
}, {
"title": "Santa Catarina",
"rating": 7.59,
"episode": 11
}, {
"title": "Acre",
"rating": 3.74,
"episode": 12
}, {
"title": "Amapá",
"rating": 5.03,
"episode": 13
}, {
"title": "Paraíba",
"rating": 4.16,
"episode": 14
}, {
"title": "Mato Grosso",
"rating": 0.81,
"episode": 15
}, {
"title": "Rio de Janeiro",
"rating": 3.01,
"episode": 16
}, {
"title": "Rio de Janeiro",
"rating": 0,
"episode": 17
}, {
"title": "Distrito Federal",
"rating": 5.46,
"episode": 18
}, {
"title": "São Paulo",
"rating": 9.71,
"episode": 19
}, {
"title": "Mato Grosso",
"rating": 7.9,
"episode": 20
}, {
"title": "Tocantins",
"rating": 4.2,
"episode": 21
}, {
"title": "Amapá",
"rating": 6,
"episode": 22
}, {
"title": "Paraná",
"rating": 7.99,
"episode": 23
}, {
"title": "Mato Grosso do Sul",
"rating": 1.07,
"episode": 24
}, {
"title": "Tocantins",
"rating": 1.42,
"episode": 25
}, {
"title": "Paraná",
"rating": 5.94,
"episode": 26
}, {
"title": "Maranhão",
"rating": 3.17,
"episode": 27
}, {
"title": "Maranhão",
"rating": 1.58,
"episode": 28
}, {
"title": "Rondônia",
"rating": 6.12,
"episode": 29
}, {
"title": "Roraima",
"rating": 7.28,
"episode": 30
}, {
"title": "Mato Grosso",
"rating": 4.74,
"episode": 31
}, {
"title": "Roraima",
"rating": 1.47,
"episode": 32
}, {
"title": "Alagoas",
"rating": 9,
"episode": 33
}, {
"title": "Amazonas",
"rating": 0.43,
"episode": 34
}, {
"title": "Mato Grosso do Sul",
"rating": 8.61,
"episode": 35
}, {
"title": "Tocantins",
"rating": 0.6,
"episode": 36
}, {
"title": "Maranhão",
"rating": 9.62,
"episode": 37
}, {
"title": "Rio de Janeiro",
"rating": 4.79,
"episode": 38
}, {
"title": "Santa Catarina",
"rating": 7.71,
"episode": 39
}, {
"title": "Piauí",
"rating": 3.83,
"episode": 40
}, {
"title": "Pernambuco",
"rating": 8.19,
"episode": 41
}, {
"title": "Bahia",
"rating": 6.98,
"episode": 42
}, {
"title": "Minas Gerais",
"rating": 4.52,
"episode": 43
}]
]
let options = {
width: 290,
height: 290,
r: 2,
margin: {
top: 20,
left: 40,
bottom: 30,
right: 30
},
fill: "#2980B9",
stroke: "#3E90F0",
animate: {
type: 'delayed',
duration: 200
},
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
}
return (
<View>
<Scatterplot data={data} options={options} xKey="episode" yKey="rating" />
</View>
)
}
```
|
0 | capitalone_repos/react-native-pathjs-charts/docs | capitalone_repos/react-native-pathjs-charts/docs/pie/index.md | # Pie Charts
Basic Pie Chart
```javascript
render() {
let data = [{
"name": "Washington",
"population": 7694980
}, {
"name": "Oregon",
"population": 2584160
}, {
"name": "Minnesota",
"population": 6590667
}, {
"name": "Alaska",
"population": 7284698
}]
let options = {
margin: {
top: 20,
left: 20,
right: 20,
bottom: 20
},
width: 350,
height: 350,
color: '#2980B9',
r: 50,
R: 150,
legendPosition: 'topLeft',
animate: {
type: 'oneByOne',
duration: 200,
fillTransition: 3
},
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
color: '#ECF0F1'
}
}
return (
<View>
<Pie
data={data}
options={options}
accessorKey="population" />
</View>
)
}
```
|
0 | capitalone_repos/react-native-pathjs-charts/docs | capitalone_repos/react-native-pathjs-charts/docs/radar/index.md | # Radar Charts
Basic Radar Chart
```javascript
render() {
let data = [{
"speed": 74,
"balance": 29,
"explosives": 40,
"energy": 40,
"flexibility": 30,
"agility": 25,
"endurance": 44
}]
let options = {
width: 290,
height: 290,
margin: {
top: 20,
left: 20,
right: 30,
bottom: 20
},
r: 150,
max: 100,
fill: "#2980B9",
stroke: "#2980B9",
animate: {
type: 'oneByOne',
duration: 200
},
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
}
return (
<View>
<Radar data={data} options={options} />
</View>
)
}
```
|
0 | capitalone_repos/react-native-pathjs-charts/docs | capitalone_repos/react-native-pathjs-charts/docs/stockline/index.md | # StockLine Charts
Basic StockLine Chart
```javascript
render() {
let data = [
[{
"x": 0,
"y": 47782
}, {
"x": 1,
"y": 48497
}, {
"x": 2,
"y": 77128
}, {
"x": 3,
"y": 73413
}, {
"x": 4,
"y": 58257
}, {
"x": 5,
"y": 40579
}, {
"x": 6,
"y": 72893
}, {
"x": 7,
"y": 60663
}, {
"x": 8,
"y": 15715
}, {
"x": 9,
"y": 40305
}, {
"x": 10,
"y": 68592
}, {
"x": 11,
"y": 95664
}, {
"x": 12,
"y": 17908
}, {
"x": 13,
"y": 22838
}, {
"x": 14,
"y": 32153
}, {
"x": 15,
"y": 56594
}, {
"x": 16,
"y": 76348
}, {
"x": 17,
"y": 46222
}, {
"x": 18,
"y": 59304
}],
[{
"x": 0,
"y": 132189
}, {
"x": 1,
"y": 61705
}, {
"x": 2,
"y": 154976
}, {
"x": 3,
"y": 81304
}, {
"x": 4,
"y": 172572
}, {
"x": 5,
"y": 140656
}, {
"x": 6,
"y": 148606
}, {
"x": 7,
"y": 53010
}, {
"x": 8,
"y": 110783
}, {
"x": 9,
"y": 196446
}, {
"x": 10,
"y": 117057
}, {
"x": 11,
"y": 186765
}, {
"x": 12,
"y": 174908
}, {
"x": 13,
"y": 75247
}, {
"x": 14,
"y": 192894
}, {
"x": 15,
"y": 150356
}, {
"x": 16,
"y": 180360
}, {
"x": 17,
"y": 175697
}, {
"x": 18,
"y": 114967
}],
[{
"x": 0,
"y": 125797
}, {
"x": 1,
"y": 256656
}, {
"x": 2,
"y": 222260
}, {
"x": 3,
"y": 265642
}, {
"x": 4,
"y": 263902
}, {
"x": 5,
"y": 113453
}, {
"x": 6,
"y": 289461
}, {
"x": 7,
"y": 293850
}, {
"x": 8,
"y": 206079
}, {
"x": 9,
"y": 240859
}, {
"x": 10,
"y": 152776
}, {
"x": 11,
"y": 297282
}, {
"x": 12,
"y": 175177
}, {
"x": 13,
"y": 169233
}, {
"x": 14,
"y": 237827
}, {
"x": 15,
"y": 242429
}, {
"x": 16,
"y": 218230
}, {
"x": 17,
"y": 161511
}, {
"x": 18,
"y": 153227
}]
]
let options = {
width: 250,
height: 250,
color: '#2980B9',
margin: {
top: 10,
left: 35,
bottom: 30,
right: 10
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
}
return (
<View>
<StockLine data={data} options={options} xKey='x' yKey='y' />
</View>
)
}
```
|
0 | capitalone_repos/react-native-pathjs-charts/docs | capitalone_repos/react-native-pathjs-charts/docs/smoothline/index.md | # SmoothLine Charts
Basic SmoothLine Chart
```javascript
render() {
let data = [
[{
"x": -10,
"y": -1000
}, {
"x": -9,
"y": -729
}, {
"x": -8,
"y": -512
}, {
"x": -7,
"y": -343
}, {
"x": -6,
"y": -216
}, {
"x": -5,
"y": -125
}, {
"x": -4,
"y": -64
}, {
"x": -3,
"y": -27
}, {
"x": -2,
"y": -8
}, {
"x": -1,
"y": -1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 8
}, {
"x": 3,
"y": 27
}, {
"x": 4,
"y": 64
}, {
"x": 5,
"y": 125
}, {
"x": 6,
"y": 216
}, {
"x": 7,
"y": 343
}, {
"x": 8,
"y": 512
}, {
"x": 9,
"y": 729
}, {
"x": 10,
"y": 1000
}],
[{
"x": -10,
"y": 100
}, {
"x": -9,
"y": 81
}, {
"x": -8,
"y": 64
}, {
"x": -7,
"y": 49
}, {
"x": -6,
"y": 36
}, {
"x": -5,
"y": 25
}, {
"x": -4,
"y": 16
}, {
"x": -3,
"y": 9
}, {
"x": -2,
"y": 4
}, {
"x": -1,
"y": 1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 4
}, {
"x": 3,
"y": 9
}, {
"x": 4,
"y": 16
}, {
"x": 5,
"y": 25
}, {
"x": 6,
"y": 36
}, {
"x": 7,
"y": 49
}, {
"x": 8,
"y": 64
}, {
"x": 9,
"y": 81
}, {
"x": 10,
"y": 100
}]
]
let options = {
width: 280,
height: 280,
color: '#2980B9',
margin: {
top: 20,
left: 45,
bottom: 25,
right: 20
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
}
}
return (
<View>
<SmoothLine data={data} options={options} xKey='x' yKey='y' />
</View>
)
}
```
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/src/Bar.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import React,{Component} from 'react'
import {Text as ReactText} from 'react-native'
import Svg,{ G, Path, Text } from 'react-native-svg'
import { Colors, Options, fontAdapt, cyclic, color, identity } from './util'
import _ from 'lodash'
import Axis from './Axis'
import GridAxis from './GridAxis'
const Bar = require('paths-js/bar')
export default class BarChart extends Component {
static defaultProps = {
accessorKey:'',
options: {
width: 600,
height: 600,
margin: {top: 20, left: 20, bottom: 50, right: 20},
color: '#2980B9',
gutter: 20,
animate: {
type: 'oneByOne',
duration: 200,
fillTransition: 3
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 14,
bold: true,
color: '#34495E',
rotate: 45,
}
},
axisY: {
min: false,
max: false,
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 14,
bold: true,
color: '#34495E'
}
}
}
}
color(i) {
let color = this.props.options.color
if (!_.isString(this.props.options.color)) color = color.color
const pallete = this.props.pallete || Colors.mix(color || '#9ac7f7')
return Colors.string(cyclic(pallete, i))
}
getMaxAndMin(values, scale) {
const axisY = this.props.options.axisY
let maxValue = axisY.max || 0
let minValue = axisY.min || 0
let max = _.max(values)
if (max > maxValue) maxValue = max
let min = _.min(values)
if (min < minValue) minValue = min
return {
minValue: minValue,
maxValue: maxValue,
min: scale(minValue),
max: scale(maxValue)
}
}
render() {
const noDataMsg = this.props.noDataMessage || 'No data available'
if (this.props.data === undefined) return (<ReactText>{noDataMsg}</ReactText>)
let options = new Options(this.props)
let accessor = this.props.accessor || identity(this.props.accessorKey)
let chart = Bar({
data: this.props.data,
gutter: this.props.options.gutter || 10,
width: options.chartWidth,
height: options.chartHeight,
accessor: accessor,
min: this.props.options.axisY.min || undefined,
max: this.props.options.axisY.max || undefined,
})
let values = chart.curves.map((curve) => accessor(curve.item))
let chartArea = {x: {minValue: 0, maxValue: 200, min: 0, max: options.chartWidth},
y: this.getMaxAndMin(values, chart.scale),
margin:options.margin}
let textStyle = fontAdapt(options.axisX.label)
let labelOffset = this.props.options.axisX.label.offset || 20
let lines = chart.curves.map(function (c, i) {
let numDataGroups = this.props.data.length || 0
let colorVariationVal = numDataGroups > 1 ? numDataGroups : 3
let color = this.color(i % colorVariationVal)
let stroke = Colors.darkenColor(color)
return (
<G key={'lines' + i}>
<Path d={ c.line.path.print() } stroke={stroke} fill={color}/>
{options.axisX.showLabels ?
<Text fontFamily={textStyle.fontFamily}
fontSize={textStyle.fontSize} fontWeight={textStyle.fontWeight} fontStyle={textStyle.fontStyle}
fill={textStyle.fill} x={c.line.centroid[0]} y={labelOffset + chartArea.y.min}
originX={c.line.centroid[0]} originY={labelOffset + chartArea.y.min} rotate={textStyle.rotate}
textAnchor="middle">
{c.item.name}
</Text>
: null}
</G>
)
}, this)
return (<Svg width={options.width} height={options.height}>
<G x={options.margin.left} y={options.margin.top}>
<GridAxis scale={chart.scale} options={options.axisY} chartArea={chartArea} />
{lines}
<Axis scale={chart.scale} options={options.axisY} chartArea={chartArea} />
</G>
</Svg>)
}
}
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/src/Tree.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import React, {Component} from 'react'
import {Text as ReactText} from 'react-native'
import Svg,{ Circle, G, Path, Text } from 'react-native-svg'
import { Options, styleSvg, fontAdapt } from './util'
import _ from 'lodash'
const Tree = require('paths-js/tree')
function children(x) {
if(x.collapsed) {
return []
}
else {
return x.children || []
}
}
export default class TreeChart extends Component {
static defaultProps = {
options: {
margin: {top: 20, left: 50, right: 80, bottom: 20},
width: 600,
height: 600,
fill: '#2980B9',
stroke: '#3E90F0',
r: 5,
animate: {
type: 'oneByOne',
duration: 200,
fillTransition: 3
},
label: {
fontFamily: 'Arial',
fontSize: 14,
bold: true,
fill: '#34495E'
}
}
}
render() {
const noDataMsg = this.props.noDataMessage || 'No data available'
if (this.props.data === undefined) return (<ReactText>{noDataMsg}</ReactText>)
const options = new Options(this.props)
const tree = Tree({
data: this.props.data,
children: children,
width: options.chartWidth,
height: options.chartHeight
})
const colors = styleSvg({},options)
const curves = _.map(tree.curves,function (c,i) {
return <Path key={'curves_' + i} d={ c.connector.path.print() } fill="none" stroke={colors.stroke} strokeOpacity={colors.strokeOpacity} />
})
const fillOpacityStyle = 1
const textStyle = fontAdapt(options.label)
const r = options.r || 5
const nodes = _.map(tree.nodes,function (n,index) {
let text
if (children(n.item).length > 0) {
text = <Text fontFamily={textStyle.fontFamily}
fontSize={textStyle.fontSize}
fontWeight={textStyle.fontWeight}
fontStyle={textStyle.fontStyle} x={-10} y={-10} textAnchor="end">{ n.item.name }</Text>
} else {
text = <Text fontFamily={textStyle.fontFamily}
fontSize={textStyle.fontSize}
fontWeight={textStyle.fontWeight}
fontStyle={textStyle.fontStyle} x={10} y={-10} textAnchor="start">{ n.item.name }</Text>
}
return (<G key={'tree_' + index} x={n.point[0]} y={n.point[1]}>
<Circle fillOpacity={fillOpacityStyle} {...colors} r={r} cx="0" cy="0" />
{ text }
</G>)
})
return (
<Svg width={options.width} height={options.height}>
<G x={options.margin.left} y={options.margin.top}>
{ curves }
{ nodes }
</G>
</Svg>
)
}
}
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/src/SmoothLine.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import LineChart from './Line'
const SmoothLine = require('paths-js/smooth-line')
export default class SmoothLineChart extends LineChart {
constructor(props) {
super(props, SmoothLine)
}
static defaultProps = {
options: {
width: 600,
height: 600,
color: '#2980B9',
margin: {top: 40, left: 60, bottom: 50, right: 20},
animate: {
type: 'delayed',
duration: 200,
fillTransition:3
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 14,
bold: true,
color: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 14,
bold: true,
color: '#34495E'
}
},
cursorLine: {
stroke: "white",
strokeWidth: "1"
},
interaction: false
}
}
}
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/src/Radar.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import React, {Component} from 'react'
import {Text as ReactText} from 'react-native'
import Svg,{ G, Path, Line, Text} from 'react-native-svg'
import { Options, identity, styleSvg, fontAdapt } from './util'
const Radar = require('paths-js/radar')
function accessKeys(keys) {
let a = {}
for (let i in keys) {
let key = keys[i]
a[key] = identity(key)
}
return a
}
export default class RadarChart extends Component
{
static defaultProps = {
options: {
width: 600,
height: 600,
margin: {top: 20, left: 20, right: 20, bottom: 20},
r: 300,
max: 150,
rings: 3,
fill: '#2980B9',
stroke: '#2980B9',
animate: {
type: 'oneByOne',
duration: 200,
fillTransition:3
},
label: {
fontFamily: 'Arial',
fontSize: 14,
bold: true,
color: '#34495E'
}
}
}
render() {
const noDataMsg = this.props.noDataMessage || 'No data available'
if (this.props.data === undefined) return (<ReactText>{noDataMsg}</ReactText>)
const options = new Options(this.props)
const x = options.chartWidth / 2
const y = options.chartHeight / 2
const radius = Math.min(x, y)
const center = this.props.center || [x, y]
const keys = Object.keys(this.props.data[0])
const keys_value = this.props.data[0];
const chart = Radar({
center: this.props.center || [x, y],
r: this.props.options.r || radius,
data: this.props.data,
accessor: this.props.accessor || accessKeys(keys),
max: this.props.options.max,
rings: this.props.options.rings
})
const self = this
const colors = styleSvg({}, self.props.options)
const colorsFill = self.props.options.fill
const curves = chart.curves.map(function (c, i) {
const color = colorsFill instanceof Array ? colorsFill[i] : colorsFill;
return (<Path key={i} d={c.polygon.path.print()} fill={color} fillOpacity={0.6} />)
})
const length = chart.rings.length
const rings = chart.rings.map(function (r, i) {
if (i !== length - 1 ){
return (<Path key={'rings'+i} d={r.path.print()} stroke={colors.stroke} strokeOpacity={colors.strokeOpacity} fill='none' />)
}
})
const textStyle = fontAdapt(options.label)
const labels = chart.rings[length - 1].path.points().map(function (p, i) {
function onLabelPress() {
textStyle.onLabelPress(keys[i], keys_value[`${keys[i]}`]);
}
return (
<G key={'label' + i}>
<Line x1={p[0]} y1={p[1]} x2={center[0]} y2={center[1]} stroke={colors.stroke} strokeOpacity={colors.strokeOpacity}/>
<Text
fontFamily={textStyle.fontFamily}
fontSize={textStyle.fontSize}
fontWeight={textStyle.fontWeight}
fontStyle={textStyle.fontStyle}
fill={textStyle.fill}
onPress={onLabelPress}
textAnchor="middle" x={Math.floor(p[0])} y={Math.floor(p[1])}>{keys[i]}
</Text>
</G>
)
})
return (
<Svg width={options.width} height={options.height}>
<G x={options.margin.left} y={options.margin.top}>
{labels}
<G x={options.margin.left * -1} y={options.margin.top * -1}>
{rings}
{curves}
</G>
</G>
</Svg>
);
}
}
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/src/StockLine.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import LineChart from './Line.js'
const StockLine = require('paths-js/stock')
export default class StockLineChart extends LineChart {
constructor(props) {
super(props, StockLine)
}
static defaultProps = {
options: {
width: 600,
height: 600,
color: '#2980B9',
margin: {top: 40, left: 60, bottom: 50, right: 20},
animate: {
type: 'delayed',
duration: 200,
fillTransition:3
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 14,
bold: true,
color: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 14,
bold: true,
color: '#34495E'
}
},
cursorLine: {
stroke: "white",
strokeWidth: "1"
},
interaction: false
}
}
}
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/src/index.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import Pie from './Pie'
import Tree from './Tree'
import Radar from './Radar'
import Bar from './Bar'
import SmoothLine from './SmoothLine'
import StockLine from './StockLine'
import Scatterplot from './Scatterplot.js'
import 'core-js/es6/symbol'
import 'core-js/fn/symbol/iterator'
export {
Pie,
Tree,
Bar,
SmoothLine,
StockLine,
Scatterplot,
Radar
}
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/src/util.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import _ from 'lodash'
export const cyclic = (coll, i) => { return coll[i % coll.length] }
export const identity = (key) => { return function (x) { return x[key] }}
export const color = (key) => { return function (x) { return x[key] } }
export const styleSvg = (style = {}, sourceProps) => {
if (sourceProps === undefined) return style
if (sourceProps.fill) {
style.fill = _.isString(sourceProps.fill) ? sourceProps.fill : sourceProps.fill.color
style.fillOpacity = sourceProps.fill.alpha ? sourceProps.fill.alpha/100 : 1
}
if (sourceProps.stroke) {
style.stroke = _.isString(sourceProps.stroke) ? sourceProps.stroke : sourceProps.stroke.color
style.strokeOpacity = sourceProps.stroke.alpha ? sourceProps.stroke.alpha/100 : 1
}
if (sourceProps.strokeWidth)
style.strokeWidth = sourceProps.strokeWidth
return style
}
export const fontAdapt = (fontProps) => {
const fill = fontProps.color ? (_.isString(fontProps.color) ? fontProps.color : fontProps.color.color ) : fontProps.fill
return {
fontFamily: fontProps.fontFamily,
fontSize: fontProps.fontSize,
rotate: fontProps.rotate || 0,
fontWeight: fontProps.fontWeight ? 'bold' : 'normal',
fontStyle: fontProps.fontStyle ? 'italic' : 'normal' ,
fill: fill,
onLabelPress: fontProps.onLabelPress
}
}
class colours {
cut(x) {
return Math.min(255, Math.floor(Math.abs(x)))
}
multiply(factor) {
return function (c) {
return {
r: this.cut(factor * c.r),
g: this.cut(factor * c.g),
b: this.cut(factor * c.b)
}
}.bind(this)
}
average(c1, c2) {
return {
r: this.cut((c1.r + c2.r) / 2),
g: this.cut((c1.g + c2.g) / 2),
b: this.cut((c1.b + c2.b) / 2)
}
}
lighten(c){return this.multiply(1.2)(c)}
darken(c){return this.multiply(0.8)(c)}
darkenColor(c) {return this.string(this.darken(this.hexToRgb(c)))}
mix(color1) {
const c1 = this.hexToRgb(color1)
const c2 = this.multiply(0.5)(c1)
const c3 = this.average(c1, c2)
return [this.lighten(c1), c1, this.darken(c1), this.lighten(c3), c3, this.darken(c3), this.lighten(c2), c2, this.darken(c2)]
}
string(c) {
return this.rgbToHex(Math.floor(c.r),Math.floor(c.g),Math.floor(c.b))
//return "rgb(" + (Math.floor(c.r)) + "," + (Math.floor(c.g)) + "," + (Math.floor(c.b)) + ")";
}
hexToRgb(hex) {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null
}
componentToHex(c) {
const hex = c.toString(16)
return hex.length == 1 ? '0' + hex : hex
}
rgbToHex(r, g, b) {
return '#' + this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b)
}
}
export const Colors = new colours()
export class Options {
constructor(props) {
this.props = props
this.options = props.options || {}
this.chartWidth = props.width || this.options.width || 400
this.chartHeight = props.height || this.options.height || 400
this.width = this.chartWidth + (this.margin.right || 0) + (this.margin.left || 0)
this.height = this.chartHeight + (this.margin.top || 0) + (this.margin.bottom || 0)
this.min = props.min || this.options.min
this.max = props.max || this.options.max
}
get legendPosition(){ return this.props.legendPosition || (this.props.options && this.props.options.legendPosition) || 'topLeft'}
get axisX() {return this.props.axisX || (this.props.options && this.props.options.axisX) || {}}
get axisY() {return this.props.axisY || (this.props.options && this.props.options.axisY) || {}}
get margin(){return this.props.margin || (this.props.options && this.props.options.margin) || {}}
get stroke(){return this.props.stroke || (this.props.options && this.props.options.stroke)}
get fill(){return this.props.fill || (this.props.options && this.props.options.fill)}
get r(){return this.props.r || (this.props.options && this.props.options.r)}
get R(){return this.props.R || (this.props.options && this.props.options.R)}
get label(){return this.props.label || (this.props.options && this.props.options.label) || {}}
get animate() {return this.props.animate || (this.props.options && this.props.options.animate) || {}}
}
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/src/Axis.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import React, {Component} from 'react'
import { Circle, G, Path, Text } from 'react-native-svg'
import { fontAdapt } from './util'
import _ from 'lodash'
const Pathjs = require('paths-js/path')
export class AxisStruct {
constructor(scale, options, chartArea, horizontal) {
this.scale = scale
this.options = options
this.chartArea = chartArea
this.margin = chartArea.margin
this.horizontal = horizontal
}
static calcStepSize(range, targetSteps)
{
const tempStep = range / targetSteps
const mag = Math.floor(Math.log(tempStep) / Math.log(10))
const magPow = Math.pow(10, mag)
let magMsd = Math.round(tempStep / magPow + 0.5)
if (magMsd > 5.0)
magMsd = 10.0
else if (magMsd > 2.0)
magMsd = 5.0
else if (magMsd > 1.0)
magMsd = 2.0
return magMsd * magPow
}
static roundFloat(floatVal, decimalPlaces) {
return Math.round(parseFloat((floatVal * Math.pow(10, decimalPlaces)).toFixed(decimalPlaces))) / Math.pow(10, decimalPlaces)
}
static getTickValues(axis, tickCount, decimalPlaces) {
const tickStep = AxisStruct.calcStepSize((axis.maxValue - axis.minValue),tickCount)
const maxTick = axis.minValue + (tickCount * tickStep)
let tickValues = _.range(axis.minValue, maxTick, tickStep)
tickValues = tickValues.map(tickValue => {
return AxisStruct.roundFloat(tickValue, decimalPlaces)
})
return tickValues
}
axis() {
const horizontal = this.horizontal
const xAxis = this.chartArea.x
const yAxis = this.chartArea.y
const currentAxis = horizontal?xAxis:yAxis
const tickInterval = this.options.tickCount || 10
const decimalPlaces = this.options.decimalPlaces || 2
const ticks = this.options.tickValues !== undefined && this.options.tickValues.length !== 0? _.map(this.options.tickValues,function(v){return v.value }):AxisStruct.getTickValues(currentAxis, tickInterval, decimalPlaces)
const fixed = this.options.zeroAxis?this.scale(0):horizontal?yAxis.min:xAxis.min
const start = {x: horizontal?xAxis.min:fixed, y: horizontal?fixed:yAxis.min}
const end = {x:horizontal?xAxis.max:fixed,y: horizontal?fixed:yAxis.max}
const tailLength = this.options.tailLength || 10
const margin = this.margin
if (margin !== undefined){
if (horizontal){
start.x += (margin.left - tailLength) || 0
start.y += margin.top || 0
end.x += (margin.left) || 0
end.y += margin.top || 0
}
else {
start.x += margin.left || 0
start.y += (margin.top + tailLength) || 0
end.x += margin.left || 0
end.y += (margin.top - tailLength) || 0
}
}
return {
item: currentAxis,
path: Pathjs().moveto(start).lineto(end).closepath(),
ticks: ticks,
lines: ticks.map((c,i) => {
let scaleBase = isNaN(c) ? i : c
const lineStart = {x: horizontal ? this.scale(scaleBase) + margin.left : xAxis.min + margin.left, y: horizontal ? yAxis.min + margin.top : this.scale(scaleBase) + margin.top}
return Pathjs().moveto(lineStart).lineto(horizontal ? lineStart.x : xAxis.max + margin.left, horizontal ? yAxis.max + (margin.top - tailLength) : lineStart.y)
},this)
}
}
}
export default class Axis extends Component {
render() {
const { chartArea, options, scale } = this.props
const horizontal = options.orient ==='top' || options.orient ==='bottom'
const axis = new AxisStruct(scale,options,chartArea,horizontal).axis()
let textAnchor = 'start'
if (options.orient === 'top' || options.orient === 'bottom') textAnchor = 'middle'
if (options.orient === 'left') textAnchor = 'end'
if (options.orient === 'right') textAnchor = 'start'
let xy = [0,0]
if (options.orient === 'top') xy = [0,-5]
if (options.orient === 'bottom') xy = [0,5]
if (options.orient === 'left') xy = [-5,-10]
if (options.orient === 'right') xy = [5,5]
if (typeof options.color !== 'string') {
options.color = '#3E90F0'
}
if (typeof options.opacity !== 'number') {
options.opacity = 0.5
}
if (typeof options.strokeWidth !== 'number') {
options.strokeWidth = 3
}
if (typeof options.tickSize !== 'number') {
options.tickSize = 2
}
if (typeof options.tickColor !== 'string') {
options.tickColor = 'grey'
}
const textStyle = fontAdapt(options.label)
const ticks =_.map(axis.ticks, function (c, i) {
const label = options.labelFunction !== undefined? options.labelFunction.apply(this, [c]) : c
let scaleBase = isNaN(c) ? i : c
let gxy = horizontal ? [scale(scaleBase),chartArea.y.min]:[chartArea.x.min,scale(scaleBase)]
let returnValue
if (label !== undefined && label !== null) {
returnValue =
<G key={i} x={gxy[0]} y={gxy[1]}>
{options.showTicks &&
<Circle r={options.tickSize} cx="0" cy="0" stroke={options.tickColor} fill={options.tickColor} />
}
{options.showLabels &&
<Text x={xy[0]} y={xy[1]}
fontFamily={textStyle.fontFamily}
fontSize={textStyle.fontSize}
fontWeight={textStyle.fontWeight}
fontStyle={textStyle.fontStyle}
fill={textStyle.fill}
textAnchor={textAnchor}>
{label}
</Text>}
</G>
}
return returnValue
})
let offset = {
x: chartArea.margin.left * -1,
y: chartArea.margin.top * -1
// x: 0,
// y: 0
}
let returnV = <G>
<G x={offset.x} y={offset.y}>
{options.showAxis ? <Path d={axis.path.print()} strokeOpacity={options.opacity} stroke={options.color} strokeWidth={options.strokeWidth} fill="none"/> : null}
</G>
{ticks}
</G>
return returnV
}
}
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/src/Line.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import React, { Component } from 'react';
import { Text as ReactText, View, PanResponder } from 'react-native';
import Svg, { G, Path, Rect, Text, Circle, Line } from 'react-native-svg';
import { Colors, Options, cyclic, fontAdapt } from './util';
import Axis from './Axis';
import GridAxis from './GridAxis';
import _ from 'lodash';
export default class LineChart extends Component {
constructor(props, chartType) {
super(props);
this.chartType = chartType;
this.state = { userPressing: false};
}
_calcDataPoint(evt) {
let posX = evt.nativeEvent.locationX;
let posY = evt.nativeEvent.locationY;
posX -= this.props.options.margin.left;
posY -= this.props.options.margin.top;
let chartWidth = this.props.options.width;
posX = Math.max(posX, 0);
posX = Math.min(posX, chartWidth);
// map the datapoint index with the gesture:
let curPos = Math.min(posX / chartWidth, 1);
// create a 'focus' line
let curPosX = posX;
this.curPos = curPos;
this.setState({curPos});
this.setState({curPosX});
this.setState({chartStartY: 0});
this.setState({chartEndY: this.props.options.height});
}
componentWillMount() {
this._panResponder = {};
if (!this.props.options.interaction) {return;}
this._panResponder = PanResponder.create({
// Ask to be the responder:
onStartShouldSetPanResponder: (evt, gestureState) => true,
onStartShouldSetPanResponderCapture: (evt, gestureState) => true,
onMoveShouldSetPanResponder: (evt, gestureState) => true,
onMoveShouldSetPanResponderCapture: (evt, gestureState) => true,
onPanResponderGrant: (evt, gestureState) => {
this.setState({userPressing: true});
this._calcDataPoint(evt)
if (this.props.panHandlerStart) {
this.props.panHandlerStart(this.curPos);
}
},
onPanResponderMove: (evt, gestureState) => {
this._calcDataPoint(evt);
if (this.props.panHandlerMove) {
this.props.panHandlerMove(this.curPos);
}
},
onPanResponderRelease: (evt, gestureState) => {
this._calcDataPoint(evt);
if (this.props.panHandlerEnd) {
this.props.panHandlerEnd(this.curPos);
}
this.setState({userPressing: false});
},
onPanResponderTerminationRequest: (evt, gestureState) => true,
onPanResponderTerminate: (evt, gestureState) => {
this._calcDataPoint(evt);
if (this.props.panHandlerEnd) {
this.props.panHandlerEnd(this.curPos);
}
this.setState({userPressing: false});
},
onShouldBlockNativeResponder: (evt, gestureState) => {
return true;
},
});
}
getMaxAndMin(chart, key, scale, chartMin, chartMax) {
let maxValue;
let minValue;
_.each(chart.curves, function(serie) {
let values = _.map(serie.item, function(item) {
return item[key];
});
let max = _.max(values);
if (maxValue === undefined || max > maxValue) maxValue = max;
let min = _.min(values);
if (minValue === undefined || min < minValue) minValue = min;
maxValue = chartMax > maxValue ? chartMax : maxValue;
minValue = chartMin < minValue ? chartMin : minValue;
});
return {
minValue: minValue,
maxValue: maxValue,
min: scale(minValue),
max: scale(maxValue),
};
}
color(i) {
let color = this.props.options.color;
if (!_.isString(this.props.options.color)) color = color.color;
let pallete = this.props.pallete || Colors.mix(color || '#9ac7f7');
return Colors.string(cyclic(pallete, i));
}
render() {
const noDataMsg = this.props.noDataMessage || 'No data available';
if (this.props.data === undefined) return <ReactText>{noDataMsg}</ReactText>;
let options = new Options(this.props);
let accessor = function(key) {
return function(x) {
return x[key];
};
};
let chart = this.chartType({
data: this.props.data,
xaccessor: accessor(this.props.xKey),
yaccessor: accessor(this.props.yKey),
width: options.chartWidth,
height: options.chartHeight,
closed: false,
min: options.min,
max: options.max,
});
let chartArea = {
x: this.getMaxAndMin(chart, this.props.xKey, chart.xscale),
y: this.getMaxAndMin(chart, this.props.yKey, chart.yscale, options.min, options.max),
margin: options.margin,
};
let showAreas = typeof this.props.options.showAreas !== 'undefined'
? this.props.options.showAreas
: true;
let strokeWidth = typeof this.props.options.strokeWidth !== 'undefined'
? this.props.options.strokeWidth
: '1';
let strokeDasharray = typeof this.props.options.strokeDasharray !== 'undefined'
? this.props.options.strokeDasharray
: [];
let strokeOpacity = typeof this.props.options.strokeOpacity !== 'undefined'
? this.props.options.strokeOpacity
: 1;
let lines = _.map(
chart.curves,
function(c, i) {
const strokeWidthForCurve =
(typeof strokeWidth === 'function' && strokeWidth(c, i)) || strokeWidth;
const strokeDasharrayForCurve =
(typeof strokeDasharray === 'function' && strokeDasharray(c, i)) || strokeDasharray;
const strokeOpacityForCurve =
(typeof strokeOpacity === 'function' && strokeOpacity(c, i)) || strokeOpacity;
return (
<Path
key={'lines' + i}
d={c.line.path.print()}
stroke={this.color(i)}
strokeWidth={strokeWidthForCurve}
strokeOpacity={strokeOpacityForCurve}
fill="none"
strokeDasharray={strokeDasharrayForCurve}
/>
);
}.bind(this)
);
// gesture line here
let gestureLine = null;
let color = 'white';
let width = 1;
if (this.props.options.cursorLine ) {
if (this.props.options.cursorLine.stroke)
color = this.props.options.cursorLine.stroke;
if (this.props.options.cursorLine.strokeWidth) {
width =this.props.options.cursorLine.strokeWidth;
}
}
if (this.state.userPressing
&& this.props.options.interaction) {
gestureLine = <Line
x1={this.state.curPosX}
y1={this.state.chartStartY}
x2={this.state.curPosX}
y2={this.state.chartEndY}
stroke={color}
strokeWidth={width}
/>
}
let areas = null;
let showPoints = typeof this.props.options.showPoints !== 'undefined'
? this.props.options.showPoints
: false;
let points = !showPoints
? []
: _.map(
chart.curves,
function(c, graphIndex) {
return _.map(
c.line.path.points(),
function(p, pointIndex) {
let render = null;
if (
(typeof showPoints === 'function' && showPoints(graphIndex, pointIndex)) ||
(typeof showPoints === 'boolean' && showPoints)
) {
return (
<G key={'k' + pointIndex} x={p[0]} y={p[1]}>
{typeof this.props.options.renderPoint === 'function'
? this.props.options.renderPoint(graphIndex, pointIndex)
: <Circle
fill={this.color(graphIndex)}
cx={0}
cy={0}
r={this.props.options.pointRadius || 5}
fillOpacity={1}
/>}
</G>
);
}
}.bind(this)
);
}.bind(this)
);
if (showAreas) {
areas = _.map(
chart.curves,
function(c, i) {
if (
(typeof showAreas === 'function' && showAreas(c, i)) ||
typeof showAreas === 'boolean'
)
return (
<Path
key={'areas' + i}
d={c.area.path.print()}
fillOpacity={0.5}
stroke="none"
fill={this.color(i)}
/>
);
return null;
}.bind(this)
);
}
let textStyle = fontAdapt(options.label);
let regions;
if (this.props.regions != 'undefined') {
let styling = typeof this.props.regionStyling != 'undefined' ? this.props.regionStyling : {};
let labelOffsetAllRegions = typeof styling.labelOffset != 'undefined'
? styling.labelOffset
: {};
regions = _.map(
this.props.regions,
function(c, i) {
let x, y, height, width, y1, y2, labelX, labelY;
let labelOffset = typeof c.labelOffset != 'undefined' ? c.labelOffset : {};
let labelOffsetLeft = typeof labelOffsetAllRegions.left != 'undefined'
? typeof labelOffset.left != 'undefined' ? labelOffset.left : labelOffsetAllRegions.left
: 20;
let labelOffsetTop = typeof labelOffsetAllRegions.top != 'undefined'
? typeof labelOffset.top != 'undefined' ? labelOffset.top : labelOffsetAllRegions.top
: 0;
let fillOpacity = typeof styling.fillOpacity != 'undefined'
? typeof c.fillOpacity != 'undefined' ? c.fillOpacity : styling.fillOpacity
: 0.5;
y1 = chart.yscale(c.from);
y2 = chart.yscale(c.to);
x = 0;
y = y1;
height = y2 - y1;
width = chartArea.x.max;
labelX = labelOffsetLeft;
labelY = y2 + labelOffsetTop;
let regionLabel = typeof c.label != 'undefined'
? <Text
fontFamily={textStyle.fontFamily}
fontSize={textStyle.fontSize}
fontWeight={textStyle.fontWeight}
fontStyle={textStyle.fontStyle}
fill={textStyle.fill}
textAnchor="middle"
x={labelX}
y={labelY}
>
{c.label}
</Text>
: null;
return (
<G key={'region' + i}>
<Rect
key={'region' + i}
x={x}
y={y}
width={width}
height={height}
fill={c.fill}
fillOpacity={fillOpacity}
/>
{regionLabel}
</G>
);
}.bind(this)
);
}
let returnValue = (
<View width={options.width} height={options.height} {...this._panResponder.panHandlers}>
<Svg width={options.width} height={options.height}>
<G x={options.margin.left} y={options.margin.top}>
<GridAxis key="grid-x" scale={chart.xscale} options={options.axisX} chartArea={chartArea} />
<GridAxis key="grid-y" scale={chart.yscale} options={options.axisY} chartArea={chartArea} />
{regions}
{areas}
{lines}
{points}
{gestureLine}
<Axis key="axis-x" scale={chart.xscale} options={options.axisX} chartArea={chartArea} />
<Axis key="axis-y" scale={chart.yscale} options={options.axisY} chartArea={chartArea} />
</G>
</Svg>
</View>
);
return returnValue;
}
}
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/src/GridAxis.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import React, { Component } from 'react'
import { G, Path } from 'react-native-svg'
import _ from 'lodash'
import { AxisStruct } from './Axis'
export default class GridAxis extends Component {
render() {
const { chartArea, options, scale } = this.props
const horizontal = options.orient ==='top' || options.orient ==='bottom'
const axis = new AxisStruct(scale,options,chartArea,horizontal).axis()
if (typeof options.gridColor !== 'string') {
options.gridColor = '#3E90F0'
}
if (typeof options.opacity !== 'number') {
options.opacity = 0.5
}
const gridLines = options.showLines ? _.map(axis.lines, function (c, i) {
return (
<Path key={'gridLines' + i} d={c.print()} strokeOpacity={options.opacity} stroke={options.gridColor} fill="none"/>
)
}) : []
let offset = {
x: chartArea.margin.left * -1,
y: chartArea.margin.top * -1
};
let returnV = <G x={offset.x} y={offset.y}>
{gridLines}
</G>;
return returnV
}
}
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/src/Scatterplot.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import React, {Component} from 'react'
import {Text as ReactText} from 'react-native'
import Svg,{ Circle, G } from 'react-native-svg'
import { Options, styleSvg } from './util'
import Axis from './Axis'
import GridAxis from './GridAxis'
import _ from 'lodash'
const Stock = require('paths-js/stock')
export default class Scatterplot extends Component {
static defaultProps = {
xKey:'',
yKey:'',
options: {
width: 600,
height: 600,
margin: {top: 40, left: 60, bottom: 30, right: 30},
fill: '#2980B9',
stroke: '#3E90F0',
animate: {
type: 'delayed',
duration: 200,
fillTransition:3
},
label: {
fontFamily: 'Arial',
fontSize: 14,
bold: true,
color: '#34495E'
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 14,
bold: true,
color: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 14,
bold: true,
color: '#34495E'
}
}
}
}
getMaxAndMin(chart, key,scale) {
let maxValue
let minValue
_.each(chart.curves, function (serie) {
let values = _.map(serie.item, function (item) {
return item[key]
})
let max = _.max(values)
if (maxValue === undefined || max > maxValue) maxValue = max
let min = _.min(values)
if (minValue === undefined || min < minValue) minValue = min
})
return {
minValue: minValue,
maxValue: maxValue,
min:scale(minValue),
max:scale(maxValue)
}
}
render() {
const noDataMsg = this.props.noDataMessage || 'No data available'
if (this.props.data === undefined) return (<ReactText>{noDataMsg}</ReactText>)
const options = new Options(this.props)
const accessor = function (key) {
return function (x) {
return x[key]
}
}
const chart = Stock({
data: this.props.data,
xaccessor: accessor(this.props.xKey),
yaccessor: accessor(this.props.yKey),
width: options.chartWidth,
height: options.chartHeight,
closed: false
})
const chartArea = {
x:this.getMaxAndMin(chart,this.props.xKey,chart.xscale),
y:this.getMaxAndMin(chart,this.props.yKey,chart.yscale),
margin:options.margin
}
const colors = styleSvg({},options)
const points = _.map(chart.curves, function (c) {
return _.map(c.line.path.points(),function(p,j) {
let render = <G key={'k' + j} x={p[0]} y={p[1]}>
<Circle {...colors} cx={0} cy={0} r={options.r || 5} fillOpacity={1} />
</G>
return render
},this)
},this)
return (<Svg width={options.width} height={options.height}>
<G x={options.margin.left} y={options.margin.top}>
<GridAxis scale={chart.xscale} options={options.axisX} chartArea={chartArea} />
<GridAxis scale={chart.yscale} options={options.axisY} chartArea={chartArea} />
{ points }
<Axis scale={chart.xscale} options={options.axisX} chartArea={chartArea} />
<Axis scale={chart.yscale} options={options.axisY} chartArea={chartArea} />
</G>
</Svg>)
}
}
|
0 | capitalone_repos/react-native-pathjs-charts | capitalone_repos/react-native-pathjs-charts/src/Pie.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import extractProps from 'react-native-svg/lib/extract/extractProps';
import React, {Component} from 'react'
import {Text as ReactText, Animated} from 'react-native'
import Svg,{ G, Path, Text, Circle} from 'react-native-svg'
import { Colors, Options, cyclic, identity, fontAdapt } from './util'
import _ from 'lodash'
const Pie = require('paths-js/pie')
const ANIMATION_START_DELAY = 1000;
export default class PieChart extends Component {
static defaultProps = {
options: {
margin: {top: 20, left: 20, right: 20, bottom: 20},
width: 600,
height: 600,
color: '#2980B9',
r: 100,
R: 200,
legendPosition: 'topLeft',
animate: {
enabled: false,
type: 'oneByOne',
duration: 200,
fillTransition: 3
},
label: {
fontFamily: 'Arial',
fontSize: 14,
bold: true,
color: '#ECF0F1'
}
},
}
constructor(props){
super(props);
this._animationRefArray = {};
this._startAnimation = this._startAnimation.bind(this)
this._createAnimation = this._createAnimation.bind(this)
this._onAnimationFinished = this._onAnimationFinished.bind(this)
if (this._shouldAnim()) this._animationArray = new Array(props.data.length)
}
_shouldAnim = () => this.props.options.animate.enabled && this.props.data.length > 1
color(i) {
let color = this.props.color || (this.props.options && this.props.options.color)
if (Array.isArray(color)) {
if (i >= color.length) {
const pallete = Colors.mix(color[i % color.length])
return Colors.string(cyclic(pallete, i))
}
return color[i];
} else {
if (color && !_.isString(color)) color = color.color
let pallete = this.props.pallete || (this.props.options && this.props.options.pallete) || Colors.mix(color || '#9ac7f7')
return Colors.string(cyclic(pallete, i))
}
}
get defaultRange() {
return _.map(Array(this.props.data && this.props.data.length),function(){return 0})
}
_onAnimationFinished(){
this._animationArray.forEach((anim) => anim.removeAllListeners())
}
_createAnimation(index, fill) {
const maxVal = this.props.data[index][this.props.accessorKey]
this._animationArray[index] = new Animated.Value(0)
this._animationArray[index].addListener(v => {
const sliceRef = this._animationRefArray[`SLICE${index}`]
if (sliceRef === undefined) return
if (sliceRef._finished) return;
const animValue = this._animationArray[index].interpolate({
inputRange: [0, 1],
outputRange: [0, 1],
extrapolate: 'clamp'
})
const props = {
fill: fill,
fillOpacity: animValue.__getValue()
}
const nativeProps = extractProps(props, sliceRef)
sliceRef.setNativeProps(nativeProps)
if (props.fillOpacity === 1) sliceRef._finished = true
});
}
_startAnimation(){
Animated.sequence(
this._animationArray.map(a =>
Animated.timing(a, {
toValue: 1,
duration: this.props.options.animate.duration
})
)
).start(this._onAnimationFinished)
}
render() {
const noDataMsg = this.props.noDataMessage || 'No data available'
if (this.props.data === undefined) return (<ReactText>{noDataMsg}</ReactText>)
let options = new Options(this.props)
let x = (options.chartWidth / 2) - (options.margin.left || 0)
let y = (options.chartHeight / 2) - (options.margin.top || 0)
let radius = Math.min(x, y)
let r = this.props.r
r = (isNaN(r) ? (this.props.options && this.props.options.r) : r)
r = (isNaN(r) ? (radius / 2) : r)
let R = this.props.R
R = (R || (this.props.options && this.props.options.R))
R = (R || radius)
let [centerX, centerY] = this.props.center || (this.props.options && this.props.options.center) || [x, y]
let textStyle = fontAdapt(options.label)
let slices
if (this.props.data.length === 1) {
let item = this.props.data[0]
let outerFill = (item.color && Colors.string(item.color)) || this.color(0)
let innerFill = this.props.monoItemInnerFillColor || '#fff'
let stroke = typeof fill === 'string' ? outerFill : Colors.darkenColor(outerFill)
slices = (
<G>
<Circle r={R} cx={centerX} cy={centerY} stroke={stroke} fill={outerFill}/>
<Circle r={r} cx={centerX} cy={centerY} stroke={stroke} fill={innerFill}/>
<Text fontFamily={textStyle.fontFamily}
fontSize={textStyle.fontSize}
fontWeight={textStyle.fontWeight}
fontStyle={textStyle.fontStyle}
fill={textStyle.fill}
textAnchor="middle"
x={centerX}
y={centerY - R + ((R-r)/2)}>{item.name}</Text>
</G>
)
} else {
let chart = Pie({
center: [centerX, centerY],
r,
R,
data: this.props.data,
accessor: this.props.accessor || identity(this.props.accessorKey)
})
slices = chart.curves.map( (c, i) => {
let fill = (c.item.color && Colors.string(c.item.color)) || this.color(i)
let stroke = typeof fill === 'string' ? fill : Colors.darkenColor(fill)
const opacity = this._shouldAnim() ? 0 : 1
const finalStroke = this._shouldAnim() ? undefined : stroke
if (this._shouldAnim()) this._createAnimation(i, fill);
return (
<G key={ i }>
<Path ref={ref => (this._animationRefArray[`SLICE${i}`] = ref)} fill={fill} fillOpacity={opacity} d={c.sector.path.print() } stroke={finalStroke} />
<G x={options.margin.left} y={options.margin.top}>
<Text fontFamily={textStyle.fontFamily}
fontSize={textStyle.fontSize}
fontWeight={textStyle.fontWeight}
fontStyle={textStyle.fontStyle}
fill={textStyle.fill}
textAnchor="middle"
x={c.sector.centroid[0]}
y={c.sector.centroid[1]}>{ c.item.name }</Text>
</G>
</G>
)
})
}
if (this._shouldAnim()) setTimeout(this._startAnimation, ANIMATION_START_DELAY)
let returnValue = <Svg width={options.width} height={options.height}>
<G x={options.margin.left} y={options.margin.top}>
{ slices }
</G>
</Svg>
return returnValue
}
}
|
0 | capitalone_repos/react-native-pathjs-charts/src | capitalone_repos/react-native-pathjs-charts/src/__mocks__/react-native-svg.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import React from 'react'
// const rnsvg = jest.genMockFromModule('react-native-svg');
// module.exports = rnsvg;
export default function(props) {
return (
<view mockedComponent="svg-component" {...props}>
{props.children}
</view>
)
}
export const Rect = (props) => {
return (
<view mockedComponent="svg-Rect" {...props} />
)
}
export const Path = (props) => {
return (
<view mockedComponent="svg-Path" {...props} >
{props.children}
</view>
)
}
export const G = (props) => {
return (
<view mockedComponent="svg-G" {...props}>
{props.children}
</view>
)
}
export const Svg = (props) => {
return (
<view mockedComponent="svg-Svg" {...props} >
{props.children}
</view>
)
}
export const Text = (props) => {
return (
<view mockedComponent="svg-Text" {...props} >
{props.children}
</view>
)
}
export const Circle = (props) => {
return (
<view mockedComponent="svg-Circle" {...props} />
)
}
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__ | capitalone_repos/react-native-pathjs-charts/src/__tests__/SmoothLine/SmoothLineRegions-test.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import 'react-native'
import React from 'react'
import SmoothLine from '../../SmoothLine'
import renderer from 'react-test-renderer'
let data = [
[{
"x": -10,
"y": -1000
}, {
"x": -9,
"y": -729
}, {
"x": -8,
"y": -512
}, {
"x": -7,
"y": -343
}, {
"x": -6,
"y": -216
}, {
"x": -5,
"y": -125
}, {
"x": -4,
"y": -64
}, {
"x": -3,
"y": -27
}, {
"x": -2,
"y": -8
}, {
"x": -1,
"y": -1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 8
}, {
"x": 3,
"y": 27
}, {
"x": 4,
"y": 64
}, {
"x": 5,
"y": 125
}, {
"x": 6,
"y": 216
}, {
"x": 7,
"y": 343
}, {
"x": 8,
"y": 512
}, {
"x": 9,
"y": 729
}, {
"x": 10,
"y": 1000
}],
[{
"x": -10,
"y": 100
}, {
"x": -9,
"y": 81
}, {
"x": -8,
"y": 64
}, {
"x": -7,
"y": 49
}, {
"x": -6,
"y": 36
}, {
"x": -5,
"y": 25
}, {
"x": -4,
"y": 16
}, {
"x": -3,
"y": 9
}, {
"x": -2,
"y": 4
}, {
"x": -1,
"y": 1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 4
}, {
"x": 3,
"y": 9
}, {
"x": 4,
"y": 16
}, {
"x": 5,
"y": 25
}, {
"x": 6,
"y": 36
}, {
"x": 7,
"y": 49
}, {
"x": 8,
"y": 64
}, {
"x": 9,
"y": 81
}, {
"x": 10,
"y": 100
}]
]
let regions = [{
label: 'Level1',
from: 1,
to: 500,
fill: '#c81212'
}, {
label: 'Level2',
from: 500,
to: 1000,
fill: '#2d8023'
}, {
label: 'Level3',
labelOffset: {
left: 25,
top: 50,
},
from: 1000,
to: 1500,
fill: '#6a2380'
}, {
label: 'Level4',
from: 1500,
to: 2000,
fill: '#807623'
}, {
label: 'Level-1',
from: -500,
to: -1,
fill: '#8fb9b3'
}, {
label: 'Level-2',
from: -1000,
to: -501,
fill: '#e2d7c3'
}]
let regionStyling = {
labelOffset: {
left: 25,
top: 5,
},
fillOpacity: 0.5
}
let options = {
width: 280,
height: 280,
color: '#2980B9',
margin: {
top: 20,
left: 45,
bottom: 25,
right: 20
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
}
}
it('renders an example chart correctly', () => {
let tree = renderer.create(
<SmoothLine data={data} options={options} regions={regions} regionStyling={regionStyling}/>
).toJSON()
expect(tree).toMatchSnapshot()
})
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__ | capitalone_repos/react-native-pathjs-charts/src/__tests__/SmoothLine/SmoothLineRegionsExtended-test.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import 'react-native'
import React from 'react'
import SmoothLine from '../../SmoothLine'
import renderer from 'react-test-renderer'
let data = [
[{
"x": -10,
"y": -1000
}, {
"x": -9,
"y": -729
}, {
"x": -8,
"y": -512
}, {
"x": -7,
"y": -343
}, {
"x": -6,
"y": -216
}, {
"x": -5,
"y": -125
}, {
"x": -4,
"y": -64
}, {
"x": -3,
"y": -27
}, {
"x": -2,
"y": -8
}, {
"x": -1,
"y": -1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 8
}, {
"x": 3,
"y": 27
}, {
"x": 4,
"y": 64
}, {
"x": 5,
"y": 125
}, {
"x": 6,
"y": 216
}, {
"x": 7,
"y": 343
}, {
"x": 8,
"y": 512
}, {
"x": 9,
"y": 729
}, {
"x": 10,
"y": 1000
}],
[{
"x": -10,
"y": 100
}, {
"x": -9,
"y": 81
}, {
"x": -8,
"y": 64
}, {
"x": -7,
"y": 49
}, {
"x": -6,
"y": 36
}, {
"x": -5,
"y": 25
}, {
"x": -4,
"y": 16
}, {
"x": -3,
"y": 9
}, {
"x": -2,
"y": 4
}, {
"x": -1,
"y": 1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 4
}, {
"x": 3,
"y": 9
}, {
"x": 4,
"y": 16
}, {
"x": 5,
"y": 25
}, {
"x": 6,
"y": 36
}, {
"x": 7,
"y": 49
}, {
"x": 8,
"y": 64
}, {
"x": 9,
"y": 81
}, {
"x": 10,
"y": 100
}]
]
let regions = [{
label: 'Level1',
from: 1,
to: 500,
fill: '#c81212'
}, {
label: 'Level2',
from: 500,
to: 1000,
fill: '#2d8023'
}, {
label: 'Level3',
from: 1000,
to: 1500,
fill: '#6a2380'
}, {
label: 'Level4',
from: 1500,
to: 2000,
fill: '#807623'
}, {
label: 'Level-1',
from: -500,
to: -1,
fill: '#8fb9b3'
}, {
label: 'Level-2',
from: -1000,
to: -501,
fill: '#e2d7c3'
}]
let regionStyling = {
labelOffset: {
left: 25,
top: 5,
},
fillOpacity: 0.5
}
let options = {
width: 280,
height: 280,
color: '#2980B9',
margin: {
top: 20,
left: 45,
bottom: 25,
right: 20
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
},
min: -1000,
max: 2000,
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
}
}
it('renders an example chart correctly', () => {
let tree = renderer.create(
<SmoothLine data={data} options={options} regions={regions} regionStyling={regionStyling}/>
).toJSON()
expect(tree).toMatchSnapshot()
})
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__ | capitalone_repos/react-native-pathjs-charts/src/__tests__/SmoothLine/SmoothLineBasic-test.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import 'react-native'
import React from 'react'
import SmoothLine from '../../SmoothLine'
import renderer from 'react-test-renderer'
let data = [
[{
"x": -10,
"y": -1000
}, {
"x": -9,
"y": -729
}, {
"x": -8,
"y": -512
}, {
"x": -7,
"y": -343
}, {
"x": -6,
"y": -216
}, {
"x": -5,
"y": -125
}, {
"x": -4,
"y": -64
}, {
"x": -3,
"y": -27
}, {
"x": -2,
"y": -8
}, {
"x": -1,
"y": -1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 8
}, {
"x": 3,
"y": 27
}, {
"x": 4,
"y": 64
}, {
"x": 5,
"y": 125
}, {
"x": 6,
"y": 216
}, {
"x": 7,
"y": 343
}, {
"x": 8,
"y": 512
}, {
"x": 9,
"y": 729
}, {
"x": 10,
"y": 1000
}],
[{
"x": -10,
"y": 100
}, {
"x": -9,
"y": 81
}, {
"x": -8,
"y": 64
}, {
"x": -7,
"y": 49
}, {
"x": -6,
"y": 36
}, {
"x": -5,
"y": 25
}, {
"x": -4,
"y": 16
}, {
"x": -3,
"y": 9
}, {
"x": -2,
"y": 4
}, {
"x": -1,
"y": 1
}, {
"x": 0,
"y": 0
}, {
"x": 1,
"y": 1
}, {
"x": 2,
"y": 4
}, {
"x": 3,
"y": 9
}, {
"x": 4,
"y": 16
}, {
"x": 5,
"y": 25
}, {
"x": 6,
"y": 36
}, {
"x": 7,
"y": 49
}, {
"x": 8,
"y": 64
}, {
"x": 9,
"y": 81
}, {
"x": 10,
"y": 100
}]
]
let options = {
width: 280,
height: 280,
color: '#2980B9',
margin: {
top: 20,
left: 45,
bottom: 25,
right: 20
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 14,
fontWeight: true,
fill: '#34495E'
}
}
}
it('renders an example chart correctly', () => {
let tree = renderer.create(
<SmoothLine data={data} options={options}/>
).toJSON()
expect(tree).toMatchSnapshot()
})
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__/SmoothLine | capitalone_repos/react-native-pathjs-charts/src/__tests__/SmoothLine/__snapshots__/SmoothLineBasic-test.js.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders an example chart correctly 1`] = `
<View
height={325}
width={345}
>
<view
height={325}
mockedComponent="svg-component"
width={345}
>
<view
mockedComponent="svg-G"
x={45}
y={20}
>
<view
mockedComponent="svg-G"
x={-45}
y={-20}
/>
<view
mockedComponent="svg-G"
x={-45}
y={-20}
/>
<view
d="M NaN NaN C NaN NaN NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN L NaN NaN L NaN NaN Z "
fill="#3199de"
fillOpacity={0.5}
mockedComponent="svg-Path"
stroke="none"
/>
<view
d="M NaN NaN C NaN NaN NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN L NaN NaN L NaN NaN Z "
fill="#2980b9"
fillOpacity={0.5}
mockedComponent="svg-Path"
stroke="none"
/>
<view
d="M NaN NaN C NaN NaN NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3199de"
strokeDasharray={Array []}
strokeOpacity={1}
strokeWidth="1"
/>
<view
d="M NaN NaN C NaN NaN NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#2980b9"
strokeDasharray={Array []}
strokeOpacity={1}
strokeWidth="1"
/>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-45}
y={-20}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-45}
y={-20}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
</view>
</view>
</View>
`;
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__/SmoothLine | capitalone_repos/react-native-pathjs-charts/src/__tests__/SmoothLine/__snapshots__/SmoothLineRegions-test.js.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders an example chart correctly 1`] = `
<View
height={325}
width={345}
>
<view
height={325}
mockedComponent="svg-component"
width={345}
>
<view
mockedComponent="svg-G"
x={45}
y={20}
>
<view
mockedComponent="svg-G"
x={-45}
y={-20}
/>
<view
mockedComponent="svg-G"
x={-45}
y={-20}
/>
<view
mockedComponent="svg-G"
>
<view
fill="#c81212"
fillOpacity={0.5}
height={NaN}
mockedComponent="svg-Rect"
width={NaN}
x={0}
y={NaN}
/>
<view
fill={undefined}
fontFamily={undefined}
fontSize={undefined}
fontStyle="normal"
fontWeight="normal"
mockedComponent="svg-Text"
textAnchor="middle"
x={25}
y={NaN}
>
Level1
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
fill="#2d8023"
fillOpacity={0.5}
height={NaN}
mockedComponent="svg-Rect"
width={NaN}
x={0}
y={NaN}
/>
<view
fill={undefined}
fontFamily={undefined}
fontSize={undefined}
fontStyle="normal"
fontWeight="normal"
mockedComponent="svg-Text"
textAnchor="middle"
x={25}
y={NaN}
>
Level2
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
fill="#6a2380"
fillOpacity={0.5}
height={NaN}
mockedComponent="svg-Rect"
width={NaN}
x={0}
y={NaN}
/>
<view
fill={undefined}
fontFamily={undefined}
fontSize={undefined}
fontStyle="normal"
fontWeight="normal"
mockedComponent="svg-Text"
textAnchor="middle"
x={25}
y={NaN}
>
Level3
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
fill="#807623"
fillOpacity={0.5}
height={NaN}
mockedComponent="svg-Rect"
width={NaN}
x={0}
y={NaN}
/>
<view
fill={undefined}
fontFamily={undefined}
fontSize={undefined}
fontStyle="normal"
fontWeight="normal"
mockedComponent="svg-Text"
textAnchor="middle"
x={25}
y={NaN}
>
Level4
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
fill="#8fb9b3"
fillOpacity={0.5}
height={NaN}
mockedComponent="svg-Rect"
width={NaN}
x={0}
y={NaN}
/>
<view
fill={undefined}
fontFamily={undefined}
fontSize={undefined}
fontStyle="normal"
fontWeight="normal"
mockedComponent="svg-Text"
textAnchor="middle"
x={25}
y={NaN}
>
Level-1
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
fill="#e2d7c3"
fillOpacity={0.5}
height={NaN}
mockedComponent="svg-Rect"
width={NaN}
x={0}
y={NaN}
/>
<view
fill={undefined}
fontFamily={undefined}
fontSize={undefined}
fontStyle="normal"
fontWeight="normal"
mockedComponent="svg-Text"
textAnchor="middle"
x={25}
y={NaN}
>
Level-2
</view>
</view>
<view
d="M NaN NaN C NaN NaN NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN L NaN NaN L NaN NaN Z "
fill="#3199de"
fillOpacity={0.5}
mockedComponent="svg-Path"
stroke="none"
/>
<view
d="M NaN NaN C NaN NaN NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN L NaN NaN L NaN NaN Z "
fill="#2980b9"
fillOpacity={0.5}
mockedComponent="svg-Path"
stroke="none"
/>
<view
d="M NaN NaN C NaN NaN NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3199de"
strokeDasharray={Array []}
strokeOpacity={1}
strokeWidth="1"
/>
<view
d="M NaN NaN C NaN NaN NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#2980b9"
strokeDasharray={Array []}
strokeOpacity={1}
strokeWidth="1"
/>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-45}
y={-20}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-45}
y={-20}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
</view>
</view>
</View>
`;
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__/SmoothLine | capitalone_repos/react-native-pathjs-charts/src/__tests__/SmoothLine/__snapshots__/SmoothLineRegionsExtended-test.js.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders an example chart correctly 1`] = `
<View
height={325}
width={345}
>
<view
height={325}
mockedComponent="svg-component"
width={345}
>
<view
mockedComponent="svg-G"
x={45}
y={20}
>
<view
mockedComponent="svg-G"
x={-45}
y={-20}
/>
<view
mockedComponent="svg-G"
x={-45}
y={-20}
/>
<view
mockedComponent="svg-G"
>
<view
fill="#c81212"
fillOpacity={0.5}
height={-46.57333333333332}
mockedComponent="svg-Rect"
width={NaN}
x={0}
y={186.57333333333332}
/>
<view
fill={undefined}
fontFamily={undefined}
fontSize={undefined}
fontStyle="normal"
fontWeight="normal"
mockedComponent="svg-Text"
textAnchor="middle"
x={25}
y={145}
>
Level1
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
fill="#2d8023"
fillOpacity={0.5}
height={-46.66666666666666}
mockedComponent="svg-Rect"
width={NaN}
x={0}
y={140}
/>
<view
fill={undefined}
fontFamily={undefined}
fontSize={undefined}
fontStyle="normal"
fontWeight="normal"
mockedComponent="svg-Text"
textAnchor="middle"
x={25}
y={98.33333333333334}
>
Level2
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
fill="#6a2380"
fillOpacity={0.5}
height={-46.666666666666686}
mockedComponent="svg-Rect"
width={NaN}
x={0}
y={93.33333333333334}
/>
<view
fill={undefined}
fontFamily={undefined}
fontSize={undefined}
fontStyle="normal"
fontWeight="normal"
mockedComponent="svg-Text"
textAnchor="middle"
x={25}
y={51.66666666666666}
>
Level3
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
fill="#807623"
fillOpacity={0.5}
height={-46.66666666666666}
mockedComponent="svg-Rect"
width={NaN}
x={0}
y={46.66666666666666}
/>
<view
fill={undefined}
fontFamily={undefined}
fontSize={undefined}
fontStyle="normal"
fontWeight="normal"
mockedComponent="svg-Text"
textAnchor="middle"
x={25}
y={5}
>
Level4
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
fill="#8fb9b3"
fillOpacity={0.5}
height={-46.57333333333335}
mockedComponent="svg-Rect"
width={NaN}
x={0}
y={233.33333333333334}
/>
<view
fill={undefined}
fontFamily={undefined}
fontSize={undefined}
fontStyle="normal"
fontWeight="normal"
mockedComponent="svg-Text"
textAnchor="middle"
x={25}
y={191.76}
>
Level-1
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
fill="#e2d7c3"
fillOpacity={0.5}
height={-46.57333333333332}
mockedComponent="svg-Rect"
width={NaN}
x={0}
y={280}
/>
<view
fill={undefined}
fontFamily={undefined}
fontSize={undefined}
fontStyle="normal"
fontWeight="normal"
mockedComponent="svg-Text"
textAnchor="middle"
x={25}
y={238.42666666666668}
>
Level-2
</view>
</view>
<view
d="M NaN NaN C NaN NaN NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN L NaN 280 L NaN 280 Z "
fill="#3199de"
fillOpacity={0.5}
mockedComponent="svg-Path"
stroke="none"
/>
<view
d="M NaN NaN C NaN NaN NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN L NaN 280 L NaN 280 Z "
fill="#2980b9"
fillOpacity={0.5}
mockedComponent="svg-Path"
stroke="none"
/>
<view
d="M NaN NaN C NaN NaN NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3199de"
strokeDasharray={Array []}
strokeOpacity={1}
strokeWidth="1"
/>
<view
d="M NaN NaN C NaN NaN NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN S NaN NaN NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#2980b9"
strokeDasharray={Array []}
strokeOpacity={1}
strokeWidth="1"
/>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-45}
y={-20}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-45}
y={-20}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
</view>
</view>
</View>
`;
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__ | capitalone_repos/react-native-pathjs-charts/src/__tests__/scatterplot/ScatterplotBasic-test.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import 'react-native'
import React from 'react'
import Axis from '../../Axis'
import Scatterplot from '../../Scatterplot'
import renderer from 'react-test-renderer'
let data = [
[{
"title": "Amapá",
"rating": 4.47,
"episode": 0
}, {
"title": "Santa Catarina",
"rating": 3.3,
"episode": 1
}, {
"title": "Minas Gerais",
"rating": 6.46,
"episode": 2
}, {
"title": "Amazonas",
"rating": 3.87,
"episode": 3
}, {
"title": "Mato Grosso do Sul",
"rating": 2.8,
"episode": 4
}, {
"title": "Mato Grosso do Sul",
"rating": 2.05,
"episode": 5
}, {
"title": "Tocantins",
"rating": 7.28,
"episode": 6
}, {
"title": "Roraima",
"rating": 5.23,
"episode": 7
}, {
"title": "Roraima",
"rating": 7.76,
"episode": 8
}, {
"title": "Amazonas",
"rating": 2.26,
"episode": 9
}, {
"title": "Mato Grosso do Sul",
"rating": 2.46,
"episode": 10
}, {
"title": "Santa Catarina",
"rating": 7.59,
"episode": 11
}, {
"title": "Acre",
"rating": 3.74,
"episode": 12
}, {
"title": "Amapá",
"rating": 5.03,
"episode": 13
}, {
"title": "Paraíba",
"rating": 4.16,
"episode": 14
}, {
"title": "Mato Grosso",
"rating": 0.81,
"episode": 15
}, {
"title": "Rio de Janeiro",
"rating": 3.01,
"episode": 16
}, {
"title": "Rio de Janeiro",
"rating": 0,
"episode": 17
}, {
"title": "Distrito Federal",
"rating": 5.46,
"episode": 18
}, {
"title": "São Paulo",
"rating": 9.71,
"episode": 19
}, {
"title": "Mato Grosso",
"rating": 7.9,
"episode": 20
}, {
"title": "Tocantins",
"rating": 4.2,
"episode": 21
}, {
"title": "Amapá",
"rating": 6,
"episode": 22
}, {
"title": "Paraná",
"rating": 7.99,
"episode": 23
}, {
"title": "Mato Grosso do Sul",
"rating": 1.07,
"episode": 24
}, {
"title": "Tocantins",
"rating": 1.42,
"episode": 25
}, {
"title": "Paraná",
"rating": 5.94,
"episode": 26
}, {
"title": "Maranhão",
"rating": 3.17,
"episode": 27
}, {
"title": "Maranhão",
"rating": 1.58,
"episode": 28
}, {
"title": "Rondônia",
"rating": 6.12,
"episode": 29
}, {
"title": "Roraima",
"rating": 7.28,
"episode": 30
}, {
"title": "Mato Grosso",
"rating": 4.74,
"episode": 31
}, {
"title": "Roraima",
"rating": 1.47,
"episode": 32
}, {
"title": "Alagoas",
"rating": 9,
"episode": 33
}, {
"title": "Amazonas",
"rating": 0.43,
"episode": 34
}, {
"title": "Mato Grosso do Sul",
"rating": 8.61,
"episode": 35
}, {
"title": "Tocantins",
"rating": 0.6,
"episode": 36
}, {
"title": "Maranhão",
"rating": 9.62,
"episode": 37
}, {
"title": "Rio de Janeiro",
"rating": 4.79,
"episode": 38
}, {
"title": "Santa Catarina",
"rating": 7.71,
"episode": 39
}, {
"title": "Piauí",
"rating": 3.83,
"episode": 40
}, {
"title": "Pernambuco",
"rating": 8.19,
"episode": 41
}, {
"title": "Bahia",
"rating": 6.98,
"episode": 42
}, {
"title": "Minas Gerais",
"rating": 4.52,
"episode": 43
}]
]
let options = {
width: 290,
height: 290,
r: 2,
margin: {
top: 20,
left: 40,
bottom: 30,
right: 30
},
fill: "#2980B9",
stroke: "#3E90F0",
animate: {
type: 'delayed',
duration: 200
},
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
}
it('renders an example chart correctly', () => {
let tree = renderer.create(
<Scatterplot data={data}
options={options}/>
).toJSON()
expect(tree).toMatchSnapshot()
})
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__/scatterplot | capitalone_repos/react-native-pathjs-charts/src/__tests__/scatterplot/__snapshots__/ScatterplotBasic-test.js.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders an example chart correctly 1`] = `
<view
height={340}
mockedComponent="svg-component"
width={360}
>
<view
mockedComponent="svg-G"
x={40}
y={20}
>
<view
mockedComponent="svg-G"
x={-40}
y={-20}
/>
<view
mockedComponent="svg-G"
x={-40}
y={-20}
/>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx={0}
cy={0}
fill="#2980B9"
fillOpacity={1}
mockedComponent="svg-Circle"
r={2}
stroke="#3E90F0"
strokeOpacity={1}
/>
</view>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-40}
y={-20}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-40}
y={-20}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
</view>
</view>
`;
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__ | capitalone_repos/react-native-pathjs-charts/src/__tests__/pie/PieBasic-test.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import 'react-native'
import React from 'react'
import Pie from '../../Pie'
import renderer from 'react-test-renderer'
import { diffJson } from 'diff'
let data = [{
"name": "Washington",
"population": 7694980
}, {
"name": "Oregon",
"population": 2584160
}, {
"name": "Minnesota",
"population": 6590667,
"color": {'r':223,'g':154,'b':20}
}, {
"name": "Alaska",
"population": 7284698
}]
let options = {
margin: {
top: 20,
left: 20,
right: 20,
bottom: 20
},
width: 350,
height: 350,
color: '#2980B9',
r: 50,
R: 150,
legendPosition: 'topLeft',
animate: {
type: 'oneByOne',
duration: 200,
fillTransition: 3
},
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
color: '#ECF0F1'
}
}
it('renders using options property correctly', () => {
let tree = renderer.create(
<Pie data={data}
options={options}/>
).toJSON()
expect(tree).toMatchSnapshot()
})
it('renders using flattened properties correctly', () => {
let tree = renderer.create(
<Pie data={data}
options={options}
r={10} />
).toJSON()
expect(tree).toMatchSnapshot()
})
it('contains expected diff between flattened vs non-flattened option usage', () => {
let treeUsingOptionsProp = renderer.create(
<Pie data={data}
options={options}/>
).toJSON()
let treeUsingFlattenedProps = renderer.create(
<Pie data={data}
options={options}
r={10}/>
).toJSON()
let jsonDiff = diffJson(treeUsingOptionsProp, treeUsingFlattenedProps)
const expectedRemoveCount = 4
const expectedAddCount = 4
var actualRemoveCount = 0
var actualAddCount = 0
jsonDiff.forEach((part) => {
if (part.removed && part.value.trim()
=== '"d": "M NaN NaN A 150 150 0 0 1 NaN NaN L NaN NaN A 50 50 0 0 0 NaN NaN Z ",') {
actualRemoveCount++
}
if (part.added && part.value.trim()
=== '"d": "M NaN NaN A 150 150 0 0 1 NaN NaN L NaN NaN A 10 10 0 0 0 NaN NaN Z ",') {
actualAddCount++
}
})
expect(actualRemoveCount).toBe(expectedRemoveCount)
expect(actualAddCount).toBe(expectedAddCount)
})
it('renders with 1 data item correctly', () => {
let data = [{"name": "Washington", "population": 7694980}]
let tree = renderer.create(
<Pie data={data}
options={options}/>
).toJSON()
expect(tree).toMatchSnapshot()
})
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__/pie | capitalone_repos/react-native-pathjs-charts/src/__tests__/pie/__snapshots__/PieBasic-test.js.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders using flattened properties correctly 1`] = `
<view
height={390}
mockedComponent="svg-component"
width={390}
>
<view
mockedComponent="svg-G"
x={20}
y={20}
>
<view
mockedComponent="svg-G"
>
<view
d="M NaN NaN A 150 150 0 0 1 NaN NaN L NaN NaN A 10 10 0 0 0 NaN NaN Z "
fill="#3199de"
fillOpacity={1}
mockedComponent="svg-Path"
stroke="#3199de"
/>
<view
mockedComponent="svg-G"
x={20}
y={20}
>
<view
fill="#ECF0F1"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={NaN}
y={NaN}
>
Washington
</view>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
d="M NaN NaN A 150 150 0 0 1 NaN NaN L NaN NaN A 10 10 0 0 0 NaN NaN Z "
fill="#2980b9"
fillOpacity={1}
mockedComponent="svg-Path"
stroke="#2980b9"
/>
<view
mockedComponent="svg-G"
x={20}
y={20}
>
<view
fill="#ECF0F1"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={NaN}
y={NaN}
>
Oregon
</view>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
d="M NaN NaN A 150 150 0 0 1 NaN NaN L NaN NaN A 10 10 0 0 0 NaN NaN Z "
fill="#df9a14"
fillOpacity={1}
mockedComponent="svg-Path"
stroke="#df9a14"
/>
<view
mockedComponent="svg-G"
x={20}
y={20}
>
<view
fill="#ECF0F1"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={NaN}
y={NaN}
>
Minnesota
</view>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
d="M NaN NaN A 150 150 0 0 1 NaN NaN L NaN NaN A 10 10 0 0 0 NaN NaN Z "
fill="#2473a5"
fillOpacity={1}
mockedComponent="svg-Path"
stroke="#2473a5"
/>
<view
mockedComponent="svg-G"
x={20}
y={20}
>
<view
fill="#ECF0F1"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={NaN}
y={NaN}
>
Alaska
</view>
</view>
</view>
</view>
</view>
`;
exports[`renders using options property correctly 1`] = `
<view
height={390}
mockedComponent="svg-component"
width={390}
>
<view
mockedComponent="svg-G"
x={20}
y={20}
>
<view
mockedComponent="svg-G"
>
<view
d="M NaN NaN A 150 150 0 0 1 NaN NaN L NaN NaN A 50 50 0 0 0 NaN NaN Z "
fill="#3199de"
fillOpacity={1}
mockedComponent="svg-Path"
stroke="#3199de"
/>
<view
mockedComponent="svg-G"
x={20}
y={20}
>
<view
fill="#ECF0F1"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={NaN}
y={NaN}
>
Washington
</view>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
d="M NaN NaN A 150 150 0 0 1 NaN NaN L NaN NaN A 50 50 0 0 0 NaN NaN Z "
fill="#2980b9"
fillOpacity={1}
mockedComponent="svg-Path"
stroke="#2980b9"
/>
<view
mockedComponent="svg-G"
x={20}
y={20}
>
<view
fill="#ECF0F1"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={NaN}
y={NaN}
>
Oregon
</view>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
d="M NaN NaN A 150 150 0 0 1 NaN NaN L NaN NaN A 50 50 0 0 0 NaN NaN Z "
fill="#df9a14"
fillOpacity={1}
mockedComponent="svg-Path"
stroke="#df9a14"
/>
<view
mockedComponent="svg-G"
x={20}
y={20}
>
<view
fill="#ECF0F1"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={NaN}
y={NaN}
>
Minnesota
</view>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
d="M NaN NaN A 150 150 0 0 1 NaN NaN L NaN NaN A 50 50 0 0 0 NaN NaN Z "
fill="#2473a5"
fillOpacity={1}
mockedComponent="svg-Path"
stroke="#2473a5"
/>
<view
mockedComponent="svg-G"
x={20}
y={20}
>
<view
fill="#ECF0F1"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={NaN}
y={NaN}
>
Alaska
</view>
</view>
</view>
</view>
</view>
`;
exports[`renders with 1 data item correctly 1`] = `
<view
height={390}
mockedComponent="svg-component"
width={390}
>
<view
mockedComponent="svg-G"
x={20}
y={20}
>
<view
mockedComponent="svg-G"
>
<view
cx={155}
cy={155}
fill="#3199de"
mockedComponent="svg-Circle"
r={150}
stroke="#277ab1"
/>
<view
cx={155}
cy={155}
fill="#fff"
mockedComponent="svg-Circle"
r={50}
stroke="#277ab1"
/>
<view
fill="#ECF0F1"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={155}
y={55}
>
Washington
</view>
</view>
</view>
</view>
`;
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__ | capitalone_repos/react-native-pathjs-charts/src/__tests__/stockline/StockLineBasic-test.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import 'react-native'
import React from 'react'
import StockLine from '../../StockLine'
import renderer from 'react-test-renderer'
let data = [
[{
"x": 0,
"y": 47782
}, {
"x": 1,
"y": 48497
}, {
"x": 2,
"y": 77128
}, {
"x": 3,
"y": 73413
}, {
"x": 4,
"y": 58257
}, {
"x": 5,
"y": 40579
}, {
"x": 6,
"y": 72893
}, {
"x": 7,
"y": 60663
}, {
"x": 8,
"y": 15715
}, {
"x": 9,
"y": 40305
}, {
"x": 10,
"y": 68592
}, {
"x": 11,
"y": 95664
}, {
"x": 12,
"y": 17908
}, {
"x": 13,
"y": 22838
}, {
"x": 14,
"y": 32153
}, {
"x": 15,
"y": 56594
}, {
"x": 16,
"y": 76348
}, {
"x": 17,
"y": 46222
}, {
"x": 18,
"y": 59304
}],
[{
"x": 0,
"y": 132189
}, {
"x": 1,
"y": 61705
}, {
"x": 2,
"y": 154976
}, {
"x": 3,
"y": 81304
}, {
"x": 4,
"y": 172572
}, {
"x": 5,
"y": 140656
}, {
"x": 6,
"y": 148606
}, {
"x": 7,
"y": 53010
}, {
"x": 8,
"y": 110783
}, {
"x": 9,
"y": 196446
}, {
"x": 10,
"y": 117057
}, {
"x": 11,
"y": 186765
}, {
"x": 12,
"y": 174908
}, {
"x": 13,
"y": 75247
}, {
"x": 14,
"y": 192894
}, {
"x": 15,
"y": 150356
}, {
"x": 16,
"y": 180360
}, {
"x": 17,
"y": 175697
}, {
"x": 18,
"y": 114967
}],
[{
"x": 0,
"y": 125797
}, {
"x": 1,
"y": 256656
}, {
"x": 2,
"y": 222260
}, {
"x": 3,
"y": 265642
}, {
"x": 4,
"y": 263902
}, {
"x": 5,
"y": 113453
}, {
"x": 6,
"y": 289461
}, {
"x": 7,
"y": 293850
}, {
"x": 8,
"y": 206079
}, {
"x": 9,
"y": 240859
}, {
"x": 10,
"y": 152776
}, {
"x": 11,
"y": 297282
}, {
"x": 12,
"y": 175177
}, {
"x": 13,
"y": 169233
}, {
"x": 14,
"y": 237827
}, {
"x": 15,
"y": 242429
}, {
"x": 16,
"y": 218230
}, {
"x": 17,
"y": 161511
}, {
"x": 18,
"y": 153227
}]
]
let options = {
width: 250,
height: 250,
color: '#2980B9',
margin: {
top: 10,
left: 35,
bottom: 30,
right: 10
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
}
it('renders an example chart correctly', () => {
let tree = renderer.create(
<StockLine data={data}
options={options}/>
).toJSON()
expect(tree).toMatchSnapshot()
})
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__ | capitalone_repos/react-native-pathjs-charts/src/__tests__/stockline/StockLineDynamicTickLabels-test.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import 'react-native'
import React from 'react'
import StockLine from '../../StockLine'
import renderer from 'react-test-renderer'
let data = [
[{
"x": 0,
"y": 47782
}, {
"x": 1,
"y": 48497
}, {
"x": 2,
"y": 77128
}, {
"x": 3,
"y": 73413
}]
]
let options = {
width: 250,
height: 250,
color: '#2980B9',
margin: {
top: 10,
left: 35,
bottom: 30,
right: 10
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
tickValues: [],
labelFunction: ((v) => {
let d = moment('2016-10-08 14:00','YYYY-MM-DD HH:mm')
return d.add((v * 2),'hours').format('MM/DD/YY[\n]h:mm A')
}),
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
}
it('renders an example chart correctly', () => {
let tree = renderer.create(
<StockLine data={data}
options={options}/>
).toJSON()
expect(tree).toMatchSnapshot()
})
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__ | capitalone_repos/react-native-pathjs-charts/src/__tests__/stockline/StockLineStaticTickLabels-test.js | /*
Copyright 2016 Capital One Services, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
SPDX-Copyright: Copyright (c) Capital One Services, LLC
SPDX-License-Identifier: Apache-2.0
*/
import 'react-native'
import React from 'react'
import StockLine from '../../StockLine'
import renderer from 'react-test-renderer'
let data = [
[{
"x": 0,
"y": 47782
}, {
"x": 1,
"y": 48497
}, {
"x": 2,
"y": 77128
}, {
"x": 3,
"y": 73413
}, {
"x": 4,
"y": 58257
}, {
"x": 5,
"y": 40579
}, {
"x": 6,
"y": 72893
}]
]
let options = {
width: 250,
height: 250,
color: '#2980B9',
margin: {
top: 10,
left: 35,
bottom: 30,
right: 10
},
animate: {
type: 'delayed',
duration: 200
},
axisX: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'bottom',
tickValues: [
{value:'name1'},
{value:'name2'},
{value:'name3'},
{value:'name4'},
{value:'name5'},
{value:'name6'},
{value:'name7'}
],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
},
axisY: {
showAxis: true,
showLines: true,
showLabels: true,
showTicks: true,
zeroAxis: false,
orient: 'left',
tickValues: [],
label: {
fontFamily: 'Arial',
fontSize: 8,
fontWeight: true,
fill: '#34495E'
}
}
}
it('renders an example chart correctly', () => {
let tree = renderer.create(
<StockLine data={data}
options={options}/>
).toJSON()
expect(tree).toMatchSnapshot()
})
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__/stockline | capitalone_repos/react-native-pathjs-charts/src/__tests__/stockline/__snapshots__/StockLineBasic-test.js.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders an example chart correctly 1`] = `
<View
height={290}
width={295}
>
<view
height={290}
mockedComponent="svg-component"
width={295}
>
<view
mockedComponent="svg-G"
x={35}
y={10}
>
<view
mockedComponent="svg-G"
x={-35}
y={-10}
/>
<view
mockedComponent="svg-G"
x={-35}
y={-10}
/>
<view
d="M NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN Z "
fill="#3199de"
fillOpacity={0.5}
mockedComponent="svg-Path"
stroke="none"
/>
<view
d="M NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN Z "
fill="#2980b9"
fillOpacity={0.5}
mockedComponent="svg-Path"
stroke="none"
/>
<view
d="M NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN Z "
fill="#206694"
fillOpacity={0.5}
mockedComponent="svg-Path"
stroke="none"
/>
<view
d="M NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3199de"
strokeDasharray={Array []}
strokeOpacity={1}
strokeWidth="1"
/>
<view
d="M NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#2980b9"
strokeDasharray={Array []}
strokeOpacity={1}
strokeWidth="1"
/>
<view
d="M NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#206694"
strokeDasharray={Array []}
strokeOpacity={1}
strokeWidth="1"
/>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-35}
y={-10}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-35}
y={-10}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
</view>
</view>
</View>
`;
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__/stockline | capitalone_repos/react-native-pathjs-charts/src/__tests__/stockline/__snapshots__/StockLineStaticTickLabels-test.js.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders an example chart correctly 1`] = `
<View
height={290}
width={295}
>
<view
height={290}
mockedComponent="svg-component"
width={295}
>
<view
mockedComponent="svg-G"
x={35}
y={10}
>
<view
mockedComponent="svg-G"
x={-35}
y={-10}
>
<view
d="M NaN NaN L NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
/>
<view
d="M NaN NaN L NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
/>
<view
d="M NaN NaN L NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
/>
<view
d="M NaN NaN L NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
/>
<view
d="M NaN NaN L NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
/>
<view
d="M NaN NaN L NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
/>
<view
d="M NaN NaN L NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
/>
</view>
<view
mockedComponent="svg-G"
x={-35}
y={-10}
/>
<view
d="M NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN Z "
fill="#3199de"
fillOpacity={0.5}
mockedComponent="svg-Path"
stroke="none"
/>
<view
d="M NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3199de"
strokeDasharray={Array []}
strokeOpacity={1}
strokeWidth="1"
/>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-35}
y={-10}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx="0"
cy="0"
fill="grey"
mockedComponent="svg-Circle"
r={2}
stroke="grey"
/>
<view
fill="#34495E"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={0}
y={5}
>
name1
</view>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx="0"
cy="0"
fill="grey"
mockedComponent="svg-Circle"
r={2}
stroke="grey"
/>
<view
fill="#34495E"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={0}
y={5}
>
name2
</view>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx="0"
cy="0"
fill="grey"
mockedComponent="svg-Circle"
r={2}
stroke="grey"
/>
<view
fill="#34495E"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={0}
y={5}
>
name3
</view>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx="0"
cy="0"
fill="grey"
mockedComponent="svg-Circle"
r={2}
stroke="grey"
/>
<view
fill="#34495E"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={0}
y={5}
>
name4
</view>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx="0"
cy="0"
fill="grey"
mockedComponent="svg-Circle"
r={2}
stroke="grey"
/>
<view
fill="#34495E"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={0}
y={5}
>
name5
</view>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx="0"
cy="0"
fill="grey"
mockedComponent="svg-Circle"
r={2}
stroke="grey"
/>
<view
fill="#34495E"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={0}
y={5}
>
name6
</view>
</view>
<view
mockedComponent="svg-G"
x={NaN}
y={NaN}
>
<view
cx="0"
cy="0"
fill="grey"
mockedComponent="svg-Circle"
r={2}
stroke="grey"
/>
<view
fill="#34495E"
fontFamily="Arial"
fontSize={8}
fontStyle="normal"
fontWeight="bold"
mockedComponent="svg-Text"
textAnchor="middle"
x={0}
y={5}
>
name7
</view>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-35}
y={-10}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
</view>
</view>
</View>
`;
|
0 | capitalone_repos/react-native-pathjs-charts/src/__tests__/stockline | capitalone_repos/react-native-pathjs-charts/src/__tests__/stockline/__snapshots__/StockLineDynamicTickLabels-test.js.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders an example chart correctly 1`] = `
<View
height={290}
width={295}
>
<view
height={290}
mockedComponent="svg-component"
width={295}
>
<view
mockedComponent="svg-G"
x={35}
y={10}
>
<view
mockedComponent="svg-G"
x={-35}
y={-10}
/>
<view
mockedComponent="svg-G"
x={-35}
y={-10}
/>
<view
d="M NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN L NaN NaN Z "
fill="#3199de"
fillOpacity={0.5}
mockedComponent="svg-Path"
stroke="none"
/>
<view
d="M NaN NaN L NaN NaN L NaN NaN L NaN NaN"
fill="none"
mockedComponent="svg-Path"
stroke="#3199de"
strokeDasharray={Array []}
strokeOpacity={1}
strokeWidth="1"
/>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-35}
y={-10}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
<view
mockedComponent="svg-G"
>
<view
mockedComponent="svg-G"
x={-35}
y={-10}
>
<view
d="M NaN NaN L NaN NaN Z "
fill="none"
mockedComponent="svg-Path"
stroke="#3E90F0"
strokeOpacity={0.5}
strokeWidth={3}
/>
</view>
</view>
</view>
</view>
</View>
`;
|
0 | capitalone_repos | capitalone_repos/serverless-shell/.eslintrc.yml | extends: google
parserOptions:
ecmaVersion: 6
rules:
no-console: 2
|
0 | capitalone_repos | capitalone_repos/serverless-shell/LICENSE | MIT License
Copyright (c) 2016 Logan Raarup
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
|
0 | capitalone_repos | capitalone_repos/serverless-shell/index.js | 'use strict';
const {spawnSync} = require('child_process');
const {Promise} = require('bluebird');
const _ = require('lodash');
/**
* Plugin for Serverless 1.x that drops you to a shell with your env vars!
*/
class ServerlessLocalShell {
/**
* The plugin constructor
* @param {Object} serverless
* @param {Object} options
* makes
* @return {undefined}
*/
constructor(serverless, options) {
this.serverless = serverless;
this.options = options;
this.provider = this.serverless.getProvider(
this.serverless.service.provider.name);
this.commands = {
'shell': {
usage: 'Drop to a REPL with your environment variables properly set',
lifecycleEvents: [
'shell',
],
options: {
function: {
usage:
'Specify the function whose environment you want (e.g. ' +
'"--function myFunction")',
shortcut: 'f',
required: false,
type: 'string',
},
shell: {
usage: 'Specify a different shell (e.g. "--shell bash")',
shortcut: 'S',
required: false,
type: 'string',
},
quiet: {
usage:
`Don't output anay log messages besides the subcommand's output`,
shortcut: 'q',
required: false,
default: false,
type: 'boolean',
},
},
},
};
this.hooks = {
'shell:shell': () => Promise.bind(this)
.then(this.loadEnvVars)
.then(this.shell),
};
}
/**
* cribbed from serverless's invoke local (except get rid of lodash)
*/
loadEnvVars() {
try {
// from invoke local's extendedValidate
this.options.functionObj = this.serverless.service.getFunction(
this.options.function);
} catch (e) {
// skip if no function defined
this.options.functionObj = {};
}
const lambdaName = this.options.functionObj.name;
const memorySize = Number(this.options.functionObj.memorySize) ||
Number(this.serverless.service.provider.memorySize) ||
1024;
const lambdaDefaultEnvVars = {
// PATH: '/usr/local/lib64/node-v4.3.x/bin:/usr/local/bin:/usr/bin/:/bin',
LANG: 'en_US.UTF-8',
LD_LIBRARY_PATH: '/usr/local/lib64/node-v4.3.x/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib', // eslint-disable-line max-len
LAMBDA_TASK_ROOT: '/var/task',
LAMBDA_RUNTIME_DIR: '/var/runtime',
AWS_REGION:
this.options.region ||
_.get(this.serverless, 'service.provider.region'),
AWS_DEFAULT_REGION:
this.options.region ||
_.get(this.serverless, 'service.provider.region'),
AWS_LAMBDA_LOG_GROUP_NAME:
this.provider.naming.getLogGroupName(lambdaName),
AWS_LAMBDA_LOG_STREAM_NAME:
'2016/12/02/[$LATEST]f77ff5e4026c45bda9a9ebcec6bc9cad',
AWS_LAMBDA_FUNCTION_NAME: lambdaName,
AWS_LAMBDA_FUNCTION_MEMORY_SIZE: memorySize,
AWS_LAMBDA_FUNCTION_VERSION: '$LATEST',
NODE_PATH: '/var/runtime:/var/task:/var/runtime/node_modules',
};
const providerEnvVars = this.serverless.service.provider.environment || {};
const functionEnvVars = this.options.functionObj.environment || {};
const enterpriseCredsEnvVars = {};
if (this.serverless.service.provider.name === 'aws') {
const {cachedCredentials} = this.serverless.getProvider('aws');
if (cachedCredentials) {
enterpriseCredsEnvVars.AWS_ACCESS_KEY_ID =
cachedCredentials.accessKeyId;
enterpriseCredsEnvVars.AWS_SECRET_ACCESS_KEY =
cachedCredentials.secretAccessKey;
enterpriseCredsEnvVars.AWS_SESSION_TOKEN =
cachedCredentials.sessionToken;
enterpriseCredsEnvVars.AWS_REGION =
cachedCredentials.region;
}
}
Object.assign(
process.env,
lambdaDefaultEnvVars,
providerEnvVars,
functionEnvVars,
enterpriseCredsEnvVars
);
}
/**
* load the right environment variables and start shell
*/
shell() {
let shellBinary;
if (this.options.shell) {
shellBinary = this.options.shell;
} else if (_.has(this.serverless, 'service.custom.shellBinary')) {
shellBinary = this.serverless.service.custom.shellBinary;
} else if (this.serverless.service.provider.runtime.startsWith('nodejs')) {
shellBinary = 'node';
} else {
shellBinary = this.serverless.service.provider.runtime;
}
if (!this.options.quiet) {
this.serverless.cli.log(`Spawning ${shellBinary}...`);
}
if (process.env.SLS_DEBUG) {
// eslint-disable-next-line no-console
console.log(`Setting env: ${JSON.stringify(process.env, null, 2)}`);
}
spawnSync(shellBinary, [], {
env: process.env,
stdio: 'inherit',
shell: true,
});
};
/**
* get the custom.pythonRequirements contents, with defaults set
* @return {Object}
*/
custom() {
return Object.assign({
zip: false,
cleanupZipHelper: true,
}, this.serverless.service.custom &&
this.serverless.service.custom.pythonRequirements || {});
}
}
module.exports = ServerlessLocalShell;
|
0 | capitalone_repos | capitalone_repos/serverless-shell/package.json | {
"name": "serverless-shell",
"version": "1.1.0",
"engines": {
"node": ">=6.0"
},
"description": "Serverless Shell with env vars Plugin",
"author": "United Income <uiengineering@capitalone.com>",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/UnitedIncome/serverless-shell"
},
"keywords": [
"serverless",
"shell",
"environment",
"env",
"env vars",
"variables",
"environment variables",
"lambda",
"aws",
"aws lambda",
"amazon",
"amazon web services",
"serverless.com"
],
"files": [
"index.js",
"LICENSE",
"package.json",
"README.md"
],
"main": "index.js",
"bin": {},
"scripts": {
"test": "true",
"lint": "eslint *.js"
},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-google": "^0.14.0"
},
"dependencies": {
"bluebird": "^3.5.0",
"lodash": "^4.17.4"
}
}
|
0 | capitalone_repos | capitalone_repos/serverless-shell/README.md | # United Income at Capital One created this project with the intention of it helping us with Serverless Framework development and debugging. We have stopped providing updates to this project and archived it as of September 30th, 2021.
# Serverless Shell
[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com)
[![npm](https://nodei.co/npm/serverless-shell.png?mini=true)](https://www.npmjs.com/package/serverless-shell)
A Serverless v1.x plugin to drop to a local shell with your environment
variables from `serverless.yml`.
## Install
```
npm install --save serverless-shell
```
Add the plugin and set some env vars in your `serverless.yml`:
```yaml
provider:
name: aws
environment:
SOME_VAR: foobar
plugins:
- serverless-shell
```
## Usage
Example in a python project
```
$ serverless shell
Serverless: Spawning python3.6...
Python 3.6.1 (default, Mar 22 2017, 06:17:05)
[GCC 6.3.0 20170321] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['SOME_VAR']
'foobar'
```
and in a NodeJS project:
```
$ serverless shell
Serverless: Spawning node...
> process.env.SHELL
'foobar'
```
### Per function & stage specific env vars
Since the main reason for building this was to test code with the configs for
various stages, it supports properly building the environment. For example:
```
$ serverless -s staging shell -f status
```
## Custom shell (babel) support
If you want to launch a different shell than the runtime's default, you can
specify that with in the `custom` section of your config. This can be used
to for things like using `babel-node` instead of `node` or even dropping to
`bash` with the right env vars set.
Example:
```
custom:
shellBinary: babel-node
```
This feature can also be activated by a CLI switch:
```
$ sls shell -S bash
```
|
0 | capitalone_repos | capitalone_repos/serverless-shell/yarn.lock | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@babel/code-frame@^7.0.0":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e"
integrity sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==
dependencies:
"@babel/highlight" "^7.8.3"
"@babel/helper-validator-identifier@^7.9.0":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.0.tgz#ad53562a7fc29b3b9a91bbf7d10397fd146346ed"
integrity sha512-6G8bQKjOh+of4PV/ThDm/rRqlU7+IGoJuofpagU5GlEl29Vv0RGqqt86ZGRV8ZuSOY3o+8yXl5y782SMcG7SHw==
"@babel/highlight@^7.8.3":
version "7.9.0"
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.9.0.tgz#4e9b45ccb82b79607271b2979ad82c7b68163079"
integrity sha512-lJZPilxX7Op3Nv/2cvFdnlepPXDxi29wxteT57Q965oc5R9v86ztx0jfxVrTcBk8C2kcPkkDa2Z4T3ZsPPVWsQ==
dependencies:
"@babel/helper-validator-identifier" "^7.9.0"
chalk "^2.0.0"
js-tokens "^4.0.0"
acorn-jsx@^5.0.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.2.0.tgz#4c66069173d6fdd68ed85239fc256226182b2ebe"
integrity sha512-HiUX/+K2YpkpJ+SzBffkM/AQ2YE03S0U1kjTLVpoJdhZMOWy8qvXVN9JdLqv2QsaQ6MPYQIuNmwD8zOiYUofLQ==
acorn@^6.0.7:
version "6.4.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.1.tgz#531e58ba3f51b9dacb9a6646ca4debf5b14ca474"
integrity sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==
ajv@^6.10.2, ajv@^6.9.1:
version "6.12.0"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.0.tgz#06d60b96d87b8454a5adaba86e7854da629db4b7"
integrity sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw==
dependencies:
fast-deep-equal "^3.1.1"
fast-json-stable-stringify "^2.0.0"
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"
ansi-escapes@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b"
integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==
ansi-regex@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998"
integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=
ansi-regex@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997"
integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==
ansi-styles@^3.2.0, ansi-styles@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==
dependencies:
color-convert "^1.9.0"
argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
dependencies:
sprintf-js "~1.0.2"
astral-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9"
integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==
balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
bluebird@^3.5.0:
version "3.7.2"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
callsites@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==
chalk@^2.0.0, chalk@^2.1.0, chalk@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
dependencies:
ansi-styles "^3.2.1"
escape-string-regexp "^1.0.5"
supports-color "^5.3.0"
chardet@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==
cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
integrity sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=
dependencies:
restore-cursor "^2.0.0"
cli-width@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=
color-convert@^1.9.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==
dependencies:
color-name "1.1.3"
color-name@1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
cross-spawn@^6.0.5:
version "6.0.5"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==
dependencies:
nice-try "^1.0.4"
path-key "^2.0.1"
semver "^5.5.0"
shebang-command "^1.2.0"
which "^1.2.9"
debug@^4.0.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791"
integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==
dependencies:
ms "^2.1.1"
deep-is@~0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=
doctrine@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961"
integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==
dependencies:
esutils "^2.0.2"
emoji-regex@^7.0.1:
version "7.0.3"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156"
integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==
escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
eslint-config-google@^0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/eslint-config-google/-/eslint-config-google-0.14.0.tgz#4f5f8759ba6e11b424294a219dbfa18c508bcc1a"
integrity sha512-WsbX4WbjuMvTdeVL6+J3rK1RGhCTqjsFjX7UMSMgZiyxxaNLkoJENbrGExzERFeoTpGw3F3FypTiWAP9ZXzkEw==
eslint-scope@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848"
integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==
dependencies:
esrecurse "^4.1.0"
estraverse "^4.1.1"
eslint-utils@^1.3.1:
version "1.4.3"
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-1.4.3.tgz#74fec7c54d0776b6f67e0251040b5806564e981f"
integrity sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==
dependencies:
eslint-visitor-keys "^1.1.0"
eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz#e2a82cea84ff246ad6fb57f9bde5b46621459ec2"
integrity sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A==
eslint@^5.16.0:
version "5.16.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.16.0.tgz#a1e3ac1aae4a3fbd8296fcf8f7ab7314cbb6abea"
integrity sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==
dependencies:
"@babel/code-frame" "^7.0.0"
ajv "^6.9.1"
chalk "^2.1.0"
cross-spawn "^6.0.5"
debug "^4.0.1"
doctrine "^3.0.0"
eslint-scope "^4.0.3"
eslint-utils "^1.3.1"
eslint-visitor-keys "^1.0.0"
espree "^5.0.1"
esquery "^1.0.1"
esutils "^2.0.2"
file-entry-cache "^5.0.1"
functional-red-black-tree "^1.0.1"
glob "^7.1.2"
globals "^11.7.0"
ignore "^4.0.6"
import-fresh "^3.0.0"
imurmurhash "^0.1.4"
inquirer "^6.2.2"
js-yaml "^3.13.0"
json-stable-stringify-without-jsonify "^1.0.1"
levn "^0.3.0"
lodash "^4.17.11"
minimatch "^3.0.4"
mkdirp "^0.5.1"
natural-compare "^1.4.0"
optionator "^0.8.2"
path-is-inside "^1.0.2"
progress "^2.0.0"
regexpp "^2.0.1"
semver "^5.5.1"
strip-ansi "^4.0.0"
strip-json-comments "^2.0.1"
table "^5.2.3"
text-table "^0.2.0"
espree@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/espree/-/espree-5.0.1.tgz#5d6526fa4fc7f0788a5cf75b15f30323e2f81f7a"
integrity sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==
dependencies:
acorn "^6.0.7"
acorn-jsx "^5.0.0"
eslint-visitor-keys "^1.0.0"
esprima@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
esquery@^1.0.1:
version "1.2.0"
resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.2.0.tgz#a010a519c0288f2530b3404124bfb5f02e9797fe"
integrity sha512-weltsSqdeWIX9G2qQZz7KlTRJdkkOCTPgLYJUz1Hacf48R4YOwGPHO3+ORfWedqJKbq5WQmsgK90n+pFLIKt/Q==
dependencies:
estraverse "^5.0.0"
esrecurse@^4.1.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf"
integrity sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==
dependencies:
estraverse "^4.1.0"
estraverse@^4.1.0, estraverse@^4.1.1:
version "4.3.0"
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d"
integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==
estraverse@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.0.0.tgz#ac81750b482c11cca26e4b07e83ed8f75fbcdc22"
integrity sha512-j3acdrMzqrxmJTNj5dbr1YbjacrYgAxVMeF0gK16E3j494mOe7xygM/ZLIguEQ0ETwAg2hlJCtHRGav+y0Ny5A==
esutils@^2.0.2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==
external-editor@^3.0.3:
version "3.1.0"
resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.1.0.tgz#cb03f740befae03ea4d283caed2741a83f335495"
integrity sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==
dependencies:
chardet "^0.7.0"
iconv-lite "^0.4.24"
tmp "^0.0.33"
fast-deep-equal@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz#545145077c501491e33b15ec408c294376e94ae4"
integrity sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==
fast-json-stable-stringify@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633"
integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==
fast-levenshtein@~2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=
figures@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962"
integrity sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=
dependencies:
escape-string-regexp "^1.0.5"
file-entry-cache@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c"
integrity sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==
dependencies:
flat-cache "^2.0.1"
flat-cache@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0"
integrity sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==
dependencies:
flatted "^2.0.0"
rimraf "2.6.3"
write "1.0.3"
flatted@^2.0.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
functional-red-black-tree@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=
glob@^7.1.2, glob@^7.1.3:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
globals@^11.7.0:
version "11.12.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==
has-flag@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0=
iconv-lite@^0.4.24:
version "0.4.24"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"
integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==
dependencies:
safer-buffer ">= 2.1.2 < 3"
ignore@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==
import-fresh@^3.0.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66"
integrity sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==
dependencies:
parent-module "^1.0.0"
resolve-from "^4.0.0"
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
integrity sha1-khi5srkoojixPcT7a21XbyMUU+o=
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
inquirer@^6.2.2:
version "6.5.2"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.5.2.tgz#ad50942375d036d327ff528c08bd5fab089928ca"
integrity sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==
dependencies:
ansi-escapes "^3.2.0"
chalk "^2.4.2"
cli-cursor "^2.1.0"
cli-width "^2.0.0"
external-editor "^3.0.3"
figures "^2.0.0"
lodash "^4.17.12"
mute-stream "0.0.7"
run-async "^2.2.0"
rxjs "^6.4.0"
string-width "^2.1.0"
strip-ansi "^5.1.0"
through "^2.3.6"
is-fullwidth-code-point@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=
is-promise@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa"
integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=
isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=
js-tokens@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
js-yaml@^3.13.0:
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
integrity sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
json-schema-traverse@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660"
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==
json-stable-stringify-without-jsonify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=
levn@^0.3.0, levn@~0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee"
integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=
dependencies:
prelude-ls "~1.1.2"
type-check "~0.3.2"
lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.4:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
mimic-fn@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==
minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==
dependencies:
brace-expansion "^1.1.7"
minimist@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
mkdirp@^0.5.1:
version "0.5.5"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==
dependencies:
minimist "^1.2.5"
ms@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
mute-stream@0.0.7:
version "0.0.7"
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=
natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
nice-try@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"
onetime@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4"
integrity sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=
dependencies:
mimic-fn "^1.0.0"
optionator@^0.8.2:
version "0.8.3"
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495"
integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==
dependencies:
deep-is "~0.1.3"
fast-levenshtein "~2.0.6"
levn "~0.3.0"
prelude-ls "~1.1.2"
type-check "~0.3.2"
word-wrap "~1.2.3"
os-tmpdir@~1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=
parent-module@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2"
integrity sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==
dependencies:
callsites "^3.0.0"
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
path-is-inside@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=
path-key@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=
prelude-ls@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=
progress@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"
integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==
punycode@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
regexpp@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f"
integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==
resolve-from@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==
restore-cursor@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"
integrity sha1-n37ih/gv0ybU/RYpI9YhKe7g368=
dependencies:
onetime "^2.0.0"
signal-exit "^3.0.2"
rimraf@2.6.3:
version "2.6.3"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab"
integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==
dependencies:
glob "^7.1.3"
run-async@^2.2.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.0.tgz#e59054a5b86876cfae07f431d18cbaddc594f1e8"
integrity sha512-xJTbh/d7Lm7SBhc1tNvTpeCHaEzoyxPrqNlvSdMfBTYwaY++UJFyXUOxAtsRUXjlqOfj8luNaR9vjCh4KeV+pg==
dependencies:
is-promise "^2.1.0"
rxjs@^6.4.0:
version "6.5.5"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.5.tgz#c5c884e3094c8cfee31bf27eb87e54ccfc87f9ec"
integrity sha512-WfQI+1gohdf0Dai/Bbmk5L5ItH5tYqm3ki2c5GdWhKjalzjg93N3avFjVStyZZz+A2Em+ZxKH5bNghw9UeylGQ==
dependencies:
tslib "^1.9.0"
"safer-buffer@>= 2.1.2 < 3":
version "2.1.2"
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
semver@^5.5.0, semver@^5.5.1:
version "5.7.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=
dependencies:
shebang-regex "^1.0.0"
shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=
signal-exit@^3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"
integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==
slice-ansi@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636"
integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==
dependencies:
ansi-styles "^3.2.0"
astral-regex "^1.0.0"
is-fullwidth-code-point "^2.0.0"
sprintf-js@~1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
string-width@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==
dependencies:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^4.0.0"
string-width@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961"
integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==
dependencies:
emoji-regex "^7.0.1"
is-fullwidth-code-point "^2.0.0"
strip-ansi "^5.1.0"
strip-ansi@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f"
integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8=
dependencies:
ansi-regex "^3.0.0"
strip-ansi@^5.1.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae"
integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==
dependencies:
ansi-regex "^4.1.0"
strip-json-comments@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=
supports-color@^5.3.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==
dependencies:
has-flag "^3.0.0"
table@^5.2.3:
version "5.4.6"
resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e"
integrity sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==
dependencies:
ajv "^6.10.2"
lodash "^4.17.14"
slice-ansi "^2.1.0"
string-width "^3.0.0"
text-table@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=
through@^2.3.6:
version "2.3.8"
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
tmp@^0.0.33:
version "0.0.33"
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"
integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==
dependencies:
os-tmpdir "~1.0.2"
tslib@^1.9.0:
version "1.11.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35"
integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==
type-check@~0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72"
integrity sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=
dependencies:
prelude-ls "~1.1.2"
uri-js@^4.2.2:
version "4.2.2"
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0"
integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==
dependencies:
punycode "^2.1.0"
which@^1.2.9:
version "1.3.1"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==
dependencies:
isexe "^2.0.0"
word-wrap@~1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=
write@1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3"
integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==
dependencies:
mkdirp "^0.5.1"
|
0 | capitalone_repos | capitalone_repos/json-syntax/setup.cfg | [flake8]
# D203: one blank line before class docstring, this or D211
# W503: line break before binary operator, have to pick this or W504
# Everything after the first line is fixed with black.
ignore = D203, W503,
E111, E121, E122, E123, E124, E125, E126, E201, E202, E203,
E221, E222, E225, E226, E227, E231, E241, E251, E261, E262,
E265, E271, E272, E302, E303, E306, E502, E701, E702, E703,
E704, W291, W292, W293, W391
exclude =
.tox
__pycache__
.git
htmlcov
max-line-length = 92
disable-noqa = False
|
0 | capitalone_repos | capitalone_repos/json-syntax/LICENSE | MIT License
Copyright (c) 2019 Ben Samuel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
|
0 | capitalone_repos | capitalone_repos/json-syntax/pyproject.toml | [tool.poetry]
name = "json-syntax"
version = "2.3.1"
description = "Generates functions to convert Python classes to JSON dumpable objects."
authors = ["Ben Samuel <bsamuel@unitedincome.com>"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/UnitedIncome/json-syntax"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries"
]
[tool.poetry.dependencies]
python = "^3.4"
python-dateutil = {version="^2.7", python = "<3.7"}
typing = {version = "^3.7", python = "<3.5"}
[tool.poetry.dev-dependencies]
pytest = "^4.1"
attrs = "^19.2"
pytest-cov = "^2.6"
hypothesis = "^4"
dataclasses = {version="0.4", python = ">=3.6,<3.7"}
typing-extensions = {version = "^3.7", python = "<3.8"}
# Install these tools via pipx.
# black = {version = "^19.3-beta.0", allow-prereleases = true, python = ">=3.7"}
# dephell = {version = '^0.8.0', python = '>=3.6'}
[tool.black]
line-length = 88
target-version = ["py34"]
[build-system]
requires = ["poetry>=1.0"]
build-backend = "poetry.masonry.api"
[tool.dephell.setup]
# dephell deps convert -e setup; then pip install -e path/to/json_syntax will work
from = {format = "poetry", path = "pyproject.toml"}
to = {format = 'setuppy', path = "setup.py"}
[tool.dephell.req]
# Use `dephell deps convert -e req` to generate requirements.txt.
from = {format = "poetry", path = "pyproject.toml"}
to = {format = 'pip', path = "requirements.txt"}
[tool.dephell.test34.docker]
# dephell docker run -e test34 pip install -r requirements.txt
# dephell docker run -e test34 pytest tests/
container = "test34"
repo = "python"
tag = "3.4"
[tool.dephell.test35.docker]
container = "test35"
repo = "python"
tag = "3.5"
[tool.dephell.test36.docker]
container = "test36"
repo = "python"
tag = "3.6"
[tool.dephell.test37.docker]
container = "test37"
repo = "python"
tag = "3.7"
[tool.dephell.test38.docker]
container = "test38"
repo = "python"
tag = "3.8"
[tool.dephell.test39.docker]
container = "test39"
repo = "python"
tag = "3.9-rc"
|
0 | capitalone_repos | capitalone_repos/json-syntax/poetry.lock | [[package]]
category = "dev"
description = "Atomic file writes."
name = "atomicwrites"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "1.3.0"
[[package]]
category = "dev"
description = "Classes Without Boilerplate"
name = "attrs"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "19.3.0"
[package.extras]
azure-pipelines = ["coverage", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface", "pytest-azurepipelines"]
dev = ["coverage", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface", "sphinx", "pre-commit"]
docs = ["sphinx", "zope.interface"]
tests = ["coverage", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "zope.interface"]
[[package]]
category = "dev"
description = "Cross-platform colored terminal text."
marker = "sys_platform == \"win32\" and python_version == \"3.4\""
name = "colorama"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "0.4.1"
[[package]]
category = "dev"
description = "Cross-platform colored terminal text."
marker = "sys_platform == \"win32\" and python_version != \"3.4\""
name = "colorama"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
version = "0.4.3"
[[package]]
category = "dev"
description = "Code coverage measurement for Python"
name = "coverage"
optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <4"
version = "4.5.4"
[[package]]
category = "dev"
description = "Code coverage measurement for Python"
name = "coverage"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
version = "5.0.3"
[package.extras]
toml = ["toml"]
[[package]]
category = "dev"
description = "An implementation of PEP 557: Data Classes"
marker = "python_version >= \"3.6\" and python_version < \"3.7\""
name = "dataclasses"
optional = false
python-versions = "*"
version = "0.4"
[[package]]
category = "dev"
description = "A library for property based testing"
name = "hypothesis"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "4.13.0"
[package.dependencies]
attrs = ">=16.0.0"
[package.extras]
all = ["django (>=1.11)", "dpcontracts (>=0.4)", "lark-parser (>=0.6.5)", "numpy (>=1.9.0)", "pandas (>=0.19)", "pytest (>=3.0)", "python-dateutil (>=1.4)", "pytz (>=2014.1)", "pytz"]
dateutil = ["python-dateutil (>=1.4)"]
django = ["django (>=1.11)", "pytz"]
dpcontracts = ["dpcontracts (>=0.4)"]
lark = ["lark-parser (>=0.6.5)"]
numpy = ["numpy (>=1.9.0)"]
pandas = ["pandas (>=0.19)"]
pytest = ["pytest (>=3.0)"]
pytz = ["pytz (>=2014.1)"]
[[package]]
category = "dev"
description = "A library for property-based testing"
name = "hypothesis"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
version = "4.57.1"
[package.dependencies]
attrs = ">=19.2.0"
sortedcontainers = ">=2.1.0,<3.0.0"
[package.extras]
all = ["django (>=1.11)", "dpcontracts (>=0.4)", "lark-parser (>=0.6.5)", "numpy (>=1.9.0)", "pandas (>=0.19)", "pytest (>=4.3)", "python-dateutil (>=1.4)", "pytz (>=2014.1)"]
dateutil = ["python-dateutil (>=1.4)"]
django = ["pytz (>=2014.1)", "django (>=1.11)"]
dpcontracts = ["dpcontracts (>=0.4)"]
lark = ["lark-parser (>=0.6.5)"]
numpy = ["numpy (>=1.9.0)"]
pandas = ["pandas (>=0.19)"]
pytest = ["pytest (>=4.3)"]
pytz = ["pytz (>=2014.1)"]
[[package]]
category = "dev"
description = "Read metadata from Python packages"
marker = "python_version < \"3.8\""
name = "importlib-metadata"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7"
version = "1.1.3"
[package.dependencies]
zipp = ">=0.5"
[package.extras]
docs = ["sphinx", "rst.linker"]
testing = ["packaging", "importlib-resources"]
[[package]]
category = "dev"
description = "Read metadata from Python packages"
marker = "python_version < \"3.8\""
name = "importlib-metadata"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
version = "1.5.0"
[package.dependencies]
zipp = ">=0.5"
[package.extras]
docs = ["sphinx", "rst.linker"]
testing = ["packaging", "importlib-resources"]
[[package]]
category = "dev"
description = "More routines for operating on iterables, beyond itertools"
marker = "python_version > \"2.7\""
name = "more-itertools"
optional = false
python-versions = ">=3.4"
version = "7.2.0"
[[package]]
category = "dev"
description = "More routines for operating on iterables, beyond itertools"
marker = "python_version > \"2.7\""
name = "more-itertools"
optional = false
python-versions = ">=3.5"
version = "8.2.0"
[[package]]
category = "dev"
description = "Core utilities for Python packages"
name = "packaging"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "20.1"
[package.dependencies]
pyparsing = ">=2.0.2"
six = "*"
[[package]]
category = "dev"
description = "Object-oriented filesystem paths"
marker = "python_version < \"3.6\""
name = "pathlib2"
optional = false
python-versions = "*"
version = "2.3.5"
[package.dependencies]
six = "*"
[package.dependencies.scandir]
python = "<3.5"
version = "*"
[[package]]
category = "dev"
description = "plugin and hook calling mechanisms for python"
name = "pluggy"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "0.13.1"
[package.dependencies]
[package.dependencies.importlib-metadata]
python = "<3.8"
version = ">=0.12"
[package.extras]
dev = ["pre-commit", "tox"]
[[package]]
category = "dev"
description = "library with cross-python path, ini-parsing, io, code, log facilities"
name = "py"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "1.8.1"
[[package]]
category = "dev"
description = "Python parsing module"
name = "pyparsing"
optional = false
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
version = "2.4.6"
[[package]]
category = "dev"
description = "pytest: simple powerful testing with Python"
name = "pytest"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7"
version = "4.6.9"
[package.dependencies]
atomicwrites = ">=1.0"
attrs = ">=17.4.0"
packaging = "*"
pluggy = ">=0.12,<1.0"
py = ">=1.5.0"
six = ">=1.10.0"
wcwidth = "*"
[[package.dependencies.colorama]]
python = "<3.4.0 || >=3.5.0"
version = "*"
[[package.dependencies.colorama]]
python = ">=3.4,<3.5"
version = "<=0.4.1"
[package.dependencies.importlib-metadata]
python = "<3.8"
version = ">=0.12"
[package.dependencies.more-itertools]
python = ">=2.8"
version = ">=4.0.0"
[package.dependencies.pathlib2]
python = "<3.6"
version = ">=2.2.0"
[package.extras]
testing = ["argcomplete", "hypothesis (>=3.56)", "nose", "requests", "mock"]
[[package]]
category = "dev"
description = "Pytest plugin for measuring coverage."
name = "pytest-cov"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
version = "2.8.1"
[package.dependencies]
coverage = ">=4.4"
pytest = ">=3.6"
[package.extras]
testing = ["fields", "hunter", "process-tests (2.0.2)", "six", "virtualenv"]
[[package]]
category = "main"
description = "Extensions to the standard Python datetime module"
marker = "python_version < \"3.7\""
name = "python-dateutil"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7"
version = "2.8.1"
[package.dependencies]
six = ">=1.5"
[[package]]
category = "dev"
description = "scandir, a better directory iterator and faster os.walk()"
marker = "python_version < \"3.5\""
name = "scandir"
optional = false
python-versions = "*"
version = "1.10.0"
[[package]]
category = "main"
description = "Python 2 and 3 compatibility utilities"
name = "six"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
version = "1.14.0"
[[package]]
category = "dev"
description = "Sorted Containers -- Sorted List, Sorted Dict, Sorted Set"
name = "sortedcontainers"
optional = false
python-versions = "*"
version = "2.1.0"
[[package]]
category = "main"
description = "Type Hints for Python"
marker = "python_version < \"3.5\""
name = "typing"
optional = false
python-versions = "*"
version = "3.7.4.1"
[[package]]
category = "dev"
description = "Backported and Experimental Type Hints for Python 3.5+"
marker = "python_version < \"3.8\""
name = "typing-extensions"
optional = false
python-versions = "*"
version = "3.7.4.1"
[package.dependencies]
[package.dependencies.typing]
python = "<3.5"
version = ">=3.7.4"
[[package]]
category = "dev"
description = "Measures number of Terminal column cells of wide-character codes"
name = "wcwidth"
optional = false
python-versions = "*"
version = "0.1.8"
[[package]]
category = "dev"
description = "Backport of pathlib-compatible object wrapper for zip files"
marker = "python_version < \"3.8\""
name = "zipp"
optional = false
python-versions = ">=2.7"
version = "1.1.0"
[package.extras]
docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"]
testing = ["pathlib2", "unittest2", "jaraco.itertools"]
[metadata]
content-hash = "3443d2eb40682c0356661b3bb3db19a29bc8100c6d3f43f467dfc230cd9defb0"
python-versions = "^3.4"
[metadata.files]
atomicwrites = [
{file = "atomicwrites-1.3.0-py2.py3-none-any.whl", hash = "sha256:03472c30eb2c5d1ba9227e4c2ca66ab8287fbfbbda3888aa93dc2e28fc6811b4"},
{file = "atomicwrites-1.3.0.tar.gz", hash = "sha256:75a9445bac02d8d058d5e1fe689654ba5a6556a1dfd8ce6ec55a0ed79866cfa6"},
]
attrs = [
{file = "attrs-19.3.0-py2.py3-none-any.whl", hash = "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c"},
{file = "attrs-19.3.0.tar.gz", hash = "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72"},
]
colorama = [
{file = "colorama-0.4.1-py2.py3-none-any.whl", hash = "sha256:f8ac84de7840f5b9c4e3347b3c1eaa50f7e49c2b07596221daec5edaabbd7c48"},
{file = "colorama-0.4.1.tar.gz", hash = "sha256:05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d"},
{file = "colorama-0.4.3-py2.py3-none-any.whl", hash = "sha256:7d73d2a99753107a36ac6b455ee49046802e59d9d076ef8e47b61499fa29afff"},
{file = "colorama-0.4.3.tar.gz", hash = "sha256:e96da0d330793e2cb9485e9ddfd918d456036c7149416295932478192f4436a1"},
]
coverage = [
{file = "coverage-4.5.4-cp26-cp26m-macosx_10_12_x86_64.whl", hash = "sha256:eee64c616adeff7db37cc37da4180a3a5b6177f5c46b187894e633f088fb5b28"},
{file = "coverage-4.5.4-cp27-cp27m-macosx_10_12_x86_64.whl", hash = "sha256:ef824cad1f980d27f26166f86856efe11eff9912c4fed97d3804820d43fa550c"},
{file = "coverage-4.5.4-cp27-cp27m-macosx_10_13_intel.whl", hash = "sha256:9a334d6c83dfeadae576b4d633a71620d40d1c379129d587faa42ee3e2a85cce"},
{file = "coverage-4.5.4-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:7494b0b0274c5072bddbfd5b4a6c6f18fbbe1ab1d22a41e99cd2d00c8f96ecfe"},
{file = "coverage-4.5.4-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:826f32b9547c8091679ff292a82aca9c7b9650f9fda3e2ca6bf2ac905b7ce888"},
{file = "coverage-4.5.4-cp27-cp27m-win32.whl", hash = "sha256:63a9a5fc43b58735f65ed63d2cf43508f462dc49857da70b8980ad78d41d52fc"},
{file = "coverage-4.5.4-cp27-cp27m-win_amd64.whl", hash = "sha256:e2ede7c1d45e65e209d6093b762e98e8318ddeff95317d07a27a2140b80cfd24"},
{file = "coverage-4.5.4-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:dd579709a87092c6dbee09d1b7cfa81831040705ffa12a1b248935274aee0437"},
{file = "coverage-4.5.4-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:08907593569fe59baca0bf152c43f3863201efb6113ecb38ce7e97ce339805a6"},
{file = "coverage-4.5.4-cp33-cp33m-macosx_10_10_x86_64.whl", hash = "sha256:6b62544bb68106e3f00b21c8930e83e584fdca005d4fffd29bb39fb3ffa03cb5"},
{file = "coverage-4.5.4-cp34-cp34m-macosx_10_12_x86_64.whl", hash = "sha256:331cb5115673a20fb131dadd22f5bcaf7677ef758741312bee4937d71a14b2ef"},
{file = "coverage-4.5.4-cp34-cp34m-manylinux1_i686.whl", hash = "sha256:bf1ef9eb901113a9805287e090452c05547578eaab1b62e4ad456fcc049a9b7e"},
{file = "coverage-4.5.4-cp34-cp34m-manylinux1_x86_64.whl", hash = "sha256:386e2e4090f0bc5df274e720105c342263423e77ee8826002dcffe0c9533dbca"},
{file = "coverage-4.5.4-cp34-cp34m-win32.whl", hash = "sha256:fa964bae817babece5aa2e8c1af841bebb6d0b9add8e637548809d040443fee0"},
{file = "coverage-4.5.4-cp34-cp34m-win_amd64.whl", hash = "sha256:df6712284b2e44a065097846488f66840445eb987eb81b3cc6e4149e7b6982e1"},
{file = "coverage-4.5.4-cp35-cp35m-macosx_10_12_x86_64.whl", hash = "sha256:efc89291bd5a08855829a3c522df16d856455297cf35ae827a37edac45f466a7"},
{file = "coverage-4.5.4-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:e4ef9c164eb55123c62411f5936b5c2e521b12356037b6e1c2617cef45523d47"},
{file = "coverage-4.5.4-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:ff37757e068ae606659c28c3bd0d923f9d29a85de79bf25b2b34b148473b5025"},
{file = "coverage-4.5.4-cp35-cp35m-win32.whl", hash = "sha256:bf0a7aed7f5521c7ca67febd57db473af4762b9622254291fbcbb8cd0ba5e33e"},
{file = "coverage-4.5.4-cp35-cp35m-win_amd64.whl", hash = "sha256:19e4df788a0581238e9390c85a7a09af39c7b539b29f25c89209e6c3e371270d"},
{file = "coverage-4.5.4-cp36-cp36m-macosx_10_13_x86_64.whl", hash = "sha256:60851187677b24c6085248f0a0b9b98d49cba7ecc7ec60ba6b9d2e5574ac1ee9"},
{file = "coverage-4.5.4-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:245388cda02af78276b479f299bbf3783ef0a6a6273037d7c60dc73b8d8d7755"},
{file = "coverage-4.5.4-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:c0afd27bc0e307a1ffc04ca5ec010a290e49e3afbe841c5cafc5c5a80ecd81c9"},
{file = "coverage-4.5.4-cp36-cp36m-win32.whl", hash = "sha256:6ba744056423ef8d450cf627289166da65903885272055fb4b5e113137cfa14f"},
{file = "coverage-4.5.4-cp36-cp36m-win_amd64.whl", hash = "sha256:af7ed8a8aa6957aac47b4268631fa1df984643f07ef00acd374e456364b373f5"},
{file = "coverage-4.5.4-cp37-cp37m-macosx_10_13_x86_64.whl", hash = "sha256:3a794ce50daee01c74a494919d5ebdc23d58873747fa0e288318728533a3e1ca"},
{file = "coverage-4.5.4-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:0be0f1ed45fc0c185cfd4ecc19a1d6532d72f86a2bac9de7e24541febad72650"},
{file = "coverage-4.5.4-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:eca2b7343524e7ba246cab8ff00cab47a2d6d54ada3b02772e908a45675722e2"},
{file = "coverage-4.5.4-cp37-cp37m-win32.whl", hash = "sha256:93715dffbcd0678057f947f496484e906bf9509f5c1c38fc9ba3922893cda5f5"},
{file = "coverage-4.5.4-cp37-cp37m-win_amd64.whl", hash = "sha256:23cc09ed395b03424d1ae30dcc292615c1372bfba7141eb85e11e50efaa6b351"},
{file = "coverage-4.5.4-cp38-cp38-macosx_10_13_x86_64.whl", hash = "sha256:141f08ed3c4b1847015e2cd62ec06d35e67a3ac185c26f7635f4406b90afa9c5"},
{file = "coverage-4.5.4.tar.gz", hash = "sha256:e07d9f1a23e9e93ab5c62902833bf3e4b1f65502927379148b6622686223125c"},
{file = "coverage-5.0.3-cp27-cp27m-macosx_10_12_x86_64.whl", hash = "sha256:cc1109f54a14d940b8512ee9f1c3975c181bbb200306c6d8b87d93376538782f"},
{file = "coverage-5.0.3-cp27-cp27m-macosx_10_13_intel.whl", hash = "sha256:be18f4ae5a9e46edae3f329de2191747966a34a3d93046dbdf897319923923bc"},
{file = "coverage-5.0.3-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:3230d1003eec018ad4a472d254991e34241e0bbd513e97a29727c7c2f637bd2a"},
{file = "coverage-5.0.3-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:e69215621707119c6baf99bda014a45b999d37602cb7043d943c76a59b05bf52"},
{file = "coverage-5.0.3-cp27-cp27m-win32.whl", hash = "sha256:1daa3eceed220f9fdb80d5ff950dd95112cd27f70d004c7918ca6dfc6c47054c"},
{file = "coverage-5.0.3-cp27-cp27m-win_amd64.whl", hash = "sha256:51bc7710b13a2ae0c726f69756cf7ffd4362f4ac36546e243136187cfcc8aa73"},
{file = "coverage-5.0.3-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:9bea19ac2f08672636350f203db89382121c9c2ade85d945953ef3c8cf9d2a68"},
{file = "coverage-5.0.3-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:5012d3b8d5a500834783689a5d2292fe06ec75dc86ee1ccdad04b6f5bf231691"},
{file = "coverage-5.0.3-cp35-cp35m-macosx_10_12_x86_64.whl", hash = "sha256:d513cc3db248e566e07a0da99c230aca3556d9b09ed02f420664e2da97eac301"},
{file = "coverage-5.0.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:3dbb72eaeea5763676a1a1efd9b427a048c97c39ed92e13336e726117d0b72bf"},
{file = "coverage-5.0.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:15cf13a6896048d6d947bf7d222f36e4809ab926894beb748fc9caa14605d9c3"},
{file = "coverage-5.0.3-cp35-cp35m-win32.whl", hash = "sha256:fca1669d464f0c9831fd10be2eef6b86f5ebd76c724d1e0706ebdff86bb4adf0"},
{file = "coverage-5.0.3-cp35-cp35m-win_amd64.whl", hash = "sha256:1e44a022500d944d42f94df76727ba3fc0a5c0b672c358b61067abb88caee7a0"},
{file = "coverage-5.0.3-cp36-cp36m-macosx_10_13_x86_64.whl", hash = "sha256:b26aaf69713e5674efbde4d728fb7124e429c9466aeaf5f4a7e9e699b12c9fe2"},
{file = "coverage-5.0.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:722e4557c8039aad9592c6a4213db75da08c2cd9945320220634f637251c3894"},
{file = "coverage-5.0.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:7afad9835e7a651d3551eab18cbc0fdb888f0a6136169fbef0662d9cdc9987cf"},
{file = "coverage-5.0.3-cp36-cp36m-win32.whl", hash = "sha256:25dbf1110d70bab68a74b4b9d74f30e99b177cde3388e07cc7272f2168bd1477"},
{file = "coverage-5.0.3-cp36-cp36m-win_amd64.whl", hash = "sha256:c312e57847db2526bc92b9bfa78266bfbaabac3fdcd751df4d062cd4c23e46dc"},
{file = "coverage-5.0.3-cp37-cp37m-macosx_10_13_x86_64.whl", hash = "sha256:a8b8ac7876bc3598e43e2603f772d2353d9931709345ad6c1149009fd1bc81b8"},
{file = "coverage-5.0.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:527b4f316e6bf7755082a783726da20671a0cc388b786a64417780b90565b987"},
{file = "coverage-5.0.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:d649dc0bcace6fcdb446ae02b98798a856593b19b637c1b9af8edadf2b150bea"},
{file = "coverage-5.0.3-cp37-cp37m-win32.whl", hash = "sha256:cd60f507c125ac0ad83f05803063bed27e50fa903b9c2cfee3f8a6867ca600fc"},
{file = "coverage-5.0.3-cp37-cp37m-win_amd64.whl", hash = "sha256:c60097190fe9dc2b329a0eb03393e2e0829156a589bd732e70794c0dd804258e"},
{file = "coverage-5.0.3-cp38-cp38-macosx_10_13_x86_64.whl", hash = "sha256:d7008a6796095a79544f4da1ee49418901961c97ca9e9d44904205ff7d6aa8cb"},
{file = "coverage-5.0.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:ea9525e0fef2de9208250d6c5aeeee0138921057cd67fcef90fbed49c4d62d37"},
{file = "coverage-5.0.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:c62a2143e1313944bf4a5ab34fd3b4be15367a02e9478b0ce800cb510e3bbb9d"},
{file = "coverage-5.0.3-cp38-cp38m-win32.whl", hash = "sha256:b0840b45187699affd4c6588286d429cd79a99d509fe3de0f209594669bb0954"},
{file = "coverage-5.0.3-cp38-cp38m-win_amd64.whl", hash = "sha256:76e2057e8ffba5472fd28a3a010431fd9e928885ff480cb278877c6e9943cc2e"},
{file = "coverage-5.0.3-cp39-cp39m-win32.whl", hash = "sha256:b63dd43f455ba878e5e9f80ba4f748c0a2156dde6e0e6e690310e24d6e8caf40"},
{file = "coverage-5.0.3-cp39-cp39m-win_amd64.whl", hash = "sha256:da93027835164b8223e8e5af2cf902a4c80ed93cb0909417234f4a9df3bcd9af"},
{file = "coverage-5.0.3.tar.gz", hash = "sha256:77afca04240c40450c331fa796b3eab6f1e15c5ecf8bf2b8bee9706cd5452fef"},
]
dataclasses = [
{file = "dataclasses-0.4-py3-none-any.whl", hash = "sha256:068953b730c80cbb13ca6aac6ceedaa5d483fb6081a372ac4788aa5179ed9597"},
{file = "dataclasses-0.4.tar.gz", hash = "sha256:0f75133f21f6c9bd0fe82bc75d9908e46f531682911c9cffa75bce0e40ef09ef"},
]
hypothesis = [
{file = "hypothesis-4.13.0-py2-none-any.whl", hash = "sha256:035d95b47651490b138fa45b3239894a60a122ab7e66b93a355b20342506cdcf"},
{file = "hypothesis-4.13.0-py3-none-any.whl", hash = "sha256:83a5c2cae72b2b5cce13ca4e0df6cc9cc2d057b502e4c111678dae69674471dd"},
{file = "hypothesis-4.13.0.tar.gz", hash = "sha256:1896d88507c63e55036d7ea4ca73281e1c001167f8c4f92f788dbac7bb811832"},
{file = "hypothesis-4.57.1-py3-none-any.whl", hash = "sha256:94f0910bc87e0ae8c098f4ada28dfdc381245e0c8079c674292b417dbde144b5"},
{file = "hypothesis-4.57.1.tar.gz", hash = "sha256:3c4369a4b0a1348561048bcda5f1db951a1b8e2a514ea8e8c70d36e656bf6fa0"},
]
importlib-metadata = [
{file = "importlib_metadata-1.1.3-py2.py3-none-any.whl", hash = "sha256:7c7f8ac40673f507f349bef2eed21a0e5f01ddf5b2a7356a6c65eb2099b53764"},
{file = "importlib_metadata-1.1.3.tar.gz", hash = "sha256:7a99fb4084ffe6dae374961ba7a6521b79c1d07c658ab3a28aa264ee1d1b14e3"},
{file = "importlib_metadata-1.5.0-py2.py3-none-any.whl", hash = "sha256:b97607a1a18a5100839aec1dc26a1ea17ee0d93b20b0f008d80a5a050afb200b"},
{file = "importlib_metadata-1.5.0.tar.gz", hash = "sha256:06f5b3a99029c7134207dd882428a66992a9de2bef7c2b699b5641f9886c3302"},
]
more-itertools = [
{file = "more-itertools-7.2.0.tar.gz", hash = "sha256:409cd48d4db7052af495b09dec721011634af3753ae1ef92d2b32f73a745f832"},
{file = "more_itertools-7.2.0-py3-none-any.whl", hash = "sha256:92b8c4b06dac4f0611c0729b2f2ede52b2e1bac1ab48f089c7ddc12e26bb60c4"},
{file = "more-itertools-8.2.0.tar.gz", hash = "sha256:b1ddb932186d8a6ac451e1d95844b382f55e12686d51ca0c68b6f61f2ab7a507"},
{file = "more_itertools-8.2.0-py3-none-any.whl", hash = "sha256:5dd8bcf33e5f9513ffa06d5ad33d78f31e1931ac9a18f33d37e77a180d393a7c"},
]
packaging = [
{file = "packaging-20.1-py2.py3-none-any.whl", hash = "sha256:170748228214b70b672c581a3dd610ee51f733018650740e98c7df862a583f73"},
{file = "packaging-20.1.tar.gz", hash = "sha256:e665345f9eef0c621aa0bf2f8d78cf6d21904eef16a93f020240b704a57f1334"},
]
pathlib2 = [
{file = "pathlib2-2.3.5-py2.py3-none-any.whl", hash = "sha256:0ec8205a157c80d7acc301c0b18fbd5d44fe655968f5d947b6ecef5290fc35db"},
{file = "pathlib2-2.3.5.tar.gz", hash = "sha256:6cd9a47b597b37cc57de1c05e56fb1a1c9cc9fab04fe78c29acd090418529868"},
]
pluggy = [
{file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"},
{file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"},
]
py = [
{file = "py-1.8.1-py2.py3-none-any.whl", hash = "sha256:c20fdd83a5dbc0af9efd622bee9a5564e278f6380fffcacc43ba6f43db2813b0"},
{file = "py-1.8.1.tar.gz", hash = "sha256:5e27081401262157467ad6e7f851b7aa402c5852dbcb3dae06768434de5752aa"},
]
pyparsing = [
{file = "pyparsing-2.4.6-py2.py3-none-any.whl", hash = "sha256:c342dccb5250c08d45fd6f8b4a559613ca603b57498511740e65cd11a2e7dcec"},
{file = "pyparsing-2.4.6.tar.gz", hash = "sha256:4c830582a84fb022400b85429791bc551f1f4871c33f23e44f353119e92f969f"},
]
pytest = [
{file = "pytest-4.6.9-py2.py3-none-any.whl", hash = "sha256:c77a5f30a90e0ce24db9eaa14ddfd38d4afb5ea159309bdd2dae55b931bc9324"},
{file = "pytest-4.6.9.tar.gz", hash = "sha256:19e8f75eac01dd3f211edd465b39efbcbdc8fc5f7866d7dd49fedb30d8adf339"},
]
pytest-cov = [
{file = "pytest-cov-2.8.1.tar.gz", hash = "sha256:cc6742d8bac45070217169f5f72ceee1e0e55b0221f54bcf24845972d3a47f2b"},
{file = "pytest_cov-2.8.1-py2.py3-none-any.whl", hash = "sha256:cdbdef4f870408ebdbfeb44e63e07eb18bb4619fae852f6e760645fa36172626"},
]
python-dateutil = [
{file = "python-dateutil-2.8.1.tar.gz", hash = "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c"},
{file = "python_dateutil-2.8.1-py2.py3-none-any.whl", hash = "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a"},
]
scandir = [
{file = "scandir-1.10.0-cp27-cp27m-win32.whl", hash = "sha256:92c85ac42f41ffdc35b6da57ed991575bdbe69db895507af88b9f499b701c188"},
{file = "scandir-1.10.0-cp27-cp27m-win_amd64.whl", hash = "sha256:cb925555f43060a1745d0a321cca94bcea927c50114b623d73179189a4e100ac"},
{file = "scandir-1.10.0-cp34-cp34m-win32.whl", hash = "sha256:2c712840c2e2ee8dfaf36034080108d30060d759c7b73a01a52251cc8989f11f"},
{file = "scandir-1.10.0-cp34-cp34m-win_amd64.whl", hash = "sha256:2586c94e907d99617887daed6c1d102b5ca28f1085f90446554abf1faf73123e"},
{file = "scandir-1.10.0-cp35-cp35m-win32.whl", hash = "sha256:2b8e3888b11abb2217a32af0766bc06b65cc4a928d8727828ee68af5a967fa6f"},
{file = "scandir-1.10.0-cp35-cp35m-win_amd64.whl", hash = "sha256:8c5922863e44ffc00c5c693190648daa6d15e7c1207ed02d6f46a8dcc2869d32"},
{file = "scandir-1.10.0-cp36-cp36m-win32.whl", hash = "sha256:2ae41f43797ca0c11591c0c35f2f5875fa99f8797cb1a1fd440497ec0ae4b022"},
{file = "scandir-1.10.0-cp36-cp36m-win_amd64.whl", hash = "sha256:7d2d7a06a252764061a020407b997dd036f7bd6a175a5ba2b345f0a357f0b3f4"},
{file = "scandir-1.10.0-cp37-cp37m-win32.whl", hash = "sha256:67f15b6f83e6507fdc6fca22fedf6ef8b334b399ca27c6b568cbfaa82a364173"},
{file = "scandir-1.10.0-cp37-cp37m-win_amd64.whl", hash = "sha256:b24086f2375c4a094a6b51e78b4cf7ca16c721dcee2eddd7aa6494b42d6d519d"},
{file = "scandir-1.10.0.tar.gz", hash = "sha256:4d4631f6062e658e9007ab3149a9b914f3548cb38bfb021c64f39a025ce578ae"},
]
six = [
{file = "six-1.14.0-py2.py3-none-any.whl", hash = "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"},
{file = "six-1.14.0.tar.gz", hash = "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a"},
]
sortedcontainers = [
{file = "sortedcontainers-2.1.0-py2.py3-none-any.whl", hash = "sha256:d9e96492dd51fae31e60837736b38fe42a187b5404c16606ff7ee7cd582d4c60"},
{file = "sortedcontainers-2.1.0.tar.gz", hash = "sha256:974e9a32f56b17c1bac2aebd9dcf197f3eb9cd30553c5852a3187ad162e1a03a"},
]
typing = [
{file = "typing-3.7.4.1-py2-none-any.whl", hash = "sha256:c8cabb5ab8945cd2f54917be357d134db9cc1eb039e59d1606dc1e60cb1d9d36"},
{file = "typing-3.7.4.1-py3-none-any.whl", hash = "sha256:f38d83c5a7a7086543a0f649564d661859c5146a85775ab90c0d2f93ffaa9714"},
{file = "typing-3.7.4.1.tar.gz", hash = "sha256:91dfe6f3f706ee8cc32d38edbbf304e9b7583fb37108fef38229617f8b3eba23"},
]
typing-extensions = [
{file = "typing_extensions-3.7.4.1-py2-none-any.whl", hash = "sha256:910f4656f54de5993ad9304959ce9bb903f90aadc7c67a0bef07e678014e892d"},
{file = "typing_extensions-3.7.4.1-py3-none-any.whl", hash = "sha256:cf8b63fedea4d89bab840ecbb93e75578af28f76f66c35889bd7065f5af88575"},
{file = "typing_extensions-3.7.4.1.tar.gz", hash = "sha256:091ecc894d5e908ac75209f10d5b4f118fbdb2eb1ede6a63544054bb1edb41f2"},
]
wcwidth = [
{file = "wcwidth-0.1.8-py2.py3-none-any.whl", hash = "sha256:8fd29383f539be45b20bd4df0dc29c20ba48654a41e661925e612311e9f3c603"},
{file = "wcwidth-0.1.8.tar.gz", hash = "sha256:f28b3e8a6483e5d49e7f8949ac1a78314e740333ae305b4ba5defd3e74fb37a8"},
]
zipp = [
{file = "zipp-1.1.0-py2.py3-none-any.whl", hash = "sha256:15428d652e993b6ce86694c3cccf0d71aa7afdc6ef1807fa25a920e9444e0281"},
{file = "zipp-1.1.0.tar.gz", hash = "sha256:d9d2efe11d3a3fb9184da550d35bd1319dc8e30a63255927c82bb42fca1f4f7c"},
]
|
0 | capitalone_repos | capitalone_repos/json-syntax/README.md | # United Income at Capital One created this project with the intention of it helping us with JSON parsing. This project has not gained wide adoption. As such, we have stopped providing updates to this project and archived it as of June 28th, 2021.
# json-syntax
A Python library to translate between JSON compatible structures and native Python
classes using customizable rules.
## Use case
If you're like the authors, you tried writing an encoding function that attempted to
encode and decode by interrogating the types at runtime, maybe calling some method like
`asdict`. This works fine for generating JSON, but it gets sketchy<sup
id="a1">[1](#f1)</sup> when trying to decode the same JSON.
Further, we have annotations in Python 3! Even if you're not using a type checker, just
labeling the types of fields makes complex data structures far more comprehensible.
This library is aimed at projects that have a complex JSON schema that they're trying to
structure using libraries like [attrs][].
* It exploits [gradual typing][] via annotations, [typing][] and [dataclasses][]
* It expects classes to be *statically* described using types
* But a fallback can be provided to handle data described at runtime
* It provides hooks to normalize legacy inputs
* It makes it trivial to extend the library with your own rules
* Actions and Rules are simply functions
* Encoders and decoders can be pickled
* The library has no dependencies of its own on python 3.7+
* It does not read or write JSON
### Supported types
* Atoms including `None`, `bool`, `int`, `float`, `str`.
* Floats may optionally be represented as strings.
* The `decimal.Decimal` class, represented as itself or in string form.
* The `datetime.date` and `datetime.datetime` classes, represented in ISO8601 form.
* Preliminary support for `datetime.timedelta` as ISO8601 time durations.
* Subclasses of `enum.Enum`, represented by the string names.
* Also, a `faux_enums` rule will accept an Enum type if you just use strings in your
code.
* The `typing.Optional[E]` type allows a JSON `null` to be substituted for a value.
* Collections including `typing.List[E]`, `typing.Tuple[E, ...]`, `typing.Set[E]` and
`typing.FrozenSet[E]`.
* The `...` is [literal][ellipsis] and indicates a homogenous tuple, essentially a
frozen list.
* The `typing.Dict[K, V]` type allows a JSON object to represent a homogenous `dict`.
* Restriction: the keys must be strings, ints, enums or dates.
* **New**: The `typing.TypedDict` type allows a JSON object to represent a `dict` with specific
keys.
* Python classes implemented using `attrs.attrs`, `dataclasses.dataclass` are
represented as JSON dicts and
* Named tuples via `typing.NamedTuple` and heterogenous tuples via `typing.Tuple`.
* Though, you should consider converting these to `dataclass`.
* The `typing.Union[A, B, C]` rule will recognize alternate types by inspection.
In addition, `dataclass` and `attrs` classes support hooks to let you completely customize
their JSON representation.
### Extras
These were originally intended as examples for how to use the package, but they're potentially
useful in their own right.
* [A ruleset][extras ddb] for use with AWS DynamoDB is included with basic facilities.
* Restriction: No general support for `typing.Union`, only `Optional`.
* Restriction: No general support for `Set`, only the special cases that are native to DynamoDB.
* [A `Flag` pseudo-type][extras flag] allows you to use regular strings directly as flags.
* [A rule][extras loose] that will accept a complete `datetime` and return a `date` by truncating the timestamp.
## Usage
This example is also implemented in unit tests. First, let's declare some classes.
```python
import json_syntax as syn
from dataclasses import dataclass # attrs works too
from decimal import Decimal
from datetime import date
from enum import Enum
@dataclass
class Account:
user: str
transactions: List['Trans'] # Forward references work!
balance: Decimal = Decimal()
class TransType(Enum):
withdraw = 0
deposit = 1
@dataclass
class Trans:
type: TransType
amount: Decimal
stamp: date
```
We'll next set up a RuleSet and use it to construct an encoder. The `std_ruleset`
function is a one-liner with some reasonable overrides. Here, we've decided that because
some intermediate services don't reliably retain decimal values, we're going to
represent them in JSON as strings.
```python
>>> rules = syn.std_ruleset(decimals=syn.decimals_as_str)
>>> encode_account = rules.python_to_json(typ=Account)
>>> decode_account = rules.json_to_python(typ=Account)
```
The RuleSet examines the type and verb, searches its list of Rules, and then uses the
first one that handles that type and verb to produce an Action.
For example, `attrs_classes` is a Rule that recognizes the verbs `python_to_json` and
`json_to_python` and will accept any class decorated with `@attr.s` or `@dataclass`.
It will scan the fields and ask the RuleSet how to encode them. So when it sees
`Account.user`, the `atoms` rule will match and report that converting a `str` to JSON
can be accomplished by simply calling `str` on it. The action it returns will literally
be the `str` builtin.
Thus `attrs_classes` will build a list of attributes on `Account` and actions to convert
them, and constructs an action to represent them.
```python
>>> sample_value = Account(
... 'bob', [
... Trans(TransType.withdraw, Decimal('523.33'), date(2019, 4, 4))
... ], Decimal('77.00')
... )
>>> encode_account(sample_value)
{
'user': 'bob',
'transactions': [
{
'type': 'withdraw',
'amount': '523.33',
'stamp': '2019-04-04'
}
], 'balance': '77.00'
}
```
#### Encoding and decoding
The aim of all this is to enable reliable usage with your preferred JSON library:
```python
with open('myfile.json', 'r') as fh:
my_account = decode_account(json.load(fh))
with open('myfile.json', 'w') as fh:
json.dump(encode_account(my_account))
```
### Using generic types
Generally, the [typing][] module simply provides capital letter type names that explicitly
correspond to the internal types. [See TYPES for a more thorough introduction][types].
And you specify the type of the contents as a parameter in square brackets.
Thus we have:
* `list` and `List[E]`
* `set` and `Set[E]`
* `tuple` and `Tuple[E, ...]` is a special case!
* `frozenset` and `FrozenSet[E]`
* `dict` and `Dict[K, V]`
Tuple is a special case. In Python, they're often used to mean "frozenlist", so
`Tuple[E, ...]` (the `...` is [the Ellipsis object][ellipsis]) indicates all elements have
the type `E`.
They're also used to represent an unnamed record. In this case, you can use
`Tuple[A, B, C, D]` or however many types. It's generally better to use a `dataclass`.
The standard rules don't support:
1. Using abstract types like `Iterable` or `Mapping`.
2. Using type variables.
3. Any kind of callable, coroutine, file handle, etc.
#### Support for deriving from Generic
There is experimental support for deriving from `typing.Generic`. An `attrs` or `dataclass`
may declare itself a generic class. If another class invokes it as `YourGeneric[Param,
Param]`, those `Param` types will be substituted into the fields during encoding. This is
useful to construct parameterized container types. Example:
@attr.s(auto_attribs=True)
class Wrapper(Generic[T, M]):
body: T
count: int
messages: List[M]
@attr.s(auto_attribs=True)
class Message:
first: Wrapper[str, str]
second: Wrapper[Dict[str, str], int]
#### Unions
A union type lets you present alternate types that the converters will attempt in
sequence, e.g. `typing.Union[MyType, int, MyEnum]`.
This is implemented in the `unions` rule as a so-called<sup id="a2">[2](#f2)</sup>
undiscriminated union. It means the module won't add any additional information to the
value such as some kind of explicit tag.
When converting from Python to JSON, the checks are generally just using `isinstance`,
but when converting from JSON to Python, the check may be examining strings and `dict`
fields.
Thus, ambiguous values, especially JSON representations, may confuse the decoder.
See the section on [sharp edges][sharp] for more details.
### Hooks
We'll first examine decode and encode hooks. These let us entirely rewrite the JSON
representation before the normal logic is applied.
Let's suppose our `Account` class used to name the `balance` field `bal` and we need to
support legacy users.
```python
@dataclass
class Account:
@classmethod
def __json_pre_decode__(cls, value):
if 'bal' in value:
value = dict(value)
value['balance'] = value.pop('bal')
return value
def __json_post_encode__(self, value):
return dict(value, bal=value['balance'])
...
```
When we decode the value, the following sequence of steps takes place:
1. `__json_pre_decode__` is called with `{'user': 'bob', 'bal': '77.0', ...}` and it
returns `{'user': 'bob', 'balance': '77.0', ...}`
2. Decoders are called against `user` and `balance` and the other fields
3. The resulting dictionary is passed to `Account(**result)` to construct the instance.
During encoding, the reverse sequence takes place:
1. The instance's fields are read and passed to encoders.
2. The values are combined into a `dict`.
3. `__json_post_encode__` is called with `{'user': 'bob', 'balance': '77.0', ...}` and
can adjust the field name to `bal`.
#### JSON type check hook
Type checks are only used in _json-syntax_ to support `typing.Union`; in a nutshell, the
`unions` rule will inspect some JSON to see which variant is present.
If a type-check hook is not defined, `__json_pre_decode__` will be called before the
standard check is completed. (The standard check attempts to determine if required
fields are present and have the correct type.)
If you have information that can determine the type faster, a check hook can help.
Going back to our Account example, suppose we decide to support multiple account types
through a special ``class`` field. This is faster and more robust.
```python
class AbstractAccount:
@classmethod
def __json_check__(cls, value):
return isinstance(value, dict) and value.get('class') == cls.__name__
@dataclass
class AccountA(AbstractAccount):
...
encode_account = rules.lookup(typ=Union[AccountA, AccountB, AccountC],
verb='python_to_json')
```
### Adding custom rules
See [the extras][] for details on custom rules, but generally a rule is just a
function. Say, for instance, your type has class methods that encode and decode, this
would be sufficient for many cases:
```python
def my_rule(verb, typ, ctx):
if issubclass(typ, MyType):
if verb == 'json_to_python':
return typ.decoder
elif verb == 'python_to_json':
return typ.encoder
```
If your rule needs an encoder or decoder for a standard type, it can call
`ctx.lookup(verb=verb, typ=subtype)`. The helper functions defined in `json_syntax.action_v1`
are intended to stay the same so that custom rules can reuse them.
### Debugging ambiguous structures
(May need more docs and some test cases.)
As _json-syntax_ tries to directly translate your Python types to JSON, it is possible
to write ambiguous structures. To avoid this, there is a handy `is_ambiguous` method:
```python
# This is true because both are represented as an array of numbers in JSON.
rules.is_ambiguous(typ=Union[List[int], Set[int]])
@dataclass
class Account:
user: str
address: str
# This is true because such a dictionary would always match the contents of the account.
rules.is_ambiguous(typ=Union[Dict[str, str], Account])
```
The aim of this is to let you put a check in your unit tests to make sure data can be
reliably expressed given your particular case.
Internally, this is using the `PATTERN` verb to represent the JSON pattern, so this may
be helpful in understanding how _json-syntax_ is trying to represent your data:
```python
print(rules.lookup(typ=MyAmbiguousClass, verb='show_pattern'))
```
### Sharp edges
_The RuleSet caches encoders._ Construct a new ruleset if you want to change settings.
_Encoders and decoders do very little checking._ Especially, if you're translating
Python to JSON, it's assumed that your Python classes are correct. The encoders and
decoders may mask subtle issues as they are calling constructors like `str` and `int`
for you. And, by design, if you're translating from JSON to Python, it's assumed you
want to be tolerant of extra data.
_Everything to do with typing._ It's a bit magical and sort of wasn't designed for this.
[We have a guide to it to try and help][types].
_Union types._ You can use `typing.Union` to allow a member to be one of some number of
alternates, but there are some caveats. You should use the `.is_ambiguous()` method of
RuleSet to warn you of these.
_Atom rules accept specific types._ At present, the rules for atomic types (`int`,
`str`, `bool`, `date`, `float`, `Decimal`) must be declared as exactly those types. With
multiple inheritance, it's not clear which rule should apply
_Checks are stricter than converters._ For example, a check for `int` will check whether
the value is an integer, whereas the converter simply calls `int` on it. Thus there are
inputs for where `MyType` would pass but `Union[MyType, Dummy]` will fail. (Note
that `Optional` is special-cased to look for `None` and doesn't have this problem.)
_Numbers are hard._ See the rules named `floats`, `floats_nan_str`, `decimals`,
`decimals_as_str` for details on how to get numbers to transmit reliably. There is no rule for
fractions or complex numbers as there's no canonical way to transmit them via JSON.
## Maintenance
This package is maintained via the [poetry][] tool. Some useful commands:
1. Setup: `poetry install`
2. Run tests: `poetry run pytest tests/`
3. Reformat: `black json_syntax/ tests/`
4. Generate setup.py: `dephell deps convert -e setup`
5. Generate requirements.txt: `dephell deps convert -e req`
### Running tests via docker
The environments for 3.4 through 3.9 are in `pyproject.toml`, so just run:
dephell deps convert -e req # Create requirements.txt
dephell docker run -e test34 pip install -r requirements.txt
dephell docker run -e test34 pytest tests/
dephell docker shell -e test34 pytest tests/
dephell docker destroy -e test34
### Notes
<b id="f1">1</b>: Writing the encoder is deceptively easy because the instances in
Python has complete information. The standard `json` module provides a hook to let
you encode an object, and another hook to recognize `dict`s that have some special
attribute. This can work quite well, but you'll have to encode *all* non-JSON types
with dict-wrappers for the process to work in reverse. [↩](#a1)
<b id="f2">2</b>: A discriminated union has a tag that identifies the variant, such as
status codes that indicate success and a payload, or some error. Strictly, all unions
must be discriminated in some way if different code paths are executed. In the `unions`
rule, the discriminant is the class information in Python, and the structure of the JSON
data. A less flattering description would be that this is a "poorly" discriminated
union. [↩](#a2)
[poetry]: https://poetry.eustace.io/docs/#installation
[gradual typing]: https://www.python.org/dev/peps/pep-0483/#summary-of-gradual-typing
[the extras]: https://github.com/UnitedIncome/json-syntax/tree/master/json_syntax/extras
[typing]: https://docs.python.org/3/library/typing.html
[types]: https://github.com/UnitedIncome/json-syntax/blob/master/TYPES.md
[attrs]: https://attrs.readthedocs.io/en/stable/
[dataclasses]: https://docs.python.org/3/library/dataclasses.html
[sharp]: https://github.com/UnitedIncome/json-syntax/blob/master/README.md#sharp-edges
[ellipsis]: https://docs.python.org/3/library/stdtypes.html#the-ellipsis-object
[extras ddb]: https://github.com/UnitedIncome/json-syntax/tree/master/json_syntax/extras/dynamodb.py
[extras flag]: https://github.com/UnitedIncome/json-syntax/tree/master/json_syntax/extras/flags.py
[extras loose]: https://github.com/UnitedIncome/json-syntax/tree/master/json_syntax/extras/loose_dates.py
|
0 | capitalone_repos | capitalone_repos/json-syntax/TYPES.md | # Type hints and generic types for the practitioner
One pitfall of type hints and generic types is they are different from what Python coders already know. Even if you were diligent and read the entire [tutorial][], they didn't get a mention and the standard library reference has them squirrled away under "development tools." They're obscure, but we need them<sup id="a1">[1](#f1)</sup> so we ought to explain them.
## What do they do?
Type hints are used by static type checkers like [mypy][] and [Pyre][] to prove that functions are passing the correct type of data to each other. They are the same concept as [TypeScript][] and [Flow][] in the Javascript world.
The premise of "gradual typing" is that it's optional. If code works, leave it alone. If you chase down a `TypeError`, though, you can add a few annotations directly in the source rather than write yet another unit test.
Generic types are the weird capitalized square bracketed types like `Dict[str, Tuple[int, ...]]` provided by the [typing][] module.
## What's the difference between a type, a type hint and a generic type?
In Python, the primary distinction is that type hints and generic types are not native to the interpreter.
To summarize them:
* Types
* The regular `int`, `bool`, `set`, `Decimal` you already know.
* A **value** always has a type, so `5` is implicitly `int`.
* Used extensively by the interpreter.
* Type hints
* Usually looks like `name: hint`.
* Uses either a type or a generic type.
* A **variable** _may_ have a hint.
* Largely ignored by the interpreter.
* (Also an argument to a function or member of a class has a hint.)
* Generic types
* Imported from [typing][].
* Look like `FrozenSet[Decimal]`, `Dict[str, Tuple[int, str]]`.
* Used in hints to describe the type of a variable with greater precision.
The reason for all this is that if you can nail down what kind of data is coming into a function, your code doesn't have to deal with all kinds of exceptional cases.
Python doesn't have a problem with a list like `[1, 2, 'three', 'four']`, but if you're trying to sum the elements of the list, it's going to fail because summation is only defined for numbers.
A generic type like `List[int]` is an assertion that the specific `list` will _only_ contain `int`s. A type checker can scan those assertions and look for contradictions. It's going to scan your code, finding those assertions and try to generate a proof that your code is sound _before_ you run it.
And just as type checkers can use type hints to generate proofs, json-syntax can unpack such assertions and write a converter based on the structure of the data.
## How do I use type hints in my code?
This document won't go into how type checkers use hints, and [mypy][] and [Pyre][] both have tutorials. In a nutshell, though, you can put hints in your function signatures.
For what we're trying to do, which is describe your data so you can convert it to and from JSON, the nicest way is through either the [attrs][] package or the (since 3.7) standard [dataclasses][] package. They're similar because `dataclasses` is a standardized `attrs`. It typically looks something like this:
```python
@attr.s(auto_attribs=True)
class Employee:
name: str
widgets_made: int
# Don't actually mix attrs and dataclasses,
# this is just to show they're similar.
@dataclass
class Department:
name: str
budget: float
staff: List[Employee]
@property
def widgets_made(self):
return sum(peon.widgets_made for peon in staff)
```
And what they do is write the `__dunder__` methods for you:
```python
>>> Employee('Bob', 55) # __init__ and __repr__
Employee('Bob', 55)
>>> Employee('Bob', 55) == Employe('Bob', 55) # comparisons
True
>>> {Employee('Bob', 55), Employee('Liz', 56)} # __hash__
{Employee('Bob', 55), Employee('Liz', 56)}
```
That said, the type hints don't enforce anything by themselves:
```python
>>> Employee(name=123, widgets_made='wat?')
Employee(name=123, widgets_made='wat?')
```
But [mypy][mypy-add] and [Pyre][pyre-dc]<sup id="a4">[4](#f4)</sup> can use them to check the correctness of your code, and json-syntax uses them to write converters for you.
### Are generic types subclasses of their related types?
Let's ask Python:
```python
>>> issubclass(List[int], list)
TypeError: issubclass() arg 1 must be a class
>>> isinstance([1, 2, 3], List[int])
TypeError: Subscripted generics cannot be used with class and instance checks
>>> List[int]([1, 2, 3])
TypeError: Type List cannot be instantiated; use list() instead
>>> type(List[int])
<class 'typing._GenericAlias'>
```
Generic types are special objects that _describe_ types, but there's a twist. Let's check the method-resolution order of `List[int]` to list all the known base classes:
```python
>>> List[int].mro()
[<class 'list'>, <class 'object'>]
```
The `mro` method is only defined on `type`s, and it turns out `List[int]` *does* inherit from `list`. Weirder still:
```python
>>> class MyList(List[int]):
... def average(self):
... return sum(self) / len(self)
>>> MyList([1, 2, 3]).average()
2
>>> MyList.mro()
[<class '__main__.MyList'>, <class 'list'>, <class 'typing.Generic'>, <class 'object'>]
```
So it's valid for your own class to inherit from `List[int]`, whereupon it will behave like a `list`.
Your type checker can then enforce that your code only stores `int`s in that class for you.
At the time of writing, inheriting from a generic type won't work with json-syntax; we'll have to see if and how people want to use that.
## How does it work?
As an example, let's suppose we have a type hint `Set[date]` and we want to convert that back and forth between the Python representation and a reasonable<sup id="a2">[2](#f2)</sup> JSON representation.
```python
>>> json.loads('["2020-02-02", "2020-03-03", "2020-04-04"]')
['2020-02-02', '2020-03-03', '2020-04-04']
```
We want a decoder that will convert this to a Python set. And json-syntax will write us a function to do that based on the type hints:
```python
decoder = lookup(verb='json_to_python', typ=Set[date])
# Should result in equivalent to:
def decoder(value):
return {date.fromisoformat(elem) for elem in data}
# And so we get our desired python values:
>>> decoder(['2020-02-02', '2020-03-03', '2020-04-04'])
{date(2020, 2, 2), date(2020, 3, 3), date(2020, 4, 4)}
```
### Under the hood
The algorithm can be visualized as transforming one tree into another.
```
Type convert_type
/ \ ---> / \
Type Type convert_type convert_type
Set convert_set
| ----> |
date convert_date
```
We can deconstruct complex types, like an `attrs` class:
```python
>>> [(a.name, a.type) for a in attrs.fields(Employee)]
[('name', str), ('widgets_made', int)]
```
Back to our example:
```python
decoder = lookup(verb='json_to_python', typ=Set[date])
```
We first need to take apart that generic `Set[date]`:
```python
>>> from typing import Set
>>> Set[date].__origin__
set
>>> Set[date].__args__
(date,)
```
We know it's a python `set` of something, and that it takes a single argument `date`.
The `sets` rule catches that we're dealing with a set, but it doesn't know how `date`s work, so it internally calls:
```python
inner = lookup(verb='json_to_python', typ=date)
```
The `dates` rule knows that `date` is an atom, it has no inner types to deal with. So it can simply return:
```python
def convert_date(value):
return date.fromisoformat(value)
```
The `date.fromisoformat` method will parse a correctly formatted `str` to a `date`.
Now we're back in the `sets` rule and it knows that in the JSON representation it will have a `list` of something that it should convert to a `set`. Its action is a little less elegant than our original set comprehension:
```python
def convert_set(value, inner):
return set(map(inner, value))
```
We use the [functools.partial][functools] builtin<sup id="a3">[3](#f3)</sup> to put this together, and wind up with an expression like:
```python
decoder = partial(convert_set, inner=convert_date)
# Same as:
def decoder(value):
return convert_set(value, inner=convert_date)
```
### What are other generic types in `typing` for?
Some of the generic types are generic versions of abstract base classes from `collections` and others, which can be used to write custom classes, or to declare as little as possible. In the latter case, if your function just uses `for` to walk through the contents of an argument, it could hint that argument with `Iterable[Whatever]`.
This package doesn't have any standard rules supporting abstract types, as they seem like they'd suit specific use cases.
Type variables are used to allow types to change in lockstep. You might define a function `first` like this:
```python
T = TypeVar('T')
def first(elems: Iterable[T]) -> T:
for elem in elems:
return elem
```
The `T` may be different when the function is invoked in different contexts, but a type checker could infer from this that if `a: Set[str]` and `b = first(a)` that `b`'s type is `str`.
You can create a generic user-defined class with type variables. This package doesn't support type variables yet.
```python
@dataclass
class Pair(Generic[T]):
a: T
b: Set[T]
@dataclass
class Info:
x: Pair[int]
y: Pair[str]
# Effectively the same as:
@dataclass
class PairInt:
a: int
b: Set[int]
@dataclass
class PairStr:
a: str
b: Set[str]
@dataclass
class Info:
x: PairInt
y: PairStr
```
The `Union` generic type lets you select alternate types, and this is supported by json-syntax. There are some caveats, mentioned in the top level README.
## Footnotes
<b id="f1">1</b>: It's trivial to write an encoder that asks Python types to convert themselves to JSON, and `attrs`, `simplejson` and other libraries support this. Writing the decoder is trickier because you have to reconstruct that information. It can be done, it's how we did it before writing this library, but our experience was that it became a giant kludge over time.[↩](#a1)
<b id="f2">2</b>: This package defines "reasonable" as representing a set of dates as a JSON array of strings in the common ISO8601 format. You may have different needs, so you can swap in your own rules, and please submit a PR if you think they're addressing a broader need.[↩](#a2)
<b id="f3">3</b>: Using `partial` ensures that the converter can be pickled; not sure at this time if that's really helpful but it's easy to do. It should also make an `explain` function relatively easy to write.[↩](#a3)
<b id="f4">4</b>: Pyre only seems to support `dataclasses`.[↩](#a4)
[tutorial]: https://docs.python.org/3/tutorial/index.html
[dataclasses]: https://docs.python.org/3/library/dataclasses.html
[functools]: https://docs.python.org/3/library/functools.html
[typing]: https://docs.python.org/3/library/typing.html
[attrs]: https://attrs.readthedocs.io/en/stable/
[pyre]: https://pyre-check.org/
[pyre-dc]: https://github.com/facebook/pyre-check/blob/master/plugin/dataClass.ml
[mypy]: http://mypy-lang.org/
[mypy-add]: https://mypy.readthedocs.io/en/stable/additional_features.html
[typescript]: https://www.typescriptlang.org/
[flow]: https://flow.org/
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/.circleci/config.yml | version: 2.1
jobs:
test-34:
docker:
- image: circleci/python:3.4
environment:
&std_env
TERM: xterm
LANG: en_US.UTF-8
PIP_DISABLE_PIP_VERSION_CHECK: 1
working_directory: ~/json-syntax
steps:
&steps34
- checkout
- run:
name: Set up virtualenv
command: |
pip install --user 'poetry>=1'
python -m poetry install
- run:
name: Run tests
command: |
python -m poetry run pytest tests/
- store_artifacts: # If a property test fails, this contains the example that failed.
path: ".hypothesis"
destination: ".hypothesis"
test-35:
docker:
- image: circleci/python:3.5
environment: *std_env
steps: *steps34
working_directory: ~/json-syntax
test-36:
docker:
- image: circleci/python:3.6
environment: *std_env
working_directory: ~/json-syntax
steps:
&steps36
- checkout
- run:
name: Set up virtualenv
command: |
pip install --user 'poetry>=1'
python -m poetry install
- run:
name: Run tests
command: |
python -m poetry run pytest --doctest-modules json_syntax/ tests/
- store_artifacts: # If a property test fails, this contains the example that failed.
path: ".hypothesis"
destination: ".hypothesis"
test-37:
docker:
- image: circleci/python:3.7
environment: *std_env
steps: *steps36
working_directory: ~/json-syntax
test-38:
docker:
- image: circleci/python:3.8
environment: *std_env
steps: *steps36
working_directory: ~/json-syntax
workflows:
test:
jobs:
- test-34
- test-35
- test-36
- test-37
- test-38
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/common.py | from importlib import import_module
class Rules:
def __init__(self, *rules):
self.rules = rules
def lookup(self, verb, typ, accept_missing=False):
for rule in self.rules:
result = rule(verb=verb, typ=typ, ctx=self)
if result is not None:
return result
if accept_missing:
return None
else:
raise RuntimeError("No rule for verb={}, typ={}".format(verb, typ))
class SoftMod:
def __init__(self, *modules, allow_SyntaxError=False):
self.mods = mods = []
for name in modules:
try:
mods.append(import_module(name))
except ImportError:
pass
except SyntaxError:
if not allow_SyntaxError:
raise
def __getattr__(self, name):
for mod in self.mods:
val = getattr(mod, name, None)
if val is not None:
return val
return None
typing = SoftMod("typing", "typing_extensions")
dataclasses = SoftMod("dataclasses")
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/test_types.py | import pytest
from json_syntax import types as tt
from .common import typing as t, SoftMod
from .types_attrs_common import T, U
import attr
ann = SoftMod("tests.types_attrs_ann", allow_SyntaxError=True)
@attr.s
class GenExample(t.Generic[T, U]):
body = attr.ib(type=T)
count = attr.ib(type=int)
messages = attr.ib(type=t.List[U])
def test_has_origin_not_typing():
"Test that has_origin disregards a type value if it's not from `typing`."
assert tt.has_origin(list, list)
def test_has_origin_handle_tuple():
"Test that has_origin accepts a tuple of origins."
assert tt.has_origin(t.List[int], (str, list, tuple))
def test_has_origin_num_args():
"Test that has_origin checks the number of arguments."
assert tt.has_origin(t.Tuple[int, str, float], tuple, num_args=3)
def test_issub_safe_normal_type1():
"Test that issub_safe behaves like issubclass for normal types."
assert tt.issub_safe(bool, int)
assert tt.issub_safe(bool, (int, float, str))
assert not tt.issub_safe(int, str)
def test_issub_safe_normal_type2():
"Test that issub_safe returns False for generic types."
assert not tt.issub_safe(t.List[int], list)
def test_eval_type_imports():
"Test that the private ``typing._eval_type`` function imports."
assert (
tt._eval_type is not None
), "typing._eval_type is not available, investigate an alternative."
class SomeClass:
some_type = t.List["AnotherClass"]
class AnotherClass:
pass
def test_resolve_fwd_ref():
"Test that resolve_fwd_ref correctly identifies the target of a forward reference."
actual = tt.resolve_fwd_ref(SomeClass.some_type, SomeClass)
assert tt.has_origin(actual, list)
assert actual.__args__ == (AnotherClass,)
def test_resolve_fwd_ref_bad_context():
"Test that resolve_fwd_ref returns the original if the module can't be determined."
Forward = t.ForwardRef or t._ForwardRef
subj = Forward("AnotherClass")
actual = tt.resolve_fwd_ref(subj, "dummy")
assert actual is subj
@pytest.mark.parametrize(
"GenClass, origin",
[
(GenExample, None),
(GenExample[str, int], GenExample),
(t.List[int], t.List),
(t.List["int"], t.List),
(t.List, None),
(t.Union[int, str], None),
(int, None),
],
)
def test_get_generic_origin(GenClass, origin):
"Test that get_generic_origin finds the origin class, unless the class is not generic."
assert tt.get_generic_origin(GenClass) == origin
@pytest.mark.parametrize(
"GenClass, origin",
[
(GenExample, GenExample),
(GenExample[str, int], GenExample),
(t.List[int], list),
(t.List["int"], list),
(t.List, list),
(t.Union[int, str], t.Union),
(t.Union, t.Union),
(int, int),
],
)
def test_get_origin(GenClass, origin):
"Test that get_generic_origin finds the origin class, unless the class is not generic."
assert tt.get_origin(GenClass) == origin
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/test_union.py | import pytest
import attr
from datetime import date, datetime
from decimal import Decimal
from enum import Enum
from itertools import product
from typing import Union, List, Tuple, Set, FrozenSet, Dict
from json_syntax import std_ruleset
from json_syntax.helpers import PY2JSON, JSON2PY, INSP_PY, INSP_JSON, NoneType
@attr.s(frozen=True)
class Point:
x = attr.ib(type=float)
y = attr.ib(0.0, type=float)
class Dir(Enum):
UP = 1
DOWN = 2
atoms = [(NoneType, None, None), (bool, True, True)]
nums = [(int, 5, 5), (float, 3.3, 3.3), (Decimal, Decimal("5.5"), Decimal("5.5"))]
strings = [
(str, "str", "str"),
(date, date(2010, 10, 10), "2010-10-10"),
(datetime, datetime(2011, 11, 11, 11, 11, 11), "2011-11-11T11:11:11"),
(Dir, Dir.UP, "UP"),
]
arrays = [
(List[Point], [Point(x=4.5, y=6.6)], [{"x": 4.5, "y": 6.6}]),
(Tuple[Point, ...], (Point(x=4.5, y=6.6),), [{"x": 4.5, "y": 6.6}]),
(Set[Point], {Point(x=4.5, y=6.6)}, [{"x": 4.5, "y": 6.6}]),
(FrozenSet[Point], frozenset([Point(x=4.5, y=6.6)]), [{"x": 4.5, "y": 6.6}]),
]
dicts = [
(Point, Point(x=4.5, y=6.6), {"x": 4.5, "y": 6.6}),
(Dict[Dir, Decimal], {Dir.UP: Decimal("7.7")}, {"UP": Decimal("7.7")}),
(Dict[str, float], {"a": 2.3, "b": 3.4}, {"a": 2.3, "b": 3.4}),
]
cats = [atoms, nums, strings, arrays, dicts]
@pytest.mark.parametrize("typ,py,js", [trip for cat in cats for trip in cat])
def test_simple(typ, py, js):
rs = std_ruleset()
act = rs.lookup(verb=PY2JSON, typ=typ)
assert act(py) == js
act = rs.lookup(verb=JSON2PY, typ=typ)
assert act(js) == py
def _pairs():
for i in range(0, len(cats)):
lefts = cats[i]
rights = cats[(i + 2) % len(cats)]
yield from product(lefts, rights)
def cvt_map():
for left, right in _pairs():
left_type, left_python, left_json = left
right_type, right_python, right_json = right
typ = Union[left_type, right_type]
yield (PY2JSON, typ, left_python, left_json)
yield (PY2JSON, typ, right_python, right_json)
yield (JSON2PY, typ, left_json, left_python)
yield (JSON2PY, typ, right_json, right_python)
@pytest.mark.parametrize("verb,typ,subj,expect", cvt_map())
def test_convert_unions(verb, typ, subj, expect):
"Test that the unions rule is able to convert possible types."
action = std_ruleset().lookup(verb=verb, typ=typ)
assert action(subj) == expect
def check_map():
for left, right in _pairs():
left_type, left_python, left_json = left
right_type, right_python, right_json = right
typ = Union[left_type, right_type]
yield (INSP_PY, typ, left_python)
yield (INSP_PY, typ, right_python)
yield (INSP_JSON, typ, left_json)
yield (INSP_JSON, typ, right_json)
@pytest.mark.parametrize("verb,typ,subj", check_map())
def test_check_unions(verb, typ, subj):
"Test that the unions rule is able to verify possible types."
action = std_ruleset().lookup(verb=verb, typ=typ)
assert action(subj)
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/test_std.py | import pytest
from tests.common import Rules
from unittest.mock import Mock
from json_syntax import std
from json_syntax.helpers import JSON2PY, PY2JSON, INSP_PY, INSP_JSON, NoneType
from json_syntax.string import stringify_keys
from datetime import datetime, date
from decimal import Decimal
from enum import Enum, IntEnum
import math
from typing import Optional, Union, Tuple, List, Set, FrozenSet, Dict
from pickle import dumps
try:
from typing import OrderedDict # 3.7.2
except ImportError:
OrderedDict = None
Mystery = Tuple["Mystery", "Thing"]
def test_atoms_disregard():
"Test the atoms rule will disregard unknown types and verbs."
assert std.atoms(verb="unknown", typ=str, ctx=Rules()) is None
for verb in (JSON2PY, PY2JSON, INSP_PY, INSP_JSON):
assert std.atoms(verb=verb, typ=Mystery, ctx=Rules()) is None
def test_atoms_str():
"Test the atoms rule will generate encoders and decoders for strings."
decoder = std.atoms(verb=JSON2PY, typ=str, ctx=Rules())
assert decoder("some string") == "some string"
encoder = std.atoms(verb=PY2JSON, typ=str, ctx=Rules())
assert encoder("some string") == "some string"
inspect = std.atoms(verb=INSP_PY, typ=str, ctx=Rules())
assert inspect("string")
assert not inspect(5)
inspect = std.atoms(verb=INSP_JSON, typ=str, ctx=Rules())
assert inspect("string")
assert not inspect(5)
def test_atoms_int():
"Test the atoms rule will generate encoders and decoders for integers."
decoder = std.atoms(verb=JSON2PY, typ=int, ctx=Rules())
assert decoder(77) == 77
encoder = std.atoms(verb=PY2JSON, typ=int, ctx=Rules())
assert encoder(77) == 77
inspect = std.atoms(verb=INSP_PY, typ=int, ctx=Rules())
assert not inspect("string")
assert inspect(5)
inspect = std.atoms(verb=INSP_JSON, typ=int, ctx=Rules())
assert not inspect("string")
assert inspect(5)
def test_atoms_bool():
"Test the atoms rule will generate encoders and decoders for booleans."
decoder = std.atoms(verb=JSON2PY, typ=bool, ctx=Rules())
assert decoder(False) is False
assert decoder(True) is True
encoder = std.atoms(verb=PY2JSON, typ=bool, ctx=Rules())
assert encoder(False) is False
assert encoder(True) is True
inspect = std.atoms(verb=INSP_PY, typ=bool, ctx=Rules())
assert not inspect("string")
assert inspect(True)
inspect = std.atoms(verb=INSP_JSON, typ=bool, ctx=Rules())
assert not inspect("string")
assert inspect(False)
def test_atoms_null():
"Test the atoms rule will generate encoders and decoders for None / null."
decoder = std.atoms(verb=JSON2PY, typ=NoneType, ctx=Rules())
assert decoder(None) is None
with pytest.raises(ValueError):
decoder(5)
encoder = std.atoms(verb=PY2JSON, typ=NoneType, ctx=Rules())
assert encoder(None) is None
with pytest.raises(ValueError):
encoder(5)
inspect = std.atoms(verb=INSP_PY, typ=NoneType, ctx=Rules())
assert inspect(None)
assert not inspect(0)
inspect = std.atoms(verb=INSP_JSON, typ=NoneType, ctx=Rules())
assert inspect(None)
assert not inspect(0)
def test_atoms_picklable():
"Test that actions generated by the atoms rule can be pickled."
actions = [
std.atoms(verb=verb, typ=typ, ctx=Rules())
for verb in [JSON2PY, PY2JSON, INSP_PY, INSP_JSON]
for typ in [str, int, bool, NoneType]
]
assert None not in actions
dumps(actions)
def test_floats_disregard():
"Test the floats rule will disregard unknown types and verbs."
assert std.floats(verb="unknown", typ=str, ctx=Rules()) is None
for verb in (JSON2PY, PY2JSON, INSP_PY, INSP_JSON):
assert std.floats(verb=verb, typ=Mystery, ctx=Rules()) is None
def test_floats():
"Test the floats rule generates encoders and decoders that are tolerant of integers."
decoder = std.floats(verb=JSON2PY, typ=float, ctx=Rules())
assert decoder(77.7) == 77.7
assert decoder(77) == 77.0
assert math.isnan(decoder("nan"))
assert math.isnan(decoder(float("nan")))
encoder = std.floats(verb=PY2JSON, typ=float, ctx=Rules())
assert encoder(77.7) == 77.7
assert encoder(float("inf")) == float("inf")
inspect = std.floats(verb=INSP_PY, typ=float, ctx=Rules())
assert not inspect("string")
assert not inspect("-inf")
assert inspect(float("-inf"))
assert not inspect(44)
assert inspect(77.7)
inspect = std.floats(verb=INSP_JSON, typ=float, ctx=Rules())
assert not inspect("string")
assert not inspect("-inf")
assert inspect(float("-inf"))
assert inspect(44)
assert inspect(77.7)
def test_floats_nan_str():
"Test floats_nan_str rule generates encoders and decoders that stringify 'nan'."
decoder = std.floats_nan_str(verb=JSON2PY, typ=float, ctx=Rules())
assert decoder(77.7) == 77.7
assert decoder(77) == 77.0
assert math.isnan(decoder("nan"))
assert math.isnan(decoder(float("nan")))
encoder = std.floats_nan_str(verb=PY2JSON, typ=float, ctx=Rules())
assert encoder(77.7) == 77.7
assert encoder(float("inf")) == "Infinity"
inspect = std.floats_nan_str(verb=INSP_PY, typ=float, ctx=Rules())
assert not inspect("string")
assert not inspect("-inf")
assert inspect(float("-inf"))
assert not inspect(44)
assert inspect(77.7)
inspect = std.floats_nan_str(verb=INSP_JSON, typ=float, ctx=Rules())
assert not inspect("string")
assert not inspect("-inf")
assert inspect(float("-inf"))
assert inspect(44)
assert inspect(77.7)
def test_floats_picklable():
"Test that actions generated by the floats rule can be pickled."
actions = [
rule(verb=verb, typ=float, ctx=Rules())
for verb in [JSON2PY, PY2JSON, INSP_PY, INSP_JSON]
for rule in (std.floats, std.floats_nan_str)
]
assert None not in actions
dumps(actions)
def test_decimals_disregard():
"Test the decimals rule will disregard unknown types and verbs."
assert std.decimals(verb="unknown", typ=date, ctx=Rules()) is None
assert std.decimals(verb=JSON2PY, typ=Mystery, ctx=Rules()) is None
assert std.decimals(verb=PY2JSON, typ=Mystery, ctx=Rules()) is None
assert std.decimals(verb=INSP_JSON, typ=Mystery, ctx=Rules()) is None
assert std.decimals(verb=INSP_PY, typ=Mystery, ctx=Rules()) is None
def test_decimals():
"Test the decimals rule will generate encoders and decoders for decimals."
decoder = std.decimals(verb=JSON2PY, typ=Decimal, ctx=Rules())
assert decoder(Decimal("77.7")) == Decimal("77.7")
encoder = std.decimals(verb=PY2JSON, typ=Decimal, ctx=Rules())
assert encoder(Decimal("77.7")) == Decimal("77.7")
inspect = std.decimals(verb=INSP_PY, typ=Decimal, ctx=Rules())
assert not inspect("string")
assert not inspect(44)
assert not inspect(77.7)
assert not inspect("77.7")
assert inspect(Decimal("77.7"))
inspect = std.decimals(verb=INSP_JSON, typ=Decimal, ctx=Rules())
assert not inspect("string")
assert not inspect(44)
assert not inspect(77.7)
assert not inspect("77.7")
assert inspect(Decimal("77.7"))
def test_decimals_as_str_disregard():
"Test the decimals_as_str rule will disregard unknown types and verbs."
assert std.decimals_as_str(verb="unknown", typ=date, ctx=Rules()) is None
assert std.decimals_as_str(verb=JSON2PY, typ=Mystery, ctx=Rules()) is None
assert std.decimals_as_str(verb=PY2JSON, typ=Mystery, ctx=Rules()) is None
assert std.decimals_as_str(verb=INSP_JSON, typ=Mystery, ctx=Rules()) is None
assert std.decimals_as_str(verb=INSP_PY, typ=Mystery, ctx=Rules()) is None
def test_decimals_as_str():
"Test the decimals_as_str rule will generate encoders and decoders for decimals."
decoder = std.decimals_as_str(verb=JSON2PY, typ=Decimal, ctx=Rules())
assert decoder(Decimal("77.7")) == Decimal("77.7")
assert decoder("77.7") == Decimal("77.7")
encoder = std.decimals_as_str(verb=PY2JSON, typ=Decimal, ctx=Rules())
assert encoder(Decimal("77.7")) == "77.7"
inspect = std.decimals_as_str(verb=INSP_PY, typ=Decimal, ctx=Rules())
assert not inspect("string")
assert not inspect(44)
assert not inspect(77.7)
assert not inspect("77.7")
assert inspect(Decimal("77.7"))
inspect = std.decimals_as_str(verb=INSP_JSON, typ=Decimal, ctx=Rules())
assert not inspect("string")
assert inspect(44)
assert inspect(77.7)
assert inspect("77.7")
assert inspect(Decimal("77.7"))
def test_iso_dates_disregard():
"Test the iso_dates rule will disregard unknown types and verbs."
assert std.iso_dates(verb="unknown", typ=date, ctx=Rules()) is None
assert std.iso_dates(verb=JSON2PY, typ=Mystery, ctx=Rules()) is None
assert std.iso_dates(verb=PY2JSON, typ=Mystery, ctx=Rules()) is None
assert std.iso_dates(verb=INSP_JSON, typ=Mystery, ctx=Rules()) is None
assert std.iso_dates(verb=INSP_PY, typ=Mystery, ctx=Rules()) is None
def test_iso_dates():
"Test the iso_dates rule handles dates using ISO8601 and rejects datetimes."
decoder = std.iso_dates(verb=JSON2PY, typ=date, ctx=Rules())
assert decoder("1776-07-04") == date(1776, 7, 4)
with pytest.raises(ValueError):
decoder("6543-02-01T09:09:09")
encoder = std.iso_dates(verb=PY2JSON, typ=date, ctx=Rules())
assert encoder(date(1776, 7, 4)) == "1776-07-04"
inspect = std.iso_dates(verb=INSP_PY, typ=date, ctx=Rules())
assert inspect(date(1776, 7, 4))
assert not inspect(datetime(1776, 7, 4, 3, 3))
assert not inspect("2000-01-01")
assert not inspect("2000-01-01T03:03:03")
assert not inspect("string")
inspect = std.iso_dates(verb=INSP_JSON, typ=date, ctx=Rules())
assert not inspect(date(1776, 7, 4))
assert not inspect(datetime(1776, 7, 4, 3, 3))
assert inspect("2000-01-01")
assert not inspect("2000-01-01T03:03:03")
assert not inspect("string")
def test_iso_datetimes():
"Test the iso_dates rule generates encoders and decoders for datetimes using ISO8601."
decoder = std.iso_dates(verb=JSON2PY, typ=datetime, ctx=Rules())
assert decoder("6666-06-06T12:12:12.987654") == datetime(
6666, 6, 6, 12, 12, 12, 987654
)
encoder = std.iso_dates(verb=PY2JSON, typ=datetime, ctx=Rules())
assert (
encoder(datetime(6666, 6, 6, 12, 12, 12, 987654))
== "6666-06-06T12:12:12.987654"
)
inspect = std.iso_dates(verb=INSP_PY, typ=datetime, ctx=Rules())
assert not inspect(date(1776, 7, 4))
assert inspect(datetime(1776, 7, 4, 3, 3))
assert not inspect("2000-01-01")
assert not inspect("2000-01-01T03:03:03")
assert not inspect("string")
inspect = std.iso_dates(verb=INSP_JSON, typ=datetime, ctx=Rules())
assert not inspect(date(1776, 7, 4))
assert not inspect(datetime(1776, 7, 4, 3, 3))
assert inspect("2000-01-01")
assert inspect("2000-01-01T03:03:03")
assert not inspect("string")
def test_iso_dates_picklable():
"Test that actions generated by the iso_dates rule can be pickled."
actions = [
std.iso_dates(verb=verb, typ=typ, ctx=Rules())
for verb in [JSON2PY, PY2JSON]
for typ in [date, datetime]
]
assert None not in actions
dumps(actions)
class Enum1(Enum):
ABLE = "a"
BAKER = "b"
CHARLIE = "c"
class Enum2(IntEnum):
ALPHA = 1
BETA = 2
GAMMA = 3
def test_enums_disregard():
"Test the iso_dates rule will disregard unknown types and verbs."
assert std.enums(verb="unknown", typ=Enum1, ctx=Rules()) is None
assert std.enums(verb=JSON2PY, typ=Mystery, ctx=Rules()) is None
assert std.enums(verb=PY2JSON, typ=Mystery, ctx=Rules()) is None
def test_enums():
"Test the enums rule will generate encoders and decoders for enumerated types."
decoder = std.enums(verb=JSON2PY, typ=Enum1, ctx=Rules())
assert decoder("ABLE") == Enum1.ABLE
assert decoder("CHARLIE") == Enum1.CHARLIE
encoder = std.enums(verb=PY2JSON, typ=Enum1, ctx=Rules())
assert encoder(Enum1.BAKER) == "BAKER"
assert encoder(Enum1.CHARLIE) == "CHARLIE"
inspect = std.enums(verb=INSP_PY, typ=Enum1, ctx=Rules())
assert not inspect("ABLE")
assert inspect(Enum1.CHARLIE)
assert not inspect(Enum2.BETA)
inspect = std.enums(verb=INSP_JSON, typ=Enum1, ctx=Rules())
assert not inspect(Enum1.BAKER)
assert not inspect("BETA")
assert inspect("CHARLIE")
def test_enums_int():
"Test the enums rule generates encoders and decoders for enumerated type subclasses."
decoder = std.enums(verb=JSON2PY, typ=Enum2, ctx=Rules())
assert decoder("ALPHA") == Enum2.ALPHA
assert decoder("GAMMA") == Enum2.GAMMA
encoder = std.enums(verb=PY2JSON, typ=Enum2, ctx=Rules())
assert encoder(Enum2.BETA) == "BETA"
assert encoder(Enum2.GAMMA) == "GAMMA"
inspect = std.enums(verb=INSP_PY, typ=Enum2, ctx=Rules())
assert not inspect("ALPA")
assert not inspect(Enum1.CHARLIE)
assert inspect(Enum2.BETA)
inspect = std.enums(verb=INSP_JSON, typ=Enum2, ctx=Rules())
assert not inspect(Enum2.GAMMA)
assert inspect("BETA")
assert not inspect("ABLE")
def test_enums_picklable():
"Test that actions generated by the enums rule can be pickled."
actions = [
std.enums(verb=verb, typ=typ, ctx=Rules())
for verb in [JSON2PY, PY2JSON, INSP_PY, INSP_JSON]
for typ in [Enum1, Enum2]
]
assert None not in actions
dumps(actions)
def test_faux_enums_disregard():
"Test the iso_dates rule will disregard unknown types and verbs."
assert std.faux_enums(verb="unknown", typ=Enum1, ctx=Rules()) is None
assert std.faux_enums(verb=JSON2PY, typ=Mystery, ctx=Rules()) is None
assert std.faux_enums(verb=PY2JSON, typ=Mystery, ctx=Rules()) is None
def test_faux_enums():
"Test the enums rule will generate encoders and decoders for enumerated types."
decoder = std.faux_enums(verb=JSON2PY, typ=Enum1, ctx=Rules())
assert decoder("ABLE") == "ABLE"
with pytest.raises(KeyError):
decoder("OTHER")
encoder = std.faux_enums(verb=PY2JSON, typ=Enum1, ctx=Rules())
assert encoder("BAKER") == "BAKER"
with pytest.raises(KeyError):
encoder("OTHER")
inspect = std.faux_enums(verb=INSP_PY, typ=Enum1, ctx=Rules())
assert inspect("ABLE")
assert not inspect(Enum1.CHARLIE)
assert not inspect(Enum2.BETA)
inspect = std.faux_enums(verb=INSP_JSON, typ=Enum1, ctx=Rules())
assert not inspect(Enum1.BAKER)
assert not inspect("BETA")
assert inspect("CHARLIE")
def test_faux_enums_picklable():
"Test that actions generated by the enums rule can be pickled."
actions = [
std.faux_enums(verb=verb, typ=typ, ctx=Rules())
for verb in [JSON2PY, PY2JSON, INSP_PY, INSP_JSON]
for typ in [Enum1, Enum2]
]
assert None not in actions
dumps(actions)
def test_optional_disregard():
"Test that optional will disregard unknown types and verbs."
assert std.optional(verb="unknown", typ=Optional[int], ctx=Rules()) is None
assert std.optional(verb=JSON2PY, typ=Union[int, str], ctx=Rules()) is None
assert (
std.optional(verb=JSON2PY, typ=Union[int, str, NoneType], ctx=Rules()) is None
)
assert std.optional(verb=JSON2PY, typ=Mystery, ctx=Rules()) is None
assert std.optional(verb=PY2JSON, typ=Mystery, ctx=Rules()) is None
def test_optional():
"Test that optional returns a action that pass non-null values to an inner action."
ctx = Rules(std.atoms)
encoder = std.optional(verb=PY2JSON, typ=Optional[int], ctx=ctx)
assert encoder("77") == 77
assert encoder(None) is None
decoder = std.optional(verb=JSON2PY, typ=Optional[int], ctx=ctx)
assert decoder("77") == 77
assert decoder(None) is None
inspect = std.optional(verb=INSP_PY, typ=Optional[int], ctx=ctx)
assert inspect(77)
assert inspect(None)
assert not inspect("77")
inspect = std.optional(verb=INSP_JSON, typ=Optional[int], ctx=ctx)
assert inspect(77)
assert inspect(None)
assert not inspect("77")
def test_optional_nonstandard():
"Test that optional recognizes Unions that are effectively Optional."
ctx = Rules(std.atoms)
encoder = std.optional(verb=PY2JSON, typ=Union[str, NoneType], ctx=ctx)
assert encoder(77) == "77"
assert encoder(None) is None
decoder = std.optional(verb=JSON2PY, typ=Union[str, NoneType], ctx=ctx)
assert decoder(77) == "77"
assert decoder(None) is None
def test_optional_invalid():
"Test that optional raises if no valid inner type is found."
ctx = Rules(std.atoms)
fake_type = Mock(__origin__=Union, __args__=(NoneType, NoneType))
for verb in (JSON2PY, PY2JSON, INSP_PY, INSP_JSON):
with pytest.raises(TypeError):
std.optional(verb=verb, typ=fake_type, ctx=ctx)
def test_optional_picklable():
"Test that actions generated by the optional rule can be pickled."
ctx = Rules(std.atoms, std.floats)
actions = [
std.optional(verb=verb, typ=typ, ctx=ctx)
for verb in [JSON2PY, PY2JSON]
for typ in [Optional[str], Optional[float], Optional[int], Optional[bool]]
]
assert None not in actions
dumps(actions)
def test_lists_disregards():
"Test that lists disregards unknown types and verbs."
assert std.lists(verb="unknown", typ=List[int], ctx=Rules()) is None
assert std.lists(verb="unknown", typ=Tuple[int, ...], ctx=Rules()) is None
assert std.lists(verb=PY2JSON, typ=bool, ctx=Rules()) is None
assert std.lists(verb=JSON2PY, typ=Tuple[int, str], ctx=Rules()) is None
assert std.lists(verb=INSP_PY, typ=bool, ctx=Rules()) is None
assert std.lists(verb=INSP_JSON, typ=Tuple[int, str], ctx=Rules()) is None
def test_lists_lists():
"Test that lists will generate encoders and decoders for lists."
ctx = Rules(std.atoms)
encoder = std.lists(verb=PY2JSON, typ=List[str], ctx=ctx)
assert encoder([33, 77]) == ["33", "77"]
decoder = std.lists(verb=JSON2PY, typ=List[str], ctx=ctx)
assert decoder([33, 77]) == ["33", "77"]
inspect = std.lists(verb=INSP_PY, typ=List[str], ctx=ctx)
assert not inspect(["33", 77])
assert inspect(["33", "77"])
assert not inspect(("33", "77"))
inspect = std.lists(verb=INSP_JSON, typ=List[str], ctx=ctx)
assert not inspect(["33", 77])
assert inspect(["33", "77"])
assert not inspect(("33", "77"))
def test_lists_tuples():
"Test that lists will generate encoders and decoders for homogenous tuples."
ctx = Rules(std.atoms)
encoder = std.lists(verb=PY2JSON, typ=Tuple[str, ...], ctx=ctx)
assert encoder((33, 77)) == ["33", "77"]
decoder = std.lists(verb=JSON2PY, typ=Tuple[str, ...], ctx=ctx)
assert decoder([33, 77]) == ("33", "77")
inspect = std.lists(verb=INSP_PY, typ=Tuple[str, ...], ctx=ctx)
assert not inspect(("33", 77))
assert inspect(("33", "77"))
assert not inspect(["33", "77"])
inspect = std.lists(verb=INSP_JSON, typ=Tuple[str, ...], ctx=ctx)
assert not inspect(["33", 77])
assert inspect(["33", "77"])
assert not inspect(("33", "77"))
# Prove these tests don't pass spuriously.
assert ["1", "2"] != ("1", "2")
def test_sets_disregards():
"Test that sets disregards unknown types and verbs."
assert std.sets(verb="unknown", typ=Set[int], ctx=Rules()) is None
assert std.sets(verb="unknown", typ=FrozenSet[set], ctx=Rules()) is None
assert std.sets(verb=PY2JSON, typ=bool, ctx=Rules()) is None
assert std.sets(verb=JSON2PY, typ=List[str], ctx=Rules()) is None
assert std.sets(verb=INSP_PY, typ=bool, ctx=Rules()) is None
assert std.sets(verb=INSP_JSON, typ=List[str], ctx=Rules()) is None
def test_sets_sets():
"Test that sets will generate encoders and decoders for sets."
ctx = Rules(std.atoms)
encoder = std.sets(verb=PY2JSON, typ=Set[str], ctx=ctx)
actual = encoder({1, 2, 2, 3})
actual.sort()
assert actual == ["1", "2", "3"]
decoder = std.sets(verb=JSON2PY, typ=Set[str], ctx=ctx)
assert decoder([1, 2, 2, 3]) == {"1", "2", "3"}
inspect = std.sets(verb=INSP_PY, typ=Set[str], ctx=ctx)
assert not inspect({"33", 77})
assert inspect({"33", "77"})
assert not inspect(["33", "77"])
inspect = std.sets(verb=INSP_JSON, typ=Set[str], ctx=ctx)
assert not inspect(["33", 77])
assert inspect(["33", "77"])
assert not inspect({"33", "77"})
def test_sets_frozen():
"Test that sets will generate encoders and decoders for frozen sets."
ctx = Rules(std.atoms)
encoder = std.sets(verb=PY2JSON, typ=FrozenSet[str], ctx=ctx)
actual = encoder(frozenset([1, 2, 2, 3]))
actual.sort()
assert actual == ["1", "2", "3"]
decoder = std.sets(verb=JSON2PY, typ=FrozenSet[str], ctx=ctx)
assert decoder([1, 2, 2, 3]) == frozenset(["1", "2", "3"])
inspect = std.sets(verb=INSP_PY, typ=FrozenSet[str], ctx=ctx)
assert not inspect(frozenset({"33", 77}))
assert inspect(frozenset({"33", "77"}))
assert not inspect(["33", "77"])
inspect = std.sets(verb=INSP_JSON, typ=FrozenSet[str], ctx=ctx)
assert not inspect(["33", 77])
assert inspect(["33", "77"])
assert not inspect({"33", "77"})
def test_dicts_disregards():
"Test that dicts disregards unknown types and verbs."
ctx = Rules(stringify_keys, std.atoms, std.floats)
assert std.dicts(verb="unknown", typ=Dict[str, int], ctx=ctx) is None
assert std.dicts(verb="unknown", typ=Dict[datetime, float], ctx=ctx) is None
if OrderedDict is not None:
assert std.dicts(verb="unknown", typ=OrderedDict[str, int], ctx=ctx) is None
assert (
std.dicts(verb="unknown", typ=OrderedDict[datetime, float], ctx=ctx) is None
)
assert std.dicts(verb=PY2JSON, typ=bool, ctx=ctx) is None
with pytest.raises(RuntimeError):
std.dicts(verb=JSON2PY, typ=Dict[float, str], ctx=ctx)
assert std.dicts(verb=INSP_JSON, typ=List[str], ctx=ctx) is None
def test_dicts_string_key():
"Test that dicts will generate encoders and decoders for dicts."
ctx = Rules(stringify_keys, std.atoms)
encoder = std.dicts(verb=PY2JSON, typ=Dict[str, int], ctx=ctx)
assert encoder({22: "11", 44: "33"}) == {"22": 11, "44": 33}
decoder = std.dicts(verb=JSON2PY, typ=Dict[str, int], ctx=ctx)
assert decoder({22: "11", 44: "33"}) == {"22": 11, "44": 33}
inspect = std.dicts(verb=INSP_PY, typ=Dict[str, int], ctx=ctx)
assert not inspect({"foo": 1, "bar": "no"})
assert inspect({"foo": 1, "bar": 2})
assert inspect({})
inspect = std.dicts(verb=INSP_JSON, typ=Dict[str, int], ctx=ctx)
assert not inspect({"foo": 1, "bar": "no"})
assert inspect({"foo": 1, "bar": 2})
assert inspect({})
def test_dicts_date_key():
"Test that dicts will generate encoders and decoders for dicts keyed by simple dates."
ctx = Rules(std.atoms, std.iso_dates, stringify_keys)
encoder = std.dicts(verb=PY2JSON, typ=Dict[date, int], ctx=ctx)
assert encoder({date(2020, 2, 22): "11", date(2040, 4, 4): "33"}) == {
"2020-02-22": 11,
"2040-04-04": 33,
}
decoder = std.dicts(verb=JSON2PY, typ=Dict[date, int], ctx=ctx)
assert decoder({"2020-02-22": "11", "2040-04-04": "33"}) == {
date(2020, 2, 22): 11,
date(2040, 4, 4): 33,
}
inspect = std.dicts(verb=INSP_PY, typ=Dict[date, int], ctx=ctx)
assert not inspect({date(2040, 4, 4): 1, date(2020, 2, 22): "no"})
assert inspect({date(2040, 4, 4): 1, date(2020, 2, 22): 2})
assert inspect({})
inspect = std.dicts(verb=INSP_JSON, typ=Dict[date, int], ctx=ctx)
assert not inspect({"2011-11-11": 1, "2022-02-02": "no"})
assert inspect({"2011-11-11": 1, "2022-02-02": 2})
assert inspect({})
class AB(Enum):
A = 1
B = 2
def test_dicts_enum_key():
"Test that dicts will generate encoders and decoders for dicts."
ctx = Rules(stringify_keys, std.atoms, std.enums)
encoder = std.dicts(verb=PY2JSON, typ=Dict[AB, int], ctx=ctx)
assert encoder({AB.A: "11", AB.B: "33"}) == {"A": 11, "B": 33}
decoder = std.dicts(verb=JSON2PY, typ=Dict[AB, int], ctx=ctx)
assert decoder({"A": "11", "B": "33"}) == {AB.A: 11, AB.B: 33}
inspect = std.dicts(verb=INSP_PY, typ=Dict[AB, int], ctx=ctx)
assert not inspect({AB.A: 1, AB.B: "no"})
assert inspect({AB.A: 1, AB.B: 2})
assert not inspect({AB.A: 1, "B": 2})
inspect = std.dicts(verb=INSP_JSON, typ=Dict[AB, int], ctx=ctx)
assert not inspect({"A": 1, "B": "no"})
assert inspect({"A": 1, "B": 2})
assert not inspect({"A": 1, "C": 2})
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/type_strategies.py | from hypothesis import strategies as st
from decimal import Decimal
import datetime as dt
from enum import Enum
from . import _strategies as _st
# Tests often want to compare for equality, and there's no good way to do this with NaNs
# breaking it. :-(
st.register_type_strategy(Decimal, st.decimals(allow_nan=False))
st.register_type_strategy(float, st.floats(allow_nan=False))
def type_value_pairs(base):
@st.composite
def tv_pairs(draw):
typ = draw(base)
try:
val = draw(st.from_type(typ))
except Exception as exc:
exc.args += (typ,)
raise
return (typ, val)
return tv_pairs()
atoms = st.sampled_from(
[
type(None),
bool,
int,
float,
Decimal,
str,
dt.date,
dt.datetime,
dt.time,
dt.timedelta,
]
)
class Head(Enum):
def __init__(self, disposition):
self.disposition = disposition
self.atomic = disposition == "atom"
self.hashable = disposition in ("atom", "immut")
self.is_union = disposition == "union"
atoms = "atom"
enums = "atom"
lists = "mut"
sets = "mut"
dicts = "mut"
mut_attrs = "mut"
mut_dataclasses = "mut"
hmg_tuples = "immut"
frozensets = "immut"
prod_tuples = "immut"
frz_attrs = "immut"
frz_dataclasses = "immut"
namedtuples = "immut"
unions = "union"
@classmethod
def short(cls, elems):
if isinstance(elems, (cls, str)):
elems = [elems]
out = set()
for elem in elems:
if isinstance(elem, cls):
out.add(elem)
elif isinstance(elem, str):
out.update(head for head in cls if head.disposition == elem)
return out
# Need to add:
# 1. default values to all of these
# 2. typeless variants
# 3. our own subclasses?
def map_heads(types, frz_types):
H = Head
yield H.atoms, atoms
yield H.enums, _st.enums
if types:
yield H.lists, _st.lists(types)
yield H.unions, _st.unions(types)
yield H.mut_attrs, _st.attrs(types, frozen=False)
yield H.mut_dataclasses, _st.dataclasses(types, frozen=False)
yield H.dicts, _st.dicts(types)
if frz_types:
yield H.hmg_tuples, _st.hmg_tuples(frz_types)
yield H.sets, _st.sets(frz_types)
yield H.frozensets, _st.frozensets(frz_types)
yield H.prod_tuples, _st.prod_tuples(frz_types)
yield H.frz_attrs, _st.attrs(frz_types, frozen=True)
yield H.frz_dataclasses, _st.dataclasses(frz_types, frozen=True)
yield H.namedtuples, _st.namedtuples(frz_types)
def type_tree(*levels):
"""
Constructs a type tree of a fixed maximum height based on the heads provided.
The last level must be leaves that can be contained by the levels above.
"""
types, frz_types = None, None
for level in map(Head.short, reversed(levels)):
tt = []
frz_tt = []
for head, typ in map_heads(types, frz_types):
if typ is None:
continue
if head in level:
tt.append(typ)
if head.hashable:
frz_tt.append(typ)
types = st.one_of(tt) if tt else None
frz_types = st.one_of(frz_tt) if frz_tt else None
if types is None:
raise ValueError("No types for {}".format(levels))
return types
complex_no_unions = type_tree(
{"atom", "mut", "immut"},
{"atom", "mut", "immut"},
{"atom", "mut", "immut"},
{"atom"},
)
unions_of_simple = type_tree({Head.unions}, {"atom", "mut", "immut"}, {"atom"})
complex_anything = type_tree(
{"atom", "mut", "immut", "unions"},
{"atom", "mut", "immut", "unions"},
{"atom", "mut", "immut", "unions"},
{"atom"},
)
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/test_attrs.py | import pytest
from .common import SoftMod, typing as t, Rules
from .types_attrs_common import Hooks, T, U
from json_syntax import attrs as at
from json_syntax import std
from json_syntax.helpers import JSON2PY, PY2JSON, INSP_PY, INSP_JSON
import attr
from collections import namedtuple
from typing import Tuple, Generic, List
ann = SoftMod("tests.types_attrs_ann", allow_SyntaxError=True)
@attr.s
class Flat:
a = attr.ib(type=int)
b = attr.ib("default", type=str)
@attr.s
class GenFlat(Generic[T]):
a = attr.ib(type=T)
b = attr.ib("default", type=str)
@attr.s
class PrivateFields:
pub = attr.ib(type=str)
_priv = attr.ib(type=int)
@attr.s
class Hook1(Hooks):
a = attr.ib(type=int)
b = attr.ib("default", type=str)
@attr.s
class GenExample(Generic[T, U]):
body = attr.ib(type=T)
count = attr.ib(type=int)
messages = attr.ib(type=t.List[U])
try:
@attr.s(slots=True)
class GenExampleSlots(Generic[T, U]):
body = attr.ib(type=T)
count = attr.ib(type=int)
messages = attr.ib(type=t.List[U])
except TypeError:
GenExampleSlots = None
class Fail:
def lookup(self, verb, typ, accept_missing):
raise RuntimeError("Should not be called in this test")
class Ctx:
def lookup(self, verb, typ, accept_missing):
if typ is None:
raise RuntimeError("Should not be called with typ=None")
if verb in (JSON2PY, PY2JSON):
return typ
else:
return lambda val: isinstance(val, typ)
def test_attrs_classes_disregards():
"Test that attrs_classes disregards unknown verbs and types."
assert at.attrs_classes(verb=PY2JSON, typ=int, ctx=Fail()) is None
assert at.attrs_classes(verb=INSP_PY, typ=int, ctx=Fail()) is None
assert at.attrs_classes(verb=JSON2PY, typ=object, ctx=Fail()) is None
assert at.attrs_classes(verb="dummy", typ=Flat, ctx=Fail()) is None
@pytest.mark.parametrize(
"con, FlatCls",
[
(Flat, Flat),
(ann.Flat, ann.Flat),
(GenFlat, GenFlat[int]),
(ann.GenFlat, ann.GenFlat[int]) if ann.GenFlat else (None, None),
(ann.FlatDc, ann.FlatDc),
(ann.GenFlatDc, ann.GenFlatDc[int]) if ann.GenFlatDc else (None, None),
],
)
def test_attrs_encoding(con, FlatCls):
"Test that attrs_classes encodes and decodes a flat class."
if FlatCls is None:
pytest.skip("Annotations unavailable")
encoder = at.attrs_classes(verb=PY2JSON, typ=FlatCls, ctx=Ctx())
assert encoder(con(33, "foo")) == {"a": 33, "b": "foo"}
assert encoder(con(33, "default")) == {"a": 33}
decoder = at.attrs_classes(verb=JSON2PY, typ=FlatCls, ctx=Ctx())
assert decoder({"a": 33, "b": "foo"}) == FlatCls(33, "foo")
assert decoder({"a": 33}) == FlatCls(33)
inspect = at.attrs_classes(verb=INSP_PY, typ=FlatCls, ctx=Ctx())
assert inspect(con(33, "foo"))
assert inspect(con("str", "foo"))
assert not inspect({"a": 33, "b": "foo"})
inspect = at.attrs_classes(verb=INSP_JSON, typ=FlatCls, ctx=Ctx())
assert not inspect(con(33, "foo"))
assert not inspect({"a": "str", "b": "foo"})
assert inspect({"a": 33})
assert inspect({"a": 33, "b": "foo"})
assert not inspect({"b": "foo"})
@pytest.mark.parametrize("PrivateCls", [PrivateFields, ann.PrivateFieldsDc,])
def test_attrs_private(PrivateCls):
"Test that attrs_classes encode and decode classes with private fields correctly."
if PrivateCls is None:
pytest.skip("Annotations unavailable")
original = PrivateCls("value", 77)
encoder = at.attrs_classes(verb=PY2JSON, typ=PrivateCls, ctx=Ctx())
encoded = encoder(original)
assert encoded["pub"] == "value"
assert encoded["_priv"] == 77
decoder = at.attrs_classes(verb=JSON2PY, typ=PrivateCls, ctx=Ctx())
decoded = decoder(encoded)
assert decoded == original
@pytest.mark.parametrize("HookCls", [Hook1, ann.Hook])
def test_attrs_hooks(HookCls):
"Test that attrs_classes enables hooks."
if HookCls is None:
pytest.skip("Annotations unavailable")
encoder = at.attrs_classes(verb=PY2JSON, typ=HookCls, ctx=Ctx())
assert encoder(HookCls(33, "foo")) == {"_type_": "Hook", "a": 33, "b": "foo"}
assert encoder(HookCls(33, "default")) == {"_type_": "Hook", "a": 33}
decoder = at.attrs_classes(verb=JSON2PY, typ=HookCls, ctx=Ctx())
assert decoder([33, "foo"]) == HookCls(33, "foo")
assert decoder({"a": 33, "b": "foo"}) == HookCls(33, "foo")
assert decoder({"a": 33}) == HookCls(33)
inspect = at.attrs_classes(verb=INSP_PY, typ=HookCls, ctx=Ctx())
assert inspect(HookCls(33, "foo"))
assert inspect(HookCls("str", "foo"))
assert not inspect({"a": 33, "b": "foo"})
inspect = at.attrs_classes(verb=INSP_JSON, typ=HookCls, ctx=Ctx())
assert inspect({"_type_": "Hook", "a": "str", "b": "foo"})
assert not inspect({"a": 33, "b": "foo"})
assert inspect({"_type_": "Hook", "a": 33, "b": "foo"})
assert inspect({"_type_": "Hook"})
@pytest.mark.parametrize(
"GenClass",
[
GenExample,
GenExampleSlots,
ann.GenExample,
ann.GenExampleSlots,
ann.GenExampleDc,
],
)
def test_attrs_generic(GenClass):
if GenClass is None:
pytest.skip()
@attr.s
class Top:
nested = attr.ib(type=GenClass[GenClass[str, str], str])
list_of = attr.ib(type=List[GenClass[Tuple[Flat, ...], int]])
rules = Rules(at.attrs_classes, std.atoms, std.lists)
py_val = Top(
nested=GenClass(
body=GenClass(body="body", count=5, messages=["msg1", "msg2"]),
count=3,
messages=["msg3", "msg4"],
),
list_of=[
GenClass(body=(Flat(a=1), Flat(a=2, b="three")), count=4, messages=[6, 7])
],
)
j_val = {
"list_of": [
{"body": [{"a": 1}, {"a": 2, "b": "three"}], "count": 4, "messages": [6, 7]}
],
"nested": {
"body": {"body": "body", "count": 5, "messages": ["msg1", "msg2"]},
"count": 3,
"messages": ["msg3", "msg4"],
},
}
encoder = at.attrs_classes(verb=PY2JSON, typ=Top, ctx=rules)
assert encoder(py_val) == j_val
decoder = at.attrs_classes(verb=JSON2PY, typ=Top, ctx=rules)
assert decoder(j_val) == py_val
inspect = at.attrs_classes(verb=INSP_PY, typ=Top, ctx=rules)
assert inspect(py_val)
inspect = at.attrs_classes(verb=INSP_JSON, typ=Top, ctx=rules)
assert inspect(j_val)
class Ctx2:
def lookup(self, *, verb, typ, accept_missing=False):
if typ is None:
assert accept_missing, "typ is None without accept_missing"
if verb in (JSON2PY, PY2JSON):
return str
else:
return lambda val: isinstance(val, str)
if verb in (JSON2PY, PY2JSON):
return typ
else:
return lambda val: isinstance(val, typ)
def test_named_tuples_disregards():
"Test that named_tuples disregards unknown verbs and types."
assert at.named_tuples(verb=PY2JSON, typ=int, ctx=Fail()) is None
assert at.named_tuples(verb=INSP_PY, typ=int, ctx=Fail()) is None
assert at.named_tuples(verb=JSON2PY, typ=tuple, ctx=Fail()) is None
assert at.named_tuples(verb="dummy", typ=Named1, ctx=Fail()) is None
Named1 = namedtuple("Named1", ["a", "b"])
try:
Named2 = namedtuple("Named2", ["a", "b"], defaults=["default"])
except TypeError:
Named2 = None
Named3 = ann.Named
def test_named_tuples_encoding1():
"Test that named_tuples encodes and decodes a namedtuple."
encoder = at.named_tuples(verb=PY2JSON, typ=Named1, ctx=Ctx2())
assert encoder(Named1(42, "foo")) == {"a": "42", "b": "foo"}
decoder = at.named_tuples(verb=JSON2PY, typ=Named1, ctx=Ctx2())
assert decoder({"a": 42, "b": "foo"}) == Named1("42", "foo")
@pytest.mark.skipif(Named2 is None, reason="defaults arg to namedtuple unavailable")
def test_named_tuples_encoding2():
"Test that named_tuples encodes and decodes a namedtuple."
encoder = at.named_tuples(verb=PY2JSON, typ=Named2, ctx=Ctx2())
assert encoder(Named2(42, "foo")) == {"a": "42", "b": "foo"}
assert encoder(Named2(42)) == {"a": "42"}
decoder = at.named_tuples(verb=JSON2PY, typ=Named2, ctx=Ctx2())
assert decoder({"a": 42, "b": "foo"}) == Named2("42", "foo")
assert decoder({"a": 42}) == Named2("42")
@pytest.mark.skipif(Named3 is None, reason="annotations unavailable")
def test_named_tuples_encoding3():
"Test that named_tuples encodes and decodes a namedtuple."
encoder = at.named_tuples(verb=PY2JSON, typ=Named3, ctx=Ctx2())
assert encoder(Named3(42, "foo")) == {"a": 42, "b": "foo"}
assert encoder(Named3(42)) == {"a": 42}
decoder = at.named_tuples(verb=JSON2PY, typ=Named3, ctx=Ctx2())
assert decoder({"a": 42, "b": "foo"}) == Named3(42, "foo")
assert decoder({"a": 42}) == Named3(42)
def test_named_tuples_checking1():
"Test that named_tuples verifies a namedtuple."
inspect = at.named_tuples(verb=INSP_PY, typ=Named1, ctx=Ctx2())
assert inspect(Named1(42, "foo"))
assert inspect(Named1("str", "foo"))
assert not inspect({"a": "42", "b": "foo"})
inspect = at.named_tuples(verb=INSP_JSON, typ=Named1, ctx=Ctx2())
assert not inspect(Named1(42, "foo"))
assert not inspect({"a": "42"})
assert not inspect({"a": 42, "b": "foo"})
assert inspect({"a": "42", "b": "foo"})
assert not inspect({"b": "foo"})
@pytest.mark.skipif(Named2 is None, reason="defaults arg to namedtuple unavailable")
def test_named_tuples_checking2():
"Test that named_tuples verifies a namedtuple."
inspect = at.named_tuples(verb=INSP_PY, typ=Named2, ctx=Ctx2())
assert inspect(Named2(42, "foo"))
assert inspect(Named2("str", "foo"))
assert not inspect({"a": "42", "b": "foo"})
inspect = at.named_tuples(verb=INSP_JSON, typ=Named2, ctx=Ctx2())
assert not inspect(Named2(42, "foo"))
assert not inspect({"a": None, "b": "foo"})
assert inspect({"a": "42"})
assert inspect({"a": "42", "b": "foo"})
assert not inspect({"b": "foo"})
@pytest.mark.skipif(Named3 is None, reason="annotations unavailable")
def test_named_tuples_checking3():
"Test that named_tuples verifies a namedtuple."
inspect = at.named_tuples(verb=INSP_PY, typ=Named3, ctx=Ctx2())
assert inspect(Named3(42, "foo"))
assert inspect(Named3("str", "foo"))
assert not inspect({"a": 42, "b": "foo"})
inspect = at.named_tuples(verb=INSP_JSON, typ=Named3, ctx=Ctx2())
assert not inspect(Named3(42, "foo"))
assert not inspect({"a": None, "b": "foo"})
assert inspect({"a": 42})
assert inspect({"a": 42, "b": "foo"})
assert not inspect({"b": "foo"})
def test_tuples_disregards():
"Test that tuples disregards unknown verbs and types."
assert at.tuples(verb=PY2JSON, typ=Tuple[int, ...], ctx=Fail()) is None
assert at.tuples(verb=INSP_PY, typ=int, ctx=Fail()) is None
assert at.tuples(verb="dummy", typ=Tuple[int, str], ctx=Fail()) is None
def test_tuples_encoding():
"Test that tuples encodes and decodes a flat class."
encoder = at.tuples(verb=PY2JSON, typ=Tuple[int, str], ctx=Ctx2())
assert encoder((33, "foo")) == [33, "foo"]
decoder = at.tuples(verb=JSON2PY, typ=Tuple[int, str], ctx=Ctx2())
assert decoder([33, "foo"]) == (33, "foo")
inspect = at.tuples(verb=INSP_PY, typ=Tuple[int, str], ctx=Ctx2())
assert inspect((33, "foo"))
assert not inspect(("str", "foo"))
assert not inspect((33, "foo", None))
inspect = at.tuples(verb=INSP_JSON, typ=Tuple[int, str], ctx=Ctx2())
assert inspect([33, "foo"])
assert not inspect(["str", "foo"])
assert not inspect([33, "foo", None])
assert not inspect({})
@pytest.mark.parametrize(
"dict_type", [t.TypedDict("Dict1", a=int, b=str) if t.TypedDict else None, ann.Dict]
)
def test_typed_dict_encoding(dict_type):
"Test that typed_dicts encodes and decodes a typed dict."
if dict_type is None:
pytest.skip("TypedDict or annotations unavailable")
encoder = at.typed_dicts(verb=PY2JSON, typ=dict_type, ctx=Ctx())
assert encoder({"a": 3, "b": "foo"}) == {"a": 3, "b": "foo"}
assert encoder({"a": 3, "b": "foo", "c": "extra"}) == {"a": 3, "b": "foo"}
assert encoder({"a": 3.2, "b": 5}) == {"a": 3, "b": "5"}
decoder = at.typed_dicts(verb=JSON2PY, typ=dict_type, ctx=Ctx())
assert decoder({"a": 3, "b": "foo"}) == {"a": 3, "b": "foo"}
assert decoder({"a": 3, "b": "foo", "c": "extra"}) == {"a": 3, "b": "foo"}
assert decoder({"a": 3.2, "b": 5}) == {"a": 3, "b": "5"}
inspect = at.typed_dicts(verb=INSP_PY, typ=dict_type, ctx=Ctx())
assert inspect({"a": 3, "b": "foo"})
assert not inspect({"a": 3.2, "b": False})
assert not inspect("foo")
assert not inspect({})
assert inspect({"a": 3, "b": "foo", "c": True})
inspect = at.typed_dicts(verb=INSP_JSON, typ=dict_type, ctx=Ctx())
assert inspect({"a": 3, "b": "foo"})
assert not inspect({"a": 3.2, "b": False})
assert not inspect("foo")
assert not inspect({})
assert inspect({"a": 3, "b": "foo", "c": True})
@attr.s(eq=False)
class Incomparable:
def __eq__(self, other):
raise RuntimeError("Can't compare this class")
def __ne__(self, other):
raise RuntimeError("Can't compare this class")
@attr.s
class IncomparableContainer:
field1 = attr.ib(type=Incomparable)
field2 = attr.ib(type=int, default=3)
def test_encode_incomparable():
"Test that encoding doesn't fail if a field's __eq__ method throws."
rules = Rules(at.attrs_classes, std.atoms, std.lists)
encoder = at.attrs_classes(verb=PY2JSON, typ=IncomparableContainer, ctx=rules)
assert encoder(IncomparableContainer(Incomparable())) == {"field1": {}}
assert encoder(IncomparableContainer(Incomparable(), 4)) == {"field1": {}, "field2": 4}
decoder = at.attrs_classes(verb=JSON2PY, typ=IncomparableContainer, ctx=rules)
actual = decoder({"field1": {}})
assert isinstance(actual.field1, Incomparable)
assert actual.field2 == 3
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/test_cache.py | import pytest
from json_syntax import cache
def test_forward_action():
"Test that ForwardAction can replace a function and be updated."
def func1(a, b):
return a + b
def func2(a, b):
"Doc string."
return a * b
subj = cache.ForwardAction(func1)
assert subj(3, 7) == 10
subj.__call__ = func2
assert subj(3, 7) == 21
assert repr(subj).startswith("<fwd <function")
def test_simple_cache_get():
"Test that SimpleCache handles a cache miss."
subj = cache.SimpleCache()
assert subj.get(verb="verb", typ=int) is None
@pytest.mark.filterwarnings("error")
def test_simple_cache_flight():
"Test that the SimpleCache inflight -> complete mechanism produces a forward action."
subj = cache.SimpleCache()
# Notify the cache that we're working on the result.
subj.in_flight(verb="verb", typ=int)
# Another rule needs the result before it's ready.
actual = subj.get(verb="verb", typ=int)
def action(value):
return value * 10
# The ForwardAction previously set is loaded with the callable.
subj.complete(verb="verb", typ=int, action=action)
# The ForwardAction is loaded with the action.
assert actual(5) == 50
# The cache entry is replaced with the action itself.
assert subj.get(verb="verb", typ=int) is action
class NoHashMeta(type):
__hash__ = None
class NoHash(metaclass=NoHashMeta):
pass
def test_simple_cache_unhashable():
"Test that SimpleCache warns on unhashable type instances."
subj = cache.SimpleCache()
with pytest.warns(cache.UnhashableType):
subj.get(verb="verb", typ=NoHash)
with pytest.warns(cache.UnhashableType):
subj.in_flight(verb="verb", typ=NoHash)
with pytest.warns(cache.UnhashableType):
subj.complete(verb="verb", typ=NoHash, action=lambda val: val + 1)
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/test_std_ruleset.py | import pytest
from datetime import date
from decimal import Decimal
import json_syntax as syn
try:
from tests.types_std_ann import things, accounts
except SyntaxError:
from tests.types_std_noann import things, accounts
@pytest.mark.parametrize("Thing,Other", things)
def test_encoding_of_composite_thing(Thing, Other):
"Test encoding of a cyclic type."
rs = syn.std_ruleset()
encoder = rs.lookup(typ=Thing, verb=syn.PY2JSON)
decoder = rs.lookup(typ=Thing, verb=syn.JSON2PY)
def pythonic():
return Thing(
foo=False,
bar=[
Other(x=3.3, y=date(1944, 4, 4), z=None),
Other(x=4.4, y=date(1955, 5, 5), z=None),
],
qux=77,
)
def jsonic():
return {
"foo": False,
"bar": [
{"x": 3.3, "y": "1944-04-04", "z": None},
{"x": 4.4, "y": "1955-05-05", "z": None},
],
"qux": 77,
}
assert encoder(pythonic()) == jsonic()
assert decoder(jsonic()) == pythonic()
@pytest.mark.parametrize("Account,TransType,Trans", accounts)
def test_readme_example(Account, TransType, Trans):
"Test encoding the readme example."
rules = syn.std_ruleset()
encode_account = rules.lookup(typ=Account, verb=syn.PY2JSON)
decode_account = rules.lookup(typ=Account, verb=syn.JSON2PY)
def pythonic():
return Account(
"bob",
[Trans(TransType.withdraw, Decimal("523.33"), date(2019, 4, 4))],
Decimal("77.00"),
)
def jsonic():
return {
"user": "bob",
"transactions": [
{"type": "withdraw", "amount": Decimal("523.33"), "stamp": "2019-04-04"}
],
"balance": Decimal("77.00"),
}
assert encode_account(pythonic()) == jsonic()
assert decode_account(jsonic()) == pythonic()
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/_strategies.py | """
Some miscellany to keep the type_strategies module a bit more readable.
"""
from hypothesis import strategies as st
import attr
try:
import dataclasses as dc
except ImportError:
dc = None
from datetime import date
from enum import IntEnum
from keyword import iskeyword
import os
import typing
MAX_FIELDS = 8
_max_cp = None if os.environ.get("UNICODE_NAMES") else 0x7F
_any_char = st.characters(min_codepoint=1, max_codepoint=_max_cp)
_ident_start = st.characters(
whitelist_categories=["Lu", "Ll", "Lt", "Lm", "Lo", "Nl"], max_codepoint=_max_cp
)
_ident_tail = st.characters(
whitelist_categories=["Lu", "Ll", "Lt", "Lm", "Lo", "Nl", "Mn", "Mc", "Nd", "Pc"],
whitelist_characters="_",
max_codepoint=_max_cp,
)
@st.composite
def _idents(draw, lengths=st.integers(min_value=0, max_value=80)):
chars = [draw(_ident_start)]
chars.extend(draw(_ident_tail) for _ in range(draw(lengths)))
chars = "".join(chars)
if iskeyword(chars):
chars += draw(_ident_tail)
return chars
def _make_enum(name, elems):
# print(f'IntEnum(enum_{name}, {elems!r})')
return IntEnum("enum_" + name, elems)
idents = _idents()
enums = st.builds(
_make_enum, idents, st.lists(idents, min_size=1, max_size=MAX_FIELDS, unique=True)
)
def fields_idents(types):
return st.dictionaries(
idents, types, dict_class=list, min_size=0, max_size=MAX_FIELDS
)
class _Faux(attr.validators._InstanceOfValidator):
def __call__(self, inst, attr, value):
pass
def attrs(types, frozen):
def _make(name, fields, **kw):
def _attrib(typ):
# Add a bogus validator because from_type reads that, not `type`
# Can't use the real one because of generic types!
return attr.ib(type=typ, validator=_Faux(typ))
# print(f'attrs({name}, {fields}, **{kw})')
return attr.make_class(
"attrs_" + name,
{field: _attrib(typ) for field, typ in fields},
frozen=frozen,
**kw
)
return st.builds(_make, idents, fields_idents(types), slots=st.booleans())
if dc is not None:
def dataclasses(types, frozen):
def _make(name, fields, order):
# print(f'dataclass({name}, {fields}, frozen={frozen}, order={order}')
return dc.make_dataclass(
"dc_" + name, fields, frozen=frozen, eq=True, order=order
)
return st.builds(_make, idents, fields_idents(types), order=st.booleans())
else:
def dataclasses(types, frozen):
return None
try:
_NamedTuple = typing.NamedTuple
except AttributeError:
def namedtuples(types):
return None
else:
def namedtuples(types):
def _make(name, fields):
# print(f'namedtuple({name}, {fields})')
return _NamedTuple("nt_" + name, fields)
return st.builds(_make, idents, fields_idents(types))
def lists(types):
return st.builds(lambda a: typing.List[a], types)
def hmg_tuples(types):
return st.builds(lambda a: typing.Tuple[a, ...], types)
def sets(types):
return st.builds(lambda a: typing.Set[a], types)
def frozensets(types):
return st.builds(lambda a: typing.FrozenSet[a], types)
_dict_keys = atoms = st.one_of([st.sampled_from([int, str, date]), enums])
def dicts(val_types):
return st.builds(lambda k, v: typing.Dict[k, v], _dict_keys, val_types)
def prod_tuples(types):
return st.builds(
lambda a: typing.Tuple[tuple(a)],
st.lists(types, min_size=1, max_size=MAX_FIELDS),
)
def unions(types, max_size=None):
return st.builds(
lambda a: typing.Union[tuple(a)], st.lists(types, min_size=1, max_size=max_size)
)
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/test_helpers.py | from json_syntax import helpers as hlp
def test_identity():
"Test that the identity function does what it says."
subj = object()
assert hlp.identity(subj) is subj
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/types_std_ann.py | try:
from dataclasses import dataclass
except ImportError:
from attr import dataclass
from datetime import date
from decimal import Decimal
from enum import Enum
from typing import Optional, List
@dataclass
class CompositeThing:
foo: bool
bar: List["Other"]
qux: Optional[int]
@dataclass
class Other:
x: float
y: date
z: Optional[CompositeThing]
things = [(CompositeThing, Other)]
@dataclass
class Account:
user: str
transactions: List["Trans"]
balance: Decimal = Decimal(0)
class TransType(Enum):
withdraw = 0
deposit = 1
@dataclass
class Trans:
type: TransType
amount: Decimal
stamp: date
accounts = [(Account, TransType, Trans)]
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/types_attrs_ann.py | import attr
from .common import dataclasses as dc, typing as t
from .types_attrs_common import Hooks, T, U
@attr.s(auto_attribs=True)
class Flat:
a: int
b: str = "default"
@attr.s(auto_attribs=True)
class GenFlat(t.Generic[T]):
a: T
b: str = "default"
@attr.s(auto_attribs=True)
class Hook(Hooks):
a: int
b: str = "default"
class Named(t.NamedTuple):
a: int
b: str = "default"
class Dict(t.TypedDict):
a: int
b: str
@attr.s(auto_attribs=True)
class GenExample(t.Generic[T, U]):
body: T
count: int
messages: t.List[U]
try:
@attr.s(auto_attribs=True, slots=True)
class GenExampleSlots(t.Generic[T, U]):
body: T
count: int
messages: t.List[U]
except TypeError:
# Slots don't work with Generic on older versions of typing.
GenExampleSlots = None
if dc.dataclass:
@dc.dataclass
class FlatDc:
a: int
b: str = "default"
@dc.dataclass
class GenFlatDc(t.Generic[T]):
a: T
b: str = "default"
@dc.dataclass
class HookDc(Hooks):
a: int
b: str = "default"
@dc.dataclass
class GenExampleDc(t.Generic[T, U]):
body: T
count: int
messages: t.List[U]
@dc.dataclass
class PrivateFieldsDc:
pub: str
_priv: int
else:
FlatDc = GenFlatDc = HookDc = GenericExampleDc = PrivateFieldsDc = None
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/types_attrs_common.py | from typing import TypeVar
class Hooks:
@classmethod
def __json_pre_decode__(cls, value):
if isinstance(value, list):
value = {"a": value[0], "b": value[1]}
return value
@classmethod
def __json_check__(cls, value):
return value.get("_type_") == "Hook"
def __json_post_encode__(cls, value):
return dict(value, _type_="Hook")
T = TypeVar("T")
U = TypeVar("U")
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/test_errors.py | import pytest
from json_syntax import errors as err
import traceback as tb
@pytest.mark.parametrize(
"args,expect",
[
((), "ValueError: At .alpha.beta\n"),
(("message",), "ValueError: message; at .alpha.beta\n"),
(("two", "parts"), "ValueError: ('two; at .alpha.beta', 'parts')\n"),
],
)
def test_error_context(args, expect):
"Test that error contexts add information correctly."
try:
with err.ErrorContext(".", "alpha"):
with err.ErrorContext(".", "beta"):
raise ValueError(*args)
except ValueError as exc:
actual = "".join(tb.format_exception_only(type(exc), exc))
else:
assert False, "Didn't throw?!"
assert actual == expect
def test_error_ctx_inline():
"Test that err_ctx adds inline context."
def inside():
raise ValueError("message")
try:
err.err_ctx(".alpha", inside)
except ValueError as exc:
actual = "".join(tb.format_exception_only(type(exc), exc))
else:
assert False, "Didn't throw?!"
assert actual == "ValueError: message; at .alpha\n"
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/test_union_prop.py | from hypothesis import given, settings, HealthCheck
from . import type_strategies as ts
# import attr
# from datetime import date, datetime
# from decimal import Decimal
# from enum import Enum
# from itertools import product
# from typing import Union, List, Tuple, Set, FrozenSet, Dict
from json_syntax import std_ruleset
from json_syntax.helpers import PY2JSON, JSON2PY # INSP_PY, INSP_JSON, NoneType
from json_syntax.pattern import Matches
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=100, deadline=None)
@given(ts.type_value_pairs(ts.complex_no_unions))
def test_roundtrip(pair):
typ, py_value = pair
rs = std_ruleset()
act = rs.lookup(verb=PY2JSON, typ=typ)
json_value = act(py_value)
act2 = rs.lookup(verb=JSON2PY, typ=typ)
rt_py_value = act2(json_value)
assert py_value == rt_py_value
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=100, deadline=None)
@given(ts.type_value_pairs(ts.unions_of_simple))
def test_roundtrip_union_simple(pair):
typ, py_value = pair
rs = std_ruleset()
act = rs.lookup(verb=PY2JSON, typ=typ)
json_value = act(py_value)
act2 = rs.lookup(verb=JSON2PY, typ=typ)
rt_py_value = act2(json_value)
if not rs.is_ambiguous(typ=typ, threshold=Matches.potential):
assert py_value == rt_py_value
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=100, deadline=None)
@given(ts.type_value_pairs(ts.complex_anything))
def test_roundtrip_arbitrary_complex(pair):
typ, py_value = pair
rs = std_ruleset()
act = rs.lookup(verb=PY2JSON, typ=typ)
json_value = act(py_value)
act2 = rs.lookup(verb=JSON2PY, typ=typ)
rt_py_value = act2(json_value)
if not rs.is_ambiguous(typ=typ, threshold=Matches.potential):
assert py_value == rt_py_value
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/tests/types_std_noann.py | import attr
from datetime import date
from decimal import Decimal
from enum import Enum
from typing import Optional, List
@attr.s
class CompositeThing:
foo = attr.ib(type=bool)
bar = attr.ib(type=List["Other"])
qux = attr.ib(type=Optional[int])
@attr.s
class Other:
x = attr.ib(type=float)
y = attr.ib(type=date)
z = attr.ib(type=Optional[CompositeThing])
things = [(CompositeThing, Other)]
@attr.s
class Account:
user = attr.ib(type=str)
transactions = attr.ib(type=List["Trans"])
balance = attr.ib(Decimal(0), type=Decimal)
class TransType(Enum):
withdraw = 0
deposit = 1
@attr.s
class Trans:
type = attr.ib(type=TransType)
amount = attr.ib(type=Decimal)
stamp = attr.ib(type=date)
accounts = [(Account, TransType, Trans)]
|
0 | capitalone_repos/json-syntax/tests | capitalone_repos/json-syntax/tests/extras/test_flags.py | import pytest
from tests.common import Rules
from json_syntax.extras import flags as fl
from json_syntax.helpers import (
JSON2PY,
PY2JSON,
INSP_JSON,
INSP_PY,
STR2PY,
PY2STR,
INSP_STR,
python_minor,
)
@pytest.mark.skipif(
python_minor < (3, 7), reason="__class_getitem__ not supported before 3.7"
)
@pytest.mark.parametrize("verb", [JSON2PY, PY2JSON, STR2PY, PY2STR])
def test_Flag_getitem_convert(verb):
action = fl.flags(verb=verb, typ=fl.Flag["foo", "bar", "qux"], ctx=Rules())
assert action("foo") == "foo"
assert action("qux") == "qux"
with pytest.raises(ValueError):
action("nope")
@pytest.mark.parametrize("verb", [JSON2PY, PY2JSON, STR2PY, PY2STR])
def test_Flag_init_convert(verb):
action = fl.flags(verb=verb, typ=fl.Flag("foo", "bar", "qux"), ctx=Rules())
assert action("foo") == "foo"
assert action("qux") == "qux"
with pytest.raises(ValueError):
action("nope")
@pytest.mark.skipif(
python_minor < (3, 7), reason="__class_getitem__ not supported before 3.7"
)
@pytest.mark.parametrize("verb", [INSP_PY, INSP_JSON, INSP_STR])
def test_Flag_getitem_inspect(verb):
action = fl.flags(verb=verb, typ=fl.Flag["foo", "bar", "qux"], ctx=Rules())
assert action("foo")
assert action("qux")
assert not action("nope")
@pytest.mark.parametrize("verb", [INSP_PY, INSP_JSON, INSP_STR])
def test_Flag_init_inspect(verb):
action = fl.flags(verb=verb, typ=fl.Flag("foo", "bar", "qux"), ctx=Rules())
assert action("foo")
assert action("qux")
assert not action("nope")
|
0 | capitalone_repos/json-syntax/tests | capitalone_repos/json-syntax/tests/extras/test_dynamodb.py | import pytest
from json_syntax.extras.dynamodb import dynamodb_ruleset
from json_syntax.helpers import NoneType
from fractions import Fraction
from decimal import Decimal
from typing import Dict, List, Optional, Set, Tuple
try:
import attr
except ImportError:
attr = None
def encode(value, typ):
return dynamodb_ruleset().python_to_dynamodb(typ)(value)
def decode(value, typ):
return dynamodb_ruleset().dynamodb_to_python(typ)(value)
def encode_item(value, typ):
return dynamodb_ruleset().python_to_ddb_item(typ)(value)
def decode_item(value, typ):
return dynamodb_ruleset().ddb_item_to_python(typ)(value)
def test_optional():
assert encode(None, Optional[int]) == {"NULL": True}
assert encode(5, Optional[int]) == {"N": "5"}
assert decode({"NULL": True}, Optional[str]) is None
assert decode({"S": "wat"}, Optional[str]) == "wat"
def test_null():
assert encode(None, NoneType) == {"NULL": True}
assert decode({"NULL": True}, NoneType) is None
def test_bool():
assert encode(True, bool) == {"BOOL": True}
assert decode({"BOOL": False}, bool) is False
def test_binary():
assert encode(b"foobar", bytes) == {"B": "Zm9vYmFy"}
assert decode({"B": "Zm9vYmFy"}, bytes) == b"foobar"
assert decode({"B": b"Zm9vYmFy"}, bytes) == b"foobar"
def test_number1():
assert encode(55.125, float) == {"N": "55.125"}
assert decode({"N": "-55.125"}, float) == -55.125
def test_number2():
with pytest.raises(ValueError):
encode(float("nan"), float)
def test_number3():
assert encode(Fraction(441, 8), Fraction) == {"N": "55.125"}
assert decode({"N": "55.125"}, Fraction) == Fraction(441, 8)
def test_number4():
assert encode(Decimal("55.125"), Decimal) == {"N": "55.125"}
assert decode({"N": "-55.125"}, Decimal) == Decimal("-55.125")
def test_string():
assert encode("foobar", str) == {"S": "foobar"}
assert decode({"S": "foobar"}, str) == "foobar"
def test_list():
assert encode([1, 2, 4, 5], List[int]) == {
"L": [{"N": str(x)} for x in [1, 2, 4, 5]]
}
assert decode({"L": [{"S": "apple"}, {"S": "banana"}]}, List[str]) == [
"apple",
"banana",
]
def test_dict():
assert encode({"A": 1, "B": 2}, Dict[str, int]) == {
"M": {"A": {"N": "1"}, "B": {"N": "2"}}
}
assert decode({"M": {"A": {"N": "1"}, "B": {"N": "2"}}}, Dict[str, int]) == {
"A": 1,
"B": 2,
}
def cheat(value):
if isinstance(value, dict):
for key, val in value.items():
if key in ("SS", "NS", "BS"):
val.sort()
else:
cheat(val)
elif isinstance(value, list):
for val in value:
cheat(val)
return value
def test_str_set():
assert cheat(encode({"foo", "bar", "qux"}, Set[str])) == {
"SS": ["bar", "foo", "qux"]
}
assert decode({"SS": ["foo", "bar", "qux"]}, Set[str]) == {"foo", "bar", "qux"}
def test_num_set():
assert cheat(encode({-33.5, 11.25, 1.75}, Set[float])) == {
"NS": ["-33.5", "1.75", "11.25"]
}
assert decode({"NS": [11.25, 1.75, -33.5]}, Set[float]) == {-33.5, 11.25, 1.75}
def test_bin_set():
assert cheat(encode({b"foo", b"bar", b"qux"}, Set[bytes])) == {
"BS": ["YmFy", "Zm9v", "cXV4"]
}
assert decode({"BS": ["YmFy", "Zm9v", "cXV4"]}, Set[bytes]) == {
b"foo",
b"bar",
b"qux",
}
assert decode({"BS": [b"YmFy", b"Zm9v", b"cXV4"]}, Set[bytes]) == {
b"foo",
b"bar",
b"qux",
}
@attr.s
class Inner:
name = attr.ib(type=str)
@attr.s
class Outer:
stuff = attr.ib(type=Inner)
count = attr.ib(type=int, default=7)
def test_map1():
subj = Outer(count=3, stuff=Inner(name="bob"))
expected = {"M": {"count": {"N": "3"}, "stuff": {"M": {"name": {"S": "bob"}}}}}
assert encode(subj, Outer) == expected
subj = {"M": {"count": {"N": "3"}, "stuff": {"M": {"name": {"S": "bob"}}}}}
expected = Outer(count=3, stuff=Inner(name="bob"))
assert decode(subj, Outer) == expected
def test_map2():
subj = Outer(stuff=Inner(name="bob"))
expected = {"M": {"stuff": {"M": {"name": {"S": "bob"}}}}}
assert encode(subj, Outer) == expected
subj = {
"M": {"stuff": {"M": {"name": {"S": "bob"}}}, "other_key": {"S": "ignored"}}
}
expected = Outer(stuff=Inner(name="bob"))
assert decode(subj, Outer) == expected
def test_item1():
subj = Outer(count=3, stuff=Inner(name="bob"))
expected = {"count": {"N": "3"}, "stuff": {"M": {"name": {"S": "bob"}}}}
assert encode_item(subj, Outer) == expected
subj = {"count": {"N": "3"}, "stuff": {"M": {"name": {"S": "bob"}}}}
expected = Outer(count=3, stuff=Inner(name="bob"))
assert decode_item(subj, Outer) == expected
def test_item2():
subj = Outer(stuff=Inner(name="bob"))
expected = {"stuff": {"M": {"name": {"S": "bob"}}}}
assert encode_item(subj, Outer) == expected
subj = {"stuff": {"M": {"name": {"S": "bob"}}}, "other_key": {"S": "ignored"}}
expected = Outer(stuff=Inner(name="bob"))
assert decode_item(subj, Outer) == expected
def test_ad_hoc_atoms():
rs = dynamodb_ruleset()
actual = rs.ad_hoc(
":",
arg_null=None,
arg_bool=False,
arg_int=3,
arg_float=6.6,
arg_dec=Decimal("-7.888"),
arg_str="some_string",
arg_bytes=b"some_byes",
arg_class=Outer(stuff=Inner(name="bob")),
)
assert actual == {
":arg_bool": {"BOOL": False},
":arg_bytes": {"B": "c29tZV9ieWVz"},
":arg_dec": {"N": "-7.888"},
":arg_float": {"N": "6.6"},
":arg_int": {"N": "3"},
":arg_null": {"NULL": True},
":arg_str": {"S": "some_string"},
":arg_class": {"M": {"stuff": {"M": {"name": {"S": "bob"}}}}},
}
def test_ad_hoc_typed():
rs = dynamodb_ruleset()
actual = rs.ad_hoc(
":",
arg_opt1=(None, Optional[int]),
arg_opt2=(5, Optional[int]),
arg_list=([3, 2.2, 6.0], List[float]),
arg_tup=((3, 2.2, 6.0), Tuple[float, ...]),
arg_class=(Outer(stuff=Inner(name="bob")), Outer),
arg_str_set=({"foo", "bar", "qux"}, Set[str]),
)
assert cheat(actual) == {
":arg_opt1": {"NULL": True},
":arg_opt2": {"N": "5"},
":arg_list": {"L": [{"N": "3"}, {"N": "2.2"}, {"N": "6.0"}]},
":arg_tup": {"L": [{"N": "3"}, {"N": "2.2"}, {"N": "6.0"}]},
":arg_class": {"M": {"stuff": {"M": {"name": {"S": "bob"}}}}},
":arg_str_set": {"SS": ["bar", "foo", "qux"]},
}
|
0 | capitalone_repos/json-syntax/tests | capitalone_repos/json-syntax/tests/extras/test_loose_dates.py | import pytest
from tests.common import Rules
from json_syntax.extras import loose_dates as exam
from json_syntax.helpers import JSON2PY, PY2JSON, INSP_PY, INSP_JSON, python_minor
from datetime import date, datetime
@pytest.mark.skipif(
python_minor < (3, 7), reason="datetime.isoformat not supported before python 3.7"
)
def test_iso_dates_loose():
"Test the iso_dates_loose handles dates using ISO8601 and accepts datetimes."
decoder = exam.iso_dates_loose(verb=JSON2PY, typ=date, ctx=Rules())
assert decoder("1776-07-04") == date(1776, 7, 4)
assert decoder("6543-02-01T09:09:09") == date(6543, 2, 1)
encoder = exam.iso_dates_loose(verb=PY2JSON, typ=date, ctx=Rules())
assert encoder(date(1776, 7, 4)) == "1776-07-04"
inspect = exam.iso_dates_loose(verb=INSP_PY, typ=date, ctx=Rules())
assert inspect(date(1776, 7, 4))
assert not inspect(datetime(1776, 7, 4, 3, 3))
assert not inspect("2000-01-01")
assert not inspect("2000-01-01T03:03:03")
assert not inspect("string")
inspect = exam.iso_dates_loose(verb=INSP_JSON, typ=date, ctx=Rules())
assert not inspect(date(1776, 7, 4))
assert not inspect(datetime(1776, 7, 4, 3, 3))
assert inspect("2000-01-01")
assert inspect("2000-01-01T03:03:03")
assert not inspect("string")
|
0 | capitalone_repos/json-syntax/tests | capitalone_repos/json-syntax/tests/extras/__init__.py | # noqa
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/json_syntax/string.py | from .action_v1 import (
check_parse_error,
check_str_enum,
convert_date,
convert_enum_str,
convert_str_enum,
)
from .helpers import STR2PY, PY2STR, INSP_STR, issub_safe
from datetime import date
from enum import Enum
from functools import partial
"""
As JSON requires string keys, unless dicts are only allowed to be Dict[str, T], we need to
be able to encode values as strings.
Recommendations:
* The string verbs are not intended for direct use.
* Use these verbs for any type that must be represented as a key in a JSON object.
* The standard rules will only handle types that are reliable keys and have obvious string
encodings.
See std.dicts for an example.
"""
def stringify_keys(verb, typ, ctx):
if verb not in (STR2PY, PY2STR, INSP_STR):
return
if typ in (str, int):
if verb == STR2PY:
return typ
elif verb == PY2STR:
return str
elif verb == INSP_STR:
return partial(check_parse_error, parser=typ, error=ValueError)
elif typ == date:
if verb == PY2STR:
return typ.isoformat
elif verb in (STR2PY, INSP_STR):
parse = convert_date
if verb == STR2PY:
return parse
else:
return partial(
check_parse_error, parser=parse, error=(TypeError, ValueError)
)
elif issub_safe(typ, Enum):
if verb == PY2STR:
return partial(convert_enum_str, typ=typ)
elif verb == STR2PY:
return partial(convert_str_enum, typ=typ)
elif verb == INSP_STR:
return partial(check_str_enum, typ=typ)
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/json_syntax/std.py | from .helpers import (
JSON2PY,
PY2JSON,
INSP_JSON,
INSP_PY,
PATTERN,
STR2PY,
PY2STR,
INSP_STR,
)
from .types import (
has_origin,
get_origin,
issub_safe,
NoneType,
)
from .action_v1 import (
check_collection,
check_float,
check_isinst,
check_has_type,
check_mapping,
check_optional,
check_parse_error,
check_str_enum,
convert_collection,
convert_date,
convert_datetime,
convert_decimal_str,
convert_enum_str,
convert_float,
convert_mapping,
convert_none,
convert_optional,
convert_str_enum,
convert_str_timedelta,
convert_time,
convert_timedelta_str,
pass_faux_enum,
)
from . import pattern as pat
from collections import OrderedDict
from datetime import datetime, date, time, timedelta
from decimal import Decimal
from enum import Enum
from functools import partial
from typing import Union
"""
These are standard rules to handle various types.
All rules take a verb, a Python type and a context, which is generally a RuleSet. A rule
returns a conversion function for that verb.
"""
def atoms(verb, typ, ctx):
"Rule to handle atoms that translate trivially."
if issub_safe(typ, (str, int, NoneType)):
if verb in (JSON2PY, PY2JSON):
if typ is NoneType:
return convert_none
for base in (str, bool, int): # n.b. bool is a subclass of int.
if typ == base:
return base
elif verb in (INSP_PY, INSP_JSON):
for base in (NoneType, str, bool, int):
if typ == base:
return partial(check_isinst, typ=base)
elif verb == PATTERN:
for base, node in [
(NoneType, pat.Null),
(str, pat.String.any),
(bool, pat.Bool),
(int, pat.Number),
]:
if typ == base:
return node
def floats(verb, typ, ctx):
"""
Rule to handle floats passing NaNs through unaltered.
JSON technically recognizes integers and floats. Many JSON generators will represent
floats with integral value as integers. Thus, this rule will convert both integers and
floats in JSON to floats in Python.
Python's standard JSON libraries treat `nan` and `inf` as special constants, but this is
not standard JSON.
This rule simply treats them as regular float values. If you want to catch them, you can
set ``allow_nan=False`` in ``json.dump()``.
"""
if typ == float:
if verb in (JSON2PY, PY2JSON):
return float
elif verb == INSP_PY:
return partial(check_isinst, typ=float)
elif verb == INSP_JSON:
return partial(check_isinst, typ=(int, float))
elif verb == PATTERN:
return pat.Number
def floats_nan_str(verb, typ, ctx):
"""
Rule to handle floats passing NaNs through as strings.
Python's standard JSON libraries treat `nan` and `inf` as special constants, but this is
not standard JSON.
This rule converts special constants to string names.
"""
if typ == float:
if verb == JSON2PY:
return float
elif verb == PY2JSON:
return convert_float
elif verb == INSP_PY:
return partial(check_isinst, typ=float)
elif verb == INSP_JSON:
return check_float
elif verb == PATTERN:
return pat.Number
def decimals(verb, typ, ctx):
"""
Rule to handle decimals natively.
This rule requires that your JSON library has decimal support, e.g. simplejson.
Other JSON processors may convert values to and from floating-point; if that's a
concern, consider `decimals_as_str`.
This rule will fail if passed a special constant.
"""
if typ == Decimal:
if verb in (JSON2PY, PY2JSON):
return Decimal
elif verb in (INSP_JSON, INSP_PY):
return partial(check_isinst, typ=Decimal)
elif verb == PATTERN:
return pat.Number
def decimals_as_str(verb, typ, ctx):
"""
Rule to handle decimals as strings.
This rule bypasses JSON library decimal support, e.g. simplejson.
This rule will fail if passed a special constant.
"""
if typ == Decimal:
if verb == JSON2PY:
return Decimal
elif verb == PY2JSON:
return convert_decimal_str
elif verb == INSP_PY:
return partial(check_isinst, typ=Decimal)
elif verb in (INSP_JSON, PATTERN):
inspect = partial(check_parse_error, parser=Decimal, error=ArithmeticError)
return pat.String("number", inspect) if verb == PATTERN else inspect
def iso_dates(verb, typ, ctx):
"""
Rule to handle iso formatted datetimes and dates.
This simply uses the `fromisoformat` and `isoformat` methods of `date` and `datetime`.
There is a loose variant in the examples that will accept a datetime in a date. A
datetime always accepts both dates and datetimes.
"""
if typ not in (date, datetime, time, timedelta):
return
if verb == PY2JSON:
return convert_timedelta_str if typ == timedelta else typ.isoformat
elif verb == INSP_PY:
return partial(check_has_type, typ=typ)
elif verb in (JSON2PY, INSP_JSON, PATTERN):
if typ == date:
parse = convert_date
elif typ == datetime:
parse = convert_datetime
elif typ == time:
parse = convert_time
elif typ == timedelta:
parse = convert_str_timedelta
else:
return
if verb == JSON2PY:
return parse
inspect = partial(
check_parse_error, parser=parse, error=(TypeError, ValueError)
)
return pat.String(typ.__name__, inspect) if verb == PATTERN else inspect
def enums(verb, typ, ctx):
"Rule to convert between enumerated types and strings."
if issub_safe(typ, Enum):
if verb == PY2JSON:
return partial(convert_enum_str, typ=typ)
elif verb == JSON2PY:
return partial(convert_str_enum, typ=typ)
elif verb == INSP_PY:
return partial(check_isinst, typ=typ)
elif verb in (INSP_JSON, PATTERN):
inspect = partial(check_str_enum, typ=typ)
return pat.String(typ.__name__, inspect) if verb == PATTERN else inspect
def faux_enums(verb, typ, ctx):
"Rule to fake an Enum by actually using strings."
if issub_safe(typ, Enum):
if verb in (JSON2PY, PY2JSON):
return partial(pass_faux_enum, typ=typ)
elif verb in (INSP_JSON, INSP_PY, PATTERN):
inspect = partial(check_str_enum, typ=typ)
return pat.String(typ.__name__, inspect) if verb == PATTERN else inspect
def optional(verb, typ, ctx):
"""
Handle an ``Optional[inner]`` by passing ``None`` through.
"""
if verb not in (JSON2PY, PY2JSON, INSP_PY, INSP_JSON, PATTERN):
return
if has_origin(typ, Union, num_args=2):
if NoneType not in typ.__args__:
return
inner = None
for arg in typ.__args__:
if arg is not NoneType:
inner = arg
if inner is None:
raise TypeError("Could not find inner type for Optional: " + str(typ))
else:
return
inner = ctx.lookup(verb=verb, typ=inner)
if verb in (JSON2PY, PY2JSON):
return partial(convert_optional, inner=inner)
elif verb in (INSP_JSON, INSP_PY):
return partial(check_optional, inner=inner)
elif verb == PATTERN:
return pat.Alternatives([pat.Null, inner])
def lists(verb, typ, ctx):
"""
Handle a ``List[type]`` or ``Tuple[type, ...]``.
Trivia: the ellipsis indicates a homogenous tuple; ``Tuple[A, B, C]`` is a product
type that contains exactly those elements.
"""
if verb not in (JSON2PY, PY2JSON, INSP_PY, INSP_JSON, PATTERN):
return
if has_origin(typ, list, num_args=1):
(inner,) = typ.__args__
elif has_origin(typ, tuple, num_args=2):
(inner, ell) = typ.__args__
if ell is not Ellipsis:
return
else:
return
inner = ctx.lookup(verb=verb, typ=inner)
con = list if verb in (PY2JSON, INSP_JSON, PATTERN) else get_origin(typ)
if verb in (JSON2PY, PY2JSON):
return partial(convert_collection, inner=inner, con=con)
elif verb in (INSP_JSON, INSP_PY):
return partial(check_collection, inner=inner, con=con)
elif verb == PATTERN:
return pat.Array.homog(inner)
def sets(verb, typ, ctx):
"""
Handle a ``Set[type]`` or ``FrozenSet[type]``.
"""
if verb not in (JSON2PY, PY2JSON, INSP_PY, INSP_JSON, PATTERN):
return
if not has_origin(typ, (set, frozenset), num_args=1):
return
(inner,) = typ.__args__
con = list if verb in (PY2JSON, INSP_JSON, PATTERN) else get_origin(typ)
inner = ctx.lookup(verb=verb, typ=inner)
if verb in (JSON2PY, PY2JSON):
return partial(convert_collection, inner=inner, con=con)
elif verb in (INSP_JSON, INSP_PY):
return partial(check_collection, inner=inner, con=con)
elif verb == PATTERN:
return pat.Array.homog(inner)
_STRING = {
JSON2PY: STR2PY,
PY2JSON: PY2STR,
INSP_JSON: INSP_STR,
INSP_PY: INSP_PY,
PATTERN: PATTERN,
}
def dicts(verb, typ, ctx):
"""
Handle a ``Dict[key, value]`` where key is a string, integer, date or enum type.
"""
if verb not in _STRING or not has_origin(typ, (dict, OrderedDict), num_args=2):
return
(key_type, val_type) = typ.__args__
inner_key = ctx.lookup(verb=_STRING[verb], typ=key_type)
inner_val = ctx.lookup(verb=verb, typ=val_type)
if verb in (JSON2PY, PY2JSON):
return partial(
convert_mapping, key=inner_key, val=inner_val, con=get_origin(typ)
)
elif verb in (INSP_JSON, INSP_PY):
return partial(check_mapping, key=inner_key, val=inner_val, con=get_origin(typ))
elif verb == PATTERN:
return pat.Object.homog(inner_key, inner_val)
|
0 | capitalone_repos/json-syntax | capitalone_repos/json-syntax/json_syntax/attrs.py | from .helpers import JSON2PY, PY2JSON, INSP_JSON, INSP_PY, PATTERN, has_origin, identity
from .action_v1 import (
check_dict,
check_isinst,
check_tuple_as_list,
convert_attrs_to_dict,
convert_dict_to_dict,
convert_dict_to_attrs,
convert_tuple_as_list,
)
from . import pattern as pat
from .product import build_attribute_map, build_named_tuple_map, build_typed_dict_map
from .types import is_generic, get_origin, get_argument_map
from functools import partial
_SUPPORTED_VERBS = (JSON2PY, PY2JSON, INSP_PY, INSP_JSON, PATTERN)
def attrs_classes(
verb,
typ,
ctx,
pre_hook="__json_pre_decode__",
post_hook="__json_post_encode__",
check="__json_check__",
):
"""
Handle an ``@attr.s`` or ``@dataclass`` decorated class.
This rule also implements several hooks to handle complex cases, especially to
manage backwards compatibility. Hooks should be resilient against invalid data,
and should not mutate their inputs.
`__json_pre_decode__` is used by decoders constructed by `RuleSet.json_to_python`.
It will be called before decoding with the JSON object and may adjust them to fit
the expected structure, which must be a `dict` with the necessary fields.
The checker generated by `inspect_json` will also call `__json_pre_decode__` before
inspecting the value generated.
`__json_post_encode__` is used by encoders constructed by `RuleSet.python_to_json`.
It will be called after encoding with the JSON object and may adjust it as
necessary.
`__json_check__` may be used to completely override the `inspect_json` check generated
for this class.
"""
if verb not in _SUPPORTED_VERBS:
return
if is_generic(typ):
typ_args = get_argument_map(typ)
typ = get_origin(typ)
else:
typ_args = None
inner_map = build_attribute_map(verb, typ, ctx, typ_args)
if inner_map is None:
return
if verb == INSP_PY:
return partial(check_isinst, typ=typ)
if verb == JSON2PY:
pre_hook_method = getattr(typ, pre_hook, identity)
return partial(
convert_dict_to_attrs,
pre_hook=pre_hook_method,
inner_map=inner_map,
con=typ,
)
elif verb == PY2JSON:
post_hook = post_hook if hasattr(typ, post_hook) else None
return partial(convert_attrs_to_dict, post_hook=post_hook, inner_map=inner_map)
elif verb == INSP_JSON:
check = getattr(typ, check, None)
if check:
return check
pre_hook_method = getattr(typ, pre_hook, identity)
return partial(check_dict, inner_map=inner_map, pre_hook=pre_hook_method)
elif verb == PATTERN:
return pat.Object.exact(
(pat.String.exact(attr.name), attr.inner or pat.Unkown)
for attr in inner_map
if attr.is_required
)
def named_tuples(verb, typ, ctx):
"""
Handle a ``NamedTuple(name, [('field', type), ('field', type)])`` type.
Also handles a ``collections.namedtuple`` if you have a fallback handler.
Warning: there's no clear runtime marker that something is a namedtuple; it's just
a subclass of ``tuple`` that has some special fields.
"""
if verb not in _SUPPORTED_VERBS:
return
inner_map = build_named_tuple_map(verb, typ, ctx)
if inner_map is None:
return
if verb == INSP_PY:
return partial(check_isinst, typ=typ)
elif verb == JSON2PY:
return partial(
convert_dict_to_attrs, pre_hook=identity, inner_map=inner_map, con=typ
)
elif verb == PY2JSON:
return partial(convert_attrs_to_dict, post_hook=None, inner_map=inner_map)
elif verb == INSP_JSON:
return partial(check_dict, pre_hook=identity, inner_map=inner_map)
elif verb == PATTERN:
return pat.Object.exact(
(pat.String.exact(attr.name), attr.inner)
for attr in inner_map
if attr.is_required
)
def typed_dicts(verb, typ, ctx):
"""
Handle the TypedDict product type. This allows you to construct a dict with specific
(string) keys, which is often how people really use dicts.
Both the class form and the functional form,
``TypedDict('Name', {'field': type, 'field': type})`` are supported.
"""
if verb not in _SUPPORTED_VERBS:
return
inner_map = build_typed_dict_map(verb, typ, ctx)
if inner_map is None:
return
# Note: we pass `dict` as the typ here because it's the correct constructor.
if verb in (JSON2PY, PY2JSON):
return partial(convert_dict_to_dict, inner_map=inner_map, con=typ)
elif verb in (INSP_JSON, INSP_PY):
return partial(check_dict, pre_hook=identity, inner_map=inner_map)
elif verb == PATTERN:
return pat.Object.exact(
(pat.String.exact(attr.name), attr.inner)
for attr in inner_map
if attr.is_required
)
def tuples(verb, typ, ctx):
"""
Handle a ``Tuple[type, type, type]`` product type. Use a ``NamedTuple`` if you don't
want a list. Though, if possible, prefer ``attrs`` or ``dataclass``.
"""
if verb not in _SUPPORTED_VERBS or not has_origin(typ, tuple):
return
args = typ.__args__
if Ellipsis in args:
# This is a homogeneous tuple, use the lists rule.
return
inner = [ctx.lookup(verb=verb, typ=arg) for arg in args]
if verb == JSON2PY:
return partial(convert_tuple_as_list, inner=inner, con=tuple)
elif verb == PY2JSON:
return partial(convert_tuple_as_list, inner=inner, con=list)
elif verb == INSP_PY:
return partial(check_tuple_as_list, inner=inner, con=tuple)
elif verb == INSP_JSON:
return partial(check_tuple_as_list, inner=inner, con=list)
elif verb == PATTERN:
return pat.Array.exact(inner)
|