• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jecisc / STONCustomizer / 6746797553

03 Nov 2023 02:57PM UTC coverage: 96.094% (-3.9%) from 100.0%
6746797553

push

github

web-flow
Merge pull request #1 from Gabriel-Darbord/class-side-do-not-force-pretty

Do not force pretty printing

53 of 53 new or added lines in 2 files covered. (100.0%)

5 existing lines in 1 file now uncovered.

123 of 128 relevant lines covered (96.09%)

6.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.42
/src/STONCustomizer/SCExporter.class.st
1
"
2
Description
3
--------------------
4

5
I am an exporter processing STON customizations while exporting variables of a class.
6

7
Examples
8
--------------------
9

10
        | countryHolder france belgium germany peoples |
11
        countryHolder := SCMockCountryHolder new.
12

13
        france := countryHolder countryNamed: 'France'.
14
        belgium := countryHolder countryNamed: 'Belgium'.
15
        germany := countryHolder countryNamed: 'Germany'.
16

17
        peoples := {
18
                (SCMockPerson country: france yearOfBirth: 1993 asYear).
19
                (SCMockPerson country: france yearOfBirth: 1992 asYear).
20
                (SCMockPerson country: belgium yearOfBirth: 1990 asYear).
21
                (SCMockPerson country: germany yearOfBirth: 1999 asYear )
22
        }.
23

24
        SCExporter toString: peoples.
25
        
26
        SCExporter export: peoples inFile: (FileSystem memory / 'test.ston')
27

28
"
29
Class {
30
        #name : 'SCExporter',
31
        #superclass : 'STONWriter',
32
        #category : 'STONCustomizer',
33
        #package : 'STONCustomizer'
34
}
35

36
{ #category : 'writing' }
37
SCExporter class >> export: anObject inFile: aFileReference [
7✔
38

7✔
39
        ^ aFileReference writeStreamDo: [ :s |
7✔
40
                  self export: anObject onStream: s ]
7✔
41
]
7✔
42

43
{ #category : 'writing' }
44
SCExporter class >> export: anObject inFilePretty: aFileReference [
7✔
45

7✔
46
        ^ aFileReference writeStreamDo: [ :s |
7✔
47
                  self export: anObject onStreamPretty: s ]
7✔
48
]
7✔
49

50
{ #category : 'writing' }
51
SCExporter class >> export: anObject onStream: writeStream [
7✔
52

7✔
53
        (self on: writeStream) nextPut: anObject
7✔
54
]
7✔
55

56
{ #category : 'writing' }
57
SCExporter class >> export: anObject onStreamPretty: writeStream [
7✔
58

7✔
59
        (self on: writeStream)
7✔
60
                prettyPrint: true;
7✔
61
                nextPut: anObject
7✔
62
]
7✔
63

64
{ #category : 'writing' }
65
SCExporter class >> toString: anObject [
7✔
66

7✔
67
        ^ String streamContents: [ :s | self export: anObject onStream: s ]
7✔
68
]
7✔
69

70
{ #category : 'writing' }
71
SCExporter class >> toStringPretty: anObject [
7✔
72

7✔
73
        ^ String streamContents: [ :s |
7✔
74
                  self export: anObject onStreamPretty: s ]
7✔
75
]
7✔
76

77
{ #category : 'writing' }
UNCOV
78
SCExporter >> export: anObject onStream: stream [
×
UNCOV
79
        ^ (self on: stream)
×
UNCOV
80
                prettyPrint: true;
×
UNCOV
81
                nextPut: anObject
×
UNCOV
82
]
×
83

84
{ #category : 'writing' }
85
SCExporter >> getCustomizationsFor: anObject [
7✔
86
        ^ (Pragma allNamed: #stonCustomizationFor: from: anObject class class to: Object)
7✔
87
                inject: Dictionary new
7✔
88
                into: [ :dict :p | 
7✔
89
                        dict at: (p argumentAt: 1) put: (anObject class perform: p method selector).
7✔
90
                        dict ]
7✔
91
]
7✔
92

93
{ #category : 'initialization' }
94
SCExporter >> initialize [
7✔
95

7✔
96
        super initialize.
7✔
97
        "We want to be sure to use platform line ending in Pharo < 11. Afterward STON manages this well."
7✔
98
        newLine := OSPlatform current lineEnding
7✔
99
]
7✔
100

101
{ #category : 'writing' }
102
SCExporter >> writeObject: anObject [
7✔
103
        anObject class stonAllInstVarNames
7✔
104
                ifEmpty: [ self writeObject: anObject do: [ self encodeMap: #() ] ]
7✔
105
                ifNotEmpty: [ :instanceVariableNames |
7✔
106
                        | customizers |
7✔
107
                        customizers := self getCustomizationsFor: anObject.
7✔
108
                        self writeObject: anObject streamMap: [ :dictionary |
7✔
109
                                instanceVariableNames do: [ :each |
7✔
110
                                        (anObject instVarNamed: each)
7✔
111
                                                ifNotNil: [ :value |
7✔
112
                                                        dictionary at: each asSymbol put: (customizers
7✔
113
                                                                         at: each asSymbol
7✔
114
                                                                         ifPresent: [ :customizer |
7✔
115
                                                                         customizer writeBlock cull: anObject cull: self ]
7✔
116
                                                                         ifAbsent: [ value ]) ]
7✔
117
                                                ifNil: [
7✔
118
                                                        anObject stonShouldWriteNilInstVars ifTrue: [
7✔
119
                                                                dictionary at: each asSymbol put: nil ] ] ] ] ]
7✔
120
]
7✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc