8.17: Chapter Summary
- Page ID
- 45553
Metacello is an important part of Pharo. It will allow your project to scale and allows you to control when you want to migrate to a new version and for which packages. It is an important architectural backbone.
Metacello Memento
ConfigurationOfCoolToolSet>>baseline06: spec "could be called differently just a convention" <version: '0.6-baseline'> "Convention. Used in the version: method" spec for: #common do: [ "#common/#pharo/#gemstone/#pharo’1.4’" spec blessing: #baseline. "Important: identifies a baseline" spec repository: 'http://www.example.com/CoolToolSet'. "When we depend on other projects" spec project: 'CoolBrowser default' with: [ spec className: 'ConfigurationOfCoolBrowser'; "Optional if convention followed" versionString: #bleedingEdge; "Optional. Could be #stable/#bleedingEdge/specific version" loads: #('default'); "which packages or groups to load" file: 'CoolBrowser-Metacello'; "Optional when same as class name" repository: 'http://www.example.com/CoolBrowser']; project: 'CoolBrowser Tests' copyFrom: 'CoolBrowser default' "Just to reuse information" with: [ spec loads: #('Tests').]. "Just to reuse information" "Our internal package dependencies" spec package: 'CoolToolSet-Core'; package: 'CoolToolSet-Tests' with: [ spec requires: #('CoolToolSet-Core') ]; package: 'CoolBrowser-Addons' with: [ spec requires: 'CoolBrowser-Core' ] ; package: 'CoolBrowser-AddonsTests' with: [ spec requires: #('CoolBrowser-Addons' 'CoolBrowser-Tests' ) ]. spec group: ’default’ with: #(’CoolBrowser-Core’ ’CoolBrowser-Addons’); group: 'Core' with: #('CoolBrowser-Core'); group: 'Extras' with: #('CoolBrowser-Addon'); group: 'Tests' with: #('CoolBrowser-Tests' 'CoolBrowser-AddonsTests'); group: 'CompleteWithoutTests' with: #('Core' 'Extras'); group: 'CompleteWithTests' with: #('CompleteWithoutTests' 'Tests') ].
ConfigurationOfCoolBrowser>>version07: spec "could be called differently just a convention" <version: '0.7' imports: #('0.6-baseline')> "Convention. No baseline so this is version" "do not import baseline from other baselines" spec for: #common do: [ "#common/#pharo/#gemstone/#pharo’1.4’" spec blessing: #release. "Required #development/#release: release means that it will not change anymore" spec description: 'In this release .....'. spec author: 'JohnLewis'. spec timestamp: '10/12/2009 09:26'. spec package: 'CoolBrowser-Core' with: 'CoolBrowser-Core-BobJones.20'; package: 'CoolBrowser-Tests' with: 'CoolBrowser-Tests-JohnLewis.8'; package: 'CoolBrowser-Addons' with: 'CoolBrowser-Addons-JohnLewis.6' ; package: 'CoolBrowser-AddonsTests' with: 'CoolBrowser-AddonsTests-JohnLewis.1'] ConfigurationOfGemToolsExample>>development: spec "note that the selector can be anything" <symbolicVersion: #development> "#stable/#development/#bleedingEdge" spec for: #common version: '1.0'. "’1.0’ is the version of your development version" "#common or your platform attributes: #gemstone, #pharo, or #’pharo1.4’"
ConfigurationOfGemToolsExample>>baseline10: spec <version: '1.0-baseline'> spec for: #common do: [ spec blessing: #'baseline'. "required see above" spec repository: 'http://seaside.gemstone.com/ss/GLASSClient'. spec project: 'FFI' with: [ spec className: 'ConfigurationOfFFI'; versionString: #bleedingEdge; "Optional. #stable/#development/#bleedingEdge/specific version" repository: 'http://www.squeaksource.com/MetacelloRepository' ]; project: 'OmniBrowser' with: [ spec className: 'ConfigurationOfOmniBrowser'; versionString: #stable; "Optional. #stable/#development/#bleedingEdge/specific version" repository: 'http://www.squeaksource.com/MetacelloRepository' ]; project: 'Shout' with: [ spec className: 'ConfigurationOfShout'; versionString: #stable; repository: 'http://www.squeaksource.com/MetacelloRepository' ]; project: 'HelpSystem' with: [ spec className: 'ConfigurationOfHelpSystem'; versionString: #stable; repository: 'http://www.squeaksource.com/MetacelloRepository']. spec package: 'OB-SUnitGUI' with: [spec requires: #('OmniBrowser')]; package: 'GemTools-Client' with: [ spec requires: #('OmniBrowser' 'FFI' 'Shout' 'OB-SUnitGUI' ).]; package: 'GemTools-Platform' with: [ spec requires: #('GemTools-Client' ). ]; package: 'GemTools-Help' with: [ spec requires: #('HelpSystem' 'GemTools-Client' ). ]. spec group: 'default' with: #('OB-SUnitGUI' 'GemTools-Client' 'GemTools-Platform' 'GemTools-Help')].
ConfigurationOfGemToolsExample>>version10: spec <version: '1.0' imports: #('1.0-baseline' )> spec for: #common do: [ spec blessing: #development. spec description: 'initial development version'. spec author: 'dkh'. spec timestamp: '1/12/2011 12:29'. spec project: 'FFI' with: '1.2'; project: 'OmniBrowser' with: #stable; project: 'Shout' with: #stable; project: 'HelpSystem' with: #stable. spec package: 'OB-SUnitGUI' with: 'OB-SUnitGUI-dkh.52'; package: 'GemTools-Client' with: 'GemTools-Client-NorbertHartl.544'; package: 'GemTools-Platform' with: 'GemTools-Platform.pharo10beta-dkh.5'; package: 'GemTools-Help' with: 'GemTools-Help-DaleHenrichs.24'. ].
Loading. load
, load:
The load
method loads the default group and if there is no default group defined, then all packages are loaded. The load:
method takes as parameter the name of a package, a project, a group, or a collection of those items.
(ConfigurationOfCoolBrowser project version: '0.1') load. (ConfigurationOfCoolBrowser project version: '0.2') load: {'CBrowser-Core' . 'CBrowser- Addons'}.
Debugging. record
, record: loadDirectives
The message record does the record for the default group and if you want a specific group of items, you can use record:
, just as it is for load
.
((ConfigurationOfCoolBrowser project version: '0.2') record: { 'CoolBrowser-Core' . 'CoolBrowser-Addons' }) loadDirective.
If you want to recursively access all the file versions, use packageDirectivesDo:
as in the following example:
| pkgs loader | loader := ((Smalltalk globals at: #ConfigurationOfMoose) project version: 'default') ignoreImage: true; record. pkgs := OrderedCollection new. loader loadDirective packageDirectivesDo: [:directive |pkgs add: directive spec file ]. pkgs.
Proposed development process. Using metacello we suggest the following development steps.
Baseline "first we define a baseline" Version development "Then a version tagged as development" Validate the map "Once it is validated and the project status arrives to the desired status" Version release "We are ready to tag a version as release" Version development "Since development continues we create a new version" ... "Tagged as development. It will be tagged as release and so on" Baseline "When architecture or structure changes, a new baseline will appear" Version development "and the story will continue" Version release