Skip to content

Commit a887d01

Browse files
committed
chore: format with cfformat
1 parent 66c2570 commit a887d01

36 files changed

+1652
-1593
lines changed

.cfformat.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"array.empty_padding": false,
3+
"array.padding": true,
4+
"array.multiline.min_length": 40,
5+
"array.multiline.element_count": 2,
6+
"array.multiline.leading_comma.padding": true,
7+
"array.multiline.leading_comma": false,
8+
"alignment.consecutive.assignments": true,
9+
"alignment.consecutive.properties": true,
10+
"alignment.consecutive.params": true,
11+
"brackets.padding": true,
12+
"comment.asterisks": "align",
13+
"binary_operators.padding": true,
14+
"for_loop_semicolons.padding": true,
15+
"function_call.empty_padding": false,
16+
"function_call.padding": true,
17+
"function_call.multiline.leading_comma.padding": true,
18+
"function_call.casing.builtin": "cfdocs",
19+
"function_call.casing.userdefined": "camel",
20+
"function_call.multiline.element_count": 3,
21+
"function_call.multiline.leading_comma": false,
22+
"function_call.multiline.min_length": 40,
23+
"function_declaration.padding": true,
24+
"function_declaration.empty_padding": false,
25+
"function_declaration.multiline.leading_comma": false,
26+
"function_declaration.multiline.leading_comma.padding": true,
27+
"function_declaration.multiline.element_count": 3,
28+
"function_declaration.multiline.min_length": 40,
29+
"function_declaration.group_to_block_spacing": "spaced",
30+
"function_anonymous.empty_padding": false,
31+
"function_anonymous.group_to_block_spacing": "spaced",
32+
"function_anonymous.multiline.element_count": 3,
33+
"function_anonymous.multiline.leading_comma": false,
34+
"function_anonymous.multiline.leading_comma.padding": true,
35+
"function_anonymous.multiline.min_length": 40,
36+
"function_anonymous.padding": true,
37+
"indent_size": 4,
38+
"keywords.block_to_keyword_spacing": "spaced",
39+
"keywords.group_to_block_spacing": "spaced",
40+
"keywords.padding_inside_group": true,
41+
"keywords.spacing_to_block": "spaced",
42+
"keywords.spacing_to_group": true,
43+
"keywords.empty_group_spacing": false,
44+
"max_columns": 120,
45+
"metadata.multiline.element_count": 3,
46+
"metadata.multiline.min_length": 40,
47+
"newline": "\n",
48+
"property.multiline.element_count": 3,
49+
"property.multiline.min_length": 40,
50+
"parentheses.padding": true,
51+
"strings.quote": "double",
52+
"strings.convertNestedQuotes": false,
53+
"strings.attributes.quote": "double",
54+
"struct.separator": " : ",
55+
"struct.padding": true,
56+
"struct.empty_padding": false,
57+
"struct.multiline.leading_comma": false,
58+
"struct.multiline.leading_comma.padding": true,
59+
"struct.multiline.element_count": 2,
60+
"struct.multiline.min_length": 40,
61+
"tab_indent": true
62+
}

ModuleConfig.cfc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
component {
22

3-
this.name = "hyper";
4-
this.author = "";
5-
this.webUrl = "https://github.com/elpete/hyper";
6-
this.cfmapping = "hyper";
3+
this.name = "hyper";
4+
this.author = "";
5+
this.webUrl = "https://github.com/elpete/hyper";
6+
this.cfmapping = "hyper";
7+
8+
function configure() {
9+
}
710

8-
function configure() {}
911
}

models/CfhttpHttpClient.cfc

Lines changed: 91 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -3,104 +3,102 @@
33
*/
44
component implements="HyperHttpClientInterface" {
55

6-
/**
7-
* Execute the HyperRequest and map it to a HyperResponse.
8-
*
9-
* @req The HyperRequest to execute.
10-
*
11-
* @returns A HyperResponse of the executed request.
12-
*/
13-
public HyperResponse function send( required HyperRequest req ) {
14-
var cfhttpResponse = makeCFHTTPRequest( req );
15-
return new Hyper.models.HyperResponse(
16-
originalRequest = req,
17-
charset = cfhttpResponse.charset ?: "UTF-8",
18-
statusCode = cfhttpResponse.responseheader.status_code ?: 504,
19-
headers = normalizeHeaders( cfhttpResponse ),
20-
data = cfhttpResponse.filecontent
21-
);
22-
}
6+
/**
7+
* Execute the HyperRequest and map it to a HyperResponse.
8+
*
9+
* @req The HyperRequest to execute.
10+
*
11+
* @returns A HyperResponse of the executed request.
12+
*/
13+
public HyperResponse function send( required HyperRequest req ) {
14+
var cfhttpResponse = makeCFHTTPRequest( req );
15+
return new Hyper.models.HyperResponse(
16+
originalRequest = req,
17+
charset = cfhttpResponse.charset ?: "UTF-8",
18+
statusCode = cfhttpResponse.responseheader.status_code ?: 504,
19+
headers = normalizeHeaders( cfhttpResponse ),
20+
data = cfhttpResponse.filecontent
21+
);
22+
}
2323

24-
/**
25-
* Makes an HTTP request using CFHTTP.
26-
*
27-
* @req The request to execute
28-
*
29-
* @returns The CFHTTP response struct.
30-
*/
31-
private struct function makeCFHTTPRequest( required HyperRequest req ) {
32-
local.res = "";
33-
var attrCollection = {
34-
result = "local.res",
35-
timeout = req.getTimeout(),
36-
url = req.getFullUrl(),
37-
method = req.getMethod(),
38-
redirect = false,
39-
throwonerror = req.getThrowOnError(),
40-
resolveURL = req.getResolveUrls()
41-
};
24+
/**
25+
* Makes an HTTP request using CFHTTP.
26+
*
27+
* @req The request to execute
28+
*
29+
* @returns The CFHTTP response struct.
30+
*/
31+
private struct function makeCFHTTPRequest( required HyperRequest req ) {
32+
local.res = "";
33+
var attrCollection = {
34+
result : "local.res",
35+
timeout : req.getTimeout(),
36+
url : req.getFullUrl(),
37+
method : req.getMethod(),
38+
redirect : false,
39+
throwonerror : req.getThrowOnError(),
40+
resolveURL : req.getResolveUrls()
41+
};
4242

43-
if ( len( req.getUsername() ) ) {
44-
attrCollection[ "username" ] = req.getUsername();
45-
}
46-
if ( len( req.getPassword() ) ) {
47-
attrCollection[ "password" ] = req.getPassword();
48-
}
43+
if ( len( req.getUsername() ) ) {
44+
attrCollection[ "username" ] = req.getUsername();
45+
}
46+
if ( len( req.getPassword() ) ) {
47+
attrCollection[ "password" ] = req.getPassword();
48+
}
4949

50-
cfhttp( attributeCollection = attrCollection ) {
51-
var headers = req.getHeaders();
52-
for ( var name in headers ) {
53-
cfhttpparam(
54-
type = "header",
55-
name = name,
56-
value = headers[ name ]
57-
);
58-
}
50+
cfhttp( attributeCollection=attrCollection ) {
51+
var headers = req.getHeaders();
52+
for ( var name in headers ) {
53+
cfhttpparam(
54+
type ="header",
55+
name =name,
56+
value=headers[ name ]
57+
);
58+
}
5959

60-
var queryParams = req.getQueryParams();
61-
for ( var name in queryParams ) {
62-
cfhttpparam(
63-
type = "url",
64-
name = name,
65-
value = queryParams[ name ]
66-
);
67-
}
60+
var queryParams = req.getQueryParams();
61+
for ( var name in queryParams ) {
62+
cfhttpparam(
63+
type ="url",
64+
name =name,
65+
value=queryParams[ name ]
66+
);
67+
}
6868

69-
if ( req.hasBody() ) {
70-
if ( req.getBodyFormat() == "json" ) {
71-
cfhttpparam( type = "body", value = req.prepareBody() );
72-
}
73-
else if ( req.getBodyFormat() == "formFields" ) {
74-
var body = req.getBody();
75-
for ( var fieldName in body ) {
76-
cfhttpparam(
77-
type = "formfield",
78-
name = fieldName,
79-
value = body[ fieldName ]
80-
);
81-
}
82-
}
83-
else {
84-
cfhttpparam( type = "body", value = req.prepareBody() );
85-
}
86-
}
87-
}
88-
return local.res;
89-
}
69+
if ( req.hasBody() ) {
70+
if ( req.getBodyFormat() == "json" ) {
71+
cfhttpparam( type="body", value=req.prepareBody() );
72+
} else if ( req.getBodyFormat() == "formFields" ) {
73+
var body = req.getBody();
74+
for ( var fieldName in body ) {
75+
cfhttpparam(
76+
type ="formfield",
77+
name =fieldName,
78+
value=body[ fieldName ]
79+
);
80+
}
81+
} else {
82+
cfhttpparam( type="body", value=req.prepareBody() );
83+
}
84+
}
85+
}
86+
return local.res;
87+
}
9088

91-
/**
92-
* Normalizes the headers from a CFHTTP response into a normalized struct.
93-
*
94-
* @cfhttpResponse The cfhttp response struct.
95-
*
96-
* @returns A struct of normalized headers.
97-
*/
98-
private struct function normalizeHeaders( required struct cfhttpResponse ) {
99-
var headers = {};
100-
cfhttpResponse.responseheader.each( function( name, value ) {
101-
headers[ lcase( name ) ] = value;
102-
} );
103-
return headers;
104-
}
89+
/**
90+
* Normalizes the headers from a CFHTTP response into a normalized struct.
91+
*
92+
* @cfhttpResponse The cfhttp response struct.
93+
*
94+
* @returns A struct of normalized headers.
95+
*/
96+
private struct function normalizeHeaders( required struct cfhttpResponse ) {
97+
var headers = {};
98+
cfhttpResponse.responseheader.each( function( name, value ) {
99+
headers[ lCase( name ) ] = value;
100+
} );
101+
return headers;
102+
}
105103

106104
}

models/HyperBuilder.cfc

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,49 @@
11
/**
2-
* Creates new requests with optional defaults.
3-
*/
2+
* Creates new requests with optional defaults.
3+
*/
44
component singleton {
55

6-
/**
7-
* The default request object.
8-
* This object is duplicated for each new request.
9-
*/
10-
this.defaults = new Hyper.models.HyperRequest();
6+
/**
7+
* The default request object.
8+
* This object is duplicated for each new request.
9+
*/
10+
this.defaults = new Hyper.models.HyperRequest();
1111

12-
/**
13-
* Create a new HyperBuilder.
14-
* Any arguments passed are set on the default request.
15-
*
16-
* @returns The new HyperBuilder instance.
17-
*/
18-
function init() {
19-
for ( var key in arguments ) {
20-
invoke( this.defaults, "set#key#", { 1 = arguments[ key ] } );
21-
}
22-
return this;
23-
}
12+
/**
13+
* Create a new HyperBuilder.
14+
* Any arguments passed are set on the default request.
15+
*
16+
* @returns The new HyperBuilder instance.
17+
*/
18+
function init() {
19+
for ( var key in arguments ) {
20+
invoke(
21+
this.defaults,
22+
"set#key#",
23+
{ 1 : arguments[ key ] }
24+
);
25+
}
26+
return this;
27+
}
2428

25-
/**
26-
* Create a new request from the default request.
27-
*
28-
* @returns A new HyperRequest instance from the default request.
29-
*/
30-
function new() {
31-
return duplicate( this.defaults );
32-
}
29+
/**
30+
* Create a new request from the default request.
31+
*
32+
* @returns A new HyperRequest instance from the default request.
33+
*/
34+
function new() {
35+
return duplicate( this.defaults );
36+
}
3337

34-
/**
35-
* Forward on other calls to a new request instance.
36-
*/
37-
function onMissingMethod( missingMethodName, missingMethodArguments ) {
38-
return invoke( variables.new(), missingMethodName, missingMethodArguments );
39-
}
38+
/**
39+
* Forward on other calls to a new request instance.
40+
*/
41+
function onMissingMethod( missingMethodName, missingMethodArguments ) {
42+
return invoke(
43+
variables.new(),
44+
missingMethodName,
45+
missingMethodArguments
46+
);
47+
}
4048

4149
}

models/HyperHttpClientInterface.cfc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
*/
44
interface displayname="HyperHttpClientInterface" {
55

6-
/**
7-
* Execute the HyperRequest and map it to a HyperResponse.
8-
*
9-
* @req The HyperRequest to execute.
10-
*
11-
* @returns A HyperResponse of the executed request.
12-
*/
13-
public HyperResponse function send( required HyperRequest req );
6+
/**
7+
* Execute the HyperRequest and map it to a HyperResponse.
8+
*
9+
* @req The HyperRequest to execute.
10+
*
11+
* @returns A HyperResponse of the executed request.
12+
*/
13+
public HyperResponse function send( required HyperRequest req );
1414

1515
}

0 commit comments

Comments
 (0)