class DTK::DSL::Template

Copyright (C) 2010-2016 dtk contributors

This file is part of the dtk project.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2010-2016 dtk contributors

This file is part of the dtk project.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2010-2016 dtk contributors

This file is part of the dtk project.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2010-2016 dtk contributors

This file is part of the dtk project.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2010-2016 dtk contributors

This file is part of the dtk project.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2010-2016 dtk contributors

This file is part of the dtk project.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2010-2016 dtk contributors

This file is part of the dtk project.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2010-2016 dtk contributors

This file is part of the dtk project.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2010-2016 dtk contributors

This file is part of the dtk project.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2010-2016 dtk contributors

This file is part of the dtk project.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright (C) 2010-2016 dtk contributors

This file is part of the dtk project.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Public Class Methods

create_for_generation(content, opts = {}) click to toggle source

Content is of type InputOutput::Canonical Array or Hash opts can have keys

:filter
# File lib/dsl/template.rb, line 43
def self.create_for_generation(content, opts = {})
  new(:generation, opts.merge(:content => content))
end
create_for_parsing(raw_input, opts = {}) click to toggle source

opts can have keys

:file_obj
:parent_key
# File lib/dsl/template.rb, line 36
def self.create_for_parsing(raw_input, opts = {})
  new(:parsing, opts.merge(:raw_input => raw_input))
end
new(type, opts = {}) click to toggle source
# File lib/dsl/template.rb, line 47
def initialize(type, opts = {})
  case @type = type
  when :parsing then parsing_initialize(opts)
  when :generation then generation_initialize(opts)
  else raise Error, "Illegal type '#{type}'"
  end
end

Private Class Methods

template_class(parse_template_type, dsl_version) click to toggle source
# File lib/dsl/template.rb, line 96
def self.template_class(parse_template_type, dsl_version)
  Loader.template_class(parse_template_type, :dsl_version => dsl_version)
end

Public Instance Methods

add(array_element) click to toggle source
# File lib/dsl/template.rb, line 87
def add(array_element)
  case @type
  when :parsing then parsing_add(array_element)
  when :generation then generation_add(array_element)
  end
end
merge(hash) click to toggle source
# File lib/dsl/template.rb, line 80
def merge(hash)
  case @type
  when :parsing then parsing_merge(hash)
  when :generation then generation_merge(hash)
  end
end
req(key) click to toggle source
# File lib/dsl/template.rb, line 62
def req(key)
  case @type
  when :generation then generation_req(key)
  else fail(Error,"Method 'req' undefined for type '#{@type}'")
  end
end
set(constant, val) click to toggle source
# File lib/dsl/template.rb, line 55
def set(constant, val)
  case @type
  when :parsing then parsing_set(constant, val)
  when :generation then generation_set(constant, val)
  end 
end
set?(constant, val) click to toggle source
# File lib/dsl/template.rb, line 76
def set?(constant, val)
  set(constant, val) unless val.nil?
end
val(key) click to toggle source
# File lib/dsl/template.rb, line 69
def val(key)
  case @type
  when :generation then generation_val(key)
  else fail(Error,"Method 'val' undefined for type '#{@type}'")
  end
end

Private Instance Methods

canonical_key(constant) click to toggle source
# File lib/dsl/template.rb, line 104
def canonical_key(constant)
  constant_class.canonical_value(constant)
end
constant_class() click to toggle source
# File lib/dsl/template.rb, line 108
def constant_class
  self.class::Constant
end
template_class(parse_template_type) click to toggle source
# File lib/dsl/template.rb, line 100
def template_class(parse_template_type)
  self.class.template_class(parse_template_type, template_version)
end