lib/i18n/coverage.rb in i18n-coverage-0.1.1 vs lib/i18n/coverage.rb in i18n-coverage-0.2.0
- old
+ new
@@ -1,11 +1,28 @@
-require "i18n"
-require "i18n/coverage/version"
-require "i18n/coverage/reporter"
-require "i18n/backend/key_logger"
+require 'i18n'
+require 'i18n/coverage/version'
+require 'i18n/coverage/reporter'
+require 'i18n/backend/key_logger'
+require 'i18n/coverage/config'
module I18n
module Coverage
+ def self.start
+ I18n::Backend::Simple.include I18n::Backend::KeyLogger
+ at_exit { I18n::Coverage::Reporter.report }
+ end
+
+ def self.config
+ @config ||= Config.new
+ end
+
+ def self.configure
+ @config = Config.new
+ yield @config if block_given?
+ end
end
end
-I18n::Backend::Simple.send(:include, I18n::Backend::KeyLogger) if ENV['I18N_COVERAGE']
+if ENV['I18N_COVERAGE']
+ warn 'DEPRECATED: use I18n::Coverage.start instead'
+ I18n::Backend::Simple.include I18n::Backend::KeyLogger
+end