Support for BreaOperators

This commit is contained in:
Offray Vladimir Luna Cárdenas 2020-12-19 11:24:21 -05:00
parent 9f0f06d285
commit 9f28bccc1e
4 changed files with 29 additions and 29 deletions

View File

@ -2,16 +2,16 @@
A BreaQueryTest is a test class for testing the behavior of BreaQuery
"
Class {
#name : #BreaQueryTest,
#name : #BreaOperatorTest,
#superclass : #TestCase,
#category : #'Brea-Tests'
}
{ #category : #tests }
BreaQueryTest >> testSTONSerialization [
BreaOperatorTest >> testSTONSerialization [
| original store deserialized |
original := BreaQuery new
original := BreaOperator new
name: 'plus';
inputs: {'a' -> 3. 'b' -> 4} asDictionary;
codeBlock: [ :x :y | x + y ].

View File

@ -113,6 +113,7 @@ BreaPageTest >> setUp [
super setUp.
self createMarkdownFile.
self createHTMLTemplateFile.
self createJSONFile
]
{ #category : #tests }

View File

@ -20,7 +20,7 @@ Internal Representation and Key Implementation Points.
Implementation Points
"
Class {
#name : #BreaQuery,
#name : #BreaOperator,
#superclass : #Object,
#instVars : [
'name',
@ -32,12 +32,12 @@ Class {
}
{ #category : #converting }
BreaQuery >> asSton [
BreaOperator >> asSton [
^ STON toStringPretty: self
]
{ #category : #converting }
BreaQuery >> cleanInputs [
BreaOperator >> cleanInputs [
self cleanedInputs ifNil: [ ^ self ].
self cleanedInputs ifTrue: [
self inputs keysAndValuesDo: [ :k :v | | currentValue |
@ -48,48 +48,48 @@ BreaQuery >> cleanInputs [
]
{ #category : #accessing }
BreaQuery >> cleanedInputs [
BreaOperator >> cleanedInputs [
^ cleanedInputs
]
{ #category : #accessing }
BreaQuery >> cleanedInputs: aBoolean [
BreaOperator >> cleanedInputs: aBoolean [
"I tell if the inputs should be cleaned when the query is serialized as STON, for
example when they contain sensible information, like API keys or passwords"
cleanedInputs := aBoolean
]
{ #category : #accessing }
BreaQuery >> codeBlock [
BreaOperator >> codeBlock [
^ codeBlock
]
{ #category : #accessing }
BreaQuery >> codeBlock: anObject [
BreaOperator >> codeBlock: anObject [
codeBlock := anObject
]
{ #category : #execution }
BreaQuery >> execute [
BreaOperator >> execute [
^ self codeBlock valueWithArguments: self inputs values.
]
{ #category : #accessing }
BreaQuery >> inputs [
BreaOperator >> inputs [
^ inputs
]
{ #category : #accessing }
BreaQuery >> inputs: anOrderedDictionary [
BreaOperator >> inputs: anOrderedDictionary [
inputs := anOrderedDictionary
]
{ #category : #accessing }
BreaQuery >> name [
BreaOperator >> name [
^ name
]
{ #category : #accessing }
BreaQuery >> name: anObject [
BreaOperator >> name: anObject [
name := anObject
]

View File

@ -32,8 +32,7 @@ Class {
'url',
'preview',
'license',
'queries',
'customizations'
'operators'
],
#category : #Brea
}
@ -103,8 +102,8 @@ BreaTheme class >> downloadLinks [
]
{ #category : #operation }
BreaTheme >> addQuery: aBreaQuery [
self queries add: aBreaQuery cleanInputs
BreaTheme >> addOperator: aBreaQuery [
self operators add: aBreaQuery cleanInputs
]
{ #category : #operation }
@ -184,6 +183,16 @@ BreaTheme >> name: anObject [
name := anObject
]
{ #category : #accessing }
BreaTheme >> operators [
^ operators ifNil: [ operators := OrderedCollection new ]
]
{ #category : #accessing }
BreaTheme >> operators: cleanedBreaQueriesCollection [
operators := cleanedBreaQueriesCollection
]
{ #category : #accessing }
BreaTheme >> preview [
^ preview
@ -204,16 +213,6 @@ BreaTheme >> provider: anObject [
provider := anObject
]
{ #category : #accessing }
BreaTheme >> queries [
^ queries ifNil: [ queries := OrderedCollection new ]
]
{ #category : #accessing }
BreaTheme >> queries: cleanedBreaQueriesCollection [
queries := cleanedBreaQueriesCollection
]
{ #category : #accessing }
BreaTheme >> url [
^ url ifNil: [ url := self class downloadLinks at: self name. ]