-
-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2807902
commit d57936c
Showing
7 changed files
with
132 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
local State = require('state') | ||
local Type = require('type') | ||
|
||
local dom = select(1, ...) | ||
|
||
local Block = Type.declare('Block', State) | ||
|
||
|
||
--- | ||
-- Instantiate a new block configuration helper. | ||
-- | ||
-- @param state | ||
-- The block configuration state. | ||
-- @returns | ||
-- The new block helper instance. | ||
--- | ||
|
||
function Block.new(state) | ||
local blk = Type.assign(Block, state) | ||
|
||
local name = state.blocks[1] | ||
blk.name = name | ||
|
||
return blk | ||
end | ||
|
||
|
||
--- | ||
-- Retrieve the configurations contained by this block. | ||
-- | ||
-- @param createCallback | ||
-- A function with signature `(workspace, build, platform)` which will be called for | ||
-- each build/platform pair found in the block. Return a new `dom.Config` to represent | ||
-- the configuration, or `nil` to ignore it. | ||
-- @returns | ||
-- An array of `dom.Config`. | ||
--- | ||
|
||
function Block.fetchConfigs(self, createCallback) | ||
local configs = {} | ||
|
||
local selectors = dom.Config.fetchConfigPlatformPairs(self) | ||
for i = 1, #selectors do | ||
local selector = selectors[i] | ||
local cfg = createCallback(self, selector.configurations, selector.platforms) | ||
configs[i] = cfg | ||
configs[cfg.name] = cfg | ||
end | ||
|
||
return configs | ||
end | ||
|
||
|
||
return Block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
local premake = require('premake') | ||
local dom = require('dom') | ||
|
||
local DomBlockTests = test.declare('DomBlockTests', 'dom') | ||
|
||
local _blk | ||
|
||
|
||
--- | ||
-- Sets up the DOM Block Tests. | ||
--- | ||
function DomBlockTests.setup() | ||
block('MyBlock', function() | ||
|
||
end) | ||
|
||
_blk = dom.Block.new(dom.Root.new():select({ blocks = 'MyBlock' })) | ||
end | ||
|
||
|
||
--- | ||
-- Tests to make sure the name of the Block element is set correctly. | ||
--- | ||
function DomBlockTests.new_setsName() | ||
test.isEqual('MyBlock', _blk.name) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters