Add ability to use RegExp as an active layer name match.
This commit is contained in:
parent
9d78279d5e
commit
1f293bcaa4
@ -83,6 +83,8 @@ Create a `Cardfile` in your working directory. It should look something like thi
|
||||
@session.configure do |c|
|
||||
# manipulate the data after reading from the spreadsheet
|
||||
# c.post_read_data = proc { |data|
|
||||
# data[:active_layers] << "My Cool Layer"
|
||||
# data[:active_layers] << /a regular expression/i
|
||||
# data[:replacements]['Superpower Text'] << '!!'
|
||||
# }
|
||||
|
||||
|
@ -55,6 +55,27 @@ module SVGGVS
|
||||
card_finished!
|
||||
end
|
||||
|
||||
class ActiveLayerMatcher < SimpleDelegator
|
||||
def initialize(layers)
|
||||
@layers = layers
|
||||
end
|
||||
|
||||
def __getobj__
|
||||
@layers
|
||||
end
|
||||
|
||||
def include?(name)
|
||||
@layers.any? { |layer|
|
||||
case layer
|
||||
when Regexp
|
||||
layer =~ name
|
||||
else
|
||||
layer == name
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def data_source=(source)
|
||||
data_source = DataSource.new(source)
|
||||
|
||||
@ -68,7 +89,7 @@ module SVGGVS
|
||||
|
||||
with_new_target do |target|
|
||||
target.inject!
|
||||
target.active_layers = card[:active_layers]
|
||||
target.active_layers = ActiveLayerMatcher.new(card[:active_layers])
|
||||
target.replacements = card[:replacements]
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user