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

View File

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

View File

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

View File

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