Skip to content

Commit

Permalink
Merge pull request #14 from ba-st/fixed-typos
Browse files Browse the repository at this point in the history
Fixed CORS support and did a few renames.
  • Loading branch information
fortizpenaloza authored Nov 17, 2018
2 parents e97b708 + 4a797ff commit 8f1d73f
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ PetOrdersRESTfulController >> provideHypermediaPolicy [
{ #category : #'private - accessing' }
PetOrdersRESTfulController >> providePaginationPolicy [

^ RESTFullControllerDoNotPaginateCollectionsPolicy for: self
^ RESTfulControllerDoNotPaginateCollectionsPolicy for: self
]

{ #category : #'private - API' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ I'm an example RESTful Web Service specification implementing Pet Order resource
"
Class {
#name : #PetOrdersRESTfulControllerSpecification,
#superclass : #ResourceRESTFulControllerSpecification,
#superclass : #ResourceRESTfulControllerSpecification,
#category : #'Stargate-Examples'
}

Expand Down
2 changes: 1 addition & 1 deletion source/Stargate-Examples/PetsRESTfulController.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ PetsRESTfulController >> provideHypermediaPolicy [
{ #category : #'private - accessing' }
PetsRESTfulController >> providePaginationPolicy [

^ RESTFullControllerPaginateCollectionsPolicy for: self with: self defaultPaginationLimit
^ RESTfulControllerPaginateCollectionsPolicy for: self with: self defaultPaginationLimit
]

{ #category : #'private - state management' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ I'm an example RESTful Web Service specification implementing Pet resource manag
"
Class {
#name : #PetsRESTfulControllerSpecification,
#superclass : #ResourceRESTFulControllerSpecification,
#superclass : #ResourceRESTfulControllerSpecification,
#category : #'Stargate-Examples'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ Class {
}

{ #category : #tests }
CrossOriginResourceSharingHandlerTest >> testValue [
CrossOriginResourceSharingHandlerTest >> testEvaluationOnRequest [

| handler response |

handler := CrossOriginResourceSharingHandler allowing: #('GET' 'POST').
response := handler value: (ZnRequest options: 'url').
response := handler teaEvalActionOnRequest: (ZnRequest options: 'url').

self
assert: response code equals: 204;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
I'm a Test Case for PaginationSpec
"
Class {
#name : #PaginationSpecTest,
#name : #PaginationSpecificationTest,
#superclass : #TestCase,
#category : #'Stargate-Model-Tests-Pagination'
}

{ #category : #tests }
PaginationSpecTest >> testAccessing [
PaginationSpecificationTest >> testAccessing [

| spec |

spec := PaginationSpec startingAt: 1 limitedTo: 5.
spec := PaginationSpecification startingAt: 1 limitedTo: 5.

self
assert: spec start equals: 1;
Expand All @@ -21,10 +21,10 @@ PaginationSpecTest >> testAccessing [
]

{ #category : #tests }
PaginationSpecTest >> testPrintString [
PaginationSpecificationTest >> testPrintString [

self
assert: (PaginationSpec startingAt: 1 limitedTo: 5) printString
assert: (PaginationSpecification startingAt: 1 limitedTo: 5) printString
equals:
'start=1
limit=5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
Unit Test
"
Class {
#name : #RESTFullControllerDoNotPaginateCollectionsPolicyTest,
#name : #RESTfulControllerDoNotPaginateCollectionsPolicyTest,
#superclass : #TestCase,
#category : #'Stargate-Model-Tests-Pagination'
}

{ #category : #private }
RESTFullControllerDoNotPaginateCollectionsPolicyTest >> evaluateQuery: aBlockClosure [
RESTfulControllerDoNotPaginateCollectionsPolicyTest >> evaluateQuery: aBlockClosure [

^ aBlockClosure value
]

{ #category : #tests }
RESTFullControllerDoNotPaginateCollectionsPolicyTest >> testBehavior [
RESTfulControllerDoNotPaginateCollectionsPolicyTest >> testBehavior [

| policy context controls response |

context := HttpRequestContext new.
controls := #().
policy := RESTFullControllerDoNotPaginateCollectionsPolicy for: self.
policy := RESTfulControllerDoNotPaginateCollectionsPolicy for: self.
self assert: (policy addPaginationControlsTo: controls within: context) isEmpty.

response := ZnResponse noContent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CrossOriginResourceSharingHandler >> initializeAllowing: anHttpMethodsCollection
]

{ #category : #evaluating }
CrossOriginResourceSharingHandler >> value: aRequest [
CrossOriginResourceSharingHandler >> teaEvalActionOnRequest: aRequest [

| response |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ I'm a policy supporting hypermedia-driven RESTful controllers.
"
Class {
#name : #HypermediaDrivenRESTfulControllerPolicy,
#superclass : #HypermediaPolicy,
#superclass : #RESTfulControllerHypermediaPolicy,
#instVars : [
'resourceController'
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ I'm a policy non-supporting hypermedia-driven RESTful controllers.
"
Class {
#name : #NonHypermediaDrivenRESTfulControllerPolicy,
#superclass : #HypermediaPolicy,
#superclass : #RESTfulControllerHypermediaPolicy,
#category : #'Stargate-Model-HATEOAS'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
I'm a pagination specification, used to know the start index and the expected page size
"
Class {
#name : #PaginationSpec,
#name : #PaginationSpecification,
#superclass : #Object,
#instVars : [
'start',
Expand All @@ -12,34 +12,34 @@ Class {
}

{ #category : #'Instance creation' }
PaginationSpec class >> startingAt: aNumber limitedTo: aLimit [
PaginationSpecification class >> startingAt: aNumber limitedTo: aLimit [

AssertionChecker enforce: [ aLimit strictlyPositive ] because: 'The page limit must be positive' raising: InstanceCreationFailed.
"We're forgiving with the starting index"
^ self new initializeStartingAt: (aNumber max: 1) limitedTo: aLimit
]

{ #category : #accessing }
PaginationSpec >> end [
PaginationSpecification >> end [

^ start + limit - 1
]

{ #category : #'initialize - release' }
PaginationSpec >> initializeStartingAt: anStartIndex limitedTo: aLimitCount [
PaginationSpecification >> initializeStartingAt: anStartIndex limitedTo: aLimitCount [

start := anStartIndex.
limit := aLimitCount
]

{ #category : #accessing }
PaginationSpec >> limit [
PaginationSpecification >> limit [

^ limit
]

{ #category : #printing }
PaginationSpec >> printOn: aStream [
PaginationSpecification >> printOn: aStream [

aStream
nextPutAll: 'start=';
Expand All @@ -50,7 +50,7 @@ PaginationSpec >> printOn: aStream [
]

{ #category : #accessing }
PaginationSpec >> start [
PaginationSpecification >> start [

^ start
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
I'm the policy indicating a RESTful controller to not support pagination of collections related to the controlled resource.
"
Class {
#name : #RESTFullControllerDoNotPaginateCollectionsPolicy,
#name : #RESTfulControllerDoNotPaginateCollectionsPolicy,
#superclass : #RESTfulControllerPaginationPolicy,
#instVars : [
'resourceController'
Expand All @@ -11,29 +11,29 @@ Class {
}

{ #category : #'instance creation' }
RESTFullControllerDoNotPaginateCollectionsPolicy class >> for: aResourceController [
RESTfulControllerDoNotPaginateCollectionsPolicy class >> for: aResourceController [

^ self new initializeFor: aResourceController
]

{ #category : #applying }
RESTFullControllerDoNotPaginateCollectionsPolicy >> addPaginationControlsTo: mediaControls within: aContext [
RESTfulControllerDoNotPaginateCollectionsPolicy >> addPaginationControlsTo: mediaControls within: aContext [

^ mediaControls
]

{ #category : #applying }
RESTFullControllerDoNotPaginateCollectionsPolicy >> affect: response within: aContext [
RESTfulControllerDoNotPaginateCollectionsPolicy >> affect: response within: aContext [
]

{ #category : #applying }
RESTFullControllerDoNotPaginateCollectionsPolicy >> evaluateQuery: aQueryEvaluationBlock basedOn: anHttpRequest [
RESTfulControllerDoNotPaginateCollectionsPolicy >> evaluateQuery: aQueryEvaluationBlock basedOn: anHttpRequest [

^ resourceController evaluateQuery: aQueryEvaluationBlock
]

{ #category : #initialization }
RESTFullControllerDoNotPaginateCollectionsPolicy >> initializeFor: aResourceController [
RESTfulControllerDoNotPaginateCollectionsPolicy >> initializeFor: aResourceController [

resourceController := aResourceController
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
I'm a policy indicating a RESTful controller if it must support or not an hypermedia driven implementation
"
Class {
#name : #HypermediaPolicy,
#name : #RESTfulControllerHypermediaPolicy,
#superclass : #Object,
#category : #'Stargate-Model-HATEOAS'
}

{ #category : #configuring }
HypermediaPolicy >> holdCollection: resourceCollection controlsBasedOn: httpRequest within: context [
RESTfulControllerHypermediaPolicy >> holdCollection: resourceCollection controlsBasedOn: httpRequest within: context [

self subclassResponsibility
]

{ #category : #configuring }
HypermediaPolicy >> holdResource: resource controlsWithin: context [
RESTfulControllerHypermediaPolicy >> holdResource: resource controlsWithin: context [

self subclassResponsibility
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
I'm the policy indicating a RESTful controller to support pagination of collections related to the controlled resource.
"
Class {
#name : #RESTFullControllerPaginateCollectionsPolicy,
#name : #RESTfulControllerPaginateCollectionsPolicy,
#superclass : #RESTfulControllerPaginationPolicy,
#instVars : [
'resourceController',
Expand All @@ -12,19 +12,19 @@ Class {
}

{ #category : #'instance creation' }
RESTFullControllerPaginateCollectionsPolicy class >> for: aResourceController with: aPaginationLimit [
RESTfulControllerPaginateCollectionsPolicy class >> for: aResourceController with: aPaginationLimit [

^ self new initializeFor: aResourceController with: aPaginationLimit
]

{ #category : #applying }
RESTFullControllerPaginateCollectionsPolicy >> addPaginationControlsTo: mediaControls within: aContext [
RESTfulControllerPaginateCollectionsPolicy >> addPaginationControlsTo: mediaControls within: aContext [

^ mediaControls , aContext paginationControls
]

{ #category : #applying }
RESTFullControllerPaginateCollectionsPolicy >> affect: response within: aContext [
RESTfulControllerPaginateCollectionsPolicy >> affect: response within: aContext [

aContext paginationControls
do: [ :assoc |
Expand All @@ -36,22 +36,22 @@ RESTFullControllerPaginateCollectionsPolicy >> affect: response within: aContext
]

{ #category : #applying }
RESTFullControllerPaginateCollectionsPolicy >> evaluateQuery: aQueryEvaluationBlock basedOn: anHttpRequest [
RESTfulControllerPaginateCollectionsPolicy >> evaluateQuery: aQueryEvaluationBlock basedOn: anHttpRequest [

^ resourceController evaluateQuery: [ aQueryEvaluationBlock cull: (self paginationFrom: anHttpRequest) ]
]

{ #category : #initialization }
RESTFullControllerPaginateCollectionsPolicy >> initializeFor: aResourceController with: aPaginationLimit [
RESTfulControllerPaginateCollectionsPolicy >> initializeFor: aResourceController with: aPaginationLimit [

resourceController := aResourceController.
defaultLimit := aPaginationLimit
]

{ #category : #private }
RESTFullControllerPaginateCollectionsPolicy >> paginationFrom: anHttpRequest [
RESTfulControllerPaginateCollectionsPolicy >> paginationFrom: anHttpRequest [

^ PaginationSpec
^ PaginationSpecification
startingAt: (IsInteger parseString: (anHttpRequest at: #start ifAbsent: [ 1 ]))
limitedTo: (IsInteger parseString: (anHttpRequest at: #limit ifAbsent: [ defaultLimit ]))
]
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ I provide the supported mediaTypes for the service to be used during content neg
I provide a set of routes to be used to configure Teapot.
"
Class {
#name : #ResourceRESTFulControllerSpecification,
#name : #ResourceRESTfulControllerSpecification,
#superclass : #Object,
#category : #'Stargate-Model-Controllers'
}

{ #category : #acccessing }
ResourceRESTFulControllerSpecification >> mappingRuleSet [
ResourceRESTfulControllerSpecification >> mappingRuleSet [

^ (ReflectiveMappingRuleSetBuilder for: self) build
]

{ #category : #acccessing }
ResourceRESTFulControllerSpecification >> mediaTypes [
ResourceRESTfulControllerSpecification >> mediaTypes [

^ (UnaryMessageSendingCollector sendingAllMessagesEndingWith: 'MediaType' to: self) value
]

{ #category : #acccessing }
ResourceRESTFulControllerSpecification >> routes [
ResourceRESTfulControllerSpecification >> routes [

^ (UnaryMessageSendingCollector sendingAllMessagesEndingWith: 'Route' to: self) value
]

0 comments on commit 8f1d73f

Please sign in to comment.