parent
845123a283
commit
73d6eb992b
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
* Added `showcase` feature to create a fancy-looking 3D reflection to showcase your cards. Documented, tested, and added a sample for it.
|
* Added `showcase` feature to create a fancy-looking 3D reflection to showcase your cards. Documented, tested, and added a sample for it.
|
||||||
* Added a basic Rakefile, documented in README.
|
* Added a basic Rakefile, documented in README.
|
||||||
* Some internal refactoring and better testing around layouts
|
* Some internal refactoring, better testing, and more documentation with layouts
|
||||||
|
|
||||||
## v0.1.0
|
## v0.1.0
|
||||||
* Added `save_sheet` command that saves a range into PNG sheets, complete with trim, gap, margin, columns, and sometimes automagically computed rows. See samples/saves.rb.
|
* Added `save_sheet` command that saves a range into PNG sheets, complete with trim, gap, margin, columns, and sometimes automagically computed rows. See samples/saves.rb.
|
||||||
|
|
|
||||||
14
README.md
14
README.md
|
|
@ -209,6 +209,20 @@ yang:
|
||||||
x: += 50
|
x: += 50
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Furthermore, if you want to extend multiple parents, it looks like this:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
socrates:
|
||||||
|
x: 100
|
||||||
|
aristotle:
|
||||||
|
y: 200
|
||||||
|
aristotle:
|
||||||
|
extends:
|
||||||
|
- socrates
|
||||||
|
- plato
|
||||||
|
x: += 50
|
||||||
|
```
|
||||||
|
|
||||||
### Multiple layout files
|
### Multiple layout files
|
||||||
|
|
||||||
Squib also supports the combination of multiple layout files. As shown in the above example, if you provide an `Array` of files then Squib will merge them sequentially. Colliding keys will be completely re-defined by the later file. Extends is processed after _each file_. YAML merge keys are NOT supported across multiple files - use extends instead. Here's a demonstrative example:
|
Squib also supports the combination of multiple layout files. As shown in the above example, if you provide an `Array` of files then Squib will merge them sequentially. Colliding keys will be completely re-defined by the later file. Extends is processed after _each file_. YAML merge keys are NOT supported across multiple files - use extends instead. Here's a demonstrative example:
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ module Squib
|
||||||
def self.recurse_extends(yml, key, visited )
|
def self.recurse_extends(yml, key, visited )
|
||||||
assert_not_visited(key, visited)
|
assert_not_visited(key, visited)
|
||||||
return yml[key] unless has_extends?(yml, key)
|
return yml[key] unless has_extends?(yml, key)
|
||||||
|
return yml[key] unless parents_exist?(yml, key)
|
||||||
visited[key] = key
|
visited[key] = key
|
||||||
parent_keys = [yml[key]['extends']].flatten
|
parent_keys = [yml[key]['extends']].flatten
|
||||||
h = {}
|
h = {}
|
||||||
|
|
@ -62,6 +63,19 @@ module Squib
|
||||||
!!yml[key] && yml[key].key?('extends')
|
!!yml[key] && yml[key].key?('extends')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Checks if we have any absentee parents
|
||||||
|
# @api private
|
||||||
|
def self.parents_exist?(yml, key)
|
||||||
|
exists = true
|
||||||
|
Array(yml[key]['extends']).each do |parent|
|
||||||
|
unless yml.key?(parent)
|
||||||
|
exists = false unless
|
||||||
|
Squib.logger.error "Processing layout: '#{key}' attempts to extend a missing '#{yml[key]['extends']}'"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return exists
|
||||||
|
end
|
||||||
|
|
||||||
# Safeguard against malformed circular extends
|
# Safeguard against malformed circular extends
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
# @api private
|
# @api private
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
verbal:
|
||||||
|
extends: kaisersoze
|
||||||
|
font_size: 25
|
||||||
|
|
@ -173,4 +173,17 @@ describe Squib::LayoutParser do
|
||||||
Squib::LayoutParser.load_layout('yeti')
|
Squib::LayoutParser.load_layout('yeti')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'freaks out if you extend something doesn\'t exist' do
|
||||||
|
expect(Squib.logger)
|
||||||
|
.to receive(:error)
|
||||||
|
.with("Processing layout: 'verbal' attempts to extend a missing 'kaisersoze'")
|
||||||
|
layout = Squib::LayoutParser.load_layout(layout_file('extends-nonexists.yml'))
|
||||||
|
expect(layout).to eq({
|
||||||
|
'verbal' => {
|
||||||
|
'font_size' => 25,
|
||||||
|
'extends' => 'kaisersoze'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
Loading…
Reference in New Issue