lib/lorj_meta.rb in lorj-1.0.11 vs lib/lorj_meta.rb in lorj-1.0.12
- old
+ new
@@ -16,10 +16,18 @@
# limitations under the License.
require 'rubygems'
require 'yaml'
+file_dir = File.join(File.dirname(__FILE__), 'compat')
+compat_version = RUBY_VERSION[0..2]
+file = File.basename(__FILE__)
+
+lib = File.join(file_dir, compat_version, file)
+lib = File.join(file_dir, file) unless File.exist?(lib)
+load lib if File.exist?(lib)
+
# Lorj module implements Lorj::Config
# Lorj exposes defaults, as attribute to access the Lorj::Defaults instance.
module Lorj
# Private functions for MetaAppConfig
class MetaAppConfig < PRC::CoreConfig
@@ -482,10 +490,15 @@
return [section, data] unless section.nil? &&
p_exist?(:keys => [:keys, data])
arr = p_get(:keys => [:keys, data])
return nil unless arr.is_a?(Array) && arr[0]
+ if /1\.8/ =~ RUBY_VERSION && arr.length > 1
+ PrcLib.warning('Avoid using Lorj::MetaAppConfig.first_section(%s) with'\
+ ' Ruby 1.8 and searching for the first section as it do'\
+ ' not preserve the order of Hash keys.', data)
+ end
[arr[0], data]
end
# return the list of sections name of a data.
#
@@ -642,26 +655,10 @@
layer = 'controller' if layer.nil? || %w(app map).include?(layer)
p_set(:keys => keys, :name => layer, :value => options)
end
- # layer setting function
- #
- # * *Args*
- # - +type+ : :sections by default. Define the section type name.
- # - +section+ : Symbol. Section name of the data to define.
- # - +keys+ : 1 Symbol or more Symbols. Name of the data and options.
- # - +options+ : Hash. List of options
- #
- # * *Returns*
- # - The value set or nil
- #
- def []=(type, section, *keys, options)
- return nil if keys.length == 0
- set(type, section, keys, options)
- end
-
# section/data removal function
#
# * *Args*
# - +section+ : Symbol. Section name of the data to define.
# - +data+ : Symbol or Array of Symbols. Name of the data
@@ -739,9 +736,11 @@
layer = 'controller' if layer.nil? || layer == 'app'
p_set(:keys => keys, :name => layer, :value => value.merge(options))
end
+
+ include Lorj::MetaRubySpec::Public
end
module_function
# Lorj::defaults exposes the application defaults and Config Lorj metadata.