From ff3344c570a8200c2a5933ae6790e24611008bbf Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Wed, 5 Sep 2018 09:14:45 -0400 Subject: ruby: add files to gemspec, ignore gemspec, add stub README.mkd --- ruby/lib/luigi-template.rb | 56 +++++----------------------------------------- 1 file changed, 5 insertions(+), 51 deletions(-) (limited to 'ruby/lib') diff --git a/ruby/lib/luigi-template.rb b/ruby/lib/luigi-template.rb index 36faf74..8b0e553 100644 --- a/ruby/lib/luigi-template.rb +++ b/ruby/lib/luigi-template.rb @@ -4,18 +4,18 @@ module Luigi # # library version # - VERSION = '0.4.0' + VERSION = '0.4.2' class LuigiError < Exception end class BaseUnknownError < LuigiError - attr_reader :type_name, + attr_reader :type, :name - def initialize(type_name, name) - @type_name, @name = type_name, name - super("unknown #{type_name}: #{name}") + def initialize(type, name) + @type, @name = type, name + super("unknown #{type}: #{name}") end end @@ -282,50 +282,4 @@ module Luigi @templates[key].run(args) end end - - # - # test module - # - module Test - # test template - TEMPLATE = ' - basic test: hello %{name} - test filters: hello %{name | uc | base64 | hash sha1} - test custom: hello %{name|custom} - test custom_with_arg: %{name|custom_with_arg asdf} - ' - - CUSTOM_FILTERS = { - custom: proc { - 'custom' - }, - - custom_with_arg: proc { |v, args| - args.first || 'custom' - }, - } - - # test template cache - CACHE = { - test: TEMPLATE - } - - # test arguments - ARGS = { - name: 'paul', - } - - def self.run - # add custom filters - Luigi::FILTERS.update(CUSTOM_FILTERS) - - # test individual template - puts Template.new(TEMPLATE).run(ARGS) - - # test template cache - puts Cache.new(CACHE).run(:test, ARGS) - end - end end - -Luigi::Test.run if __FILE__ == $0 -- cgit v1.2.3