lib/timeliness.rb in timeliness-0.4.2 vs lib/timeliness.rb in timeliness-0.4.3
- old
+ new
@@ -1,8 +1,9 @@
require 'date'
require 'forwardable'
+require 'timeliness/configuration'
require 'timeliness/helpers'
require 'timeliness/definitions'
require 'timeliness/format'
require 'timeliness/format_set'
require 'timeliness/parser'
@@ -11,40 +12,21 @@
module Timeliness
class << self
extend Forwardable
def_delegators Parser, :parse, :_parse
def_delegators Definitions, :add_formats, :remove_formats, :use_us_formats, :use_euro_formats
- attr_accessor :default_timezone, :date_for_time_type, :ambiguous_date_format, :ambiguous_year_threshold
+ attr_accessor :configuration
+
+ def_delegators :configuration, :default_timezone, :date_for_time_type, :ambiguous_date_format, :ambiguous_year_threshold
+ def_delegators :configuration, :default_timezone=, :date_for_time_type=, :ambiguous_date_format=, :ambiguous_year_threshold=
end
- # Default timezone. Options:
- # - :local (default)
- # - :utc
- #
- # If ActiveSupport loaded, also
- # - :current
- # - 'Zone name'
- #
- self.default_timezone = :local
+ def self.configuration
+ @configuration ||= Configuration.new
+ end
- # Set the default date part for a time type values.
- #
- self.date_for_time_type = lambda { Time.now }
-
- # Default parsing of ambiguous date formats. Options:
- # - :us (default, 01/02/2000 = 2nd of January 2000)
- # - :euro (01/02/2000 = 1st of February 2000)
- #
- self.ambiguous_date_format = :us
-
- # Set the threshold value for a two digit year to be considered last century
- #
- # Default: 30
- #
- # Example:
- # year = '29' is considered 2029
- # year = '30' is considered 1930
- #
- self.ambiguous_year_threshold = 30
+ def self.configure
+ yield(configuration)
+ end
end
Timeliness::Definitions.compile_formats