lib/bcdatabase.rb in bcdatabase-1.1.0 vs lib/bcdatabase.rb in bcdatabase-1.2.0

- old
+ new

@@ -118,19 +118,30 @@ :decrypt => lambda { |entry, name, group| entry.merge({ 'password' => Bcdatabase.decrypt(entry['epassword']) }) if entry['epassword'] }, :datamapper => lambda { |entry, name, group| entry.merge('adapter' => entry['datamapper_adapter']) if entry['datamapper_adapter'] + }, + :jruby => lambda { |entry, name, group| + entry.merge('adapter' => entry['jruby_adapter']) if entry['jruby_adapter'] } } + def self.automatic_transforms + @automatic_transforms ||= [ + :key_defaults, + :decrypt, + (:jruby if RUBY_PLATFORM =~ /java/) + ].compact + end + ## # Creates a configuration from a set of YAML files. # # General use of the library should not use this method, but # instead should use {Bcdatabase.load}. def initialize(files, transforms=[]) - @transforms = ([:key_defaults, :decrypt] + transforms).collect do |t| + @transforms = (self.class.automatic_transforms + transforms).collect do |t| case t when Symbol BUILT_IN_TRANSFORMS[t] or fail "No built-in transform named #{t.inspect}" else fail 'Transforms must by callable' unless t.respond_to?(:call)