From 16b027df6a5e44020a284b5f7a62a7b30c18c552 Mon Sep 17 00:00:00 2001 From: Richard Clamp Date: Tue, 7 Jan 2014 16:04:39 +0000 Subject: [PATCH] MCO-138 revert "18663 - should be internationalized" This reverts commits c6b9451f8bd719c72335ccb2759feb1655055933 and 6d52920470a6135ac1368111d9ddfe3c50264bee. The i18n based around the i18n gem was incomplete and a little hard to deal with. For now we're pulling this implementation out for the stable series and will revisit it in a topic branch until we have something more mature. --- Rakefile | 40 -- etc/msg-help.erb | 11 - lib/mcollective.rb | 18 +- lib/mcollective/application.rb | 17 +- lib/mcollective/cache.rb | 30 +- lib/mcollective/config.rb | 5 +- lib/mcollective/data.rb | 6 +- lib/mcollective/ddl.rb | 15 +- lib/mcollective/ddl/agentddl.rb | 12 +- lib/mcollective/ddl/base.rb | 16 +- lib/mcollective/exception.rb | 40 -- lib/mcollective/locales/en.yml | 344 ------------------ lib/mcollective/log.rb | 80 +--- lib/mcollective/logger/base.rb | 4 - lib/mcollective/logger/console_logger.rb | 6 +- lib/mcollective/logger/syslog_logger.rb | 4 +- lib/mcollective/rpc/agent.rb | 17 +- lib/mcollective/runner.rb | 22 +- lib/mcollective/translatable.rb | 24 -- lib/mcollective/util.rb | 13 +- lib/mcollective/vendor/i18n/.gitignore | 8 - lib/mcollective/vendor/i18n/.travis.yml | 7 - lib/mcollective/vendor/i18n/CHANGELOG.textile | 152 -------- lib/mcollective/vendor/i18n/MIT-LICENSE | 20 - lib/mcollective/vendor/i18n/README.textile | 105 ------ lib/mcollective/vendor/i18n/Rakefile | 27 -- lib/mcollective/vendor/i18n/lib/i18n.rb | 332 ----------------- .../vendor/i18n/lib/i18n/backend.rb | 18 - .../vendor/i18n/lib/i18n/backend/base.rb | 181 --------- .../vendor/i18n/lib/i18n/backend/cache.rb | 96 ----- .../vendor/i18n/lib/i18n/backend/cascade.rb | 54 --- .../vendor/i18n/lib/i18n/backend/chain.rb | 78 ---- .../vendor/i18n/lib/i18n/backend/fallbacks.rb | 65 ---- .../vendor/i18n/lib/i18n/backend/flatten.rb | 113 ------ .../vendor/i18n/lib/i18n/backend/gettext.rb | 72 ---- .../i18n/backend/interpolation_compiler.rb | 121 ------ .../vendor/i18n/lib/i18n/backend/key_value.rb | 101 ----- .../vendor/i18n/lib/i18n/backend/memoize.rb | 46 --- .../vendor/i18n/lib/i18n/backend/metadata.rb | 65 ---- .../i18n/lib/i18n/backend/pluralization.rb | 53 --- .../vendor/i18n/lib/i18n/backend/simple.rb | 87 ----- .../i18n/lib/i18n/backend/transliterator.rb | 98 ----- .../vendor/i18n/lib/i18n/config.rb | 86 ----- .../vendor/i18n/lib/i18n/core_ext/hash.rb | 29 -- .../i18n/core_ext/kernel/surpress_warnings.rb | 9 - .../lib/i18n/core_ext/string/interpolate.rb | 105 ------ .../vendor/i18n/lib/i18n/exceptions.rb | 106 ------ .../vendor/i18n/lib/i18n/gettext.rb | 25 -- .../vendor/i18n/lib/i18n/gettext/helpers.rb | 64 ---- .../vendor/i18n/lib/i18n/gettext/po_parser.rb | 329 ----------------- .../vendor/i18n/lib/i18n/interpolate/ruby.rb | 31 -- .../vendor/i18n/lib/i18n/locale.rb | 6 - .../vendor/i18n/lib/i18n/locale/fallbacks.rb | 96 ----- .../vendor/i18n/lib/i18n/locale/tag.rb | 28 -- .../i18n/lib/i18n/locale/tag/parents.rb | 22 -- .../i18n/lib/i18n/locale/tag/rfc4646.rb | 74 ---- .../vendor/i18n/lib/i18n/locale/tag/simple.rb | 39 -- lib/mcollective/vendor/i18n/lib/i18n/tests.rb | 12 - .../vendor/i18n/lib/i18n/tests/basics.rb | 54 --- .../vendor/i18n/lib/i18n/tests/defaults.rb | 40 -- .../i18n/lib/i18n/tests/interpolation.rb | 133 ------- .../vendor/i18n/lib/i18n/tests/link.rb | 56 --- .../i18n/lib/i18n/tests/localization.rb | 19 - .../i18n/lib/i18n/tests/localization/date.rb | 84 ----- .../lib/i18n/tests/localization/date_time.rb | 77 ---- .../i18n/lib/i18n/tests/localization/procs.rb | 116 ------ .../i18n/lib/i18n/tests/localization/time.rb | 76 ---- .../vendor/i18n/lib/i18n/tests/lookup.rb | 74 ---- .../i18n/lib/i18n/tests/pluralization.rb | 35 -- .../vendor/i18n/lib/i18n/tests/procs.rb | 55 --- .../vendor/i18n/lib/i18n/version.rb | 3 - lib/mcollective/vendor/load_i18n.rb | 1 - lib/mcollective/vendor/require_vendored.rb | 1 - plugins/mcollective/application/doc.rb | 25 -- spec/matchers/exception_matchers.rb | 75 ---- spec/spec_helper.rb | 5 - spec/unit/cache_spec.rb | 60 +-- spec/unit/data_spec.rb | 6 +- spec/unit/ddl/agentddl_spec.rb | 12 +- spec/unit/ddl/base_spec.rb | 24 +- spec/unit/log_spec.rb | 94 +---- spec/unit/logger/base_spec.rb | 10 +- spec/unit/logger/console_logger_spec.rb | 9 + spec/unit/logger/syslog_logger_spec.rb | 7 + spec/unit/rpc/agent_spec.rb | 8 +- spec/unit/util_spec.rb | 12 +- website/messages/PLMC1.md | 15 - website/messages/PLMC10.md | 23 -- website/messages/PLMC11.md | 19 - website/messages/PLMC12.md | 21 -- website/messages/PLMC13.md | 17 - website/messages/PLMC14.md | 24 -- website/messages/PLMC15.md | 17 - website/messages/PLMC16.md | 19 - website/messages/PLMC17.md | 19 - website/messages/PLMC18.md | 17 - website/messages/PLMC19.md | 19 - website/messages/PLMC2.md | 15 - website/messages/PLMC20.md | 17 - website/messages/PLMC21.md | 17 - website/messages/PLMC22.md | 27 -- website/messages/PLMC23.md | 15 - website/messages/PLMC24.md | 17 - website/messages/PLMC25.md | 21 -- website/messages/PLMC26.md | 17 - website/messages/PLMC27.md | 19 - website/messages/PLMC28.md | 19 - website/messages/PLMC29.md | 17 - website/messages/PLMC3.md | 19 - website/messages/PLMC30.md | 15 - website/messages/PLMC31.md | 22 -- website/messages/PLMC32.md | 15 - website/messages/PLMC33.md | 17 - website/messages/PLMC34.md | 21 -- website/messages/PLMC35.md | 17 - website/messages/PLMC36.md | 24 -- website/messages/PLMC37.md | 17 - website/messages/PLMC38.md | 21 -- website/messages/PLMC39.md | 17 - website/messages/PLMC4.md | 17 - website/messages/PLMC5.md | 17 - website/messages/PLMC6.md | 21 -- website/messages/PLMC7.md | 17 - website/messages/PLMC8.md | 17 - website/messages/PLMC9.md | 21 -- 125 files changed, 134 insertions(+), 5447 deletions(-) delete mode 100644 etc/msg-help.erb delete mode 100644 lib/mcollective/exception.rb delete mode 100644 lib/mcollective/locales/en.yml delete mode 100644 lib/mcollective/translatable.rb delete mode 100644 lib/mcollective/vendor/i18n/.gitignore delete mode 100644 lib/mcollective/vendor/i18n/.travis.yml delete mode 100644 lib/mcollective/vendor/i18n/CHANGELOG.textile delete mode 100755 lib/mcollective/vendor/i18n/MIT-LICENSE delete mode 100644 lib/mcollective/vendor/i18n/README.textile delete mode 100644 lib/mcollective/vendor/i18n/Rakefile delete mode 100755 lib/mcollective/vendor/i18n/lib/i18n.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/base.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/cache.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/cascade.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/chain.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/fallbacks.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/flatten.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/gettext.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/interpolation_compiler.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/key_value.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/memoize.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/metadata.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/pluralization.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/simple.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/backend/transliterator.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/config.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/core_ext/hash.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/core_ext/kernel/surpress_warnings.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/core_ext/string/interpolate.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/exceptions.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/gettext.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/gettext/helpers.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/gettext/po_parser.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/interpolate/ruby.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/locale.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/locale/fallbacks.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/locale/tag.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/locale/tag/parents.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/locale/tag/rfc4646.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/locale/tag/simple.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests/basics.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests/defaults.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests/interpolation.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests/link.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests/localization.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests/localization/date.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests/localization/date_time.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests/localization/procs.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests/localization/time.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests/lookup.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests/pluralization.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/tests/procs.rb delete mode 100644 lib/mcollective/vendor/i18n/lib/i18n/version.rb delete mode 100644 lib/mcollective/vendor/load_i18n.rb delete mode 100644 plugins/mcollective/application/doc.rb delete mode 100644 spec/matchers/exception_matchers.rb delete mode 100644 website/messages/PLMC1.md delete mode 100644 website/messages/PLMC10.md delete mode 100644 website/messages/PLMC11.md delete mode 100644 website/messages/PLMC12.md delete mode 100644 website/messages/PLMC13.md delete mode 100644 website/messages/PLMC14.md delete mode 100644 website/messages/PLMC15.md delete mode 100644 website/messages/PLMC16.md delete mode 100644 website/messages/PLMC17.md delete mode 100644 website/messages/PLMC18.md delete mode 100644 website/messages/PLMC19.md delete mode 100644 website/messages/PLMC2.md delete mode 100644 website/messages/PLMC20.md delete mode 100644 website/messages/PLMC21.md delete mode 100644 website/messages/PLMC22.md delete mode 100644 website/messages/PLMC23.md delete mode 100644 website/messages/PLMC24.md delete mode 100644 website/messages/PLMC25.md delete mode 100644 website/messages/PLMC26.md delete mode 100644 website/messages/PLMC27.md delete mode 100644 website/messages/PLMC28.md delete mode 100644 website/messages/PLMC29.md delete mode 100644 website/messages/PLMC3.md delete mode 100644 website/messages/PLMC30.md delete mode 100644 website/messages/PLMC31.md delete mode 100644 website/messages/PLMC32.md delete mode 100644 website/messages/PLMC33.md delete mode 100644 website/messages/PLMC34.md delete mode 100644 website/messages/PLMC35.md delete mode 100644 website/messages/PLMC36.md delete mode 100644 website/messages/PLMC37.md delete mode 100644 website/messages/PLMC38.md delete mode 100644 website/messages/PLMC39.md delete mode 100644 website/messages/PLMC4.md delete mode 100644 website/messages/PLMC5.md delete mode 100644 website/messages/PLMC6.md delete mode 100644 website/messages/PLMC7.md delete mode 100644 website/messages/PLMC8.md delete mode 100644 website/messages/PLMC9.md diff --git a/Rakefile b/Rakefile index 3fd519f3..7f63e416 100644 --- a/Rakefile +++ b/Rakefile @@ -107,43 +107,3 @@ task :website => :clean do safe_system("tar -cvzf marionette-collective-org-#{Time.now.to_i}.tgz marionette-collective.org") end end - -desc "Update the website error code reference based on current local" -task :update_msgweb do - mcollective_dir = File.join(File.dirname(__FILE__)) - - $:.insert(0, File.join(mcollective_dir, "lib")) - - require 'mcollective' - - messages = YAML.load_file(File.join(mcollective_dir, "lib", "mcollective", "locales", "en.yml")) - - webdir = File.join(mcollective_dir, "website", "messages") - - I18n.load_path = Dir[File.join(mcollective_dir, "lib", "mcollective", "locales", "*.yml")] - I18n.locale = :en - - messages["en"].keys.each do |msg_code| - md_file = File.join(webdir, "#{msg_code}.md") - - puts "....writing %s" % md_file - - File.open(md_file, "w") do |md| - md.puts "---" - md.puts "layout: default" - md.puts "title: Message detail for %s" % msg_code - md.puts "toc: false" - md.puts "---" - md.puts - md.puts "Example Message" - md.puts "---------------" - md.puts - md.puts " %s" % (MCollective::Util.t("%s.example" % msg_code, :raise => true) rescue MCollective::Util.t("%s.pattern" % msg_code)) - md.puts - md.puts "Additional Information" - md.puts "----------------------" - md.puts - md.puts MCollective::Util.t("%s.expanded" % msg_code, :raise => true) - end - end -end diff --git a/etc/msg-help.erb b/etc/msg-help.erb deleted file mode 100644 index c6ade314..00000000 --- a/etc/msg-help.erb +++ /dev/null @@ -1,11 +0,0 @@ -Help for message: <%= msg_code %> - -Example Message: - -<%= Util.align_text(msg_example, nil, 3) %> - -Message Detail: - -<%= Util.align_text(msg_detail, nil, 3) %> - -For more information please see http://docs.puppetlabs.com/mcollective/messages/<%= msg_code %>.html diff --git a/lib/mcollective.rb b/lib/mcollective.rb index 8b1431fe..740f1c6e 100644 --- a/lib/mcollective.rb +++ b/lib/mcollective.rb @@ -11,9 +11,7 @@ require 'rbconfig' require 'tempfile' require 'tmpdir' -require 'mcollective/exception' require 'mcollective/monkey_patches' -require "mcollective/translatable" require 'mcollective/cache' # == The Marionette Collective @@ -24,9 +22,23 @@ # and allow you to run agents matching discovery criteria. # # For an overview of the idea behind this and what it enables please see: -# # http://www.devco.net/archives/2009/10/18/middleware_for_systems_administration.php module MCollective + # Exceptions for the RPC system + class DDLValidationError cache_name) unless has_cache?(cache_name) - end - def self.has_cache?(cache_name) @locks_mutex.synchronize do @cache.include?(cache_name) @@ -78,9 +72,9 @@ def self.has_cache?(cache_name) end def self.delete!(cache_name) - check_cache!(cache_name) - @locks_mutex.synchronize do + raise("No cache called '%s'" % cache_name) unless @cache_locks.include?(cache_name) + @cache_locks.delete(cache_name) @cache.delete(cache_name) end @@ -89,7 +83,7 @@ def self.delete!(cache_name) end def self.write(cache_name, key, value) - check_cache!(cache_name) + raise("No cache called '%s'" % cache_name) unless @cache.include?(cache_name) @cache_locks[cache_name].synchronize do @cache[cache_name][key] ||= {} @@ -101,13 +95,14 @@ def self.write(cache_name, key, value) end def self.read(cache_name, key) - check_cache!(cache_name) + raise("No cache called '%s'" % cache_name) unless @cache.include?(cache_name) unless ttl(cache_name, key) > 0 - raise_code(:PLMC11, "Cache expired on '%{cache_name}' key '%{item}'", :debug, :cache_name => cache_name, :item => key) + Log.debug("Cache expired on '%s' key '%s'" % [cache_name, key]) + raise("Cache for item '%s' on cache '%s' has expired" % [key, cache_name]) end - log_code(:PLMC12, "Cache hit on '%{cache_name}' key '%{item}'", :debug, :cache_name => cache_name, :item => key) + Log.debug("Cache hit on '%s' key '%s'" % [cache_name, key]) @cache_locks[cache_name].synchronize do @cache[cache_name][key][:value] @@ -115,11 +110,12 @@ def self.read(cache_name, key) end def self.ttl(cache_name, key) - check_cache!(cache_name) + raise("No cache called '%s'" % cache_name) unless @cache.include?(cache_name) @cache_locks[cache_name].synchronize do unless @cache[cache_name].include?(key) - raise_code(:PLMC15, "No item called '%{item}' for cache '%{cache_name}'", :debug, :cache_name => cache_name, :item => key) + Log.debug("Cache miss on '%s' key '%s'" % [cache_name, key]) + raise("No item called '%s' for cache '%s'" % [key, cache_name]) end @cache[cache_name][:max_age] - (Time.now - @cache[cache_name][key][:cache_create_time]) @@ -127,9 +123,9 @@ def self.ttl(cache_name, key) end def self.synchronize(cache_name) - check_cache!(cache_name) + raise("No cache called '%s'" % cache_name) unless @cache.include?(cache_name) - raise_code(:PLMC14, "No block supplied to synchronize on cache '%{cache_name}'", :debug, :cache_name => cache_name) unless block_given? + raise ("No block supplied to synchronize") unless block_given? @cache_locks[cache_name].synchronize do yield @@ -137,7 +133,7 @@ def self.synchronize(cache_name) end def self.invalidate!(cache_name, key) - check_cache!(cache_name) + raise("No cache called '%s'" % cache_name) unless @cache.include?(cache_name) @cache_locks[cache_name].synchronize do return false unless @cache[cache_name].include?(key) diff --git a/lib/mcollective/config.rb b/lib/mcollective/config.rb index 4bf67c78..98275077 100644 --- a/lib/mcollective/config.rb +++ b/lib/mcollective/config.rb @@ -125,9 +125,6 @@ def loadconfig(configfile) raise('The %s config file does not specify a libdir setting, cannot continue' % configfile) if @libdir.empty? - I18n.load_path = Dir[File.expand_path(File.join(File.dirname(__FILE__), "locales", "*.yml"))] - I18n.locale = :en - read_plugin_config_dir("#{@configdir}/plugin.d") raise 'Identities can only match /\w\.\-/' unless @identity.match(/^[\w\.\-]+$/) @@ -147,7 +144,7 @@ def loadconfig(configfile) PluginManager.loadclass("Mcollective::Audit::#{@rpcauditprovider}") if @rpcaudit PluginManager << {:type => "global_stats", :class => RunnerStats.new} - Log.logmsg(:PLMC1, "The Marionette Collective version %{version} started by %{name} using config file %{config}", :info, :version => MCollective::VERSION, :name => $0, :config => configfile) + Log.info("The Marionette Collective version #{MCollective::VERSION} started by #{$0} using config file #{configfile}") else raise("Cannot find config file '#{configfile}'") end diff --git a/lib/mcollective/data.rb b/lib/mcollective/data.rb index 2d848c2b..54f68060 100644 --- a/lib/mcollective/data.rb +++ b/lib/mcollective/data.rb @@ -42,19 +42,19 @@ def self.ddl_validate(ddl, argument) name = ddl.meta[:name] query = ddl.entities[:data] - DDL.validation_fail!(:PLMC31, "No dataquery has been defined in the DDL for data plugin '%{plugin}'", :error, :plugin => name) unless query + raise DDLValidationError, "No dataquery has been defined in the DDL for data plugin #{name}" unless query input = query.fetch(:input, {}) output = query.fetch(:output, {}) - DDL.validation_fail!(:PLMC32, "No output has been defined in the DDL for data plugin %{plugin}", :error, :plugin => name) if output.keys.empty? + raise DDLValidationError, "No output has been defined in the DDL for data plugin #{name}" if output.keys.empty? if input[:query] return true if argument.nil? && input[:query][:optional] ddl.validate_input_argument(input, :query, argument) else - DDL.validation_fail!(:PLMC33, "No data plugin argument was declared in the '%{plugin}' DDL but an input was supplied", :error, :plugin => name) if argument + raise("No data plugin argument was declared in the %s DDL but an input was supplied" % name) if argument return true end end diff --git a/lib/mcollective/ddl.rb b/lib/mcollective/ddl.rb index dc2410db..2148e052 100644 --- a/lib/mcollective/ddl.rb +++ b/lib/mcollective/ddl.rb @@ -53,8 +53,6 @@ module DDL autoload :DataDDL, "mcollective/ddl/dataddl" autoload :DiscoveryDDL, "mcollective/ddl/discoveryddl" - extend Translatable - # There used to be only one big nasty DDL class with a bunch of mashed # together behaviors. It's been around for ages and we would rather not # ask all the users to change their DDL.new calls to some other factory @@ -99,7 +97,7 @@ def self.string_to_boolean(val) return true if ["true", "t", "yes", "y", "1"].include?(val.downcase) return false if ["false", "f", "no", "n", "0"].include?(val.downcase) - raise_code(:PLMC17, "%{value} does not look like a boolean argument", :debug, :value => val) + raise "#{val} does not look like a boolean argument" end # a generic string to number function, if a number looks like a float @@ -109,16 +107,7 @@ def self.string_to_number(val) return val.to_f if val =~ /^\d+\.\d+$/ return val.to_i if val =~ /^\d+$/ - raise_code(:PLMC16, "%{value} does not look like a numeric value", :debug, :value => val) - end - - # Various DDL implementations will validate and raise on error, this is a - # utility method to correctly setup a DDLValidationError exceptions and raise them - def self.validation_fail!(code, default, level, args={}) - exception = DDLValidationError.new(code, default, level, args) - exception.set_backtrace caller - - raise exception + raise "#{val} does not look like a number" end end end diff --git a/lib/mcollective/ddl/agentddl.rb b/lib/mcollective/ddl/agentddl.rb index 3d465440..d9bec279 100644 --- a/lib/mcollective/ddl/agentddl.rb +++ b/lib/mcollective/ddl/agentddl.rb @@ -68,12 +68,12 @@ def summarize(&block) # Sets the aggregate array for the given action def aggregate(function, format = {:format => nil}) - DDL.validation_fail!(:PLMC28, "Formats supplied to aggregation functions should be a hash", :error) unless format.is_a?(Hash) - DDL.validation_fail!(:PLMC27, "Formats supplied to aggregation functions must have a :format key", :error) unless format.keys.include?(:format) - DDL.validation_fail!(:PLMC26, "Functions supplied to aggregate should be a hash", :error) unless function.is_a?(Hash) + raise(DDLValidationError, "Formats supplied to aggregation functions should be a hash") unless format.is_a?(Hash) + raise(DDLValidationError, "Formats supplied to aggregation functions must have a :format key") unless format.keys.include?(:format) + raise(DDLValidationError, "Functions supplied to aggregate should be a hash") unless function.is_a?(Hash) unless (function.keys.include?(:args)) && function[:args] - DDL.validation_fail!(:PLMC25, "aggregate method for action '%{action}' missing a function parameter", :error, :action => entities[@current_entity][:action]) + raise DDLValidationError, "aggregate method for action '%s' missing a function parameter" % entities[@current_entity][:action] end entities[@current_entity][:aggregate] ||= [] @@ -178,7 +178,7 @@ def set_default_input_arguments(action, arguments) def validate_rpc_request(action, arguments) # is the action known? unless actions.include?(action) - DDL.validation_fail!(:PLMC29, "Attempted to call action %{action} for %{plugin} but it's not declared in the DDL", :debug, :action => action, :plugin => @pluginname) + raise DDLValidationError, "Attempted to call action #{action} for #{@pluginname} but it's not declared in the DDL" end input = action_interface(action)[:input] || {} @@ -186,7 +186,7 @@ def validate_rpc_request(action, arguments) input.keys.each do |key| unless input[key][:optional] unless arguments.keys.include?(key) - DDL.validation_fail!(:PLMC30, "Action '%{action}' needs a '%{key}' argument", :debug, :action => action, :key => key) + raise DDLValidationError, "Action #{action} needs a #{key} argument" end end diff --git a/lib/mcollective/ddl/base.rb b/lib/mcollective/ddl/base.rb index e9a99f93..3e7a3619 100644 --- a/lib/mcollective/ddl/base.rb +++ b/lib/mcollective/ddl/base.rb @@ -17,8 +17,6 @@ module DDL # plugin DDL then add a PlugintypeDDL class here and add your # specific behaviors to those. class Base - include Translatable - attr_reader :meta, :entities, :pluginname, :plugintype, :usage, :requirements def initialize(plugin, plugintype=:agent, loadddl=true) @@ -82,7 +80,7 @@ def loadddlfile if ddlfile = findddlfile instance_eval(File.read(ddlfile), ddlfile, 1) else - raise_code(:PLMC40, "Can't find DDL for %{type} plugin '%{name}'", :debug, :type => @plugintype, :name => @pluginname) + raise("Can't find DDL for #{@plugintype} plugin '#{@pluginname}'") end end @@ -93,7 +91,7 @@ def findddlfile(ddlname=nil, ddltype=nil) @config.libdir.each do |libdir| ddlfile = File.join([libdir, "mcollective", ddltype.to_s, "#{ddlname}.ddl"]) if File.exist?(ddlfile) - log_code(:PLMC18, "Found %{ddlname} ddl at %{ddlfile}", :debug, :ddlname => ddlname, :ddlfile => ddlfile) + Log.debug("Found #{ddlname} ddl at #{ddlfile}") return ddlfile end end @@ -103,12 +101,12 @@ def findddlfile(ddlname=nil, ddltype=nil) def validate_requirements if requirement = @requirements[:mcollective] if Util.mcollective_version == "@DEVELOPMENT_VERSION@" - log_code(:PLMC19, "DDL requirements validation being skipped in development", :warn) + Log.warn("DDL requirements validation being skipped in development") return true end if Util.versioncmp(Util.mcollective_version, requirement) < 0 - DDL.validation_fail!(:PLMC20, "%{type} plugin '%{name}' requires MCollective version %{requirement} or newer", :debug, :type => @plugintype.to_s.capitalize, :name => @pluginname, :requirement => requirement) + raise DDLValidationError, "%s plugin '%s' requires MCollective version %s or newer" % [@plugintype.to_s.capitalize, @pluginname, requirement] end end @@ -144,19 +142,19 @@ def validate_input_argument(input, key, argument) return true rescue => e - DDL.validation_fail!(:PLMC21, "Cannot validate input '%{input}': %{error}", :debug, :input => key, :error => e.to_s) + raise DDLValidationError, "Cannot validate input %s: %s" % [key, e.to_s] end # Registers an input argument for a given action # # See the documentation for action for how to use this def input(argument, properties) - raise_code(:PLMC22, "Cannot determine what entity input '%{entity}' belongs to", :error, :entity => @current_entity) unless @current_entity + raise "Cannot figure out what entity input #{argument} belongs to" unless @current_entity entity = @current_entity [:prompt, :description, :type].each do |arg| - raise_code(:PLMC23, "Input needs a :%{property} property", :debug, :property => arg) unless properties.include?(arg) + raise "Input needs a :#{arg} property" unless properties.include?(arg) end @entities[entity][:input][argument] = {:prompt => properties[:prompt], diff --git a/lib/mcollective/exception.rb b/lib/mcollective/exception.rb deleted file mode 100644 index a6cade5e..00000000 --- a/lib/mcollective/exception.rb +++ /dev/null @@ -1,40 +0,0 @@ -module MCollective - class CodedError default}.merge(@args)) - - super(msg) - end - - def set_backtrace(trace) - super - log(@log_level) - end - - def log(level, log_backtrace=false) - Log.logexception(@code, level, self, log_backtrace) - end - end - - # Exceptions for the RPC system - class DDLValidationError "Get data from a data plugin" do - input :source, - :prompt => "Data Source", - :description => "The data plugin to retrieve information from", - :type => :string, - :validation => '^\w+$', - :optional => false, - :maxlength => 50 - end - - Here the input belongs to the action entity "get_data", this error indicates that an input were found without it belonging to any specific entity - pattern: "Cannot determine what entity input '%{input}' belongs to" - PLMC23: - example: "Input needs a :prompt property" - expanded: "When writing a DDL you declare inputs for all data that you pass into the plugin. Inputs have a minimally required field set and this error indicate that you did not provide some key field while describing the input." - pattern: "Input needs a :%{property} property" - PLMC24: - example: "Failed to load DDL for the 'rpcutil' agent, DDLs are required: RuntimeError: failed to parse DDL file" - expanded: |- - As of version 2.0.0 DDL files are required by the MCollective server. This server indicates that it either could not find the DDL for the rpcutil agent or that there was a syntax error. - - Confirm that the DDL file is installed in the agent directory and that it parses correctly using the 'mco plugin doc' command. - pattern: "Failed to load DDL for the '%{agent}' agent, DDLs are required: %{error_class}: %{error}" - PLMC25: - example: "aggregate method for action 'rpcutil' is missing a function parameter" - expanded: |- - DDL files can declare aggregation rules for the data returned by actions as seen below: - - summarize do - aggregate summary(:collectives) - end - - This error indicates that you did not supply the argument - :collectives in this example. - pattern: "aggregate method for action '%{action}' is missing a function parameter" - PLMC26: - expanded: |- - Internally when MCollective parse the DDL it converts the aggregate functions into a hash with the function name and any arguments. - - This error indicates that the internal translation failed, this is a critical error and would probably indicate a structure problem in your DDL or a bug in MCollective - pattern: "Functions supplied to aggregate should be a hash" - PLMC27: - expanded: |- - DDL aggregate functions can take a custom format as in the example below: - - aggregate average(:total_resources, :format => "Average: %d") - - This error indicate that the :format above could not be correctly parsed. - pattern: "Formats supplied to aggregation functions must have a :format key" - PLMC28: - expanded: |- - DDL aggregate functions can take a custom format as in the example below: - - aggregate average(:total_resources, :format => "Average: %d") - - This error indicate that the :format above was not supplied as a hash as in the above example - pattern: "Formats supplied to aggregation functions should be a hash" - PLMC29: - example: "Attempted to call action 'yum_clean' for 'package' but it's not declared in the DDL" - expanded: |- - Every agent has a DDL file that describes valid actions that they can perform - - This error indicates you attempted to perform an action that does not exist. Review the plugin documentation using 'mco plugin doc' for correct usage - pattern: "Attempted to call action '%{action}' for '%{plugin}' but it's not declared in the DDL" - PLMC3: - expanded: |- - When sending the mcollectived process the USR2 signal on a Unix based machine this message indicates that the signal for received and the logging level is being adjusted to the next higher level or back down to debug if it was already at it's highest level. - - This message will be followed by another message similar to the one below: - - Logging level is now WARN - pattern: "Cycling logging level due to USR2 signal" - PLMC30: - example: "Action 'get_fact' needs a 'fact' argument" - expanded: "Actions can declare that they expect a required input, this error indicates that you did not supply the required input" - pattern: "Action '%{action}' needs a '%{key}' argument" - PLMC31: - example: "No dataquery has been defined in the DDL for data plugin 'package'" - expanded: |- - Each data plugin requires a DDL that has a 'dataquery' block in it. - - dataquery :description => "Agent Meta Data" do - . - . - end - - This error indicates that the DDL file for a specific data plugin did not contain this block. - pattern: "No dataquery has been defined in the DDL for data plugin '%{plugin}'" - PLMC32: - expanded: "Data plugins must return data. The DDL files for a data plugin must declare at least one output parameter else you will see this error." - pattern: "No output has been defined in the DDL for data plugin '%{plugin}'" - PLMC33: - example: "No data plugin argument was declared in the 'puppet' DDL but an input was supplied" - expanded: |- - Data plugins can take an optional input argument. This error indicate that you supplied an input argument but the plugin does not actually expect any input. - - Review the documentation for the data plugin using 'mco plugin doc' - pattern: "No data plugin argument was declared in the '%{plugin}' DDL but an input was supplied" - PLMC34: - example: "setting meta data in agents have been deprecated, DDL files are now being used for this information. Please update the 'package' agent" - expanded: |- - In the past each MCollective agent had a metadata section containing information like the timeout. - - As of 2.2.0 the agents will now consult the DDL files that ship with each agent for this purpose so the metadata in agents are not used at all. - - In order to remove confusing duplication setting metadata in agents have been deprecated and from version 2.4.0 will not be supported at all. - - Please update your agent by removing the metadata section from it and make sure the DDL file has the correct information instead. - pattern: "setting meta data in agents have been deprecated, DDL files are now being used for this information. Please update the '%{agent}' agent" - PLMC35: - expanded: |- - The MCollective client can ask that the agent just performs the action and never respond. Like when supplying the --no-results option to the 'mco rpc' application. - - This log line indicates that the request was received and interpreted as such and no reply will be sent. This does not indicate a problem generally it's just there to assist with debugging of problems. - pattern: "Client did not request a response, surpressing reply" - PLMC36: - example: "Unknown action 'png' for agent 'rpcutil'" - expanded: |- - Agents are made up of a number of named actions. When the MCollective Server receives a request it double checks if the agent in question actually implements the logic for a specific action. - - When it cannot find the implementation this error will be raised. This is an unusual situation since at this point on both the client and the server the DDL will already have been used to validate the request and the DDL would have indicated that the action is valid. - - Check your agent code and make sure you have code like: - - action "the_action" do - . - . - end - pattern: "Unknown action '%{action}' for agent '%{agent}'" - PLMC37: - example: "Starting default activation checks for the 'rpcutil' agent" - expanded: |- - Each time the MCollective daemon starts it loads each agent from disk. It then tries to determine if the agent should start on this node by using the activate_when method or per-agent configuration. - - This is a debug statement that shows you it is about to start interacting with the logic in the agent to determine if it should be made available or not. - pattern: "Starting default activation checks for the '%{agent}' agent" - PLMC38: - example: "Found plugin configuration 'exim.activate_agent' with value 'y'" - expanded: |- - The administrator can choose that a certain agent that is deployed on this machine should not be made available to the network. - - To do this you would add a configuration value like this example to the mcollective server.cfg: - - plugin.exim.activate_agent = n - - If this value is "1", "y" or "true" the agent will be activated else it will be disabled. - pattern: "Found plugin configuration '%{agent}.activate_agent' with value '%{should_activate}'" - PLMC39: - example: "Audit failed with an error, processing the request will continue." - expanded: |- - Every MCollective request can be audited. In the event where the auditing fails the processing continues. - - At present the failure handling is not configurable, in future the administrator might elect to not run unaudited requests via configuration. - PLMC4: - example: "Failed to start registration plugin: ArgumentError: meta.rb:6:in `gsub': wrong number of arguments (0 for 2)" - expanded: | - Registration plugins are loaded into the MCollective daemon at startup and ran on a regular interval. - - This message indicate that on first start this plugin failed to run, it will show the exception class, line and exception message to assist with debugging - pattern: "Failed to start registration plugin: %{error}" - PLMC40: - example: "Can't find DDL for agent plugin 'puppet'" - expanded: |- - MCollective plugins come with DDL files that describe their behaviours, versions, capabilities and requirements. - - This error indicate that a DDL file for the plugin mentioned could not be found - it could be that you have a typing error in your command line or an installation error. - pattern: "Can't find DDL for %{type} plugin '%{name}'" - PLMC41: - example: "Data plugin 'agent()' function does not return a 'foo' value" - expanded: |- - Data functions return a set of values which can be identified by name. - - This message indicates that the specified value has not been defined in the Data plugin's DDL. - pattern: "Data plugin '%{functionname}()' does not return a '%{value}' value" - PLMC42: - example: "Cannot convert string value 'hello' into a boolean. " - expanded: |- - This error gets logged when there is an attempt to convert a string value into a boolean, but the string does not match the boolean pattern. - - Strings that match "1", "y", "yes", "YES", "t", "true" and "TRUE" will be transformed into a boolean true. - - Strings that match "0", "n", "no", "NO", "f", "false" and "FALSE" will be transformed into a boolean false. - pattern: "Cannot convert string value '%{value}' into a boolean. " - PLMC5: - expanded: |- - In previous versions of MCollective a application called 'controller' were included that had the ability to request agent reloads and other commands that would control the runner. - - Unfortunately this method of controlling the daemon was never considered stable or reliable and has since been deprecate for removal during the 2.3.x development series - pattern: "Received a control message, possibly via 'mco controller' but this has been deprecated" - PLMC6: - expanded: |- - When a specific MCollective daemon receives a message from a network it validates the filter before processing the message. The filter is the list of classes, facts or other conditions that are associated with any message. - - In the case where the filter does not match the specific host this line gets logged. - - It's often the case for broadcast messages that all MCollective nodes will receive a message but only a subset of nodes are targetted using the filters, in that situation the nodes that received the request but should not respond to it will see this log line. - - It does not indicate anything to be concerned about but if you find debugging a problem and expect a node to have responded when it shouldn't this log line will give you a hint that some condition specified in the filter did not match the local host - pattern: "Message does not pass filters, ignoring" - PLMC7: - example: "Exiting after signal: SignalException: runner.rb:6:in `run': Interrupt" - expanded: |- - When the MCollective daemon gets a signal from the Operating System that it does not specifically handle it will log this line before exiting. - - You would see this whenever the daemon is stopped by init script or when sending it a kill signal, it will then proceed to disconnect from the middleware and exit its main loop - pattern: "Exiting after signal: %{error}" - PLMC8: - example: "Handling message for agent 'rpcutil' on collective 'eu_collective' with requestid 'a8a78d0ff555c931f045b6f448129846'" - expanded: |- - After receiving a message from the middleware, decoding it, validating it's security credentials and doing other checks on it the MCollective daemon will pass it off to the actual agent code for processing. - - Prior to doing so it will log this line indicating the agent name and sub-collective and other information that will assist in correlating the message sent from the client with those in the server logs being processed. - pattern: "Handling message for agent '%{agent}' on collective '%{collective} with requestid '%{requestid}'" - PLMC9: - example: "Expired Message: message 8b4fe522f0d0541dabe83ec10b7fa446 from cert=client@node created at 1358840888 is 653 seconds old, TTL is 60" - expanded: |- - Requests sent from clients to servers all have a creation time and a maximum validity time called a TTL. - - This message indicates that a message was received from the network but that it was determined to be too based on the TTL settings. - - Usually this happens because your clocks are not in sync - something that can be fixed by rolling out a tool like ntp across your server estate. - - It might also happen during very slow network conditions or when the TTL is set too low for your general network latency. - pattern: "Expired Message: %{error}" diff --git a/lib/mcollective/log.rb b/lib/mcollective/log.rb index efb84d2b..d74ddd50 100644 --- a/lib/mcollective/log.rb +++ b/lib/mcollective/log.rb @@ -4,8 +4,6 @@ class Log class << self @logger = nil - VALID_LEVELS = [:error, :fatal, :debug, :warn, :info] - # Obtain the class name of the currently configured logger def logger @logger.class @@ -46,74 +44,18 @@ def cycle_level @logger.cycle_level if @configured end - def config_and_check_level(level) - configure unless @configured - check_level(level) - @logger.should_log?(level) - end - - def check_level(level) - raise "Unknown log level" unless valid_level?(level) - end - - def valid_level?(level) - VALID_LEVELS.include?(level) - end - - def message_for(msgid, args={}) - "%s: %s" % [msgid, Util.t(msgid, args)] - end - - def logexception(msgid, level, e, backtrace=false, args={}) - return false unless config_and_check_level(level) - - path, line, method = e.backtrace[1].split(/:(\d+)/) - origin = "%s:%s%s" % [File.basename(path), line, method] - - if e.is_a?(CodedError) - msg = "%s: %s" % [e.code, e.to_s] - else - error_string = "%s: %s" % [e.class, e.to_s] - msg = message_for(msgid, args.merge(:error => error_string)) - end - - log(level, msg, origin) - - if backtrace - e.backtrace.each do |line| - log(level, "%s: %s" % [msgid, line], origin) - end - end - end - - # Logs a message at a certain level, the message must be - # a token that will be looked up from the i18n localization - # database - # - # Messages can interprolate strings from the args hash, a - # message with "foo %{bar}" in the localization database - # will use args[:bar] for the value there, the interprolation - # is handled by the i18n library itself - def logmsg(msgid, default, level, args={}) - return false unless config_and_check_level(level) - - msg = message_for(msgid, {:default => default}.merge(args)) - - log(level, msg) - end - # logs a message at a certain level - def log(level, msg, origin=nil) - return unless config_and_check_level(level) + def log(level, msg) + configure unless @configured - origin = from unless origin + raise "Unknown log level" unless [:error, :fatal, :debug, :warn, :info].include?(level) if @logger - @logger.log(level, origin, msg) + @logger.log(level, from, msg) else t = Time.new.strftime("%H:%M:%S") - STDERR.puts "#{t}: #{level}: #{origin}: #{msg}" + STDERR.puts "#{t}: #{level}: #{from}: #{msg}" end end @@ -138,9 +80,9 @@ def configure(logger=nil) @configured = true end - require "mcollective/logger/%s_logger" % logger_type.downcase + require "mcollective/logger/#{logger_type.downcase}_logger" - logger_class = MCollective::Logger.const_get("%s_logger" % logger_type.capitalize) + logger_class = MCollective::Logger.const_get("#{logger_type.capitalize}_logger") set_logger(logger_class.new) else @@ -148,25 +90,19 @@ def configure(logger=nil) @configured = true end - @logger.start rescue Exception => e @configured = false STDERR.puts "Could not start logger: #{e.class} #{e}" end - def unconfigure - @configured = false - set_logger(nil) - end - # figures out the filename that called us def from path, line, method = execution_stack[3].split(/:(\d+)/) "%s:%s%s" % [File.basename(path), line, method] end - # this method is here to facilitate testing + # this method is here to facilitate testing and from def execution_stack caller end diff --git a/lib/mcollective/logger/base.rb b/lib/mcollective/logger/base.rb index 9bdc5307..7c0bf2f8 100644 --- a/lib/mcollective/logger/base.rb +++ b/lib/mcollective/logger/base.rb @@ -20,10 +20,6 @@ def initialize end end - def should_log?(level) - @known_levels.index(level) >= @known_levels.index(@active_level) - end - # Figures out the next level and sets it def cycle_level lvl = get_next_level diff --git a/lib/mcollective/logger/console_logger.rb b/lib/mcollective/logger/console_logger.rb index 9d5b8eac..8be429d6 100644 --- a/lib/mcollective/logger/console_logger.rb +++ b/lib/mcollective/logger/console_logger.rb @@ -22,9 +22,11 @@ def valid_levels end def log(level, from, msg, normal_output=STDERR, last_resort_output=STDERR) - time = Time.new.strftime("%Y/%m/%d %H:%M:%S") + if @known_levels.index(level) >= @known_levels.index(@active_level) + time = Time.new.strftime("%Y/%m/%d %H:%M:%S") - normal_output.puts("%s %s: %s %s" % [colorize(level, level), time, from, msg]) + normal_output.puts("%s %s: %s %s" % [colorize(level, level), time, from, msg]) + end rescue # if this fails we probably cant show the user output at all, # STDERR it as last resort diff --git a/lib/mcollective/logger/syslog_logger.rb b/lib/mcollective/logger/syslog_logger.rb index af9e46ad..e2b1d9ab 100644 --- a/lib/mcollective/logger/syslog_logger.rb +++ b/lib/mcollective/logger/syslog_logger.rb @@ -40,7 +40,9 @@ def valid_levels end def log(level, from, msg) - Syslog.send(map_level(level), "#{from} #{msg}") + if @known_levels.index(level) >= @known_levels.index(@active_level) + Syslog.send(map_level(level), "#{from} #{msg}") + end rescue # if this fails we probably cant show the user output at all, # STDERR it as last resort diff --git a/lib/mcollective/rpc/agent.rb b/lib/mcollective/rpc/agent.rb index 49a9b3a2..ff324efc 100644 --- a/lib/mcollective/rpc/agent.rb +++ b/lib/mcollective/rpc/agent.rb @@ -31,9 +31,6 @@ module RPC # # We also currently have the validation code in here, this will be moved to plugins soon. class Agent - include Translatable - extend Translatable - attr_accessor :reply, :request, :agent_name attr_reader :logger, :config, :timeout, :ddl, :meta @@ -58,7 +55,8 @@ def load_ddl @timeout = @meta[:timeout] || 10 rescue Exception => e - DDL.validation_fail!(:PLMC24, "Failed to load DDL for the '%{agent}' agent, DDLs are required: %{error_class}: %{error}", :error, :agent => @agent_name, :error_class => e.class, :error => e.to_s) + Log.error("Failed to load DDL for the '%s' agent, DDLs are required: %s: %s" % [@agent_name, e.class, e.to_s]) + raise DDLValidationError end def handlemsg(msg, connection) @@ -87,7 +85,6 @@ def handlemsg(msg, connection) if respond_to?("#{@request.action}_action") send("#{@request.action}_action") else - log_code(:PLMC36, "Unknown action '%{action}' for agent '%{agent}'", :warn, :action => @request.action, :agent => @request.agent) raise UnknownRPCAction, "Unknown action '#{@request.action}' for agent '#{@request.agent}'" end rescue RPCAborted => e @@ -119,7 +116,7 @@ def handlemsg(msg, connection) if @request.should_respond? return @reply.to_hash else - log_code(:PLMC35, "Client did not request a response, surpressing reply", :debug) + Log.debug("Client did not request a response, surpressing reply") return nil end end @@ -142,12 +139,12 @@ def handlemsg(msg, connection) def self.activate? agent_name = self.to_s.split("::").last.downcase - log_code(:PLMC37, "Starting default activation checks for the '%{agent}' agent", :debug, :agent => agent_name) + Log.debug("Starting default activation checks for #{agent_name}") should_activate = Util.str_to_bool(Config.instance.pluginconf.fetch("#{agent_name}.activate_agent", true)) unless should_activate - log_code(:PLMC38, "Found plugin configuration '%{agent}.activate_agent' with value '%{should_activate}'", :debug, :agent => agent_name, :should_activate => should_activate) + Log.debug("Found plugin configuration '#{agent_name}.activate_agent' with value '#{should_activate}'") end return should_activate @@ -237,7 +234,7 @@ def run(command, options={}) def self.metadata(data) agent = File.basename(caller.first).split(":").first - log_code(:PLMC34, "setting meta data in agents have been deprecated, DDL files are now being used for this information. Please update the '%{agent}' agent", :warn, :agent => agent) + Log.warn("Setting metadata in agents has been deprecated, DDL files are now being used for this information. Please update the '#{agent}' agent") end # Creates the needed activate? class in a manner similar to the other @@ -364,7 +361,7 @@ def after_processing_hook def audit_request(msg, connection) PluginManager["rpcaudit_plugin"].audit_request(msg, connection) if @config.rpcaudit rescue Exception => e - logexception(:PLMC39, "Audit failed with an error, processing the request will continue.", :warn, e) + Log.warn("Audit failed - #{e} - continuing to process message") end end end diff --git a/lib/mcollective/runner.rb b/lib/mcollective/runner.rb index 19e6d1d9..d324ce7f 100644 --- a/lib/mcollective/runner.rb +++ b/lib/mcollective/runner.rb @@ -3,8 +3,6 @@ module MCollective # and the background, keeps detailed stats and provides hooks to access # all this information class Runner - include Translatable - def initialize(configfile) @config = Config.instance @config.loadconfig(configfile) unless @config.configured @@ -22,13 +20,12 @@ def initialize(configfile) unless Util.windows? Signal.trap("USR1") do - log_code(:PLMC2, "Reloading all agents after receiving USR1 signal", :info) + Log.info("Reloading all agents after receiving USR1 signal") @agents.loadagents end Signal.trap("USR2") do - log_code(:PLMC3, "Cycling logging level due to USR2 signal", :info) - + Log.info("Cycling logging level due to USR2 signal") Log.cycle_level end else @@ -47,7 +44,7 @@ def run begin PluginManager["registration_plugin"].run(@connection) unless @config.registerinterval == 0 rescue Exception => e - logexception(:PLMC4, "Failed to start registration plugin: %{error}", :error, e) + Log.error("Failed to start registration plugin: #{e}") end loop do @@ -57,21 +54,22 @@ def run unless request.agent == "mcollective" agentmsg(request) else - log_code(:PLMC5, "Received a control message, possibly via 'mco controller' but this has been deprecated", :error) + Log.error("Received a control message, possibly via 'mco controller' but this has been deprecated") end rescue SignalException => e - logexception(:PLMC7, "Exiting after signal: %{error}", :warn, e) + Log.warn("Exiting after signal: #{e}") @connection.disconnect raise rescue MsgTTLExpired => e - logexception(:PLMC9, "Expired Message: %{error}", :warn, e) + Log.warn(e) rescue NotTargettedAtUs => e - log_code(:PLMC6, "Message does not pass filters, ignoring", :debug) + Log.debug("Message does not pass filters, ignoring") rescue Exception => e - logexception(:PLMC10, "Failed to handle message: %{error}", :warn, e, true) + Log.warn("Failed to handle message: #{e} - #{e.class}\n") + Log.warn(e.backtrace.join("\n\t")) end end end @@ -79,7 +77,7 @@ def run private # Deals with messages directed to agents def agentmsg(request) - log_code(:PLMC8, "Handling message for agent '%{agent}' on collective '%{collective} with requestid '%{requestid}'", :debug, :agent => request.agent, :collective => request.collective, :requestid => request.requestid) + Log.debug("Handling message for agent '#{request.agent}' on collective '#{request.collective}'") @agents.dispatch(request, @connection) do |reply_message| reply(reply_message, request) if reply_message diff --git a/lib/mcollective/translatable.rb b/lib/mcollective/translatable.rb deleted file mode 100644 index 1d75ae3c..00000000 --- a/lib/mcollective/translatable.rb +++ /dev/null @@ -1,24 +0,0 @@ -module MCollective - module Translatable - def t(msgid, default, args={}) - Util.t(msgid, {:default => default}.merge(args)) - end - - def log_code(msgid, default, level, args={}) - msg = "%s: %s" % [msgid, Util.t(msgid, {:default => default}.merge(args))] - - Log.log(level, msg, File.basename(caller[1])) - end - - def raise_code(msgid, default, level, args={}) - exception = CodedError.new(msgid, default, level, args) - exception.set_backtrace caller - - raise exception - end - - def logexception(msgid, default, level, e, backtrace=false) - Log.logexception(msgid, level, e, backtrace) - end - end -end diff --git a/lib/mcollective/util.rb b/lib/mcollective/util.rb index 707df666..69993423 100644 --- a/lib/mcollective/util.rb +++ b/lib/mcollective/util.rb @@ -1,8 +1,6 @@ module MCollective # Some basic utility helper methods useful to clients, agents, runner etc. module Util - extend Translatable - # Finds out if this MCollective has an agent by the name passed # # If the passed name starts with a / it's assumed to be regex @@ -481,16 +479,7 @@ def self.str_to_bool(val) elsif clean_val =~ /^(0|no|false|n|f)$/i return false else - raise_code(:PLMC42, "Cannot convert string value '%{value}' into a boolean.", :error, :value => clean_val) - end - end - - # Looks up and interprolate the hash values into a i18n string - def self.t(msgid, args={}) - if msgid.is_a?(Symbol) - I18n.t("%s.pattern" % msgid, args) - else - I18n.t(msgid, args) + raise("Cannot convert string value '#{clean_val}' into a boolean.") end end diff --git a/lib/mcollective/vendor/i18n/.gitignore b/lib/mcollective/vendor/i18n/.gitignore deleted file mode 100644 index b066d1ea..00000000 --- a/lib/mcollective/vendor/i18n/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -.DS_Store -test/rails/fixtures -nbproject/ -vendor/**/* -*.swp -pkg -.bundle -.rvmrc diff --git a/lib/mcollective/vendor/i18n/.travis.yml b/lib/mcollective/vendor/i18n/.travis.yml deleted file mode 100644 index 792ec6ca..00000000 --- a/lib/mcollective/vendor/i18n/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -rvm: - - 1.8.7 - - 1.9.2 - - 1.9.3 - - ree - - rbx - - jruby diff --git a/lib/mcollective/vendor/i18n/CHANGELOG.textile b/lib/mcollective/vendor/i18n/CHANGELOG.textile deleted file mode 100644 index e1eeda86..00000000 --- a/lib/mcollective/vendor/i18n/CHANGELOG.textile +++ /dev/null @@ -1,152 +0,0 @@ -h1. Changelog - -h2. 0.5.0 - -* "Extract Backend::ActiveRecord to a separate gem":https://github.com/svenfuchs/i18n/commit/197dacebad356b910d69fa69a719c2ad10cf49e6 (see "i18n-active_record":https://github.com/svenfuchs/i18n-active_record) -* "Improve exception handling":https://github.com/svenfuchs/i18n/commit/2913ff9a7544f223f60e7d7b32c2a0e1af89812b (deprectates I18n.default_exception_handler) -* "Change MissingTranslationData message to 'translation missing: foo.bar'":https://github.com/svenfuchs/i18n/commit/68fdfe47952325411afe5942e971ce10b2bdf900 -* "Expose MissingTranslationsData#keys method":https://github.com/svenfuchs/i18n/commit/3a37a389ecaac9670355b334e23e775549ee9822 -* "Improve Cascade#lookup (add default options)":https://github.com/svenfuchs/i18n/commit/0b9a1f2058a2be9543106cc19d08071c359511e1 -* "Finally remove deprecated interpolation syntax":https://github.com/svenfuchs/i18n/commit/2d43846d2b2a2e596f30fa58ea1c9ddb2243bb64 - -h2. 0.4.2 (2010-10-26) - -* "Improve UTF8 handling":http://github.com/svenfuchs/i18n/commit/e8d5820a3b08eeca28de1a2b9c8a6ad2b9e6476c -* "Expose I18n::VERSION":http://github.com/svenfuchs/i18n/commit/b832037bac94c7144f45f3ff5e3b4e4089781726 -* "Better deprecation output":http://github.com/svenfuchs/i18n/commit/2bee924464b8a9c33d3d7852eb1c8423aa38cc25 - -h2. 0.4.1 (2010-06-05) - -* "Fix interpolation failure on Ruby 1.9":http://github.com/svenfuchs/i18n/commit/8d45bedb11c4136c00e853d104b00a8e67ec4894 - -h2. 0.4.0 (2010-05-27) - -* "The localization proc also receives the object as option":http://github.com/svenfuchs/i18n/commit/4a8cd9fa660daaa3078e24c5851353ca377d9213 - -h2. 0.4.0.beta1 (2010-05-03) - -* "Renamed Fast backend to Memoize backend":http://github.com/svenfuchs/i18n/commit/f7f7dc12c00a19d3876223771e14f8671ff313cd - -* "Deprecate {{}} as interpolation syntax":http://github.com/svenfuchs/i18n/commit/8894ee521ef5788c415b625a6daf522af4c416e0 - -* "Allow nil translation to be stored again":http://github.com/svenfuchs/i18n/commit/f2074f1e82d10c2e9a801c8cc2f2a0c7c30703ba - -h2. 0.4.0.beta (2010-04-30) - -* "Added a KeyValue backend":http://github.com/svenfuchs/i18n/commit/28ca5f53ade7f545f8c0804e93564d4686b416a4 - -* "Added transliteration support":http://github.com/svenfuchs/i18n/commit/928fdb4794959e779e90f360eb01ba043672d8d5 - -* "Create Flatten backend module to aid handling flatten translations":http://github.com/svenfuchs/i18n/commit/2ec9d6998aa8facd7b15a3ef47a96cf2471cd8a1 - -* "Decouple the external separator (used when storing translations) from the internal separator in Fast and ActiveRecord backends":http://github.com/svenfuchs/i18n/commit/274cb4daa0ca5e3b2bd23b45eb7f9fc58f75a79d - -h2. 0.3.7 (2010-04-17) - -* "Speed up I18n.normalize_keys by caching reused normalizations and producing less garbage":http://github.com/svenfuchs/i18n/commit/819dac0fea9c29e6545801aa107e63e355728cd4 - -h2. 0.3.6 (2010-03-23) - -* "Move gettext po parser to lib":http://github.com/svenfuchs/i18n/commit/b2f038663b55727ac2327e6f07a46ba5d69d600c - -* "Move I18n configuration to I18n.config":http://github.com/svenfuchs/i18n/commit/4a7baea86663ead8c681008c3e80a622f0546b07 - -h2. 0.3.5 (2010-02-26) - -* "Delegate I18n.normalize_translation_keys to I18n.normalize_keys and deprecate -the former":http://github.com/svenfuchs/i18n/commit/7284b04d5f5dd9679cb68875515cdd0cdfc96fef - -h2. 0.3.4 (2010-02-25) - -* "Rename I18n.normalize_translation_keys to I18n.normalize_keys and finally make it public":http://github.com/svenfuchs/i18n/commit/20b05fe5802df6c90fb70a4e3760b2b851b791b3 - -* "Added CLDR supoprt":http://github.com/svenfuchs/i18n/commit/860eadf671a231e7f5dffb1bb27fa318ff7a8786 - -h2. 0.3.3 (2009-12-29) - -* "Use lib/i18n/version":http://github.com/svenfuchs/i18n/commit/ff426c8e7a2438b814cb303adadec292dacb752e - -* "Added a benchmark suite":http://github.com/svenfuchs/i18n/commit/f9b5b9b113097724638bdab96862ffa404e67e70 - -* "Ensure links can be handled recursively":http://github.com/svenfuchs/i18n/commit/2c50bd209f3fc24fe9dfa694c81be64340f09b7d - -* "Make sure we can lookup false values as translation data":http://github.com/svenfuchs/i18n/commit/561c82ba4b8921d03bfdf56cb2d0c2f287629001 - -* "Added Fast backend module":http://github.com/svenfuchs/i18n/commit/bd2f09f0a251ca793b0e8ecc7e32177a2f091c23 - -* "Added InterpolationCompiler backend module":http://github.com/svenfuchs/i18n/commit/91810887d1abfb28996a9183bc9004678290d28b - -h2. 0.3.2 (2009-12-12) - -* "Added Cascade backend":http://github.com/svenfuchs/i18n/commit/8009aef293e9ef8564c9005090d8380feabcaf6f - -h2. 0.3.1 (2009-12-11) - -* "Add PoParser to gemspec":http://github.com/svenfuchs/i18n/commit/d6b2763f39c932f66adb039b96882a472f883c51 -* "Enable custom separators for ActiveRecord backend":http://github.com/svenfuchs/i18n/commit/9341d3fcfc951cc31807ba672d2b5d90909ef3e5 -* "Pass interpolation values to interpolation procs":http://github.com/svenfuchs/i18n/commit/39c2ed8fbad645671cd5520ce7ad0aeefe2b0cca -* "Fix that ngettext supports keys with dots":http://github.com/svenfuchs/i18n/commit/7362a43c34364d500de8899cfcca6bf1a5e6d1c8 - -h2. 0.3.0 (2009-11-30) - -* "Gettext backend and helpers":http://github.com/svenfuchs/i18n/commit/35a1740d2f10b808548af352006950da4017e374 -* "Metadata module":http://github.com/svenfuchs/i18n/commit/2677208555179b36fcbe958c0e8bc642cf5bc020 -* "Basic ActiveRecord backend":http://github.com/svenfuchs/i18n/commit/786632d0b42de423ecf0969622efc87f1691e2a2 -* "Set encoding to UTF8 for all files":http://github.com/svenfuchs/i18n/commit/9be3d4a311b5bf583eec5d39986176cc40c112f2 -* "Chain backend":http://github.com/svenfuchs/i18n/commit/08259ffb88b3005403648d77bc1cbca0b92f3cf5 -* "Backend/cache implementation":http://github.com/svenfuchs/i18n/commit/e7bf15351cd2e27f5972eb40e65a5dd6f4a0feed -* "Pluralization module":http://github.com/svenfuchs/i18n/commit/9ca4c9ed52d4706566a6abeb2d78722dcc5d4764 -* "add and adapt Globalize2 fallback implementation":http://github.com/svenfuchs/i18n/commit/1b37a303b27d6222b17162804b06323e5628768f -* "move Simple backend implementation to a Base backend class and extend Simple from Base.":http://github.com/svenfuchs/i18n/commit/32ddc80a04e6aa247f6d6613bde7f78c73396cb4 - -h2. 0.2.0 (2009-07-12) - -* "Allow using Ruby 1.9 syntax for string interpolation (API addition)":http://github.com/svenfuchs/i18n/commit/c6e0b06d512f2af57199a843a1d8a40241b32861 -* "Allow configuring the default scope separator, allow to pass a custom scope separator(API addition)":http://github.com/svenfuchs/i18n/commit/5b75bfbc348061adc11e3790187a187275bfd471 (e.g. I18n.t(:'foo|bar', :separator => '|') -* "Pass :format option to #translate for #localize more useful lambda support":http://github.com/svenfuchs/i18n/commit/e277711b3c844fe7589b8d3f9af0f7d1b969a273 -* "Refactor Simple backend #resolve to #default and #resolve for more consistency. Now allows to pass lambdas as defaults and re-resolve Symbols":http://github.com/svenfuchs/i18n/commit/8c4ce3d923ce5fa73e973fe28217e18165549aba -* "Add lambda support to #translate (API addition)":http://github.com/svenfuchs/i18n/commit/c90e62d8f7d3d5b78f34cfe328d871b58884f115 -* "Add lambda support to #localize (API addition)":http://github.com/svenfuchs/i18n/commit/9d390afcf33f3f469bb95e6888147152f6cc7442 - -h2. 0.1.3 (2009-02-27) - -* "Remove unnecessary string encoding handling in the i18n simple backend which made the backend break on Ruby 1.9":http://github.com/svenfuchs/i18n/commit/4c3a970783861a94f2e89f46714fb3434e4f4f8d - -h2. 0.1.2 (2009-01-09) - -* "added #available_locales (returns an array of locales for which translations are available)":http://github.com/svenfuchs/i18n/commit/411f8fe7c8f3f89e9b6b921fa62ed66cb92f3af4 -* "flatten load_path before using it so that a nested array of paths won't throw up":http://github.com/svenfuchs/i18n/commit/d473a068a2b90aba98135deb225d6eb6d8104d70 - -h2. 0.1.1 (2008-11-20) - -* "Use :'en' as a default locale (in favor of :'en-US')":http://github.com/svenfuchs/i18n/commit/c4b10b246aecf7da78cb2568dd0d2ab7e6b8a230 -* "Add #reload! to Simple backend":http://github.com/svenfuchs/i18n/commit/36dd2bd9973b9e1559728749a9daafa44693e964 - -h2. 0.1.0 (2008-10-25) - -* "Fix Simple backend to distinguish false from nil values":http://github.com/svenfuchs/i18n/commit/39d9a47da14b5f3ba126af48923af8c30e135166 -* "Add #load_path to public api, add initialize to simple backend and remove #load_translations from public api":http://github.com/svenfuchs/i18n/commit/c4c5649e6bc8f020f1aaf5a5470bde048e22c82d -* "Speed up Backend::Simple#interpolate":http://github.com/svenfuchs/i18n/commit/9e1ac6bf8833304e036323ec9932b9f33c468a35 -* "Remove #populate and #store_translations from public API":http://github.com/svenfuchs/i18n/commit/f4e514a80be7feb509f66824ee311905e2940900 -* "Use :other instead of :many as a plural key":http://github.com/svenfuchs/i18n/commit/0f8f20a2552bf6a2aa758d8fdd62a7154e4a1bf6 -* "Use a class instead of a module for Simple backend":http://github.com/svenfuchs/i18n/commit/08f051aa61320c17debde24a83268bc74e33b995 -* "Make Simple backend #interpolate deal with non-ASCII string encodings":http://github.com/svenfuchs/i18n/commit/d84a3f3f55543c084d5dc5d1fed613b8df148789 -* "Fix default arrays of non-existant keys returning the default array":http://github.com/svenfuchs/i18n/commit/6c04ca86c87f97dc78f07c2a4023644e5ba8b839 - -h2. Initial implementation (June/July 2008) - -Initial implementation by "Sven Fuchs":http://www.workingwithrails.com/person/9963-sven-fuchs based on previous discussion/consensus of the rails-i18n team (alphabetical order) and many others: - -* "Matt Aimonetti":http://railsontherun.com -* "Sven Fuchs":http://www.workingwithrails.com/person/9963-sven-fuchs -* "Joshua Harvey":http://www.workingwithrails.com/person/759-joshua-harvey -* "Saimon Moore":http://saimonmoore.net -* "Stephan Soller":http://www.arkanis-development.de - -h2. More information - -* "Homepage":http://rails-i18n.org -* "Wiki":http://rails-i18n.org/wiki -* "Mailinglist":http://groups.google.com/group/rails-i18n -* "About the project/history":http://www.artweb-design.de/2008/7/18/finally-ruby-on-rails-gets-internationalized -* "Initial API Intro":http://www.artweb-design.de/2008/7/18/the-ruby-on-rails-i18n-core-api diff --git a/lib/mcollective/vendor/i18n/MIT-LICENSE b/lib/mcollective/vendor/i18n/MIT-LICENSE deleted file mode 100755 index ed8e9ee6..00000000 --- a/lib/mcollective/vendor/i18n/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2008 The Ruby I18n team - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/lib/mcollective/vendor/i18n/README.textile b/lib/mcollective/vendor/i18n/README.textile deleted file mode 100644 index 57b79c10..00000000 --- a/lib/mcollective/vendor/i18n/README.textile +++ /dev/null @@ -1,105 +0,0 @@ -h1. Ruby I18n - -!https://secure.travis-ci.org/svenfuchs/i18n.png?branch=master(Build Status)!:http://travis-ci.org/svenfuchs/i18n - -Ruby Internationalization and localization solution. - -Features: - -* translation and localization -* interpolation of values to translations (Ruby 1.9 compatible syntax) -* pluralization (CLDR compatible) -* customizable transliteration to ASCII -* flexible defaults -* bulk lookup -* lambdas as translation data -* custom key/scope separator -* custom exception handlers -* extensible architecture with a swappable backend - -Pluggable features: - -* Cache -* Pluralization: lambda pluralizers stored as translation data -* Locale fallbacks, RFC4647 compliant (optionally: RFC4646 locale validation) -* Gettext support -* Translation metadata - -Alternative backends: - -* Chain -* ActiveRecord (optionally: ActiveRecord::Missing and ActiveRecord::StoreProcs) -* KeyValue (uses active_support/json and cannot store procs) - -For more information and lots of resources see: "http://ruby-i18n.org/wiki":http://ruby-i18n.org/wiki - -h2. Installation - -gem install i18n - -h4. Rails version warning - -On Rails < 2.3.6 the method I18n.localize will fail with MissingInterpolationArgument (issue "20":http://github.com/svenfuchs/i18n/issues/issue/20). Upgrade to Rails 2.3.6 or higher (2.3.8 preferably) is recommended. - -h3. Installation on Rails < 2.3.5 (deprecated) - -Up to version 2.3.4 Rails will not accept i18n gems > 0.1.3. There is an unpacked -gem inside of active_support/lib/vendor which gets loaded unless gem 'i18n', '~> 0.1.3'. -This requirement is relaxed in "6da03653":http://github.com/rails/rails/commit/6da03653 - -The new i18n gem can be loaded from vendor/plugins like this: - -
-  def reload_i18n!
-    raise "Move to i18n version 0.2.0 or greater" if Rails.version > "2.3.4"
-
-    $:.grep(/i18n/).each { |path| $:.delete(path) }
-    I18n::Backend.send :remove_const, "Simple"
-    $: << Rails.root.join('vendor', 'plugins', 'i18n', 'lib').to_s
-  end
-
- -Then you can `reload_i18n!` inside an i18n initializer. - -h2. Tests - -You can run tests both with - -* `rake test` or just `rake` -* run any test file directly, e.g. `ruby -Ilib -Itest test/api/simple_test.rb` -* run all tests with `ruby -Ilib -Itest test/all.rb` - -You can run all tests against all Gemfiles with - -* `ruby test/run_all.rb` - -The structure of the test suite is a bit unusual as it uses modules to reuse -particular tests in different test cases. - -The reason for this is that we need to enforce the I18n API across various -combinations of extensions. E.g. the Simple backend alone needs to support -the same API as any combination of feature and/or optimization modules included -to the Simple backend. We test this by reusing the same API defition (implemented -as test methods) in test cases with different setups. - -You can find the test cases that enforce the API in test/api. And you can find -the API definition test methods in test/api/tests. - -All other test cases (e.g. as defined in test/backend, test/core\_ext) etc. -follow the usual test setup and should be easy to grok. - -h2. Authors - -* "Sven Fuchs":http://www.artweb-design.de -* "Joshua Harvey":http://www.workingwithrails.com/person/759-joshua-harvey -* "Stephan Soller":http://www.arkanis-development.de -* "Saimon Moore":http://saimonmoore.net -* "Matt Aimonetti":http://railsontherun.com - -h2. Contributors - -http://github.com/svenfuchs/i18n/contributors - -h2. License - -MIT License. See the included MIT-LICENSE file. diff --git a/lib/mcollective/vendor/i18n/Rakefile b/lib/mcollective/vendor/i18n/Rakefile deleted file mode 100644 index 94036070..00000000 --- a/lib/mcollective/vendor/i18n/Rakefile +++ /dev/null @@ -1,27 +0,0 @@ -require 'rake/testtask' - -task :default => [:test] - -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.libs << 'test' - t.pattern = "#{File.dirname(__FILE__)}/test/all.rb" - t.verbose = true - t.warning = true -end -Rake::Task['test'].comment = "Run all i18n tests" - -# require "rake/gempackagetask" -# require "rake/clean" -# CLEAN << "pkg" << "doc" << "coverage" << ".yardoc" -# -# Rake::GemPackageTask.new(eval(File.read("i18n.gemspec"))) { |pkg| } -# -# begin -# require "yard" -# YARD::Rake::YardocTask.new do |t| -# t.options = ["--output-dir=doc"] -# t.options << "--files" << ["CHANGELOG.textile", "contributors.txt", "MIT-LICENSE"].join(",") -# end -# rescue LoadError -# end diff --git a/lib/mcollective/vendor/i18n/lib/i18n.rb b/lib/mcollective/vendor/i18n/lib/i18n.rb deleted file mode 100755 index a351b4a3..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n.rb +++ /dev/null @@ -1,332 +0,0 @@ -require 'i18n/version' -require 'i18n/exceptions' -require 'i18n/interpolate/ruby' - -module I18n - autoload :Backend, 'i18n/backend' - autoload :Config, 'i18n/config' - autoload :Gettext, 'i18n/gettext' - autoload :Locale, 'i18n/locale' - autoload :Tests, 'i18n/tests' - - RESERVED_KEYS = [:scope, :default, :separator, :resolve, :object, :fallback, :format, :cascade, :throw, :raise, :rescue_format] - RESERVED_KEYS_PATTERN = /%\{(#{RESERVED_KEYS.join("|")})\}/ - - extend Module.new { - # Gets I18n configuration object. - def config - Thread.current[:i18n_config] ||= I18n::Config.new - end - - # Sets I18n configuration object. - def config=(value) - Thread.current[:i18n_config] = value - end - - # Write methods which delegates to the configuration object - %w(locale backend default_locale available_locales default_separator - exception_handler load_path).each do |method| - module_eval <<-DELEGATORS, __FILE__, __LINE__ + 1 - def #{method} - config.#{method} - end - - def #{method}=(value) - config.#{method} = (value) - end - DELEGATORS - end - - # Tells the backend to reload translations. Used in situations like the - # Rails development environment. Backends can implement whatever strategy - # is useful. - def reload! - config.backend.reload! - end - - # Translates, pluralizes and interpolates a given key using a given locale, - # scope, and default, as well as interpolation values. - # - # *LOOKUP* - # - # Translation data is organized as a nested hash using the upper-level keys - # as namespaces. E.g., ActionView ships with the translation: - # :date => {:formats => {:short => "%b %d"}}. - # - # Translations can be looked up at any level of this hash using the key argument - # and the scope option. E.g., in this example I18n.t :date - # returns the whole translations hash {:formats => {:short => "%b %d"}}. - # - # Key can be either a single key or a dot-separated key (both Strings and Symbols - # work). E.g., the short format can be looked up using both: - # I18n.t 'date.formats.short' - # I18n.t :'date.formats.short' - # - # Scope can be either a single key, a dot-separated key or an array of keys - # or dot-separated keys. Keys and scopes can be combined freely. So these - # examples will all look up the same short date format: - # I18n.t 'date.formats.short' - # I18n.t 'formats.short', :scope => 'date' - # I18n.t 'short', :scope => 'date.formats' - # I18n.t 'short', :scope => %w(date formats) - # - # *INTERPOLATION* - # - # Translations can contain interpolation variables which will be replaced by - # values passed to #translate as part of the options hash, with the keys matching - # the interpolation variable names. - # - # E.g., with a translation :foo => "foo %{bar}" the option - # value for the key +bar+ will be interpolated into the translation: - # I18n.t :foo, :bar => 'baz' # => 'foo baz' - # - # *PLURALIZATION* - # - # Translation data can contain pluralized translations. Pluralized translations - # are arrays of singluar/plural versions of translations like ['Foo', 'Foos']. - # - # Note that I18n::Backend::Simple only supports an algorithm for English - # pluralization rules. Other algorithms can be supported by custom backends. - # - # This returns the singular version of a pluralized translation: - # I18n.t :foo, :count => 1 # => 'Foo' - # - # These both return the plural version of a pluralized translation: - # I18n.t :foo, :count => 0 # => 'Foos' - # I18n.t :foo, :count => 2 # => 'Foos' - # - # The :count option can be used both for pluralization and interpolation. - # E.g., with the translation - # :foo => ['%{count} foo', '%{count} foos'], count will - # be interpolated to the pluralized translation: - # I18n.t :foo, :count => 1 # => '1 foo' - # - # *DEFAULTS* - # - # This returns the translation for :foo or default if no translation was found: - # I18n.t :foo, :default => 'default' - # - # This returns the translation for :foo or the translation for :bar if no - # translation for :foo was found: - # I18n.t :foo, :default => :bar - # - # Returns the translation for :foo or the translation for :bar - # or default if no translations for :foo and :bar were found. - # I18n.t :foo, :default => [:bar, 'default'] - # - # *BULK LOOKUP* - # - # This returns an array with the translations for :foo and :bar. - # I18n.t [:foo, :bar] - # - # Can be used with dot-separated nested keys: - # I18n.t [:'baz.foo', :'baz.bar'] - # - # Which is the same as using a scope option: - # I18n.t [:foo, :bar], :scope => :baz - # - # *LAMBDAS* - # - # Both translations and defaults can be given as Ruby lambdas. Lambdas will be - # called and passed the key and options. - # - # E.g. assuming the key :salutation resolves to: - # lambda { |key, options| options[:gender] == 'm' ? "Mr. %{options[:name]}" : "Mrs. %{options[:name]}" } - # - # Then I18n.t(:salutation, :gender => 'w', :name => 'Smith') will result in "Mrs. Smith". - # - # It is recommended to use/implement lambdas in an "idempotent" way. E.g. when - # a cache layer is put in front of I18n.translate it will generate a cache key - # from the argument values passed to #translate. Therefor your lambdas should - # always return the same translations/values per unique combination of argument - # values. - def translate(*args) - options = args.last.is_a?(Hash) ? args.pop : {} - key = args.shift - backend = config.backend - locale = options.delete(:locale) || config.locale - handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise - - raise I18n::ArgumentError if key.is_a?(String) && key.empty? - - result = catch(:exception) do - if key.is_a?(Array) - key.map { |k| backend.translate(locale, k, options) } - else - backend.translate(locale, key, options) - end - end - result.is_a?(MissingTranslation) ? handle_exception(handling, result, locale, key, options) : result - end - alias :t :translate - - # Wrapper for translate that adds :raise => true. With - # this option, if no translation is found, it will raise I18n::MissingTranslationData - def translate!(key, options={}) - translate(key, options.merge(:raise => true)) - end - alias :t! :translate! - - # Transliterates UTF-8 characters to ASCII. By default this method will - # transliterate only Latin strings to an ASCII approximation: - # - # I18n.transliterate("Ærøskøbing") - # # => "AEroskobing" - # - # I18n.transliterate("日本語") - # # => "???" - # - # It's also possible to add support for per-locale transliterations. I18n - # expects transliteration rules to be stored at - # i18n.transliterate.rule. - # - # Transliteration rules can either be a Hash or a Proc. Procs must accept a - # single string argument. Hash rules inherit the default transliteration - # rules, while Procs do not. - # - # *Examples* - # - # Setting a Hash in .yml: - # - # i18n: - # transliterate: - # rule: - # ü: "ue" - # ö: "oe" - # - # Setting a Hash using Ruby: - # - # store_translations(:de, :i18n => { - # :transliterate => { - # :rule => { - # "ü" => "ue", - # "ö" => "oe" - # } - # } - # ) - # - # Setting a Proc: - # - # translit = lambda {|string| MyTransliterator.transliterate(string) } - # store_translations(:xx, :i18n => {:transliterate => {:rule => translit}) - # - # Transliterating strings: - # - # I18n.locale = :en - # I18n.transliterate("Jürgen") # => "Jurgen" - # I18n.locale = :de - # I18n.transliterate("Jürgen") # => "Juergen" - # I18n.transliterate("Jürgen", :locale => :en) # => "Jurgen" - # I18n.transliterate("Jürgen", :locale => :de) # => "Juergen" - def transliterate(*args) - options = args.pop if args.last.is_a?(Hash) - key = args.shift - locale = options && options.delete(:locale) || config.locale - handling = options && (options.delete(:throw) && :throw || options.delete(:raise) && :raise) - replacement = options && options.delete(:replacement) - config.backend.transliterate(locale, key, replacement) - rescue I18n::ArgumentError => exception - handle_exception(handling, exception, locale, key, options || {}) - end - - # Localizes certain objects, such as dates and numbers to local formatting. - def localize(object, options = {}) - locale = options.delete(:locale) || config.locale - format = options.delete(:format) || :default - config.backend.localize(locale, object, format, options) - end - alias :l :localize - - # Executes block with given I18n.locale set. - def with_locale(tmp_locale = nil) - if tmp_locale - current_locale = self.locale - self.locale = tmp_locale - end - yield - ensure - self.locale = current_locale if tmp_locale - end - - # Merges the given locale, key and scope into a single array of keys. - # Splits keys that contain dots into multiple keys. Makes sure all - # keys are Symbols. - def normalize_keys(locale, key, scope, separator = nil) - separator ||= I18n.default_separator - - keys = [] - keys.concat normalize_key(locale, separator) - keys.concat normalize_key(scope, separator) - keys.concat normalize_key(key, separator) - keys - end - - # making these private until Ruby 1.9.2 can send to protected methods again - # see http://redmine.ruby-lang.org/repositories/revision/ruby-19?rev=24280 - private - - # Any exceptions thrown in translate will be sent to the @@exception_handler - # which can be a Symbol, a Proc or any other Object unless they're forced to - # be raised or thrown (MissingTranslation). - # - # If exception_handler is a Symbol then it will simply be sent to I18n as - # a method call. A Proc will simply be called. In any other case the - # method #call will be called on the exception_handler object. - # - # Examples: - # - # I18n.exception_handler = :default_exception_handler # this is the default - # I18n.default_exception_handler(exception, locale, key, options) # will be called like this - # - # I18n.exception_handler = lambda { |*args| ... } # a lambda - # I18n.exception_handler.call(exception, locale, key, options) # will be called like this - # - # I18n.exception_handler = I18nExceptionHandler.new # an object - # I18n.exception_handler.call(exception, locale, key, options) # will be called like this - def handle_exception(handling, exception, locale, key, options) - case handling - when :raise - raise(exception.respond_to?(:to_exception) ? exception.to_exception : exception) - when :throw - throw :exception, exception - else - case handler = options[:exception_handler] || config.exception_handler - when Symbol - send(handler, exception, locale, key, options) - else - handler.call(exception, locale, key, options) - end - end - end - - def normalize_key(key, separator) - normalized_key_cache[separator][key] ||= - case key - when Array - key.map { |k| normalize_key(k, separator) }.flatten - else - keys = key.to_s.split(separator) - keys.delete('') - keys.map! { |k| k.to_sym } - keys - end - end - - def normalized_key_cache - @normalized_key_cache ||= Hash.new { |h,k| h[k] = {} } - end - - # DEPRECATED. Use I18n.normalize_keys instead. - def normalize_translation_keys(locale, key, scope, separator = nil) - puts "I18n.normalize_translation_keys is deprecated. Please use the class I18n.normalize_keys instead." - normalize_keys(locale, key, scope, separator) - end - - # DEPRECATED. Please use the I18n::ExceptionHandler class instead. - def default_exception_handler(exception, locale, key, options) - puts "I18n.default_exception_handler is deprecated. Please use the class I18n::ExceptionHandler instead " + - "(an instance of which is set to I18n.exception_handler by default)." - exception.is_a?(MissingTranslation) ? exception.message : raise(exception) - end - } -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend.rb deleted file mode 100644 index 46ef054b..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend.rb +++ /dev/null @@ -1,18 +0,0 @@ -module I18n - module Backend - autoload :Base, 'i18n/backend/base' - autoload :InterpolationCompiler, 'i18n/backend/interpolation_compiler' - autoload :Cache, 'i18n/backend/cache' - autoload :Cascade, 'i18n/backend/cascade' - autoload :Chain, 'i18n/backend/chain' - autoload :Fallbacks, 'i18n/backend/fallbacks' - autoload :Flatten, 'i18n/backend/flatten' - autoload :Gettext, 'i18n/backend/gettext' - autoload :KeyValue, 'i18n/backend/key_value' - autoload :Memoize, 'i18n/backend/memoize' - autoload :Metadata, 'i18n/backend/metadata' - autoload :Pluralization, 'i18n/backend/pluralization' - autoload :Simple, 'i18n/backend/simple' - autoload :Transliterator, 'i18n/backend/transliterator' - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/base.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/base.rb deleted file mode 100644 index 0b6217c6..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/base.rb +++ /dev/null @@ -1,181 +0,0 @@ -require 'yaml' -require 'i18n/core_ext/hash' -require 'i18n/core_ext/kernel/surpress_warnings' - -module I18n - module Backend - module Base - include I18n::Backend::Transliterator - - # Accepts a list of paths to translation files. Loads translations from - # plain Ruby (*.rb) or YAML files (*.yml). See #load_rb and #load_yml - # for details. - def load_translations(*filenames) - filenames = I18n.load_path if filenames.empty? - filenames.flatten.each { |filename| load_file(filename) } - end - - # This method receives a locale, a data hash and options for storing translations. - # Should be implemented - def store_translations(locale, data, options = {}) - raise NotImplementedError - end - - def translate(locale, key, options = {}) - raise InvalidLocale.new(locale) unless locale - entry = key && lookup(locale, key, options[:scope], options) - - if options.empty? - entry = resolve(locale, key, entry, options) - else - count, default = options.values_at(:count, :default) - values = options.except(*RESERVED_KEYS) - entry = entry.nil? && default ? - default(locale, key, default, options) : resolve(locale, key, entry, options) - end - - throw(:exception, I18n::MissingTranslation.new(locale, key, options)) if entry.nil? - entry = entry.dup if entry.is_a?(String) - - entry = pluralize(locale, entry, count) if count - entry = interpolate(locale, entry, values) if values - entry - end - - # Acts the same as +strftime+, but uses a localized version of the - # format string. Takes a key from the date/time formats translations as - # a format argument (e.g., :short in :'date.formats'). - def localize(locale, object, format = :default, options = {}) - raise ArgumentError, "Object must be a Date, DateTime or Time object. #{object.inspect} given." unless object.respond_to?(:strftime) - - if Symbol === format - key = format - type = object.respond_to?(:sec) ? 'time' : 'date' - options = options.merge(:raise => true, :object => object, :locale => locale) - format = I18n.t(:"#{type}.formats.#{key}", options) - end - - # format = resolve(locale, object, format, options) - format = format.to_s.gsub(/%[aAbBp]/) do |match| - case match - when '%a' then I18n.t(:"date.abbr_day_names", :locale => locale, :format => format)[object.wday] - when '%A' then I18n.t(:"date.day_names", :locale => locale, :format => format)[object.wday] - when '%b' then I18n.t(:"date.abbr_month_names", :locale => locale, :format => format)[object.mon] - when '%B' then I18n.t(:"date.month_names", :locale => locale, :format => format)[object.mon] - when '%p' then I18n.t(:"time.#{object.hour < 12 ? :am : :pm}", :locale => locale, :format => format) if object.respond_to? :hour - end - end - - object.strftime(format) - end - - # Returns an array of locales for which translations are available - # ignoring the reserved translation meta data key :i18n. - def available_locales - raise NotImplementedError - end - - def reload! - @skip_syntax_deprecation = false - end - - protected - - # The method which actually looks up for the translation in the store. - def lookup(locale, key, scope = [], options = {}) - raise NotImplementedError - end - - # Evaluates defaults. - # If given subject is an Array, it walks the array and returns the - # first translation that can be resolved. Otherwise it tries to resolve - # the translation directly. - def default(locale, object, subject, options = {}) - options = options.dup.reject { |key, value| key == :default } - case subject - when Array - subject.each do |item| - result = resolve(locale, object, item, options) and return result - end and nil - else - resolve(locale, object, subject, options) - end - end - - # Resolves a translation. - # If the given subject is a Symbol, it will be translated with the - # given options. If it is a Proc then it will be evaluated. All other - # subjects will be returned directly. - def resolve(locale, object, subject, options = {}) - return subject if options[:resolve] == false - result = catch(:exception) do - case subject - when Symbol - I18n.translate(subject, options.merge(:locale => locale, :throw => true)) - when Proc - date_or_time = options.delete(:object) || object - resolve(locale, object, subject.call(date_or_time, options)) - else - subject - end - end - result unless result.is_a?(MissingTranslation) - end - - # Picks a translation from an array according to English pluralization - # rules. It will pick the first translation if count is not equal to 1 - # and the second translation if it is equal to 1. Other backends can - # implement more flexible or complex pluralization rules. - def pluralize(locale, entry, count) - return entry unless entry.is_a?(Hash) && count - - key = :zero if count == 0 && entry.has_key?(:zero) - key ||= count == 1 ? :one : :other - raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key) - entry[key] - end - - # Interpolates values into a given string. - # - # interpolate "file %{file} opened by %%{user}", :file => 'test.txt', :user => 'Mr. X' - # # => "file test.txt opened by %{user}" - def interpolate(locale, string, values = {}) - if string.is_a?(::String) && !values.empty? - I18n.interpolate(string, values) - else - string - end - end - - # Loads a single translations file by delegating to #load_rb or - # #load_yml depending on the file extension and directly merges the - # data to the existing translations. Raises I18n::UnknownFileType - # for all other file extensions. - def load_file(filename) - type = File.extname(filename).tr('.', '').downcase - raise UnknownFileType.new(type, filename) unless respond_to?(:"load_#{type}", true) - data = send(:"load_#{type}", filename) - raise InvalidLocaleData.new(filename) unless data.is_a?(Hash) - data.each { |locale, d| store_translations(locale, d || {}) } - end - - # Loads a plain Ruby translations file. eval'ing the file must yield - # a Hash containing translation data with locales as toplevel keys. - def load_rb(filename) - eval(IO.read(filename), binding, filename) - end - - # Loads a YAML translations file. The data must have locales as - # toplevel keys. - def load_yml(filename) - begin - YAML.load_file(filename) - rescue TypeError - nil - rescue SyntaxError - nil - end - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/cache.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/cache.rb deleted file mode 100644 index 3c456ff9..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/cache.rb +++ /dev/null @@ -1,96 +0,0 @@ -# This module allows you to easily cache all responses from the backend - thus -# speeding up the I18n aspects of your application quite a bit. -# -# To enable caching you can simply include the Cache module to the Simple -# backend - or whatever other backend you are using: -# -# I18n::Backend::Simple.send(:include, I18n::Backend::Cache) -# -# You will also need to set a cache store implementation that you want to use: -# -# I18n.cache_store = ActiveSupport::Cache.lookup_store(:memory_store) -# -# You can use any cache implementation you want that provides the same API as -# ActiveSupport::Cache (only the methods #fetch and #write are being used). -# -# The cache_key implementation assumes that you only pass values to -# I18n.translate that return a valid key from #hash (see -# http://www.ruby-doc.org/core/classes/Object.html#M000337). -# -# If you use a lambda as a default value in your translation like this: -# -# I18n.t(:"date.order", :default => lambda {[:month, :day, :year]}) -# -# Then you will always have a cache miss, because each time this method -# is called the lambda will have a different hash value. If you know -# the result of the lambda is a constant as in the example above, then -# to cache this you can make the lambda a constant, like this: -# -# DEFAULT_DATE_ORDER = lambda {[:month, :day, :year]} -# ... -# I18n.t(:"date.order", :default => DEFAULT_DATE_ORDER) -# -# If the lambda may result in different values for each call then consider -# also using the Memoize backend. -# -module I18n - class << self - @@cache_store = nil - @@cache_namespace = nil - - def cache_store - @@cache_store - end - - def cache_store=(store) - @@cache_store = store - end - - def cache_namespace - @@cache_namespace - end - - def cache_namespace=(namespace) - @@cache_namespace = namespace - end - - def perform_caching? - !cache_store.nil? - end - end - - module Backend - # TODO Should the cache be cleared if new translations are stored? - module Cache - def translate(locale, key, options = {}) - I18n.perform_caching? ? fetch(cache_key(locale, key, options)) { super } : super - end - - protected - - def fetch(cache_key, &block) - result = _fetch(cache_key, &block) - throw(:exception, result) if result.is_a?(MissingTranslation) - result = result.dup if result.frozen? rescue result - result - end - - def _fetch(cache_key, &block) - result = I18n.cache_store.read(cache_key) and return result - result = catch(:exception, &block) - I18n.cache_store.write(cache_key, result) unless result.is_a?(Proc) - result - end - - def cache_key(locale, key, options) - # This assumes that only simple, native Ruby values are passed to I18n.translate. - "i18n/#{I18n.cache_namespace}/#{locale}/#{key.hash}/#{USE_INSPECT_HASH ? options.inspect.hash : options.hash}" - end - - private - # In Ruby < 1.9 the following is true: { :foo => 1, :bar => 2 }.hash == { :foo => 2, :bar => 1 }.hash - # Therefore we must use the hash of the inspect string instead to avoid cache key colisions. - USE_INSPECT_HASH = RUBY_VERSION <= "1.9" - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/cascade.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/cascade.rb deleted file mode 100644 index d8fb1cf4..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/cascade.rb +++ /dev/null @@ -1,54 +0,0 @@ -# The Cascade module adds the ability to do cascading lookups to backends that -# are compatible to the Simple backend. -# -# By cascading lookups we mean that for any key that can not be found the -# Cascade module strips one segment off the scope part of the key and then -# tries to look up the key in that scope. -# -# E.g. when a lookup for the key :"foo.bar.baz" does not yield a result then -# the segment :bar will be stripped off the scope part :"foo.bar" and the new -# scope :foo will be used to look up the key :baz. If that does not succeed -# then the remaining scope segment :foo will be omitted, too, and again the -# key :baz will be looked up (now with no scope). -# -# To enable a cascading lookup one passes the :cascade option: -# -# I18n.t(:'foo.bar.baz', :cascade => true) -# -# This will return the first translation found for :"foo.bar.baz", :"foo.baz" -# or :baz in this order. -# -# The cascading lookup takes precedence over resolving any given defaults. -# I.e. defaults will kick in after the cascading lookups haven't succeeded. -# -# This behavior is useful for libraries like ActiveRecord validations where -# the library wants to give users a bunch of more or less fine-grained options -# of scopes for a particular key. -# -# Thanks to Clemens Kofler for the initial idea and implementation! See -# http://github.com/clemens/i18n-cascading-backend - -module I18n - module Backend - module Cascade - def lookup(locale, key, scope = [], options = {}) - return super unless cascade = options[:cascade] - - cascade = { :step => 1 } unless cascade.is_a?(Hash) - step = cascade[:step] || 1 - offset = cascade[:offset] || 1 - separator = options[:separator] || I18n.default_separator - skip_root = cascade.has_key?(:skip_root) ? cascade[:skip_root] : true - - scope = I18n.normalize_keys(nil, key, scope, separator) - key = (scope.slice!(-offset, offset) || []).join(separator) - - begin - result = super - return result unless result.nil? - scope = scope.dup - end while (!scope.empty? || !skip_root) && scope.slice!(-step, step) - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/chain.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/chain.rb deleted file mode 100644 index 5a0c59b5..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/chain.rb +++ /dev/null @@ -1,78 +0,0 @@ -module I18n - module Backend - # Backend that chains multiple other backends and checks each of them when - # a translation needs to be looked up. This is useful when you want to use - # standard translations with a Simple backend but store custom application - # translations in a database or other backends. - # - # To use the Chain backend instantiate it and set it to the I18n module. - # You can add chained backends through the initializer or backends - # accessor: - # - # # preserves the existing Simple backend set to I18n.backend - # I18n.backend = I18n::Backend::Chain.new(I18n::Backend::ActiveRecord.new, I18n.backend) - # - # The implementation assumes that all backends added to the Chain implement - # a lookup method with the same API as Simple backend does. - class Chain - module Implementation - include Base - - attr_accessor :backends - - def initialize(*backends) - self.backends = backends - end - - def reload! - backends.each { |backend| backend.reload! } - end - - def store_translations(locale, data, options = {}) - backends.first.store_translations(locale, data, options) - end - - def available_locales - backends.map { |backend| backend.available_locales }.flatten.uniq - end - - def translate(locale, key, default_options = {}) - namespace = nil - options = default_options.except(:default) - - backends.each do |backend| - catch(:exception) do - options = default_options if backend == backends.last - translation = backend.translate(locale, key, options) - if namespace_lookup?(translation, options) - namespace ||= {} - namespace.merge!(translation) - elsif !translation.nil? - return translation - end - end - end - - return namespace if namespace - throw(:exception, I18n::MissingTranslation.new(locale, key, options)) - end - - def localize(locale, object, format = :default, options = {}) - backends.each do |backend| - catch(:exception) do - result = backend.localize(locale, object, format, options) and return result - end - end - throw(:exception, I18n::MissingTranslation.new(locale, format, options)) - end - - protected - def namespace_lookup?(result, options) - result.is_a?(Hash) && !options.has_key?(:count) - end - end - - include Implementation - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/fallbacks.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/fallbacks.rb deleted file mode 100644 index 7252bb00..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/fallbacks.rb +++ /dev/null @@ -1,65 +0,0 @@ -# I18n locale fallbacks are useful when you want your application to use -# translations from other locales when translations for the current locale are -# missing. E.g. you might want to use :en translations when translations in -# your applications main locale :de are missing. -# -# To enable locale fallbacks you can simply include the Fallbacks module to -# the Simple backend - or whatever other backend you are using: -# -# I18n::Backend::Simple.include(I18n::Backend::Fallbacks) -module I18n - @@fallbacks = nil - - class << self - # Returns the current fallbacks implementation. Defaults to +I18n::Locale::Fallbacks+. - def fallbacks - @@fallbacks ||= I18n::Locale::Fallbacks.new - end - - # Sets the current fallbacks implementation. Use this to set a different fallbacks implementation. - def fallbacks=(fallbacks) - @@fallbacks = fallbacks - end - end - - module Backend - module Fallbacks - # Overwrites the Base backend translate method so that it will try each - # locale given by I18n.fallbacks for the given locale. E.g. for the - # locale :"de-DE" it might try the locales :"de-DE", :de and :en - # (depends on the fallbacks implementation) until it finds a result with - # the given options. If it does not find any result for any of the - # locales it will then throw MissingTranslation as usual. - # - # The default option takes precedence over fallback locales only when - # it's a Symbol. When the default contains a String, Proc or Hash - # it is evaluated last after all the fallback locales have been tried. - def translate(locale, key, options = {}) - return super if options[:fallback] - default = extract_non_symbol_default!(options) if options[:default] - - options[:fallback] = true - I18n.fallbacks[locale].each do |fallback| - catch(:exception) do - result = super(fallback, key, options) - return result unless result.nil? - end - end - options.delete(:fallback) - - return super(locale, nil, options.merge(:default => default)) if default - throw(:exception, I18n::MissingTranslation.new(locale, key, options)) - end - - def extract_non_symbol_default!(options) - defaults = [options[:default]].flatten - first_non_symbol_default = defaults.detect{|default| !default.is_a?(Symbol)} - if first_non_symbol_default - options[:default] = defaults[0, defaults.index(first_non_symbol_default)] - end - return first_non_symbol_default - end - - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/flatten.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/flatten.rb deleted file mode 100644 index c23f7c13..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/flatten.rb +++ /dev/null @@ -1,113 +0,0 @@ -module I18n - module Backend - # This module contains several helpers to assist flattening translations. - # You may want to flatten translations for: - # - # 1) speed up lookups, as in the Memoize backend; - # 2) In case you want to store translations in a data store, as in ActiveRecord backend; - # - # You can check both backends above for some examples. - # This module also keeps all links in a hash so they can be properly resolved when flattened. - module Flatten - SEPARATOR_ESCAPE_CHAR = "\001" - FLATTEN_SEPARATOR = "." - - # normalize_keys the flatten way. This method is significantly faster - # and creates way less objects than the one at I18n.normalize_keys. - # It also handles escaping the translation keys. - def self.normalize_flat_keys(locale, key, scope, separator) - keys = [scope, key].flatten.compact - separator ||= I18n.default_separator - - if separator != FLATTEN_SEPARATOR - keys.map! do |k| - k.to_s.tr("#{FLATTEN_SEPARATOR}#{separator}", - "#{SEPARATOR_ESCAPE_CHAR}#{FLATTEN_SEPARATOR}") - end - end - - keys.join(".") - end - - # Receives a string and escape the default separator. - def self.escape_default_separator(key) #:nodoc: - key.to_s.tr(FLATTEN_SEPARATOR, SEPARATOR_ESCAPE_CHAR) - end - - # Shortcut to I18n::Backend::Flatten.normalize_flat_keys - # and then resolve_links. - def normalize_flat_keys(locale, key, scope, separator) - key = I18n::Backend::Flatten.normalize_flat_keys(locale, key, scope, separator) - resolve_link(locale, key) - end - - # Store flattened links. - def links - @links ||= Hash.new { |h,k| h[k] = {} } - end - - # Flatten keys for nested Hashes by chaining up keys: - # - # >> { "a" => { "b" => { "c" => "d", "e" => "f" }, "g" => "h" }, "i" => "j"}.wind - # => { "a.b.c" => "d", "a.b.e" => "f", "a.g" => "h", "i" => "j" } - # - def flatten_keys(hash, escape, prev_key=nil, &block) - hash.each_pair do |key, value| - key = escape_default_separator(key) if escape - curr_key = [prev_key, key].compact.join(FLATTEN_SEPARATOR).to_sym - yield curr_key, value - flatten_keys(value, escape, curr_key, &block) if value.is_a?(Hash) - end - end - - # Receives a hash of translations (where the key is a locale and - # the value is another hash) and return a hash with all - # translations flattened. - # - # Nested hashes are included in the flattened hash just if subtree - # is true and Symbols are automatically stored as links. - def flatten_translations(locale, data, escape, subtree) - hash = {} - flatten_keys(data, escape) do |key, value| - if value.is_a?(Hash) - hash[key] = value if subtree - else - store_link(locale, key, value) if value.is_a?(Symbol) - hash[key] = value - end - end - hash - end - - protected - - def store_link(locale, key, link) - links[locale.to_sym][key.to_s] = link.to_s - end - - def resolve_link(locale, key) - key, locale = key.to_s, locale.to_sym - links = self.links[locale] - - if links.key?(key) - links[key] - elsif link = find_link(locale, key) - store_link(locale, key, key.gsub(*link)) - else - key - end - end - - def find_link(locale, key) #:nodoc: - links[locale].each do |from, to| - return [from, to] if key[0, from.length] == from - end && nil - end - - def escape_default_separator(key) #:nodoc: - I18n::Backend::Flatten.escape_default_separator(key) - end - - end - end -end \ No newline at end of file diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/gettext.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/gettext.rb deleted file mode 100644 index c357a6d4..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/gettext.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'i18n/gettext' -require 'i18n/gettext/po_parser' - -# Experimental support for using Gettext po files to store translations. -# -# To use this you can simply include the module to the Simple backend - or -# whatever other backend you are using. -# -# I18n::Backend::Simple.include(I18n::Backend::Gettext) -# -# Now you should be able to include your Gettext translation (*.po) files to -# the I18n.load_path so they're loaded to the backend and you can use them as -# usual: -# -# I18n.load_path += Dir["path/to/locales/*.po"] -# -# Following the Gettext convention this implementation expects that your -# translation files are named by their locales. E.g. the file en.po would -# contain the translations for the English locale. -module I18n - module Backend - module Gettext - class PoData < Hash - def set_comment(msgid_or_sym, comment) - # ignore - end - end - - protected - def load_po(filename) - locale = ::File.basename(filename, '.po').to_sym - data = normalize(locale, parse(filename)) - { locale => data } - end - - def parse(filename) - GetText::PoParser.new.parse(::File.read(filename), PoData.new) - end - - def normalize(locale, data) - data.inject({}) do |result, (key, value)| - unless key.nil? || key.empty? - key = key.gsub(I18n::Gettext::CONTEXT_SEPARATOR, '|') - key, value = normalize_pluralization(locale, key, value) if key.index("\000") - - parts = key.split('|').reverse - normalized = parts.inject({}) do |_normalized, part| - { part => _normalized.empty? ? value : _normalized } - end - - result.deep_merge!(normalized) - end - result - end - end - - def normalize_pluralization(locale, key, value) - # FIXME po_parser includes \000 chars that can not be turned into Symbols - key = key.gsub("\000", I18n::Gettext::PLURAL_SEPARATOR).split(I18n::Gettext::PLURAL_SEPARATOR).first - - keys = I18n::Gettext.plural_keys(locale) - values = value.split("\000") - raise "invalid number of plurals: #{values.size}, keys: #{keys.inspect} on #{locale} locale for msgid #{key.inspect} with values #{values.inspect}" if values.size != keys.size - - result = {} - values.each_with_index { |_value, ix| result[keys[ix]] = _value } - [key, result] - end - - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/interpolation_compiler.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/interpolation_compiler.rb deleted file mode 100644 index fc8a3a10..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/interpolation_compiler.rb +++ /dev/null @@ -1,121 +0,0 @@ -# The InterpolationCompiler module contains optimizations that can tremendously -# speed up the interpolation process on the Simple backend. -# -# It works by defining a pre-compiled method on stored translation Strings that -# already bring all the knowledge about contained interpolation variables etc. -# so that the actual recurring interpolation will be very fast. -# -# To enable pre-compiled interpolations you can simply include the -# InterpolationCompiler module to the Simple backend: -# -# I18n::Backend::Simple.include(I18n::Backend::InterpolationCompiler) -# -# Note that InterpolationCompiler does not yield meaningful results and consequently -# should not be used with Ruby 1.9 (YARV) but improves performance everywhere else -# (jRuby, Rubinius and 1.8.7). -module I18n - module Backend - module InterpolationCompiler - module Compiler - extend self - - TOKENIZER = /(%%\{[^\}]+\}|%\{[^\}]+\})/ - INTERPOLATION_SYNTAX_PATTERN = /(%)?(%\{([^\}]+)\})/ - - def compile_if_an_interpolation(string) - if interpolated_str?(string) - string.instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ - def i18n_interpolate(v = {}) - "#{compiled_interpolation_body(string)}" - end - RUBY_EVAL - end - - string - end - - def interpolated_str?(str) - str.kind_of?(::String) && str =~ INTERPOLATION_SYNTAX_PATTERN - end - - protected - # tokenize("foo %{bar} baz %%{buz}") # => ["foo ", "%{bar}", " baz ", "%%{buz}"] - def tokenize(str) - str.split(TOKENIZER) - end - - def compiled_interpolation_body(str) - tokenize(str).map do |token| - (matchdata = token.match(INTERPOLATION_SYNTAX_PATTERN)) ? handle_interpolation_token(token, matchdata) : escape_plain_str(token) - end.join - end - - def handle_interpolation_token(interpolation, matchdata) - escaped, pattern, key = matchdata.values_at(1, 2, 3) - escaped ? pattern : compile_interpolation_token(key.to_sym) - end - - def compile_interpolation_token(key) - "\#{#{interpolate_or_raise_missing(key)}}" - end - - def interpolate_or_raise_missing(key) - escaped_key = escape_key_sym(key) - RESERVED_KEYS.include?(key) ? reserved_key(escaped_key) : interpolate_key(escaped_key) - end - - def interpolate_key(key) - [direct_key(key), nil_key(key), missing_key(key)].join('||') - end - - def direct_key(key) - "((t = v[#{key}]) && t.respond_to?(:call) ? t.call : t)" - end - - def nil_key(key) - "(v.has_key?(#{key}) && '')" - end - - def missing_key(key) - "raise(MissingInterpolationArgument.new(#{key}, self))" - end - - def reserved_key(key) - "raise(ReservedInterpolationKey.new(#{key}, self))" - end - - def escape_plain_str(str) - str.gsub(/"|\\|#/) {|x| "\\#{x}"} - end - - def escape_key_sym(key) - # rely on Ruby to do all the hard work :) - key.to_sym.inspect - end - end - - def interpolate(locale, string, values) - if string.respond_to?(:i18n_interpolate) - string.i18n_interpolate(values) - elsif values - super - else - string - end - end - - def store_translations(locale, data, options = {}) - compile_all_strings_in(data) - super - end - - protected - def compile_all_strings_in(data) - data.each_value do |value| - Compiler.compile_if_an_interpolation(value) - compile_all_strings_in(value) if value.kind_of?(Hash) - end - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/key_value.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/key_value.rb deleted file mode 100644 index c34b797c..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/key_value.rb +++ /dev/null @@ -1,101 +0,0 @@ -require 'i18n/backend/base' -require 'active_support/json' -require 'active_support/ordered_hash' # active_support/json/encoding uses ActiveSupport::OrderedHash but does not require it - -module I18n - module Backend - # This is a basic backend for key value stores. It receives on - # initialization the store, which should respond to three methods: - # - # * store#[](key) - Used to get a value - # * store#[]=(key, value) - Used to set a value - # * store#keys - Used to get all keys - # - # Since these stores only supports string, all values are converted - # to JSON before being stored, allowing it to also store booleans, - # hashes and arrays. However, this store does not support Procs. - # - # As the ActiveRecord backend, Symbols are just supported when loading - # translations from the filesystem or through explicit store translations. - # - # Also, avoid calling I18n.available_locales since it's a somehow - # expensive operation in most stores. - # - # == Example - # - # To setup I18n to use TokyoCabinet in memory is quite straightforward: - # - # require 'rufus/tokyo/cabinet' # gem install rufus-tokyo - # I18n.backend = I18n::Backend::KeyValue.new(Rufus::Tokyo::Cabinet.new('*')) - # - # == Performance - # - # You may make this backend even faster by including the Memoize module. - # However, notice that you should properly clear the cache if you change - # values directly in the key-store. - # - # == Subtrees - # - # In most backends, you are allowed to retrieve part of a translation tree: - # - # I18n.backend.store_translations :en, :foo => { :bar => :baz } - # I18n.t "foo" #=> { :bar => :baz } - # - # This backend supports this feature by default, but it slows down the storage - # of new data considerably and makes hard to delete entries. That said, you are - # allowed to disable the storage of subtrees on initialization: - # - # I18n::Backend::KeyValue.new(@store, false) - # - # This is useful if you are using a KeyValue backend chained to a Simple backend. - class KeyValue - module Implementation - attr_accessor :store - - include Base, Flatten - - def initialize(store, subtrees=true) - @store, @subtrees = store, subtrees - end - - def store_translations(locale, data, options = {}) - escape = options.fetch(:escape, true) - flatten_translations(locale, data, escape, @subtrees).each do |key, value| - key = "#{locale}.#{key}" - - case value - when Hash - if @subtrees && (old_value = @store[key]) - old_value = ActiveSupport::JSON.decode(old_value) - value = old_value.deep_symbolize_keys.deep_merge!(value) if old_value.is_a?(Hash) - end - when Proc - raise "Key-value stores cannot handle procs" - end - - @store[key] = ActiveSupport::JSON.encode([value]) unless value.is_a?(Symbol) - end - end - - def available_locales - locales = @store.keys.map { |k| k =~ /\./; $` } - locales.uniq! - locales.compact! - locales.map! { |k| k.to_sym } - locales - end - - protected - - def lookup(locale, key, scope = [], options = {}) - key = normalize_flat_keys(locale, key, scope, options[:separator]) - value = @store["#{locale}.#{key}"] - value = ActiveSupport::JSON.decode(value)[0] if value - value.is_a?(Hash) ? value.deep_symbolize_keys : value - end - end - - include Implementation - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/memoize.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/memoize.rb deleted file mode 100644 index ae9801fc..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/memoize.rb +++ /dev/null @@ -1,46 +0,0 @@ -# Memoize module simply memoizes the values returned by lookup using -# a flat hash and can tremendously speed up the lookup process in a backend. -# -# To enable it you can simply include the Memoize module to your backend: -# -# I18n::Backend::Simple.include(I18n::Backend::Memoize) -# -# Notice that it's the responsibility of the backend to define whenever the -# cache should be cleaned. -module I18n - module Backend - module Memoize - def available_locales - @memoized_locales ||= super - end - - def store_translations(locale, data, options = {}) - reset_memoizations!(locale) - super - end - - def reload! - reset_memoizations! - super - end - - protected - - def lookup(locale, key, scope = nil, options = {}) - flat_key = I18n::Backend::Flatten.normalize_flat_keys(locale, - key, scope, options[:separator]).to_sym - flat_hash = memoized_lookup[locale.to_sym] - flat_hash.key?(flat_key) ? flat_hash[flat_key] : (flat_hash[flat_key] = super) - end - - def memoized_lookup - @memoized_lookup ||= Hash.new { |h, k| h[k] = {} } - end - - def reset_memoizations!(locale=nil) - @memoized_locales = nil - (locale ? memoized_lookup[locale.to_sym] : memoized_lookup).clear - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/metadata.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/metadata.rb deleted file mode 100644 index 52c0a295..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/metadata.rb +++ /dev/null @@ -1,65 +0,0 @@ -# I18n translation metadata is useful when you want to access information -# about how a translation was looked up, pluralized or interpolated in -# your application. -# -# msg = I18n.t(:message, :default => 'Hi!', :scope => :foo) -# msg.translation_metadata -# # => { :key => :message, :scope => :foo, :default => 'Hi!' } -# -# If a :count option was passed to #translate it will be set to the metadata. -# Likewise, if any interpolation variables were passed they will also be set. -# -# To enable translation metadata you can simply include the Metadata module -# into the Simple backend class - or whatever other backend you are using: -# -# I18n::Backend::Simple.include(I18n::Backend::Metadata) -# -module I18n - module Backend - module Metadata - class << self - def included(base) - Object.class_eval do - def translation_metadata - @translation_metadata ||= {} - end - - def translation_metadata=(translation_metadata) - @translation_metadata = translation_metadata - end - end unless Object.method_defined?(:translation_metadata) - end - end - - def translate(locale, key, options = {}) - metadata = { - :locale => locale, - :key => key, - :scope => options[:scope], - :default => options[:default], - :separator => options[:separator], - :values => options.reject { |name, value| RESERVED_KEYS.include?(name) } - } - with_metadata(metadata) { super } - end - - def interpolate(locale, entry, values = {}) - metadata = entry.translation_metadata.merge(:original => entry) - with_metadata(metadata) { super } - end - - def pluralize(locale, entry, count) - with_metadata(:count => count) { super } - end - - protected - - def with_metadata(metadata, &block) - result = yield - result.translation_metadata = result.translation_metadata.merge(metadata) if result - result - end - - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/pluralization.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/pluralization.rb deleted file mode 100644 index c73a009a..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/pluralization.rb +++ /dev/null @@ -1,53 +0,0 @@ -# I18n Pluralization are useful when you want your application to -# customize pluralization rules. -# -# To enable locale specific pluralizations you can simply include the -# Pluralization module to the Simple backend - or whatever other backend you -# are using. -# -# I18n::Backend::Simple.include(I18n::Backend::Pluralization) -# -# You also need to make sure to provide pluralization algorithms to the -# backend, i.e. include them to your I18n.load_path accordingly. -module I18n - module Backend - module Pluralization - # Overwrites the Base backend translate method so that it will check the - # translation meta data space (:i18n) for a locale specific pluralization - # rule and use it to pluralize the given entry. I.e. the library expects - # pluralization rules to be stored at I18n.t(:'i18n.plural.rule') - # - # Pluralization rules are expected to respond to #call(count) and - # return a pluralization key. Valid keys depend on the translation data - # hash (entry) but it is generally recommended to follow CLDR's style, - # i.e., return one of the keys :zero, :one, :few, :many, :other. - # - # The :zero key is always picked directly when count equals 0 AND the - # translation data has the key :zero. This way translators are free to - # either pick a special :zero translation even for languages where the - # pluralizer does not return a :zero key. - def pluralize(locale, entry, count) - return entry unless entry.is_a?(Hash) and count - - pluralizer = pluralizer(locale) - if pluralizer.respond_to?(:call) - key = count == 0 && entry.has_key?(:zero) ? :zero : pluralizer.call(count) - raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key) - entry[key] - else - super - end - end - - protected - - def pluralizers - @pluralizers ||= {} - end - - def pluralizer(locale) - pluralizers[locale] ||= I18n.t(:'i18n.plural.rule', :locale => locale, :resolve => false) - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/simple.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/simple.rb deleted file mode 100644 index 95ffb6ab..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/simple.rb +++ /dev/null @@ -1,87 +0,0 @@ -module I18n - module Backend - # A simple backend that reads translations from YAML files and stores them in - # an in-memory hash. Relies on the Base backend. - # - # The implementation is provided by a Implementation module allowing to easily - # extend Simple backend's behavior by including modules. E.g.: - # - # module I18n::Backend::Pluralization - # def pluralize(*args) - # # extended pluralization logic - # super - # end - # end - # - # I18n::Backend::Simple.include(I18n::Backend::Pluralization) - class Simple - (class << self; self; end).class_eval { public :include } - - module Implementation - include Base - - def initialized? - @initialized ||= false - end - - # Stores translations for the given locale in memory. - # This uses a deep merge for the translations hash, so existing - # translations will be overwritten by new ones only at the deepest - # level of the hash. - def store_translations(locale, data, options = {}) - locale = locale.to_sym - translations[locale] ||= {} - data = data.deep_symbolize_keys - translations[locale].deep_merge!(data) - end - - # Get available locales from the translations hash - def available_locales - init_translations unless initialized? - translations.inject([]) do |locales, (locale, data)| - locales << locale unless (data.keys - [:i18n]).empty? - locales - end - end - - # Clean up translations hash and set initialized to false on reload! - def reload! - @initialized = false - @translations = nil - super - end - - protected - - def init_translations - load_translations - @initialized = true - end - - def translations - @translations ||= {} - end - - # Looks up a translation from the translations hash. Returns nil if - # eiher key is nil, or locale, scope or key do not exist as a key in the - # nested translations hash. Splits keys or scopes containing dots - # into multiple keys, i.e. currency.format is regarded the same as - # %w(currency format). - def lookup(locale, key, scope = [], options = {}) - init_translations unless initialized? - keys = I18n.normalize_keys(locale, key, scope, options[:separator]) - - keys.inject(translations) do |result, _key| - _key = _key.to_sym - return nil unless result.is_a?(Hash) && result.has_key?(_key) - result = result[_key] - result = resolve(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol) - result - end - end - end - - include Implementation - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/backend/transliterator.rb b/lib/mcollective/vendor/i18n/lib/i18n/backend/transliterator.rb deleted file mode 100644 index 2ce2cc82..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/backend/transliterator.rb +++ /dev/null @@ -1,98 +0,0 @@ -# encoding: utf-8 -module I18n - module Backend - module Transliterator - DEFAULT_REPLACEMENT_CHAR = "?" - - # Given a locale and a UTF-8 string, return the locale's ASCII - # approximation for the string. - def transliterate(locale, string, replacement = nil) - @transliterators ||= {} - @transliterators[locale] ||= Transliterator.get I18n.t(:'i18n.transliterate.rule', - :locale => locale, :resolve => false, :default => {}) - @transliterators[locale].transliterate(string, replacement) - end - - # Get a transliterator instance. - def self.get(rule = nil) - if !rule || rule.kind_of?(Hash) - HashTransliterator.new(rule) - elsif rule.kind_of? Proc - ProcTransliterator.new(rule) - else - raise I18n::ArgumentError, "Transliteration rule must be a proc or a hash." - end - end - - # A transliterator which accepts a Proc as its transliteration rule. - class ProcTransliterator - def initialize(rule) - @rule = rule - end - - def transliterate(string, replacement = nil) - @rule.call(string) - end - end - - # A transliterator which accepts a Hash of characters as its translation - # rule. - class HashTransliterator - DEFAULT_APPROXIMATIONS = { - "À"=>"A", "Á"=>"A", "Â"=>"A", "Ã"=>"A", "Ä"=>"A", "Å"=>"A", "Æ"=>"AE", - "Ç"=>"C", "È"=>"E", "É"=>"E", "Ê"=>"E", "Ë"=>"E", "Ì"=>"I", "Í"=>"I", - "Î"=>"I", "Ï"=>"I", "Ð"=>"D", "Ñ"=>"N", "Ò"=>"O", "Ó"=>"O", "Ô"=>"O", - "Õ"=>"O", "Ö"=>"O", "×"=>"x", "Ø"=>"O", "Ù"=>"U", "Ú"=>"U", "Û"=>"U", - "Ü"=>"U", "Ý"=>"Y", "Þ"=>"Th", "ß"=>"ss", "à"=>"a", "á"=>"a", "â"=>"a", - "ã"=>"a", "ä"=>"a", "å"=>"a", "æ"=>"ae", "ç"=>"c", "è"=>"e", "é"=>"e", - "ê"=>"e", "ë"=>"e", "ì"=>"i", "í"=>"i", "î"=>"i", "ï"=>"i", "ð"=>"d", - "ñ"=>"n", "ò"=>"o", "ó"=>"o", "ô"=>"o", "õ"=>"o", "ö"=>"o", "ø"=>"o", - "ù"=>"u", "ú"=>"u", "û"=>"u", "ü"=>"u", "ý"=>"y", "þ"=>"th", "ÿ"=>"y", - "Ā"=>"A", "ā"=>"a", "Ă"=>"A", "ă"=>"a", "Ą"=>"A", "ą"=>"a", "Ć"=>"C", - "ć"=>"c", "Ĉ"=>"C", "ĉ"=>"c", "Ċ"=>"C", "ċ"=>"c", "Č"=>"C", "č"=>"c", - "Ď"=>"D", "ď"=>"d", "Đ"=>"D", "đ"=>"d", "Ē"=>"E", "ē"=>"e", "Ĕ"=>"E", - "ĕ"=>"e", "Ė"=>"E", "ė"=>"e", "Ę"=>"E", "ę"=>"e", "Ě"=>"E", "ě"=>"e", - "Ĝ"=>"G", "ĝ"=>"g", "Ğ"=>"G", "ğ"=>"g", "Ġ"=>"G", "ġ"=>"g", "Ģ"=>"G", - "ģ"=>"g", "Ĥ"=>"H", "ĥ"=>"h", "Ħ"=>"H", "ħ"=>"h", "Ĩ"=>"I", "ĩ"=>"i", - "Ī"=>"I", "ī"=>"i", "Ĭ"=>"I", "ĭ"=>"i", "Į"=>"I", "į"=>"i", "İ"=>"I", - "ı"=>"i", "IJ"=>"IJ", "ij"=>"ij", "Ĵ"=>"J", "ĵ"=>"j", "Ķ"=>"K", "ķ"=>"k", - "ĸ"=>"k", "Ĺ"=>"L", "ĺ"=>"l", "Ļ"=>"L", "ļ"=>"l", "Ľ"=>"L", "ľ"=>"l", - "Ŀ"=>"L", "ŀ"=>"l", "Ł"=>"L", "ł"=>"l", "Ń"=>"N", "ń"=>"n", "Ņ"=>"N", - "ņ"=>"n", "Ň"=>"N", "ň"=>"n", "ʼn"=>"'n", "Ŋ"=>"NG", "ŋ"=>"ng", - "Ō"=>"O", "ō"=>"o", "Ŏ"=>"O", "ŏ"=>"o", "Ő"=>"O", "ő"=>"o", "Œ"=>"OE", - "œ"=>"oe", "Ŕ"=>"R", "ŕ"=>"r", "Ŗ"=>"R", "ŗ"=>"r", "Ř"=>"R", "ř"=>"r", - "Ś"=>"S", "ś"=>"s", "Ŝ"=>"S", "ŝ"=>"s", "Ş"=>"S", "ş"=>"s", "Š"=>"S", - "š"=>"s", "Ţ"=>"T", "ţ"=>"t", "Ť"=>"T", "ť"=>"t", "Ŧ"=>"T", "ŧ"=>"t", - "Ũ"=>"U", "ũ"=>"u", "Ū"=>"U", "ū"=>"u", "Ŭ"=>"U", "ŭ"=>"u", "Ů"=>"U", - "ů"=>"u", "Ű"=>"U", "ű"=>"u", "Ų"=>"U", "ų"=>"u", "Ŵ"=>"W", "ŵ"=>"w", - "Ŷ"=>"Y", "ŷ"=>"y", "Ÿ"=>"Y", "Ź"=>"Z", "ź"=>"z", "Ż"=>"Z", "ż"=>"z", - "Ž"=>"Z", "ž"=>"z" - } - - def initialize(rule = nil) - @rule = rule - add DEFAULT_APPROXIMATIONS - add rule if rule - end - - def transliterate(string, replacement = nil) - string.gsub(/[^\x00-\x7f]/u) do |char| - approximations[char] || replacement || DEFAULT_REPLACEMENT_CHAR - end - end - - private - - def approximations - @approximations ||= {} - end - - # Add transliteration rules to the approximations hash. - def add(hash) - hash.keys.each {|key| hash[key.to_s] = hash.delete(key).to_s} - approximations.merge! hash - end - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/config.rb b/lib/mcollective/vendor/i18n/lib/i18n/config.rb deleted file mode 100644 index 5fe05f7f..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/config.rb +++ /dev/null @@ -1,86 +0,0 @@ -module I18n - class Config - # The only configuration value that is not global and scoped to thread is :locale. - # It defaults to the default_locale. - def locale - @locale ||= default_locale - end - - # Sets the current locale pseudo-globally, i.e. in the Thread.current hash. - def locale=(locale) - @locale = locale.to_sym rescue nil - end - - # Returns the current backend. Defaults to +Backend::Simple+. - def backend - @@backend ||= Backend::Simple.new - end - - # Sets the current backend. Used to set a custom backend. - def backend=(backend) - @@backend = backend - end - - # Returns the current default locale. Defaults to :'en' - def default_locale - @@default_locale ||= :en - end - - # Sets the current default locale. Used to set a custom default locale. - def default_locale=(locale) - @@default_locale = locale.to_sym rescue nil - end - - # Returns an array of locales for which translations are available. - # Unless you explicitely set these through I18n.available_locales= - # the call will be delegated to the backend. - def available_locales - @@available_locales ||= nil - @@available_locales || backend.available_locales - end - - # Sets the available locales. - def available_locales=(locales) - @@available_locales = Array(locales).map { |locale| locale.to_sym } - @@available_locales = nil if @@available_locales.empty? - end - - # Returns the current default scope separator. Defaults to '.' - def default_separator - @@default_separator ||= '.' - end - - # Sets the current default scope separator. - def default_separator=(separator) - @@default_separator = separator - end - - # Return the current exception handler. Defaults to :default_exception_handler. - def exception_handler - @@exception_handler ||= ExceptionHandler.new - end - - # Sets the exception handler. - def exception_handler=(exception_handler) - @@exception_handler = exception_handler - end - - # Allow clients to register paths providing translation data sources. The - # backend defines acceptable sources. - # - # E.g. the provided SimpleBackend accepts a list of paths to translation - # files which are either named *.rb and contain plain Ruby Hashes or are - # named *.yml and contain YAML data. So for the SimpleBackend clients may - # register translation files like this: - # I18n.load_path << 'path/to/locale/en.yml' - def load_path - @@load_path ||= [] - end - - # Sets the load path instance. Custom implementations are expected to - # behave like a Ruby Array. - def load_path=(load_path) - @@load_path = load_path - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/core_ext/hash.rb b/lib/mcollective/vendor/i18n/lib/i18n/core_ext/hash.rb deleted file mode 100644 index f2a2422b..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/core_ext/hash.rb +++ /dev/null @@ -1,29 +0,0 @@ -class Hash - def slice(*keep_keys) - h = {} - keep_keys.each { |key| h[key] = fetch(key) } - h - end unless Hash.method_defined?(:slice) - - def except(*less_keys) - slice(*keys - less_keys) - end unless Hash.method_defined?(:except) - - def deep_symbolize_keys - inject({}) { |result, (key, value)| - value = value.deep_symbolize_keys if value.is_a?(Hash) - result[(key.to_sym rescue key) || key] = value - result - } - end unless Hash.method_defined?(:deep_symbolize_keys) - - # deep_merge_hash! by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809 - MERGER = proc do |key, v1, v2| - Hash === v1 && Hash === v2 ? v1.merge(v2, &MERGER) : v2 - end - - def deep_merge!(data) - merge!(data, &MERGER) - end unless Hash.method_defined?(:deep_merge!) -end - diff --git a/lib/mcollective/vendor/i18n/lib/i18n/core_ext/kernel/surpress_warnings.rb b/lib/mcollective/vendor/i18n/lib/i18n/core_ext/kernel/surpress_warnings.rb deleted file mode 100644 index cc03b1c1..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/core_ext/kernel/surpress_warnings.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Kernel - def suppress_warnings - original_verbosity = $VERBOSE - $VERBOSE = nil - result = yield - $VERBOSE = original_verbosity - result - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/core_ext/string/interpolate.rb b/lib/mcollective/vendor/i18n/lib/i18n/core_ext/string/interpolate.rb deleted file mode 100644 index 56de8c00..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/core_ext/string/interpolate.rb +++ /dev/null @@ -1,105 +0,0 @@ -# This backports the Ruby 1.9 String interpolation syntax to Ruby 1.8. -# -# This backport has been shipped with I18n for a number of versions. Meanwhile -# Rails has started to rely on it and we are going to move it to ActiveSupport. -# See https://rails.lighthouseapp.com/projects/8994/tickets/6013-move-19-string-interpolation-syntax-backport-from-i18n-to-activesupport -# -# Once the above patch has been applied to Rails the following code will be -# removed from I18n. - -=begin - heavily based on Masao Mutoh's gettext String interpolation extension - http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb - Copyright (C) 2005-2009 Masao Mutoh - You may redistribute it and/or modify it under the same license terms as Ruby. -=end - -begin - raise ArgumentError if ("a %{x}" % {:x=>'b'}) != 'a b' -rescue ArgumentError - # KeyError is raised by String#% when the string contains a named placeholder - # that is not contained in the given arguments hash. Ruby 1.9 includes and - # raises this exception natively. We define it to mimic Ruby 1.9's behaviour - # in Ruby 1.8.x - class KeyError < IndexError - def initialize(message = nil) - super(message || "key not found") - end - end unless defined?(KeyError) - - # Extension for String class. This feature is included in Ruby 1.9 or later but not occur TypeError. - # - # String#% method which accept "named argument". The translator can know - # the meaning of the msgids using "named argument" instead of %s/%d style. - class String - # For older ruby versions, such as ruby-1.8.5 - alias :bytesize :size unless instance_methods.find {|m| m.to_s == 'bytesize'} - alias :interpolate_without_ruby_19_syntax :% # :nodoc: - - INTERPOLATION_PATTERN = Regexp.union( - /%\{(\w+)\}/, # matches placeholders like "%{foo}" - /%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%.d" - ) - - INTERPOLATION_PATTERN_WITH_ESCAPE = Regexp.union( - /%%/, - INTERPOLATION_PATTERN - ) - - # % uses self (i.e. the String) as a format specification and returns the - # result of applying it to the given arguments. In other words it interpolates - # the given arguments to the string according to the formats the string - # defines. - # - # There are three ways to use it: - # - # * Using a single argument or Array of arguments. - # - # This is the default behaviour of the String class. See Kernel#sprintf for - # more details about the format string. - # - # Example: - # - # "%d %s" % [1, "message"] - # # => "1 message" - # - # * Using a Hash as an argument and unformatted, named placeholders. - # - # When you pass a Hash as an argument and specify placeholders with %{foo} - # it will interpret the hash values as named arguments. - # - # Example: - # - # "%{firstname}, %{lastname}" % {:firstname => "Masao", :lastname => "Mutoh"} - # # => "Masao Mutoh" - # - # * Using a Hash as an argument and formatted, named placeholders. - # - # When you pass a Hash as an argument and specify placeholders with %d - # it will interpret the hash values as named arguments and format the value - # according to the formatting instruction appended to the closing >. - # - # Example: - # - # "%d, %.1f" % { :integer => 10, :float => 43.4 } - # # => "10, 43.3" - def %(args) - if args.kind_of?(Hash) - dup.gsub(INTERPOLATION_PATTERN_WITH_ESCAPE) do |match| - if match == '%%' - '%' - else - key = ($1 || $2).to_sym - raise KeyError unless args.has_key?(key) - $3 ? sprintf("%#{$3}", args[key]) : args[key] - end - end - elsif self =~ INTERPOLATION_PATTERN - raise ArgumentError.new('one hash required') - else - result = gsub(/%([{<])/, '%%\1') - result.send :'interpolate_without_ruby_19_syntax', args - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/exceptions.rb b/lib/mcollective/vendor/i18n/lib/i18n/exceptions.rb deleted file mode 100644 index 2f625a02..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/exceptions.rb +++ /dev/null @@ -1,106 +0,0 @@ -module I18n - # Handles exceptions raised in the backend. All exceptions except for - # MissingTranslationData exceptions are re-thrown. When a MissingTranslationData - # was caught the handler returns an error message string containing the key/scope. - # Note that the exception handler is not called when the option :throw was given. - class ExceptionHandler - include Module.new { - def call(exception, locale, key, options) - if exception.is_a?(MissingTranslation) - options[:rescue_format] == :html ? exception.html_message : exception.message - elsif exception.is_a?(Exception) - raise exception - else - throw :exception, exception - end - end - } - end - - class ArgumentError < ::ArgumentError; end - - class InvalidLocale < ArgumentError - attr_reader :locale - def initialize(locale) - @locale = locale - super "#{locale.inspect} is not a valid locale" - end - end - - class InvalidLocaleData < ArgumentError - attr_reader :filename - def initialize(filename) - @filename = filename - super "can not load translations from #{filename}, expected it to return a hash, but does not" - end - end - - class MissingTranslation - module Base - attr_reader :locale, :key, :options - - def initialize(locale, key, options = nil) - @key, @locale, @options = key, locale, options.dup || {} - options.each { |k, v| self.options[k] = v.inspect if v.is_a?(Proc) } - end - - def html_message - key = keys.last.to_s.gsub('_', ' ').gsub(/\b('?[a-z])/) { $1.capitalize } - %(#{key}) - end - - def keys - @keys ||= I18n.normalize_keys(locale, key, options[:scope]).tap do |keys| - keys << 'no key' if keys.size < 2 - end - end - - def message - "translation missing: #{keys.join('.')}" - end - alias :to_s :message - - def to_exception - MissingTranslationData.new(locale, key, options) - end - end - - include Base - end - - class MissingTranslationData < ArgumentError - include MissingTranslation::Base - end - - class InvalidPluralizationData < ArgumentError - attr_reader :entry, :count - def initialize(entry, count) - @entry, @count = entry, count - super "translation data #{entry.inspect} can not be used with :count => #{count}" - end - end - - class MissingInterpolationArgument < ArgumentError - attr_reader :values, :string - def initialize(values, string) - @values, @string = values, string - super "missing interpolation argument in #{string.inspect} (#{values.inspect} given)" - end - end - - class ReservedInterpolationKey < ArgumentError - attr_reader :key, :string - def initialize(key, string) - @key, @string = key, string - super "reserved key #{key.inspect} used in #{string.inspect}" - end - end - - class UnknownFileType < ArgumentError - attr_reader :type, :filename - def initialize(type, filename) - @type, @filename = type, filename - super "can not load translations from #{filename}, the file type #{type} is not known" - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/gettext.rb b/lib/mcollective/vendor/i18n/lib/i18n/gettext.rb deleted file mode 100644 index 26a5d482..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/gettext.rb +++ /dev/null @@ -1,25 +0,0 @@ -module I18n - module Gettext - PLURAL_SEPARATOR = "\001" - CONTEXT_SEPARATOR = "\004" - - autoload :Helpers, 'i18n/gettext/helpers' - - @@plural_keys = { :en => [:one, :other] } - - class << self - # returns an array of plural keys for the given locale so that we can - # convert from gettext's integer-index based style - # TODO move this information to the pluralization module - def plural_keys(locale) - @@plural_keys[locale] || @@plural_keys[:en] - end - - def extract_scope(msgid, separator) - scope = msgid.to_s.split(separator) - msgid = scope.pop - [scope, msgid] - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/gettext/helpers.rb b/lib/mcollective/vendor/i18n/lib/i18n/gettext/helpers.rb deleted file mode 100644 index ea07d052..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/gettext/helpers.rb +++ /dev/null @@ -1,64 +0,0 @@ -require 'i18n/gettext' - -module I18n - module Gettext - # Implements classical Gettext style accessors. To use this include the - # module to the global namespace or wherever you want to use it. - # - # include I18n::Gettext::Helpers - module Helpers - def gettext(msgid, options = {}) - I18n.t(msgid, { :default => msgid, :separator => '|' }.merge(options)) - end - alias _ gettext - - def sgettext(msgid, separator = '|') - scope, msgid = I18n::Gettext.extract_scope(msgid, separator) - I18n.t(msgid, :scope => scope, :default => msgid, :separator => separator) - end - alias s_ sgettext - - def pgettext(msgctxt, msgid) - separator = I18n::Gettext::CONTEXT_SEPARATOR - sgettext([msgctxt, msgid].join(separator), separator) - end - alias p_ pgettext - - def ngettext(msgid, msgid_plural, n = 1) - nsgettext(msgid, msgid_plural, n) - end - alias n_ ngettext - - # Method signatures: - # nsgettext('Fruits|apple', 'apples', 2) - # nsgettext(['Fruits|apple', 'apples'], 2) - def nsgettext(msgid, msgid_plural, n = 1, separator = '|') - if msgid.is_a?(Array) - msgid, msgid_plural, n, separator = msgid[0], msgid[1], msgid_plural, n - separator = '|' unless separator.is_a?(::String) - end - - scope, msgid = I18n::Gettext.extract_scope(msgid, separator) - default = { :one => msgid, :other => msgid_plural } - I18n.t(msgid, :default => default, :count => n, :scope => scope, :separator => separator) - end - alias ns_ nsgettext - - # Method signatures: - # npgettext('Fruits', 'apple', 'apples', 2) - # npgettext('Fruits', ['apple', 'apples'], 2) - def npgettext(msgctxt, msgid, msgid_plural, n = 1) - separator = I18n::Gettext::CONTEXT_SEPARATOR - - if msgid.is_a?(Array) - msgid_plural, msgid, n = msgid[1], [msgctxt, msgid[0]].join(separator), msgid_plural - else - msgid = [msgctxt, msgid].join(separator) - end - - nsgettext(msgid, msgid_plural, n, separator) - end - alias np_ npgettext - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/gettext/po_parser.rb b/lib/mcollective/vendor/i18n/lib/i18n/gettext/po_parser.rb deleted file mode 100644 index 547df6a5..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/gettext/po_parser.rb +++ /dev/null @@ -1,329 +0,0 @@ -=begin - poparser.rb - Generate a .mo - - Copyright (C) 2003-2009 Masao Mutoh - - You may redistribute it and/or modify it under the same - license terms as Ruby. -=end - -#MODIFIED -# removed include GetText etc -# added stub translation method _(x) -require 'racc/parser' - -module GetText - - class PoParser < Racc::Parser - - def _(x) - x - end - -module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry', 108 - def unescape(orig) - ret = orig.gsub(/\\n/, "\n") - ret.gsub!(/\\t/, "\t") - ret.gsub!(/\\r/, "\r") - ret.gsub!(/\\"/, "\"") - ret - end - - def parse(str, data, ignore_fuzzy = true) - @comments = [] - @data = data - @fuzzy = false - @msgctxt = "" - $ignore_fuzzy = ignore_fuzzy - - str.strip! - @q = [] - until str.empty? do - case str - when /\A\s+/ - str = $' - when /\Amsgctxt/ - @q.push [:MSGCTXT, $&] - str = $' - when /\Amsgid_plural/ - @q.push [:MSGID_PLURAL, $&] - str = $' - when /\Amsgid/ - @q.push [:MSGID, $&] - str = $' - when /\Amsgstr/ - @q.push [:MSGSTR, $&] - str = $' - when /\A\[(\d+)\]/ - @q.push [:PLURAL_NUM, $1] - str = $' - when /\A\#~(.*)/ - $stderr.print _("Warning: obsolete msgid exists.\n") - $stderr.print " #{$&}\n" - @q.push [:COMMENT, $&] - str = $' - when /\A\#(.*)/ - @q.push [:COMMENT, $&] - str = $' - when /\A\"(.*)\"/ - @q.push [:STRING, $1] - str = $' - else - #c = str[0,1] - #@q.push [:STRING, c] - str = str[1..-1] - end - end - @q.push [false, '$end'] - if $DEBUG - @q.each do |a,b| - puts "[#{a}, #{b}]" - end - end - @yydebug = true if $DEBUG - do_parse - - if @comments.size > 0 - @data.set_comment(:last, @comments.join("\n")) - end - @data - end - - def next_token - @q.shift - end - - def on_message(msgid, msgstr) - if msgstr.size > 0 - @data[msgid] = msgstr - @data.set_comment(msgid, @comments.join("\n")) - end - @comments.clear - @msgctxt = "" - end - - def on_comment(comment) - @fuzzy = true if (/fuzzy/ =~ comment) - @comments << comment - end - - -..end src/poparser.ry modeval..id7a99570e05 - -##### racc 1.4.5 generates ### - -racc_reduce_table = [ - 0, 0, :racc_error, - 0, 10, :_reduce_none, - 2, 10, :_reduce_none, - 2, 10, :_reduce_none, - 2, 10, :_reduce_none, - 2, 12, :_reduce_5, - 1, 13, :_reduce_none, - 1, 13, :_reduce_none, - 4, 15, :_reduce_8, - 5, 16, :_reduce_9, - 2, 17, :_reduce_10, - 1, 17, :_reduce_none, - 3, 18, :_reduce_12, - 1, 11, :_reduce_13, - 2, 14, :_reduce_14, - 1, 14, :_reduce_15 ] - -racc_reduce_n = 16 - -racc_shift_n = 26 - -racc_action_table = [ - 3, 13, 5, 7, 9, 15, 16, 17, 20, 17, - 13, 17, 13, 13, 11, 17, 23, 20, 13, 17 ] - -racc_action_check = [ - 1, 16, 1, 1, 1, 12, 12, 12, 18, 18, - 7, 14, 15, 9, 3, 19, 20, 21, 23, 25 ] - -racc_action_pointer = [ - nil, 0, nil, 14, nil, nil, nil, 3, nil, 6, - nil, nil, 0, nil, 4, 5, -6, nil, 2, 8, - 8, 11, nil, 11, nil, 12 ] - -racc_action_default = [ - -1, -16, -2, -16, -3, -13, -4, -16, -6, -16, - -7, 26, -16, -15, -5, -16, -16, -14, -16, -8, - -16, -9, -11, -16, -10, -12 ] - -racc_goto_table = [ - 12, 22, 14, 4, 24, 6, 2, 8, 18, 19, - 10, 21, 1, nil, nil, nil, 25 ] - -racc_goto_check = [ - 5, 9, 5, 3, 9, 4, 2, 6, 5, 5, - 7, 8, 1, nil, nil, nil, 5 ] - -racc_goto_pointer = [ - nil, 12, 5, 2, 4, -7, 6, 9, -7, -17 ] - -racc_goto_default = [ - nil, nil, nil, nil, nil, nil, nil, nil, nil, nil ] - -racc_token_table = { - false => 0, - Object.new => 1, - :COMMENT => 2, - :MSGID => 3, - :MSGCTXT => 4, - :MSGID_PLURAL => 5, - :MSGSTR => 6, - :STRING => 7, - :PLURAL_NUM => 8 } - -racc_use_result_var = true - -racc_nt_base = 9 - -Racc_arg = [ - racc_action_table, - racc_action_check, - racc_action_default, - racc_action_pointer, - racc_goto_table, - racc_goto_check, - racc_goto_default, - racc_goto_pointer, - racc_nt_base, - racc_reduce_table, - racc_token_table, - racc_shift_n, - racc_reduce_n, - racc_use_result_var ] - -Racc_token_to_s_table = [ -'$end', -'error', -'COMMENT', -'MSGID', -'MSGCTXT', -'MSGID_PLURAL', -'MSGSTR', -'STRING', -'PLURAL_NUM', -'$start', -'msgfmt', -'comment', -'msgctxt', -'message', -'string_list', -'single_message', -'plural_message', -'msgstr_plural', -'msgstr_plural_line'] - -Racc_debug_parser = true - -##### racc system variables end ##### - - # reduce 0 omitted - - # reduce 1 omitted - - # reduce 2 omitted - - # reduce 3 omitted - - # reduce 4 omitted - -module_eval <<'.,.,', 'src/poparser.ry', 25 - def _reduce_5( val, _values, result ) - @msgctxt = unescape(val[1]) + "\004" - result - end -.,., - - # reduce 6 omitted - - # reduce 7 omitted - -module_eval <<'.,.,', 'src/poparser.ry', 48 - def _reduce_8( val, _values, result ) - if @fuzzy and $ignore_fuzzy - if val[1] != "" - $stderr.print _("Warning: fuzzy message was ignored.\n") - $stderr.print " msgid '#{val[1]}'\n" - else - on_message('', unescape(val[3])) - end - @fuzzy = false - else - on_message(@msgctxt + unescape(val[1]), unescape(val[3])) - end - result = "" - result - end -.,., - -module_eval <<'.,.,', 'src/poparser.ry', 65 - def _reduce_9( val, _values, result ) - if @fuzzy and $ignore_fuzzy - if val[1] != "" - $stderr.print _("Warning: fuzzy message was ignored.\n") - $stderr.print "msgid = '#{val[1]}\n" - else - on_message('', unescape(val[3])) - end - @fuzzy = false - else - on_message(@msgctxt + unescape(val[1]) + "\000" + unescape(val[3]), unescape(val[4])) - end - result = "" - result - end -.,., - -module_eval <<'.,.,', 'src/poparser.ry', 76 - def _reduce_10( val, _values, result ) - if val[0].size > 0 - result = val[0] + "\000" + val[1] - else - result = "" - end - result - end -.,., - - # reduce 11 omitted - -module_eval <<'.,.,', 'src/poparser.ry', 84 - def _reduce_12( val, _values, result ) - result = val[2] - result - end -.,., - -module_eval <<'.,.,', 'src/poparser.ry', 91 - def _reduce_13( val, _values, result ) - on_comment(val[0]) - result - end -.,., - -module_eval <<'.,.,', 'src/poparser.ry', 99 - def _reduce_14( val, _values, result ) - result = val.delete_if{|item| item == ""}.join - result - end -.,., - -module_eval <<'.,.,', 'src/poparser.ry', 103 - def _reduce_15( val, _values, result ) - result = val[0] - result - end -.,., - - def _reduce_none( val, _values, result ) - result - end - - end # class PoParser - -end # module GetText diff --git a/lib/mcollective/vendor/i18n/lib/i18n/interpolate/ruby.rb b/lib/mcollective/vendor/i18n/lib/i18n/interpolate/ruby.rb deleted file mode 100644 index 29b28146..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/interpolate/ruby.rb +++ /dev/null @@ -1,31 +0,0 @@ -# heavily based on Masao Mutoh's gettext String interpolation extension -# http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb - -module I18n - INTERPOLATION_PATTERN = Regexp.union( - /%%/, - /%\{(\w+)\}/, # matches placeholders like "%{foo}" - /%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%.d" - ) - - class << self - def interpolate(string, values) - raise ReservedInterpolationKey.new($1.to_sym, string) if string =~ RESERVED_KEYS_PATTERN - raise ArgumentError.new('Interpolation values must be a Hash.') unless values.kind_of?(Hash) - interpolate_hash(string, values) - end - - def interpolate_hash(string, values) - string.gsub(INTERPOLATION_PATTERN) do |match| - if match == '%%' - '%' - else - key = ($1 || $2).to_sym - value = values.key?(key) ? values[key] : raise(MissingInterpolationArgument.new(values, string)) - value = value.call(values) if value.respond_to?(:call) - $3 ? sprintf("%#{$3}", value) : value - end - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/locale.rb b/lib/mcollective/vendor/i18n/lib/i18n/locale.rb deleted file mode 100644 index 4f9d0266..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/locale.rb +++ /dev/null @@ -1,6 +0,0 @@ -module I18n - module Locale - autoload :Fallbacks, 'i18n/locale/fallbacks' - autoload :Tag, 'i18n/locale/tag' - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/locale/fallbacks.rb b/lib/mcollective/vendor/i18n/lib/i18n/locale/fallbacks.rb deleted file mode 100644 index 08bf6f55..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/locale/fallbacks.rb +++ /dev/null @@ -1,96 +0,0 @@ -# Locale Fallbacks -# -# Extends the I18n module to hold a fallbacks instance which is set to an -# instance of I18n::Locale::Fallbacks by default but can be swapped with a -# different implementation. -# -# Locale fallbacks will compute a number of fallback locales for a given locale. -# For example: -# -#

-# I18n.fallbacks[:"es-MX"] # => [:"es-MX", :es, :en] 
-# -# Locale fallbacks always fall back to -# -# * all parent locales of a given locale (e.g. :es for :"es-MX") first, -# * the current default locales and all of their parents second -# -# The default locales are set to [I18n.default_locale] by default but can be -# set to something else. -# -# One can additionally add any number of additional fallback locales manually. -# These will be added before the default locales to the fallback chain. For -# example: -# -# # using the default locale as default fallback locale -# -# I18n.default_locale = :"en-US" -# I18n.fallbacks = I18n::Locale::Fallbacks.new(:"de-AT" => :"de-DE") -# I18n.fallbacks[:"de-AT"] # => [:"de-AT", :"de-DE", :de, :"en-US", :en] -# -# # using a custom locale as default fallback locale -# -# I18n.fallbacks = I18n::Locale::Fallbacks.new(:"en-GB", :"de-AT" => :de, :"de-CH" => :de) -# I18n.fallbacks[:"de-AT"] # => [:"de-AT", :de, :"en-GB", :en] -# I18n.fallbacks[:"de-CH"] # => [:"de-CH", :de, :"en-GB", :en] -# -# # mapping fallbacks to an existing instance -# -# # people speaking Catalan also speak Spanish as spoken in Spain -# fallbacks = I18n.fallbacks -# fallbacks.map(:ca => :"es-ES") -# fallbacks[:ca] # => [:ca, :"es-ES", :es, :"en-US", :en] -# -# # people speaking Arabian as spoken in Palestine also speak Hebrew as spoken in Israel -# fallbacks.map(:"ar-PS" => :"he-IL") -# fallbacks[:"ar-PS"] # => [:"ar-PS", :ar, :"he-IL", :he, :"en-US", :en] -# fallbacks[:"ar-EG"] # => [:"ar-EG", :ar, :"en-US", :en] -# -# # people speaking Sami as spoken in Finnland also speak Swedish and Finnish as spoken in Finnland -# fallbacks.map(:sms => [:"se-FI", :"fi-FI"]) -# fallbacks[:sms] # => [:sms, :"se-FI", :se, :"fi-FI", :fi, :"en-US", :en] - -module I18n - module Locale - class Fallbacks < Hash - def initialize(*mappings) - @map = {} - map(mappings.pop) if mappings.last.is_a?(Hash) - self.defaults = mappings.empty? ? [I18n.default_locale.to_sym] : mappings - end - - def defaults=(defaults) - @defaults = defaults.map { |default| compute(default, false) }.flatten - end - attr_reader :defaults - - def [](locale) - raise InvalidLocale.new(locale) if locale.nil? - locale = locale.to_sym - super || store(locale, compute(locale)) - end - - def map(mappings) - mappings.each do |from, to| - from, to = from.to_sym, Array(to) - to.each do |_to| - @map[from] ||= [] - @map[from] << _to.to_sym - end - end - end - - protected - - def compute(tags, include_defaults = true, exclude = []) - result = Array(tags).collect do |tag| - tags = I18n::Locale::Tag.tag(tag).self_and_parents.map! { |t| t.to_sym } - exclude - tags.each { |_tag| tags += compute(@map[_tag], false, exclude + tags) if @map[_tag] } - tags - end.flatten - result.push(*defaults) if include_defaults - result.uniq.compact - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/locale/tag.rb b/lib/mcollective/vendor/i18n/lib/i18n/locale/tag.rb deleted file mode 100644 index a640b446..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/locale/tag.rb +++ /dev/null @@ -1,28 +0,0 @@ -# encoding: utf-8 - -module I18n - module Locale - module Tag - autoload :Parents, 'i18n/locale/tag/parents' - autoload :Rfc4646, 'i18n/locale/tag/rfc4646' - autoload :Simple, 'i18n/locale/tag/simple' - - class << self - # Returns the current locale tag implementation. Defaults to +I18n::Locale::Tag::Simple+. - def implementation - @@implementation ||= Simple - end - - # Sets the current locale tag implementation. Use this to set a different locale tag implementation. - def implementation=(implementation) - @@implementation = implementation - end - - # Factory method for locale tags. Delegates to the current locale tag implementation. - def tag(tag) - implementation.tag(tag) - end - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/locale/tag/parents.rb b/lib/mcollective/vendor/i18n/lib/i18n/locale/tag/parents.rb deleted file mode 100644 index ec53060f..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/locale/tag/parents.rb +++ /dev/null @@ -1,22 +0,0 @@ -module I18n - module Locale - module Tag - module Parents - def parent - @parent ||= begin - segs = to_a.compact - segs.length > 1 ? self.class.tag(*segs[0..(segs.length-2)].join('-')) : nil - end - end - - def self_and_parents - @self_and_parents ||= [self] + parents - end - - def parents - @parents ||= ([parent] + (parent ? parent.parents : [])).compact - end - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/locale/tag/rfc4646.rb b/lib/mcollective/vendor/i18n/lib/i18n/locale/tag/rfc4646.rb deleted file mode 100644 index 4ce4c751..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/locale/tag/rfc4646.rb +++ /dev/null @@ -1,74 +0,0 @@ -# RFC 4646/47 compliant Locale tag implementation that parses locale tags to -# subtags such as language, script, region, variant etc. -# -# For more information see by http://en.wikipedia.org/wiki/IETF_language_tag -# -# Rfc4646::Parser does not implement grandfathered tags. - -module I18n - module Locale - module Tag - RFC4646_SUBTAGS = [ :language, :script, :region, :variant, :extension, :privateuse, :grandfathered ] - RFC4646_FORMATS = { :language => :downcase, :script => :capitalize, :region => :upcase, :variant => :downcase } - - class Rfc4646 < Struct.new(*RFC4646_SUBTAGS) - class << self - # Parses the given tag and returns a Tag instance if it is valid. - # Returns false if the given tag is not valid according to RFC 4646. - def tag(tag) - matches = parser.match(tag) - new(*matches) if matches - end - - def parser - @@parser ||= Rfc4646::Parser - end - - def parser=(parser) - @@parser = parser - end - end - - include Parents - - RFC4646_FORMATS.each do |name, format| - define_method(name) { self[name].send(format) unless self[name].nil? } - end - - def to_sym - to_s.to_sym - end - - def to_s - @tag ||= to_a.compact.join("-") - end - - def to_a - members.collect { |attr| self.send(attr) } - end - - module Parser - PATTERN = %r{\A(?: - ([a-z]{2,3}(?:(?:-[a-z]{3}){0,3})?|[a-z]{4}|[a-z]{5,8}) # language - (?:-([a-z]{4}))? # script - (?:-([a-z]{2}|\d{3}))? # region - (?:-([0-9a-z]{5,8}|\d[0-9a-z]{3}))* # variant - (?:-([0-9a-wyz](?:-[0-9a-z]{2,8})+))* # extension - (?:-(x(?:-[0-9a-z]{1,8})+))?| # privateuse subtag - (x(?:-[0-9a-z]{1,8})+)| # privateuse tag - /* ([a-z]{1,3}(?:-[0-9a-z]{2,8}){1,2}) */ # grandfathered - )\z}xi - - class << self - def match(tag) - c = PATTERN.match(tag.to_s).captures - c[0..4] << (c[5].nil? ? c[6] : c[5]) << c[7] # TODO c[7] is grandfathered, throw a NotImplemented exception here? - rescue - false - end - end - end - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/locale/tag/simple.rb b/lib/mcollective/vendor/i18n/lib/i18n/locale/tag/simple.rb deleted file mode 100644 index 68642a12..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/locale/tag/simple.rb +++ /dev/null @@ -1,39 +0,0 @@ -# Simple Locale tag implementation that computes subtags by simply splitting -# the locale tag at '-' occurences. -module I18n - module Locale - module Tag - class Simple - class << self - def tag(tag) - new(tag) - end - end - - include Parents - - attr_reader :tag - - def initialize(*tag) - @tag = tag.join('-').to_sym - end - - def subtags - @subtags = tag.to_s.split('-').map { |subtag| subtag.to_s } - end - - def to_sym - tag - end - - def to_s - tag.to_s - end - - def to_a - subtags - end - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests.rb deleted file mode 100644 index 554cdefe..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests.rb +++ /dev/null @@ -1,12 +0,0 @@ -module I18n - module Tests - autoload :Basics, 'i18n/tests/basics' - autoload :Defaults, 'i18n/tests/defaults' - autoload :Interpolation, 'i18n/tests/interpolation' - autoload :Link, 'i18n/tests/link' - autoload :Localization, 'i18n/tests/localization' - autoload :Lookup, 'i18n/tests/lookup' - autoload :Pluralization, 'i18n/tests/pluralization' - autoload :Procs, 'i18n/tests/procs' - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests/basics.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests/basics.rb deleted file mode 100644 index 101e7c52..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests/basics.rb +++ /dev/null @@ -1,54 +0,0 @@ -module I18n - module Tests - module Basics - def teardown - I18n.available_locales = nil - end - - test "available_locales returns the locales stored to the backend by default" do - I18n.backend.store_translations('de', :foo => 'bar') - I18n.backend.store_translations('en', :foo => 'foo') - - assert I18n.available_locales.include?(:de) - assert I18n.available_locales.include?(:en) - end - - test "available_locales can be set to something else independently from the actual locale data" do - I18n.backend.store_translations('de', :foo => 'bar') - I18n.backend.store_translations('en', :foo => 'foo') - - I18n.available_locales = :foo - assert_equal [:foo], I18n.available_locales - - I18n.available_locales = [:foo, 'bar'] - assert_equal [:foo, :bar], I18n.available_locales - - I18n.available_locales = nil - assert I18n.available_locales.include?(:de) - assert I18n.available_locales.include?(:en) - end - - test "available_locales memoizes when set explicitely" do - I18n.backend.expects(:available_locales).never - I18n.available_locales = [:foo] - I18n.backend.store_translations('de', :bar => 'baz') - I18n.reload! - assert_equal [:foo], I18n.available_locales - end - - test "available_locales delegates to the backend when not set explicitely" do - I18n.backend.expects(:available_locales).twice - assert_equal I18n.available_locales, I18n.available_locales - end - - test "storing a nil value as a translation removes it from the available locale data" do - I18n.backend.store_translations(:en, :to_be_deleted => 'bar') - assert_equal 'bar', I18n.t(:to_be_deleted, :default => 'baz') - - I18n.cache_store.clear if I18n.respond_to?(:cache_store) && I18n.cache_store - I18n.backend.store_translations(:en, :to_be_deleted => nil) - assert_equal 'baz', I18n.t(:to_be_deleted, :default => 'baz') - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests/defaults.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests/defaults.rb deleted file mode 100644 index 081dcbd1..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests/defaults.rb +++ /dev/null @@ -1,40 +0,0 @@ -# encoding: utf-8 - -module I18n - module Tests - module Defaults - def setup - super - I18n.backend.store_translations(:en, :foo => { :bar => 'bar', :baz => 'baz' }) - end - - test "defaults: given nil as a key it returns the given default" do - assert_equal 'default', I18n.t(nil, :default => 'default') - end - - test "defaults: given a symbol as a default it translates the symbol" do - assert_equal 'bar', I18n.t(nil, :default => :'foo.bar') - end - - test "defaults: given a symbol as a default and a scope it stays inside the scope when looking up the symbol" do - assert_equal 'bar', I18n.t(:missing, :default => :bar, :scope => :foo) - end - - test "defaults: given an array as a default it returns the first match" do - assert_equal 'bar', I18n.t(:does_not_exist, :default => [:does_not_exist_2, :'foo.bar']) - end - - test "defaults: given an array of missing keys it raises a MissingTranslationData exception" do - assert_raise I18n::MissingTranslationData do - I18n.t(:does_not_exist, :default => [:does_not_exist_2, :does_not_exist_3], :raise => true) - end - end - - test "defaults: using a custom scope separator" do - # data must have been stored using the custom separator when using the ActiveRecord backend - I18n.backend.store_translations(:en, { :foo => { :bar => 'bar' } }, { :separator => '|' }) - assert_equal 'bar', I18n.t(nil, :default => :'foo|bar', :separator => '|') - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests/interpolation.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests/interpolation.rb deleted file mode 100644 index 06613f27..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests/interpolation.rb +++ /dev/null @@ -1,133 +0,0 @@ -# encoding: utf-8 - -module I18n - module Tests - module Interpolation - # If no interpolation parameter is not given, I18n should not alter the string. - # This behavior is due to three reasons: - # - # * Checking interpolation keys in all strings hits performance, badly; - # - # * This allows us to retrieve untouched values through I18n. For example - # I could have a middleware that returns I18n lookup results in JSON - # to be processed through Javascript. Leaving the keys untouched allows - # the interpolation to happen at the javascript level; - # - # * Security concerns: if I allow users to translate a web site, they can - # insert %{} in messages causing the I18n lookup to fail in every request. - # - test "interpolation: given no values it does not alter the string" do - assert_equal 'Hi %{name}!', interpolate(:default => 'Hi %{name}!') - end - - test "interpolation: given values it interpolates them into the string" do - assert_equal 'Hi David!', interpolate(:default => 'Hi %{name}!', :name => 'David') - end - - test "interpolation: given a nil value it still interpolates it into the string" do - assert_equal 'Hi !', interpolate(:default => 'Hi %{name}!', :name => nil) - end - - test "interpolation: given a lambda as a value it calls it if the string contains the key" do - assert_equal 'Hi David!', interpolate(:default => 'Hi %{name}!', :name => lambda { |*args| 'David' }) - end - - test "interpolation: given a lambda as a value it does not call it if the string does not contain the key" do - assert_nothing_raised { interpolate(:default => 'Hi!', :name => lambda { |*args| raise 'fail' }) } - end - - test "interpolation: given values but missing a key it raises I18n::MissingInterpolationArgument" do - assert_raise(I18n::MissingInterpolationArgument) do - interpolate(:default => '%{foo}', :bar => 'bar') - end - end - - test "interpolation: it does not raise I18n::MissingInterpolationArgument for escaped variables" do - assert_nothing_raised(I18n::MissingInterpolationArgument) do - assert_equal 'Barr %{foo}', interpolate(:default => '%{bar} %%{foo}', :bar => 'Barr') - end - end - - test "interpolation: it does not change the original, stored translation string" do - I18n.backend.store_translations(:en, :interpolate => 'Hi %{name}!') - assert_equal 'Hi David!', interpolate(:interpolate, :name => 'David') - assert_equal 'Hi Yehuda!', interpolate(:interpolate, :name => 'Yehuda') - end - - test "interpolation: given the translation is in utf-8 it still works" do - assert_equal 'Häi David!', interpolate(:default => 'Häi %{name}!', :name => 'David') - end - - test "interpolation: given the value is in utf-8 it still works" do - assert_equal 'Hi ゆきひろ!', interpolate(:default => 'Hi %{name}!', :name => 'ゆきひろ') - end - - test "interpolation: given the translation and the value are in utf-8 it still works" do - assert_equal 'こんにちは、ゆきひろさん!', interpolate(:default => 'こんにちは、%{name}さん!', :name => 'ゆきひろ') - end - - if Kernel.const_defined?(:Encoding) - test "interpolation: given a euc-jp translation and a utf-8 value it raises Encoding::CompatibilityError" do - assert_raise(Encoding::CompatibilityError) do - interpolate(:default => euc_jp('こんにちは、%{name}さん!'), :name => 'ゆきひろ') - end - end - - test "interpolation: given a utf-8 translation and a euc-jp value it raises Encoding::CompatibilityError" do - assert_raise(Encoding::CompatibilityError) do - interpolate(:default => 'こんにちは、%{name}さん!', :name => euc_jp('ゆきひろ')) - end - end - - test "interpolation: ASCII strings in the backend should be encoded to UTF8 if interpolation options are in UTF8" do - I18n.backend.store_translations 'en', 'encoding' => ('%{who} let me go'.force_encoding("ASCII")) - result = I18n.t 'encoding', :who => "måmmå miå" - assert_equal Encoding::UTF_8, result.encoding - end - - test "interpolation: UTF8 strings in the backend are still returned as UTF8 with ASCII interpolation" do - I18n.backend.store_translations 'en', 'encoding' => 'måmmå miå %{what}' - result = I18n.t 'encoding', :what => 'let me go'.force_encoding("ASCII") - assert_equal Encoding::UTF_8, result.encoding - end - - test "interpolation: UTF8 strings in the backend are still returned as UTF8 even with numbers interpolation" do - I18n.backend.store_translations 'en', 'encoding' => '%{count} times: måmmå miå' - result = I18n.t 'encoding', :count => 3 - assert_equal Encoding::UTF_8, result.encoding - end - end - - test "interpolation: given a translations containing a reserved key it raises I18n::ReservedInterpolationKey" do - assert_raise(I18n::ReservedInterpolationKey) { interpolate(:default => '%{default}', :foo => :bar) } - assert_raise(I18n::ReservedInterpolationKey) { interpolate(:default => '%{scope}', :foo => :bar) } - assert_raise(I18n::ReservedInterpolationKey) { interpolate(:default => '%{separator}', :foo => :bar) } - end - - protected - - def capture(stream) - begin - stream = stream.to_s - eval "$#{stream} = StringIO.new" - yield - result = eval("$#{stream}").string - ensure - eval("$#{stream} = #{stream.upcase}") - end - - result - end - - def euc_jp(string) - string.encode!(Encoding::EUC_JP) - end - - def interpolate(*args) - options = args.last.is_a?(Hash) ? args.pop : {} - key = args.pop - I18n.backend.translate('en', key, options) - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests/link.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests/link.rb deleted file mode 100644 index da84a2c8..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests/link.rb +++ /dev/null @@ -1,56 +0,0 @@ -# encoding: utf-8 - -module I18n - module Tests - module Link - test "linked lookup: if a key resolves to a symbol it looks up the symbol" do - I18n.backend.store_translations 'en', { - :link => :linked, - :linked => 'linked' - } - assert_equal 'linked', I18n.backend.translate('en', :link) - end - - test "linked lookup: if a key resolves to a dot-separated symbol it looks up the symbol" do - I18n.backend.store_translations 'en', { - :link => :"foo.linked", - :foo => { :linked => 'linked' } - } - assert_equal('linked', I18n.backend.translate('en', :link)) - end - - test "linked lookup: if a dot-separated key resolves to a symbol it looks up the symbol" do - I18n.backend.store_translations 'en', { - :foo => { :link => :linked }, - :linked => 'linked' - } - assert_equal('linked', I18n.backend.translate('en', :'foo.link')) - end - - test "linked lookup: if a dot-separated key resolves to a dot-separated symbol it looks up the symbol" do - I18n.backend.store_translations 'en', { - :foo => { :link => :"bar.linked" }, - :bar => { :linked => 'linked' } - } - assert_equal('linked', I18n.backend.translate('en', :'foo.link')) - end - - test "linked lookup: links always refer to the absolute key" do - I18n.backend.store_translations 'en', { - :foo => { :link => :linked, :linked => 'linked in foo' }, - :linked => 'linked absolutely' - } - assert_equal 'linked absolutely', I18n.backend.translate('en', :link, :scope => :foo) - end - - test "linked lookup: a link can resolve to a namespace in the middle of a dot-separated key" do - I18n.backend.store_translations 'en', { - :activemodel => { :errors => { :messages => { :blank => "can't be blank" } } }, - :activerecord => { :errors => { :messages => :"activemodel.errors.messages" } } - } - assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank") - assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank") - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests/localization.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests/localization.rb deleted file mode 100644 index 53b15029..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests/localization.rb +++ /dev/null @@ -1,19 +0,0 @@ -module I18n - module Tests - module Localization - autoload :Date, 'i18n/tests/localization/date' - autoload :DateTime, 'i18n/tests/localization/date_time' - autoload :Time, 'i18n/tests/localization/time' - autoload :Procs, 'i18n/tests/localization/procs' - - def self.included(base) - base.class_eval do - include I18n::Tests::Localization::Date - include I18n::Tests::Localization::DateTime - include I18n::Tests::Localization::Procs - include I18n::Tests::Localization::Time - end - end - end - end -end \ No newline at end of file diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests/localization/date.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests/localization/date.rb deleted file mode 100644 index a866f90c..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests/localization/date.rb +++ /dev/null @@ -1,84 +0,0 @@ -# encoding: utf-8 - -module I18n - module Tests - module Localization - module Date - def setup - super - setup_date_translations - @date = ::Date.new(2008, 3, 1) - end - - test "localize Date: given the short format it uses it" do - # TODO should be Mrz, shouldn't it? - assert_equal '01. Mar', I18n.l(@date, :format => :short, :locale => :de) - end - - test "localize Date: given the long format it uses it" do - assert_equal '01. März 2008', I18n.l(@date, :format => :long, :locale => :de) - end - - test "localize Date: given the default format it uses it" do - assert_equal '01.03.2008', I18n.l(@date, :format => :default, :locale => :de) - end - - test "localize Date: given a day name format it returns the correct day name" do - assert_equal 'Samstag', I18n.l(@date, :format => '%A', :locale => :de) - end - - test "localize Date: given an abbreviated day name format it returns the correct abbreviated day name" do - assert_equal 'Sa', I18n.l(@date, :format => '%a', :locale => :de) - end - - test "localize Date: given a month name format it returns the correct month name" do - assert_equal 'März', I18n.l(@date, :format => '%B', :locale => :de) - end - - test "localize Date: given an abbreviated month name format it returns the correct abbreviated month name" do - # TODO should be Mrz, shouldn't it? - assert_equal 'Mar', I18n.l(@date, :format => '%b', :locale => :de) - end - - test "localize Date: given an unknown format it does not fail" do - assert_nothing_raised { I18n.l(@date, :format => '%x') } - end - - test "localize Date: given nil it raises I18n::ArgumentError" do - assert_raise(I18n::ArgumentError) { I18n.l(nil) } - end - - test "localize Date: given a plain Object it raises I18n::ArgumentError" do - assert_raise(I18n::ArgumentError) { I18n.l(Object.new) } - end - - test "localize Date: given a format is missing it raises I18n::MissingTranslationData" do - assert_raise(I18n::MissingTranslationData) { I18n.l(@date, :format => :missing) } - end - - test "localize Date: it does not alter the format string" do - assert_equal '01. Februar 2009', I18n.l(::Date.parse('2009-02-01'), :format => :long, :locale => :de) - assert_equal '01. Oktober 2009', I18n.l(::Date.parse('2009-10-01'), :format => :long, :locale => :de) - end - - protected - - def setup_date_translations - I18n.backend.store_translations :de, { - :date => { - :formats => { - :default => "%d.%m.%Y", - :short => "%d. %b", - :long => "%d. %B %Y", - }, - :day_names => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag), - :abbr_day_names => %w(So Mo Di Mi Do Fr Sa), - :month_names => %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember).unshift(nil), - :abbr_month_names => %w(Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil) - } - } - end - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests/localization/date_time.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests/localization/date_time.rb deleted file mode 100644 index a926d1c4..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests/localization/date_time.rb +++ /dev/null @@ -1,77 +0,0 @@ -# encoding: utf-8 - -module I18n - module Tests - module Localization - module DateTime - def setup - super - setup_datetime_translations - @datetime = ::DateTime.new(2008, 3, 1, 6) - @other_datetime = ::DateTime.new(2008, 3, 1, 18) - end - - test "localize DateTime: given the short format it uses it" do - # TODO should be Mrz, shouldn't it? - assert_equal '01. Mar 06:00', I18n.l(@datetime, :format => :short, :locale => :de) - end - - test "localize DateTime: given the long format it uses it" do - assert_equal '01. März 2008 06:00', I18n.l(@datetime, :format => :long, :locale => :de) - end - - test "localize DateTime: given the default format it uses it" do - # TODO should be Mrz, shouldn't it? - assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.l(@datetime, :format => :default, :locale => :de) - end - - test "localize DateTime: given a day name format it returns the correct day name" do - assert_equal 'Samstag', I18n.l(@datetime, :format => '%A', :locale => :de) - end - - test "localize DateTime: given an abbreviated day name format it returns the correct abbreviated day name" do - assert_equal 'Sa', I18n.l(@datetime, :format => '%a', :locale => :de) - end - - test "localize DateTime: given a month name format it returns the correct month name" do - assert_equal 'März', I18n.l(@datetime, :format => '%B', :locale => :de) - end - - test "localize DateTime: given an abbreviated month name format it returns the correct abbreviated month name" do - # TODO should be Mrz, shouldn't it? - assert_equal 'Mar', I18n.l(@datetime, :format => '%b', :locale => :de) - end - - test "localize DateTime: given a meridian indicator format it returns the correct meridian indicator" do - assert_equal 'am', I18n.l(@datetime, :format => '%p', :locale => :de) - assert_equal 'pm', I18n.l(@other_datetime, :format => '%p', :locale => :de) - end - - test "localize DateTime: given an unknown format it does not fail" do - assert_nothing_raised { I18n.l(@datetime, :format => '%x') } - end - - test "localize DateTime: given a format is missing it raises I18n::MissingTranslationData" do - assert_raise(I18n::MissingTranslationData) { I18n.l(@datetime, :format => :missing) } - end - - protected - - def setup_datetime_translations - # time translations might have been set up in Tests::Api::Localization::Time - I18n.backend.store_translations :de, { - :time => { - :formats => { - :default => "%a, %d. %b %Y %H:%M:%S %z", - :short => "%d. %b %H:%M", - :long => "%d. %B %Y %H:%M" - }, - :am => 'am', - :pm => 'pm' - } - } - end - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests/localization/procs.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests/localization/procs.rb deleted file mode 100644 index 83d24bc5..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests/localization/procs.rb +++ /dev/null @@ -1,116 +0,0 @@ -# encoding: utf-8 - -module I18n - module Tests - module Localization - module Procs - test "localize: using day names from lambdas" do - setup_time_proc_translations - time = ::Time.utc(2008, 3, 1, 6, 0) - assert_match(/Суббота/, I18n.l(time, :format => "%A, %d %B", :locale => :ru)) - assert_match(/суббота/, I18n.l(time, :format => "%d %B (%A)", :locale => :ru)) - end - - test "localize: using month names from lambdas" do - setup_time_proc_translations - time = ::Time.utc(2008, 3, 1, 6, 0) - assert_match(/марта/, I18n.l(time, :format => "%d %B %Y", :locale => :ru)) - assert_match(/Март /, I18n.l(time, :format => "%B %Y", :locale => :ru)) - end - - test "localize: using abbreviated day names from lambdas" do - setup_time_proc_translations - time = ::Time.utc(2008, 3, 1, 6, 0) - assert_match(/марта/, I18n.l(time, :format => "%d %b %Y", :locale => :ru)) - assert_match(/март /, I18n.l(time, :format => "%b %Y", :locale => :ru)) - end - - test "localize Date: given a format that resolves to a Proc it calls the Proc with the object" do - setup_time_proc_translations - date = ::Date.new(2008, 3, 1, 6) - assert_equal '[Sat, 01 Mar 2008, {}]', I18n.l(date, :format => :proc, :locale => :ru) - end - - test "localize Date: given a format that resolves to a Proc it calls the Proc with the object and extra options" do - setup_time_proc_translations - date = ::Date.new(2008, 3, 1, 6) - assert_equal '[Sat, 01 Mar 2008, {:foo=>"foo"}]', I18n.l(date, :format => :proc, :foo => 'foo', :locale => :ru) - end - - test "localize DateTime: given a format that resolves to a Proc it calls the Proc with the object" do - setup_time_proc_translations - datetime = ::DateTime.new(2008, 3, 1, 6) - assert_equal '[Sat, 01 Mar 2008 06:00:00 +00:00, {}]', I18n.l(datetime, :format => :proc, :locale => :ru) - end - - test "localize DateTime: given a format that resolves to a Proc it calls the Proc with the object and extra options" do - setup_time_proc_translations - datetime = ::DateTime.new(2008, 3, 1, 6) - assert_equal '[Sat, 01 Mar 2008 06:00:00 +00:00, {:foo=>"foo"}]', I18n.l(datetime, :format => :proc, :foo => 'foo', :locale => :ru) - end - - test "localize Time: given a format that resolves to a Proc it calls the Proc with the object" do - setup_time_proc_translations - time = ::Time.utc(2008, 3, 1, 6, 0) - assert_equal inspect_args([time, {}]), I18n.l(time, :format => :proc, :locale => :ru) - end - - test "localize Time: given a format that resolves to a Proc it calls the Proc with the object and extra options" do - setup_time_proc_translations - time = ::Time.utc(2008, 3, 1, 6, 0) - options = { :foo => 'foo' } - assert_equal inspect_args([time, options]), I18n.l(time, options.merge(:format => :proc, :locale => :ru)) - end - - protected - - def inspect_args(args) - args = args.map do |arg| - case arg - when ::Time, ::DateTime - arg.strftime('%a, %d %b %Y %H:%M:%S %Z').sub('+0000', '+00:00') - when ::Date - arg.strftime('%a, %d %b %Y') - when Hash - arg.delete(:fallback) - arg.inspect - else - arg.inspect - end - end - "[#{args.join(', ')}]" - end - - def setup_time_proc_translations - I18n.backend.store_translations :ru, { - :time => { - :formats => { - :proc => lambda { |*args| inspect_args(args) } - } - }, - :date => { - :formats => { - :proc => lambda { |*args| inspect_args(args) } - }, - :'day_names' => lambda { |key, options| - (options[:format] =~ /^%A/) ? - %w(Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота) : - %w(воскресенье понедельник вторник среда четверг пятница суббота) - }, - :'month_names' => lambda { |key, options| - (options[:format] =~ /(%d|%e)(\s*)?(%B)/) ? - %w(января февраля марта апреля мая июня июля августа сентября октября ноября декабря).unshift(nil) : - %w(Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь).unshift(nil) - }, - :'abbr_month_names' => lambda { |key, options| - (options[:format] =~ /(%d|%e)(\s*)(%b)/) ? - %w(янв. февр. марта апр. мая июня июля авг. сент. окт. нояб. дек.).unshift(nil) : - %w(янв. февр. март апр. май июнь июль авг. сент. окт. нояб. дек.).unshift(nil) - }, - } - } - end - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests/localization/time.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests/localization/time.rb deleted file mode 100644 index 599f21f5..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests/localization/time.rb +++ /dev/null @@ -1,76 +0,0 @@ -# encoding: utf-8 - -module I18n - module Tests - module Localization - module Time - def setup - super - setup_time_translations - @time = ::Time.utc(2008, 3, 1, 6, 0) - @other_time = ::Time.utc(2008, 3, 1, 18, 0) - end - - test "localize Time: given the short format it uses it" do - # TODO should be Mrz, shouldn't it? - assert_equal '01. Mar 06:00', I18n.l(@time, :format => :short, :locale => :de) - end - - test "localize Time: given the long format it uses it" do - assert_equal '01. März 2008 06:00', I18n.l(@time, :format => :long, :locale => :de) - end - - # TODO Seems to break on Windows because ENV['TZ'] is ignored. What's a better way to do this? - # def test_localize_given_the_default_format_it_uses_it - # assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.l(@time, :format => :default, :locale => :de) - # end - - test "localize Time: given a day name format it returns the correct day name" do - assert_equal 'Samstag', I18n.l(@time, :format => '%A', :locale => :de) - end - - test "localize Time: given an abbreviated day name format it returns the correct abbreviated day name" do - assert_equal 'Sa', I18n.l(@time, :format => '%a', :locale => :de) - end - - test "localize Time: given a month name format it returns the correct month name" do - assert_equal 'März', I18n.l(@time, :format => '%B', :locale => :de) - end - - test "localize Time: given an abbreviated month name format it returns the correct abbreviated month name" do - # TODO should be Mrz, shouldn't it? - assert_equal 'Mar', I18n.l(@time, :format => '%b', :locale => :de) - end - - test "localize Time: given a meridian indicator format it returns the correct meridian indicator" do - assert_equal 'am', I18n.l(@time, :format => '%p', :locale => :de) - assert_equal 'pm', I18n.l(@other_time, :format => '%p', :locale => :de) - end - - test "localize Time: given an unknown format it does not fail" do - assert_nothing_raised { I18n.l(@time, :format => '%x') } - end - - test "localize Time: given a format is missing it raises I18n::MissingTranslationData" do - assert_raise(I18n::MissingTranslationData) { I18n.l(@time, :format => :missing) } - end - - protected - - def setup_time_translations - I18n.backend.store_translations :de, { - :time => { - :formats => { - :default => "%a, %d. %b %Y %H:%M:%S %z", - :short => "%d. %b %H:%M", - :long => "%d. %B %Y %H:%M", - }, - :am => 'am', - :pm => 'pm' - } - } - end - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests/lookup.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests/lookup.rb deleted file mode 100644 index 63c21ac8..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests/lookup.rb +++ /dev/null @@ -1,74 +0,0 @@ -# encoding: utf-8 - -module I18n - module Tests - module Lookup - def setup - super - I18n.backend.store_translations(:en, :foo => { :bar => 'bar', :baz => 'baz' }, :falsy => false, :truthy => true, - :string => "a", :array => %w(a b c), :hash => { "a" => "b" }) - end - - test "lookup: it returns a string" do - assert_equal("a", I18n.t(:string)) - end - - test "lookup: it returns hash" do - assert_equal({ :a => "b" }, I18n.t(:hash)) - end - - test "lookup: it returns a array" do - assert_equal(%w(a b c), I18n.t(:array)) - end - - test "lookup: it returns a native true" do - assert I18n.t(:truthy) === true - end - - test "lookup: it returns a native false" do - assert I18n.t(:falsy) === false - end - - test "lookup: given a missing key, no default and no raise option it returns an error message" do - assert_equal "translation missing: en.missing", I18n.t(:missing) - end - - test "lookup: given a missing key, no default and the raise option it raises MissingTranslationData" do - assert_raise(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) } - end - - test "lookup: does not raise an exception if no translation data is present for the given locale" do - assert_nothing_raised { I18n.t(:foo, :locale => :xx) } - end - - test "lookup: given an array of keys it translates all of them" do - assert_equal %w(bar baz), I18n.t([:bar, :baz], :scope => [:foo]) - end - - test "lookup: using a custom scope separator" do - # data must have been stored using the custom separator when using the ActiveRecord backend - I18n.backend.store_translations(:en, { :foo => { :bar => 'bar' } }, { :separator => '|' }) - assert_equal 'bar', I18n.t('foo|bar', :separator => '|') - end - - # In fact it probably *should* fail but Rails currently relies on using the default locale instead. - # So we'll stick to this for now until we get it fixed in Rails. - test "lookup: given nil as a locale it does not raise but use the default locale" do - # assert_raise(I18n::InvalidLocale) { I18n.t(:bar, :locale => nil) } - assert_nothing_raised { I18n.t(:bar, :locale => nil) } - end - - test "lookup: a resulting String is not frozen" do - assert !I18n.t(:string).frozen? - end - - test "lookup: a resulting Array is not frozen" do - assert !I18n.t(:array).frozen? - end - - test "lookup: a resulting Hash is not frozen" do - assert !I18n.t(:hash).frozen? - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests/pluralization.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests/pluralization.rb deleted file mode 100644 index d3319dcd..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests/pluralization.rb +++ /dev/null @@ -1,35 +0,0 @@ -# encoding: utf-8 - -module I18n - module Tests - module Pluralization - test "pluralization: given 0 it returns the :zero translation if it is defined" do - assert_equal 'zero', I18n.t(:default => { :zero => 'zero' }, :count => 0) - end - - test "pluralization: given 0 it returns the :other translation if :zero is not defined" do - assert_equal 'bars', I18n.t(:default => { :other => 'bars' }, :count => 0) - end - - test "pluralization: given 1 it returns the singular translation" do - assert_equal 'bar', I18n.t(:default => { :one => 'bar' }, :count => 1) - end - - test "pluralization: given 2 it returns the :other translation" do - assert_equal 'bars', I18n.t(:default => { :other => 'bars' }, :count => 2) - end - - test "pluralization: given 3 it returns the :other translation" do - assert_equal 'bars', I18n.t(:default => { :other => 'bars' }, :count => 3) - end - - test "pluralization: given nil it returns the whole entry" do - assert_equal({ :one => 'bar' }, I18n.t(:default => { :one => 'bar' }, :count => nil)) - end - - test "pluralization: given incomplete pluralization data it raises I18n::InvalidPluralizationData" do - assert_raise(I18n::InvalidPluralizationData) { I18n.t(:default => { :one => 'bar' }, :count => 2) } - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/tests/procs.rb b/lib/mcollective/vendor/i18n/lib/i18n/tests/procs.rb deleted file mode 100644 index 55ff9529..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/tests/procs.rb +++ /dev/null @@ -1,55 +0,0 @@ -# encoding: utf-8 - -module I18n - module Tests - module Procs - test "lookup: given a translation is a proc it calls the proc with the key and interpolation values" do - I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| filter_args(*args) }) - assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo') - end - - test "defaults: given a default is a Proc it calls it with the key and interpolation values" do - proc = lambda { |*args| filter_args(*args) } - assert_equal '[nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo') - end - - test "defaults: given a default is a key that resolves to a Proc it calls it with the key and interpolation values" do - I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| filter_args(*args) }) - assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => :a_lambda, :foo => 'foo') - assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => [nil, :a_lambda], :foo => 'foo') - end - - test "interpolation: given an interpolation value is a lambda it calls it with key and values before interpolating it" do - proc = lambda { |*args| filter_args(*args) } - assert_match %r(\[\{:foo=>#\}\]), I18n.t(nil, :default => '%{foo}', :foo => proc) - end - - test "interpolation: given a key resolves to a Proc that returns a string then interpolation still works" do - proc = lambda { |*args| "%{foo}: " + filter_args(*args) } - assert_equal 'foo: [nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo') - end - - test "pluralization: given a key resolves to a Proc that returns valid data then pluralization still works" do - proc = lambda { |*args| { :zero => 'zero', :one => 'one', :other => 'other' } } - assert_equal 'zero', I18n.t(:default => proc, :count => 0) - assert_equal 'one', I18n.t(:default => proc, :count => 1) - assert_equal 'other', I18n.t(:default => proc, :count => 2) - end - - test "lookup: given the option :resolve => false was passed it does not resolve proc translations" do - I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| filter_args(*args) }) - assert_equal Proc, I18n.t(:a_lambda, :resolve => false).class - end - - test "lookup: given the option :resolve => false was passed it does not resolve proc default" do - assert_equal Proc, I18n.t(nil, :default => lambda { |*args| filter_args(*args) }, :resolve => false).class - end - - protected - - def filter_args(*args) - args.map {|arg| arg.delete(:fallback) if arg.is_a?(Hash) ; arg }.inspect - end - end - end -end diff --git a/lib/mcollective/vendor/i18n/lib/i18n/version.rb b/lib/mcollective/vendor/i18n/lib/i18n/version.rb deleted file mode 100644 index 9249aa82..00000000 --- a/lib/mcollective/vendor/i18n/lib/i18n/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module I18n - VERSION = "0.6.1" -end diff --git a/lib/mcollective/vendor/load_i18n.rb b/lib/mcollective/vendor/load_i18n.rb deleted file mode 100644 index 32ec4f12..00000000 --- a/lib/mcollective/vendor/load_i18n.rb +++ /dev/null @@ -1 +0,0 @@ -$: << File.join([File.dirname(__FILE__), "i18n/lib"]) diff --git a/lib/mcollective/vendor/require_vendored.rb b/lib/mcollective/vendor/require_vendored.rb index a925168c..be5a2671 100644 --- a/lib/mcollective/vendor/require_vendored.rb +++ b/lib/mcollective/vendor/require_vendored.rb @@ -1,3 +1,2 @@ require 'systemu' require 'json' -require 'i18n' diff --git a/plugins/mcollective/application/doc.rb b/plugins/mcollective/application/doc.rb deleted file mode 100644 index bb95c288..00000000 --- a/plugins/mcollective/application/doc.rb +++ /dev/null @@ -1,25 +0,0 @@ -module MCollective - class Application::Doc 0 - end - - def msg_template - File.read(Util.templatepath("msg-help.erb")) - end - - def main - if configuration[:query] =~ /^PLMC\d+$/i - msg_code = configuration[:query].upcase - msg_example = Util.t("%s.example" % msg_code, :raise => true) rescue Util.t("%s.pattern" % msg_code) - msg_detail = Util.t("%s.expanded" % msg_code) - - helptext = ERB.new(msg_template, 0, '%') - puts helptext.result(binding) - end - end - end -end diff --git a/spec/matchers/exception_matchers.rb b/spec/matchers/exception_matchers.rb deleted file mode 100644 index db057512..00000000 --- a/spec/matchers/exception_matchers.rb +++ /dev/null @@ -1,75 +0,0 @@ -module MCollective - module Matchers - def raise_code(*args) - CodedExceptionMatcher.new(args) - end - - class CodedExceptionMatcher - def initialize(args) - @args = args - - raise "Need at least an exception to match" if args.size == 0 - - @expected_code = @args.shift - @expected_data = @args.shift - - @failure_type = nil - @failure_expected = nil - @failure_got = nil - end - - def matches?(actual) - begin - actual.call - rescue => e - unless e.is_a?(MCollective::CodedError) - @failure_type = :type - @failure_expected = "MCollective::CodedError" - @failure_got = e.class - return false - end - - unless [e.code, e.default].include?(@expected_code) - @failure_type = :code - @failure_expected = @expected_code - @failure_got = e.code - return false - end - - if @expected_data - unless e.args == @expected_data - @failure_type = :arguments - @failure_expected = @expected_data.inspect - @failure_got = e.args.inspect - return false - end - end - end - - true - end - - def failure_message - case @failure_type - when :type - "Expected an exception of type %s but got %s" % [@failure_expected, @failure_got] - when :code - "Expected a message code %s but got %s" % [@failure_expected, @failure_got] - when :arguments - "Expected arguments %s but got %s" % [@failure_expected, @failure_got] - end - end - - def negative_failure_message - case @failure_type - when :type - "Expected an exception of type %s but got %s" % [@failure_got, @failure_expected] - when :code - "Expected a message code %s but got %s" % [@failure_got, @failure_expected] - when :arguments - "Expected arguments %s but got %s" % [@failure_got, @failure_expected] - end - end - end - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f894b238..ff66c839 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,18 +18,13 @@ require 'mcollective/test' require 'monkey_patches/instance_variable_defined' -require 'matchers/exception_matchers' RSpec.configure do |config| config.mock_with :mocha - config.include(MCollective::Matchers) config.include(MCollective::Test::Matchers) config.before :each do MCollective::Config.instance.set_config_defaults("") MCollective::PluginManager.clear - MCollective::Log.stubs(:log) - MCollective::Log.stubs(:logmsg) - MCollective::Log.stubs(:logexception) end end diff --git a/spec/unit/cache_spec.rb b/spec/unit/cache_spec.rb index 4dcff11c..1eca46a8 100644 --- a/spec/unit/cache_spec.rb +++ b/spec/unit/cache_spec.rb @@ -10,16 +10,6 @@ module MCollective @cache = Cache.instance_variable_set("@cache", {}) end - describe "#check_cache!" do - it "should correctly check for valid caches" do - Cache.expects(:has_cache?).with("rspec").returns(true) - Cache.expects(:has_cache?).with("fail").returns(false) - - Cache.check_cache!("rspec") - expect { Cache.check_cache!("fail") }.to raise_code("Could not find a cache called '%{cache_name}'", :cache_name => "fail") - end - end - describe "#setup" do it "should use a mutex to manage access to the cache" do @locks_mutex.expects(:synchronize).yields @@ -47,18 +37,19 @@ module MCollective describe "#delete!" do it "should delete the cache and return true" do - Cache.expects(:check_cache!).with("rspec") - Cache.setup("rspec") Cache.delete!("rspec").should == true end end describe "#write" do + it "should detect unknown caches" do + expect { Cache.write("rspec", :key, :val) }.to raise_error("No cache called 'rspec'") + end + it "should write to the cache" do time = Time.now Time.expects(:now).returns(time) - Cache.expects(:check_cache!).with("rspec") Cache.setup("rspec") Cache.write("rspec", :key, :val).should == :val @@ -72,10 +63,6 @@ module MCollective it "should read a written entry correctly" do Cache.setup("rspec") Cache.write("rspec", :key, :val) - - Cache.expects(:check_cache!).with("rspec") - Cache.expects(:ttl).with("rspec", :key).returns(1) - Cache.read("rspec", :key).should == :val end @@ -85,63 +72,30 @@ module MCollective Cache.expects(:ttl).returns(0) - Cache.expects(:check_cache!).with("rspec") - - expect { Cache.read("rspec", :key) }.to raise_code("Cache expired on '%{cache_name}' key '%{item}'", :cache_name => "rspec", :item => :key) - end - end - - describe "#invalidate!" do - it "should return false for unknown keys" do - Cache.expects(:check_cache!).with("rspec") - - @locks_mutex.expects(:synchronize).yields - - Cache.setup("rspec") - Cache.invalidate!("rspec", "no_such_key").should == false - end - - it "should delete the key" do - Cache.setup("rspec") - Cache.write("rspec", "valid_key", "rspec") - - Cache.expects(:check_cache!).with("rspec") - @cache["rspec"].expects(:delete).with("valid_key") - - Cache.invalidate!("rspec", "valid_key") + expect { Cache.read("rspec", :key) }.to raise_error(/has expired/) end end describe "#ttl" do - it "should detect invalid key names" do - Cache.expects(:check_cache!).with("rspec") - Cache.setup("rspec", 300) - expect { Cache.ttl("rspec", :key) }.to raise_code("No item called '%{item}' for cache '%{cache_name}'", :cache_name => "rspec", :item => :key) - end - - it "should return >0 for valid" do + it "should return a positive value for an unexpired item" do Cache.setup("rspec", 300) Cache.write("rspec", :key, :val) - - Cache.expects(:check_cache!).with("rspec") Cache.ttl("rspec", :key).should >= 0 end - it "should return <0 for expired messages" do + it "should return <0 for an expired item" do Cache.setup("rspec", 300) Cache.write("rspec", :key, :val) time = Time.now + 600 Time.expects(:now).returns(time) - Cache.expects(:check_cache!).with("rspec") Cache.ttl("rspec", :key).should <= 0 end end describe "#synchronize" do it "should use the correct mutex" do - Cache.expects(:check_cache!).with("rspec") Cache.setup("rspec") rspec_lock = @cache_locks["rspec"] diff --git a/spec/unit/data_spec.rb b/spec/unit/data_spec.rb index cc7dbf8c..ed405d34 100644 --- a/spec/unit/data_spec.rb +++ b/spec/unit/data_spec.rb @@ -132,7 +132,7 @@ module MCollective it "should ensure the ddl has a dataquery" do @ddl.expects(:entities).returns({}) - expect { Data.ddl_validate(@ddl, "rspec") }.to raise_code(:PLMC31, :plugin => "rspec test") + expect { Data.ddl_validate(@ddl, "rspec") }.to raise_error("No dataquery has been defined in the DDL for data plugin rspec test") end it "should allow ddls without any input defined" do @@ -142,12 +142,12 @@ module MCollective it "should not allow input arguments when no query were defined" do @ddl.expects(:entities).returns({:data => {:input => {}, :output => {:x => {}}}}) - expect { Data.ddl_validate(@ddl, "rspec") }.to raise_code(:PLMC33, :plugin => "rspec test") + expect { Data.ddl_validate(@ddl, "rspec") }.to raise_error("No data plugin argument was declared in the rspec test DDL but an input was supplied") end it "should ensure the ddl has output" do @ddl.expects(:entities).returns({:data => {:input => {:query => {}}, :output => {}}}) - expect { Data.ddl_validate(@ddl, "rspec") }.to raise_code(:PLMC32, :plugin => "rspec test") + expect { Data.ddl_validate(@ddl, "rspec") }.to raise_error("No output has been defined in the DDL for data plugin rspec test") end it "should skip optional arguments that were not supplied" do diff --git a/spec/unit/ddl/agentddl_spec.rb b/spec/unit/ddl/agentddl_spec.rb index 615fa10f..bdb0e522 100644 --- a/spec/unit/ddl/agentddl_spec.rb +++ b/spec/unit/ddl/agentddl_spec.rb @@ -53,7 +53,7 @@ module DDL expect { @ddl.validate_rpc_request(:fail, {}) - }.to raise_code(:PLMC29, :action => :fail, :plugin => "rspec") + }.to raise_error("Attempted to call action fail for rspec but it's not declared in the DDL") @ddl.validate_rpc_request(:test, {}) end @@ -72,7 +72,7 @@ module DDL expect { @ddl.validate_rpc_request(:test, {}) - }.to raise_code(:PLMC30, :action => :test, :key => :required) + }.to raise_error("Action test needs a required argument") @ddl.validate_rpc_request(:test, {:required => "f"}).should == true end @@ -191,26 +191,26 @@ module DDL it "should raise an exception if aggregate format isn't a hash" do expect{ @ddl.aggregate(:foo, :format) - }.to raise_code(:PLMC28) + }.to raise_error(DDLValidationError, "Formats supplied to aggregation functions should be a hash") end it "should raise an exception if format hash does not include a :format key" do expect{ @ddl.aggregate(:foo, {}) - }.to raise_code(:PLMC27) + }.to raise_error(DDLValidationError, "Formats supplied to aggregation functions must have a :format key") end it "should raise an exception if aggregate function is not a hash" do expect{ @ddl.aggregate(:foo) - }.to raise_code(:PLMC26) + }.to raise_error(DDLValidationError, "Functions supplied to aggregate should be a hash") end it "should raise an exception if function hash does not include a :args key" do expect{ @ddl.stubs(:entities).returns({nil => {:action => :foo}}) @ddl.aggregate({}) - }.to raise_code(:PLMC25, :action => :foo) + }.to raise_error(DDLValidationError, "aggregate method for action 'foo' missing a function parameter") end it "should correctly add an aggregate function to the function array" do diff --git a/spec/unit/ddl/base_spec.rb b/spec/unit/ddl/base_spec.rb index 989a7fc2..bc6b8306 100644 --- a/spec/unit/ddl/base_spec.rb +++ b/spec/unit/ddl/base_spec.rb @@ -70,7 +70,7 @@ module DDL expect { @ddl.validate_input_argument(@ddl.entities[:string][:input], :string, 1) - }.to raise_code(:PLMC21, :input => :string, :error => "value should be a string") + }.to raise_error("Cannot validate input string: value should be a string") @ddl.validate_input_argument(@ddl.entities[:string][:input], :string, "1") end @@ -84,7 +84,7 @@ module DDL expect { @ddl.validate_input_argument(@ddl.entities[:string][:input], :string, "too long") - }.to raise_code(:PLMC21, :input => :string, :error => "Input string is longer than 1 character(s)") + }.to raise_error("Cannot validate input string: Input string is longer than 1 character(s)") @ddl.validate_input_argument(@ddl.entities[:string][:input], :string, "1") end @@ -98,7 +98,7 @@ module DDL expect { @ddl.validate_input_argument(@ddl.entities[:string][:input], :string, "doesnt validate") - }.to raise_code(:PLMC21, :input => :string, :error => "value should match ^regex$") + }.to raise_error("Cannot validate input string: value should match ^regex$") @ddl.validate_input_argument(@ddl.entities[:string][:input], :string, "regex") end @@ -111,7 +111,7 @@ module DDL expect { @ddl.validate_input_argument(@ddl.entities[:list][:input], :list, 3) - }.to raise_code(:PLMC21, :input => :list, :error => "value should be one of 1, 2") + }.to raise_error("Cannot validate input list: value should be one of 1, 2") @ddl.validate_input_argument(@ddl.entities[:list][:input], :list, 1) end @@ -124,7 +124,7 @@ module DDL expect { @ddl.validate_input_argument(@ddl.entities[:bool][:input], :bool, 3) - }.to raise_code(:PLMC21, :input => :bool, :error => "value should be a boolean") + }.to raise_error("Cannot validate input bool: value should be a boolean") @ddl.validate_input_argument(@ddl.entities[:bool][:input], :bool, true) @ddl.validate_input_argument(@ddl.entities[:bool][:input], :bool, false) @@ -138,11 +138,11 @@ module DDL expect { @ddl.validate_input_argument(@ddl.entities[:test][:input], :int, "1") - }.to raise_code(:PLMC21, :input => :int, :error => "value should be a integer") + }.to raise_error("Cannot validate input int: value should be a integer") expect { @ddl.validate_input_argument(@ddl.entities[:test][:input], :int, 1.1) - }.to raise_code(:PLMC21, :input => :int, :error => "value should be a integer") + }.to raise_error("Cannot validate input int: value should be a integer") @ddl.validate_input_argument(@ddl.entities[:test][:input], :int, 1) end @@ -155,11 +155,11 @@ module DDL expect { @ddl.validate_input_argument(@ddl.entities[:test][:input], :float, "1") - }.to raise_code(:PLMC21, :input => :float, :error => "value should be a float") + }.to raise_error("Cannot validate input float: value should be a float") expect { @ddl.validate_input_argument(@ddl.entities[:test][:input], :float, 1) - }.to raise_code(:PLMC21, :input => :float, :error => "value should be a float") + }.to raise_error("Cannot validate input float: value should be a float") @ddl.validate_input_argument(@ddl.entities[:test][:input], :float, 1.1) end @@ -172,7 +172,7 @@ module DDL expect { @ddl.validate_input_argument(@ddl.entities[:test][:input], :number, "1") - }.to raise_code(:PLMC21, :input => :number, :error => "value should be a number") + }.to raise_error("Cannot validate input number: value should be a number") @ddl.validate_input_argument(@ddl.entities[:test][:input], :number, 1) @ddl.validate_input_argument(@ddl.entities[:test][:input], :number, 1.1) @@ -210,7 +210,7 @@ module DDL it "should bypass checks in development" do Util.stubs(:mcollective_version).returns("@DEVELOPMENT_VERSION@") - @ddl.expects(:log_code).with(:PLMC19, anything, :warn) + Log.expects(:warn).with(regexp_matches(/skipped in development/)) @ddl.requires(:mcollective => "0.1") end end @@ -241,7 +241,7 @@ module DDL it "should return the ddl file path if found" do Config.instance.expects(:libdir).returns(["/nonexisting"]) File.expects("exist?").with("/nonexisting/mcollective/agent/foo.ddl").returns(true) - @ddl.expects(:log_code).with(:PLMC18, anything, :debug, :ddlname => "foo", :ddlfile => "/nonexisting/mcollective/agent/foo.ddl") + Log.expects(:debug).with("Found foo ddl at /nonexisting/mcollective/agent/foo.ddl") @ddl.findddlfile("foo").should == "/nonexisting/mcollective/agent/foo.ddl" end diff --git a/spec/unit/log_spec.rb b/spec/unit/log_spec.rb index 585ec712..9791789b 100755 --- a/spec/unit/log_spec.rb +++ b/spec/unit/log_spec.rb @@ -6,10 +6,10 @@ module MCollective describe Log do before do @logger = mock("logger provider") + @logger.stubs(:log) @logger.stubs(:start) @logger.stubs(:set_logging_level) @logger.stubs(:valid_levels) - @logger.stubs(:should_log?).returns(true) @logger.stubs(:new).returns(@logger) # we stub it out at the top of the test suite @@ -17,98 +17,9 @@ module MCollective Log.unstub(:logexception) Log.unstub(:logmsg) - Log.unconfigure Log.set_logger(@logger) end - describe "#config_and_check_level" do - it "should configure then not already configured" do - Log.expects(:configure) - Log.config_and_check_level(:debug) - end - - it "should not reconfigure the logger" do - Log.configure(@logger) - Log.expects(:configure).never - Log.config_and_check_level(:debug) - end - - it "should check the level is valid" do - Log.configure(@logger) - Log.expects(:check_level).with(:debug) - Log.config_and_check_level(:debug) - end - - it "should respect the loggers decision about levels" do - Log.configure(@logger) - @logger.expects(:should_log?).returns(false) - Log.config_and_check_level(:debug).should == false - end - end - - describe "#valid_level?" do - it "should correctly report for valid levels" do - [:error, :fatal, :debug, :warn, :info].each {|level| Log.valid_level?(level).should == true } - Log.valid_level?(:rspec).should == false - end - end - - describe "#message_for" do - it "should return the code and retrieved message" do - Util.expects(:t).with(:PLMC1, {:rspec => true}).returns("this is PLMC1") - Log.message_for(:PLMC1, {:rspec => true}).should == "PLMC1: this is PLMC1" - end - end - - describe "#logexception" do - it "should short circuit messages below current level" do - Log.expects(:config_and_check_level).with(:debug).returns(false) - Log.expects(:log).never - Log.logexception(:PLMC1, :debug, Exception.new, {}) - end - - it "should request the message including the exception string and log it" do - Log.stubs(:config_and_check_level).returns(true) - Log.expects(:message_for).with(:PLMC1, {:rspec => "test", :error => "Exception: this is a test"}).returns("This is a test") - Log.expects(:log).with(:debug, "This is a test", "test:2") - - e = Exception.new("this is a test") - if Util.windows? - e.set_backtrace ['C:\some\dir\test:1', 'C:\some\dir\test:2'] - else - e.set_backtrace ["/some/dir/test:1", "/some/dir/test:2"] - end - - Log.logexception(:PLMC1, :debug, e, false, {:rspec => "test"}) - end - end - - describe "#logmsg" do - it "should short circuit messages below current level" do - Log.expects(:config_and_check_level).with(:debug).returns(false) - Log.expects(:log).never - Log.logmsg(:PLMC1, "", :debug, {}) - end - - it "should request the message and log it" do - Log.stubs(:config_and_check_level).returns(true) - Log.expects(:message_for).with(:PLMC1, {:rspec => "test", :default => "default"}).returns("This is a test") - Log.expects(:log).with(:debug, "This is a test") - Log.logmsg(:PLMC1, "default", :debug, :rspec => "test") - end - end - - describe "#check_level" do - it "should check for valid levels" do - Log.expects(:valid_level?).with(:debug).returns(true) - Log.check_level(:debug) - end - - it "should raise for invalid levels" do - expect { Log.check_level(:rspec) }.to raise_error("Unknown log level") - end - end - describe "#configure" do it "should default to console logging if called prior to configuration" do Config.instance.instance_variable_set("@configured", false) @@ -126,11 +37,8 @@ module MCollective describe "#log" do it "should log at the right levels" do - Log.configure(@logger) - [:debug, :info, :fatal, :error, :warn].each do |level| @logger.expects(:log).with(level, anything, regexp_matches(/#{level} test/)) - @logger.expects(:should_log?).with(level).returns(true) Log.send(level, "#{level} test") end end diff --git a/spec/unit/logger/base_spec.rb b/spec/unit/logger/base_spec.rb index e618f65c..10c5a631 100755 --- a/spec/unit/logger/base_spec.rb +++ b/spec/unit/logger/base_spec.rb @@ -23,18 +23,10 @@ module MCollective::Logger end it "should accept correct levels" do - logger = Base.new - logger.set_level :warn - - logger.should_log?(:debug).should == false - logger.should_log?(:error).should == true + expect { Base.new }.to_not raise_error end end - describe "#should_log?" do - it "should correctly determine if a line should be logged" do - end - end describe "#valid_levels" do it "should report if valid_levels was not implimented" do Base.any_instance.unstub(:valid_levels) diff --git a/spec/unit/logger/console_logger_spec.rb b/spec/unit/logger/console_logger_spec.rb index 15da7bdb..6ae69edb 100644 --- a/spec/unit/logger/console_logger_spec.rb +++ b/spec/unit/logger/console_logger_spec.rb @@ -50,6 +50,15 @@ module Logger logger.log(:error, "rspec", "message", io) end + it "should not log lower than configured levels" do + io = StringIO.new + io.expects(:puts).never + + logger = Console_logger.new + logger.set_level(:warn) + logger.log(:debug, "rspec", "message", io) + end + it "should resort to STDERR output if all else fails" do io = StringIO.new io.expects(:puts).raises diff --git a/spec/unit/logger/syslog_logger_spec.rb b/spec/unit/logger/syslog_logger_spec.rb index 283ca5e6..fb84f495 100644 --- a/spec/unit/logger/syslog_logger_spec.rb +++ b/spec/unit/logger/syslog_logger_spec.rb @@ -59,6 +59,13 @@ module Logger logger.log(:error, "rspec", "rspec") end + it "should not log lower than configured levels" do + logger = Syslog_logger.new + logger.set_level(:fatal) + Syslog.expects(:debug).never + logger.log(:debug, "rspec", "rspec") + end + it "should log using the correctly mapped level" do logger = Syslog_logger.new Syslog.expects(:err).with("rspec rspec").once diff --git a/spec/unit/rpc/agent_spec.rb b/spec/unit/rpc/agent_spec.rb index 76630f24..b02767a4 100755 --- a/spec/unit/rpc/agent_spec.rb +++ b/spec/unit/rpc/agent_spec.rb @@ -35,8 +35,7 @@ module RPC end it "should or validate the incoming request" do - exception = DDLValidationError.new(:RSPEC, "Failed to validate", :error) - Request.any_instance.expects(:validate!).raises(exception) + Request.any_instance.expects(:validate!).raises(DDLValidationError, "Failed to validate") reply = @agent.handlemsg(@msg, DDL.new) @@ -147,7 +146,7 @@ module RPC describe "#meta" do it "should be deprecated" do - Agent.expects(:log_code).with(:PLMC34, is_a(String), :warn, has_value(regexp_matches(/agent_spec.rb/))) + Log.expects(:warn).with(regexp_matches(/Setting metadata in agents has been deprecated/)) Agent.metadata("foo") end end @@ -164,7 +163,8 @@ module RPC it "should fail if the DDL isn't loaded" do DDL.expects(:new).raises("failed to load") - expect { Agent.new }.to raise_code(:PLMC24) + Log.expects(:error).once + expect { Agent.new }.to raise_error(DDLValidationError) end it "should default to 10 second timeout" do diff --git a/spec/unit/util_spec.rb b/spec/unit/util_spec.rb index 59e6e08b..1aaee0ec 100755 --- a/spec/unit/util_spec.rb +++ b/spec/unit/util_spec.rb @@ -11,15 +11,6 @@ class MCollective::Connector::Stomp "connector_plugin", :class => MCollective::Connector::Stomp.new} end - describe "#t" do - it "should correctly translate the message" do - I18n.expects(:t).with("PLMC1.pattern", {:rspec => "test"}) - I18n.expects(:t).with("PLMC1.expanded", {:rspec => "test"}) - Util.t(:PLMC1, :rspec => "test") - Util.t("PLMC1.expanded", :rspec => "test") - end - end - describe "#windows?" do it "should correctly detect windows on unix platforms" do RbConfig::CONFIG.expects("[]").returns("linux") @@ -515,8 +506,7 @@ class MCollective::Connector::Stomp val) - Util.str_to_bool(val).should be_false + expect { Util.str_to_bool(val) }.to raise_error("Cannot convert string value '#{val}' into a boolean.") end end end diff --git a/website/messages/PLMC1.md b/website/messages/PLMC1.md deleted file mode 100644 index 92bf9a6f..00000000 --- a/website/messages/PLMC1.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -layout: default -title: Message detail for PLMC1 -toc: false ---- - -Example Message ---------------- - - The Marionette Collective version 2.2.2 started by /usr/bin/mco using config file /etc/mcollective/client.cfg - -Additional Information ----------------------- - -This message gets logged each time MCollective reads it's config file. Generally this only happens once per process. It shows the version, process name and config file as a simple debugging aid diff --git a/website/messages/PLMC10.md b/website/messages/PLMC10.md deleted file mode 100644 index a0fd7b5b..00000000 --- a/website/messages/PLMC10.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -layout: default -title: Message detail for PLMC10 -toc: false ---- - -Example Message ---------------- - - Failed to handle message: RuntimeError: none.rb:15:in `decodemsg': Could not decrypt message - -Additional Information ----------------------- - -When a message arrives from the middleware it gets decoded, security validated and then dispatched to the agent code. - -There exist a number of errors that can happen here, some are handled specifically others will be logged by this "catch all" handler. - -Generally there should not be many messages logged here but we include a stack trace to assist with debugging these. - -The messages here do not tend to originate from your Agents unless they are syntax error related but more likely to be situations like security failures due to incorrect SSL keys and so forth - -Should you come across one that is a regular accorance in your logs please open a ticket including your backtrace and we will improve the handling of that situation diff --git a/website/messages/PLMC11.md b/website/messages/PLMC11.md deleted file mode 100644 index e07cd16c..00000000 --- a/website/messages/PLMC11.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -layout: default -title: Message detail for PLMC11 -toc: false ---- - -Example Message ---------------- - - Cache expired on 'ddl' key 'agent/nrpe' - -Additional Information ----------------------- - -MCollective has an internal Cache used to speed up operations like parsing of DDL files. The cache is also usable from the agents and other plugins you write. - -Each entry in the cache has an associated TTL or maximum life time, once the maximum time on an item is reached it is considered expired. Next time anything attempts to read this entry from the cache this log line will be logged. - -This is part of the normal operations of MCollective and doesn't indicate any problem. We log this debug message to help you debug your own use of the cache. diff --git a/website/messages/PLMC12.md b/website/messages/PLMC12.md deleted file mode 100644 index c995c7f9..00000000 --- a/website/messages/PLMC12.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -layout: default -title: Message detail for PLMC12 -toc: false ---- - -Example Message ---------------- - - Cache hit on 'ddl' key 'agent/nrpe' - -Additional Information ----------------------- - -MCollective has an internal Cache used to speed up operations like parsing of DDL files. The cache is also usable from the agents and other plugins you write. - -Each entry in the cache has an associated TTL or maximum life time, once the maximum time on an item is reached it is considered expired. - -This log line indicates that a request for a cache entry was made, the entry had not yet expired and so the cached data is being returned. - -It does not indicate a problem, it's just a debugging aid diff --git a/website/messages/PLMC13.md b/website/messages/PLMC13.md deleted file mode 100644 index 5efd236c..00000000 --- a/website/messages/PLMC13.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC13 -toc: false ---- - -Example Message ---------------- - - Could not find a cache called 'my_cache' - -Additional Information ----------------------- - -MCollective has an internal Cache used to speed up operations like parsing of DDL files. The cache is also usable from the agents and other plugins you write. - -The cache is made up of many named caches, this error indicates that a cache has not yet been setup prior to trying to use it. diff --git a/website/messages/PLMC14.md b/website/messages/PLMC14.md deleted file mode 100644 index 8287488a..00000000 --- a/website/messages/PLMC14.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -layout: default -title: Message detail for PLMC14 -toc: false ---- - -Example Message ---------------- - - No block supplied to synchronize on cache 'my_cache' - -Additional Information ----------------------- - -When using the Cache to synchronize your own code across agents or other plugins you have to supply a block to synchronise. - -Correct usage would be: - - Cache.setup(:customer, 600) - Cache(:customer).synchronize do - # update customer record - end - -This error is raise when the logic to update the customer record is not in a block as in the example diff --git a/website/messages/PLMC15.md b/website/messages/PLMC15.md deleted file mode 100644 index 74afc2dd..00000000 --- a/website/messages/PLMC15.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC15 -toc: false ---- - -Example Message ---------------- - - No item called 'nrpe_agent' for cache 'ddl' - -Additional Information ----------------------- - -MCollective has an internal Cache used to speed up operations like parsing of DDL files. The cache is also usable from the agents and other plugins you write. - -The cache stored items using a key, this error will be logged and raised when you try to access a item that does not yet exist in the cache. diff --git a/website/messages/PLMC16.md b/website/messages/PLMC16.md deleted file mode 100644 index b169953d..00000000 --- a/website/messages/PLMC16.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -layout: default -title: Message detail for PLMC16 -toc: false ---- - -Example Message ---------------- - - 'hello' does not look like a numeric value - -Additional Information ----------------------- - -When MCollective receives an argument from the command line like port=fello it consults the DDL file to determine the desired type of this parameter, it then tries to convert the input string into the correct numeric value. - -This error indicates the input you provided could not be converted into the desired format. - -You'll usually see this when using the 'mco rpc' command to interact with an agent. This is usually a fatal error, the request will not be sent if it does not validate against the DDL. diff --git a/website/messages/PLMC17.md b/website/messages/PLMC17.md deleted file mode 100644 index bf3ededb..00000000 --- a/website/messages/PLMC17.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -layout: default -title: Message detail for PLMC17 -toc: false ---- - -Example Message ---------------- - - 'flase' does not look like a boolean value - -Additional Information ----------------------- - -When MCollective receives an argument from the command line like force=true it consults the DDL file to determine the desired type of this parameter, it then tries to convert the input string into the correct boolean value. - -This error indicates the input you provided could not be converted into the desired boolean format. It wil accept "true", "t", "yes", "y" and "1" as being true. It will accept "false", "f", "no", "n", "0" as being false. - -You'll usually see this when using the 'mco rpc' command to interact with an agent. This is usually a fatal error, the request will not be sent if it does not validate against the DDL. diff --git a/website/messages/PLMC18.md b/website/messages/PLMC18.md deleted file mode 100644 index f7152670..00000000 --- a/website/messages/PLMC18.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC18 -toc: false ---- - -Example Message ---------------- - - Found 'rpcutil' ddl at '/usr/libexec/mcollective/mcollective/agent/rpcutil.ddl' - -Additional Information ----------------------- - -Most plugin types have a DDL file that needs to be correctly installed for the plugin to function. There can be multiple libdirs that can provide the DDL file for a specific plugin. - -This message is a message designed to help you debug issues when you think the wrong DDL file is being used. diff --git a/website/messages/PLMC19.md b/website/messages/PLMC19.md deleted file mode 100644 index f449db57..00000000 --- a/website/messages/PLMC19.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -layout: default -title: Message detail for PLMC19 -toc: false ---- - -Example Message ---------------- - - DDL requirements validation being skipped in development - -Additional Information ----------------------- - -Usually when MCollective run it validates all requirements are met before publishing a request or processing a request against the DDL file for the agent. - -This can be difficult to satisfy in development perhaps because you are still writing your DDL files or debugging issues. - -This message indicates that when MCollective detects it's running against an unreleased version of MCollective - like directly out of a Git clone - it will skip the DDL validation steps. It is logged at a warning level as this significantly changes the behaviour of the client and server. diff --git a/website/messages/PLMC2.md b/website/messages/PLMC2.md deleted file mode 100644 index 39fb4763..00000000 --- a/website/messages/PLMC2.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -layout: default -title: Message detail for PLMC2 -toc: false ---- - -Example Message ---------------- - - Reloading all agents after receiving USR1 signal - -Additional Information ----------------------- - -When sending the mcollectived process the USR1 signal on a Unix based machine this message will indicate that the signal got received and all agents are being reloaded from disk diff --git a/website/messages/PLMC20.md b/website/messages/PLMC20.md deleted file mode 100644 index d9e01916..00000000 --- a/website/messages/PLMC20.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC20 -toc: false ---- - -Example Message ---------------- - - Agent plugin 'example' requires MCollective version 2.2.1 or newer - -Additional Information ----------------------- - -MCollective plugins can declare a minimum version of MCollective that they require to be functional. - -MCollective validates this when it loads the plugin and this error will be logged or shown to the user when this requirement cannot be satisfied. diff --git a/website/messages/PLMC21.md b/website/messages/PLMC21.md deleted file mode 100644 index 242e7f08..00000000 --- a/website/messages/PLMC21.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC21 -toc: false ---- - -Example Message ---------------- - - Cannot validate input 'service': Input string is longer than 40 character(s) - -Additional Information ----------------------- - -Every input you provide to a RPC request is validated against it's DDL file. This error will be shown when the supplied data does not pass validation against the DDL. - -Consult the 'mco plugin doc' command to view the DDL file for your action and input. diff --git a/website/messages/PLMC22.md b/website/messages/PLMC22.md deleted file mode 100644 index 7d7dc622..00000000 --- a/website/messages/PLMC22.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -layout: default -title: Message detail for PLMC22 -toc: false ---- - -Example Message ---------------- - - Cannot determine what entity input 'port' belongs to - -Additional Information ----------------------- - -When writing a DDL you declare inputs into plugins using the input keyword. Each input has to belong to a wrapping entity like in the example below: - - action "get_data", :description => "Get data from a data plugin" do - input :source, - :prompt => "Data Source", - :description => "The data plugin to retrieve information from", - :type => :string, - :validation => '^\w+$', - :optional => false, - :maxlength => 50 - end - -Here the input belongs to the action entity "get_data", this error indicates that an input were found without it belonging to any specific entity diff --git a/website/messages/PLMC23.md b/website/messages/PLMC23.md deleted file mode 100644 index b782478c..00000000 --- a/website/messages/PLMC23.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -layout: default -title: Message detail for PLMC23 -toc: false ---- - -Example Message ---------------- - - Input needs a :prompt property - -Additional Information ----------------------- - -When writing a DDL you declare inputs for all data that you pass into the plugin. Inputs have a minimally required field set and this error indicate that you did not provide some key field while describing the input. diff --git a/website/messages/PLMC24.md b/website/messages/PLMC24.md deleted file mode 100644 index 423d4e91..00000000 --- a/website/messages/PLMC24.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC24 -toc: false ---- - -Example Message ---------------- - - Failed to load DDL for the 'rpcutil' agent, DDLs are required: RuntimeError: failed to parse DDL file - -Additional Information ----------------------- - -As of version 2.0.0 DDL files are required by the MCollective server. This server indicates that it either could not find the DDL for the rpcutil agent or that there was a syntax error. - -Confirm that the DDL file is installed in the agent directory and that it parses correctly using the 'mco plugin doc' command. diff --git a/website/messages/PLMC25.md b/website/messages/PLMC25.md deleted file mode 100644 index 14fb3215..00000000 --- a/website/messages/PLMC25.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -layout: default -title: Message detail for PLMC25 -toc: false ---- - -Example Message ---------------- - - aggregate method for action 'rpcutil' is missing a function parameter - -Additional Information ----------------------- - -DDL files can declare aggregation rules for the data returned by actions as seen below: - - summarize do - aggregate summary(:collectives) - end - -This error indicates that you did not supply the argument - :collectives in this example. diff --git a/website/messages/PLMC26.md b/website/messages/PLMC26.md deleted file mode 100644 index 15f8335f..00000000 --- a/website/messages/PLMC26.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC26 -toc: false ---- - -Example Message ---------------- - - Functions supplied to aggregate should be a hash - -Additional Information ----------------------- - -Internally when MCollective parse the DDL it converts the aggregate functions into a hash with the function name and any arguments. - -This error indicates that the internal translation failed, this is a critical error and would probably indicate a structure problem in your DDL or a bug in MCollective diff --git a/website/messages/PLMC27.md b/website/messages/PLMC27.md deleted file mode 100644 index 77f955f7..00000000 --- a/website/messages/PLMC27.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -layout: default -title: Message detail for PLMC27 -toc: false ---- - -Example Message ---------------- - - Formats supplied to aggregation functions must have a :format key - -Additional Information ----------------------- - -DDL aggregate functions can take a custom format as in the example below: - - aggregate average(:total_resources, :format => "Average: %d") - -This error indicate that the :format above could not be correctly parsed. diff --git a/website/messages/PLMC28.md b/website/messages/PLMC28.md deleted file mode 100644 index 160bbe66..00000000 --- a/website/messages/PLMC28.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -layout: default -title: Message detail for PLMC28 -toc: false ---- - -Example Message ---------------- - - Formats supplied to aggregation functions should be a hash - -Additional Information ----------------------- - -DDL aggregate functions can take a custom format as in the example below: - - aggregate average(:total_resources, :format => "Average: %d") - -This error indicate that the :format above was not supplied as a hash as in the above example diff --git a/website/messages/PLMC29.md b/website/messages/PLMC29.md deleted file mode 100644 index 17abe894..00000000 --- a/website/messages/PLMC29.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC29 -toc: false ---- - -Example Message ---------------- - - Attempted to call action 'yum_clean' for 'package' but it's not declared in the DDL - -Additional Information ----------------------- - -Every agent has a DDL file that describes valid actions that they can perform - -This error indicates you attempted to perform an action that does not exist. Review the plugin documentation using 'mco plugin doc' for correct usage diff --git a/website/messages/PLMC3.md b/website/messages/PLMC3.md deleted file mode 100644 index 8e1c90af..00000000 --- a/website/messages/PLMC3.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -layout: default -title: Message detail for PLMC3 -toc: false ---- - -Example Message ---------------- - - Cycling logging level due to USR2 signal - -Additional Information ----------------------- - -When sending the mcollectived process the USR2 signal on a Unix based machine this message indicates that the signal for received and the logging level is being adjusted to the next higher level or back down to debug if it was already at it's highest level. - -This message will be followed by another message similar to the one below: - - Logging level is now WARN diff --git a/website/messages/PLMC30.md b/website/messages/PLMC30.md deleted file mode 100644 index 95a947f9..00000000 --- a/website/messages/PLMC30.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -layout: default -title: Message detail for PLMC30 -toc: false ---- - -Example Message ---------------- - - Action 'get_fact' needs a 'fact' argument - -Additional Information ----------------------- - -Actions can declare that they expect a required input, this error indicates that you did not supply the required input diff --git a/website/messages/PLMC31.md b/website/messages/PLMC31.md deleted file mode 100644 index 9ac14bd2..00000000 --- a/website/messages/PLMC31.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -layout: default -title: Message detail for PLMC31 -toc: false ---- - -Example Message ---------------- - - No dataquery has been defined in the DDL for data plugin 'package' - -Additional Information ----------------------- - -Each data plugin requires a DDL that has a 'dataquery' block in it. - - dataquery :description => "Agent Meta Data" do - . - . - end - -This error indicates that the DDL file for a specific data plugin did not contain this block. diff --git a/website/messages/PLMC32.md b/website/messages/PLMC32.md deleted file mode 100644 index c432da92..00000000 --- a/website/messages/PLMC32.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -layout: default -title: Message detail for PLMC32 -toc: false ---- - -Example Message ---------------- - - No output has been defined in the DDL for data plugin '%{plugin}' - -Additional Information ----------------------- - -Data plugins must return data. The DDL files for a data plugin must declare at least one output parameter else you will see this error. diff --git a/website/messages/PLMC33.md b/website/messages/PLMC33.md deleted file mode 100644 index 2bf994d4..00000000 --- a/website/messages/PLMC33.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC33 -toc: false ---- - -Example Message ---------------- - - No data plugin argument was declared in the 'puppet' DDL but an input was supplied - -Additional Information ----------------------- - -Data plugins can take an optional input argument. This error indicate that you supplied an input argument but the plugin does not actually expect any input. - -Review the documentation for the data plugin using 'mco plugin doc' diff --git a/website/messages/PLMC34.md b/website/messages/PLMC34.md deleted file mode 100644 index a14ffbe2..00000000 --- a/website/messages/PLMC34.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -layout: default -title: Message detail for PLMC34 -toc: false ---- - -Example Message ---------------- - - setting meta data in agents have been deprecated, DDL files are now being used for this information. Please update the 'package' agent - -Additional Information ----------------------- - -In the past each MCollective agent had a metadata section containing information like the timeout. - -As of 2.2.0 the agents will now consult the DDL files that ship with each agent for this purpose so the metadata in agents are not used at all. - -In order to remove confusing duplication setting metadata in agents have been deprecated and from version 2.4.0 will not be supported at all. - -Please update your agent by removing the metadata section from it and make sure the DDL file has the correct information instead. diff --git a/website/messages/PLMC35.md b/website/messages/PLMC35.md deleted file mode 100644 index 083d4780..00000000 --- a/website/messages/PLMC35.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC35 -toc: false ---- - -Example Message ---------------- - - Client did not request a response, surpressing reply - -Additional Information ----------------------- - -The MCollective client can ask that the agent just performs the action and never respond. Like when supplying the --no-results option to the 'mco rpc' application. - -This log line indicates that the request was received and interpreted as such and no reply will be sent. This does not indicate a problem generally it's just there to assist with debugging of problems. diff --git a/website/messages/PLMC36.md b/website/messages/PLMC36.md deleted file mode 100644 index ebfa38bd..00000000 --- a/website/messages/PLMC36.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -layout: default -title: Message detail for PLMC36 -toc: false ---- - -Example Message ---------------- - - Unknown action 'png' for agent 'rpcutil' - -Additional Information ----------------------- - -Agents are made up of a number of named actions. When the MCollective Server receives a request it double checks if the agent in question actually implements the logic for a specific action. - -When it cannot find the implementation this error will be raised. This is an unusual situation since at this point on both the client and the server the DDL will already have been used to validate the request and the DDL would have indicated that the action is valid. - -Check your agent code and make sure you have code like: - - action "the_action" do - . - . - end diff --git a/website/messages/PLMC37.md b/website/messages/PLMC37.md deleted file mode 100644 index a047b506..00000000 --- a/website/messages/PLMC37.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC37 -toc: false ---- - -Example Message ---------------- - - Starting default activation checks for the 'rpcutil' agent - -Additional Information ----------------------- - -Each time the MCollective daemon starts it loads each agent from disk. It then tries to determine if the agent should start on this node by using the activate_when method or per-agent configuration. - -This is a debug statement that shows you it is about to start interacting with the logic in the agent to determine if it should be made available or not. diff --git a/website/messages/PLMC38.md b/website/messages/PLMC38.md deleted file mode 100644 index 1c984759..00000000 --- a/website/messages/PLMC38.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -layout: default -title: Message detail for PLMC38 -toc: false ---- - -Example Message ---------------- - - Found plugin configuration 'exim.activate_agent' with value 'y' - -Additional Information ----------------------- - -The administrator can choose that a certain agent that is deployed on this machine should not be made available to the network. - -To do this you would add a configuration value like this example to the mcollective server.cfg: - - plugin.exim.activate_agent = n - -If this value is "1", "y" or "true" the agent will be activated else it will be disabled. diff --git a/website/messages/PLMC39.md b/website/messages/PLMC39.md deleted file mode 100644 index 728abf90..00000000 --- a/website/messages/PLMC39.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC39 -toc: false ---- - -Example Message ---------------- - - Audit failed with an error, processing the request will continue. - -Additional Information ----------------------- - -Every MCollective request can be audited. In the event where the auditing fails the processing continues. - -At present the failure handling is not configurable, in future the administrator might elect to not run unaudited requests via configuration. diff --git a/website/messages/PLMC4.md b/website/messages/PLMC4.md deleted file mode 100644 index 57e586c0..00000000 --- a/website/messages/PLMC4.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC4 -toc: false ---- - -Example Message ---------------- - - Failed to start registration plugin: ArgumentError: meta.rb:6:in `gsub': wrong number of arguments (0 for 2) - -Additional Information ----------------------- - -Registration plugins are loaded into the MCollective daemon at startup and ran on a regular interval. - -This message indicate that on first start this plugin failed to run, it will show the exception class, line and exception message to assist with debugging diff --git a/website/messages/PLMC5.md b/website/messages/PLMC5.md deleted file mode 100644 index 38f22feb..00000000 --- a/website/messages/PLMC5.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC5 -toc: false ---- - -Example Message ---------------- - - Received a control message, possibly via 'mco controller' but this has been deprecated - -Additional Information ----------------------- - -In previous versions of MCollective a application called 'controller' were included that had the ability to request agent reloads and other commands that would control the runner. - -Unfortunately this method of controlling the daemon was never considered stable or reliable and has since been deprecate for removal during the 2.3.x development series diff --git a/website/messages/PLMC6.md b/website/messages/PLMC6.md deleted file mode 100644 index 42e7e983..00000000 --- a/website/messages/PLMC6.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -layout: default -title: Message detail for PLMC6 -toc: false ---- - -Example Message ---------------- - - Message does not pass filters, ignoring - -Additional Information ----------------------- - -When a specific MCollective daemon receives a message from a network it validates the filter before processing the message. The filter is the list of classes, facts or other conditions that are associated with any message. - -In the case where the filter does not match the specific host this line gets logged. - -It's often the case for broadcast messages that all MCollective nodes will receive a message but only a subset of nodes are targetted using the filters, in that situation the nodes that received the request but should not respond to it will see this log line. - -It does not indicate anything to be concerned about but if you find debugging a problem and expect a node to have responded when it shouldn't this log line will give you a hint that some condition specified in the filter did not match the local host diff --git a/website/messages/PLMC7.md b/website/messages/PLMC7.md deleted file mode 100644 index 1a5a0649..00000000 --- a/website/messages/PLMC7.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC7 -toc: false ---- - -Example Message ---------------- - - Exiting after signal: SignalException: runner.rb:6:in `run': Interrupt - -Additional Information ----------------------- - -When the MCollective daemon gets a signal from the Operating System that it does not specifically handle it will log this line before exiting. - -You would see this whenever the daemon is stopped by init script or when sending it a kill signal, it will then proceed to disconnect from the middleware and exit its main loop diff --git a/website/messages/PLMC8.md b/website/messages/PLMC8.md deleted file mode 100644 index 53546a5b..00000000 --- a/website/messages/PLMC8.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -layout: default -title: Message detail for PLMC8 -toc: false ---- - -Example Message ---------------- - - Handling message for agent 'rpcutil' on collective 'eu_collective' with requestid 'a8a78d0ff555c931f045b6f448129846' - -Additional Information ----------------------- - -After receiving a message from the middleware, decoding it, validating it's security credentials and doing other checks on it the MCollective daemon will pass it off to the actual agent code for processing. - -Prior to doing so it will log this line indicating the agent name and sub-collective and other information that will assist in correlating the message sent from the client with those in the server logs being processed. diff --git a/website/messages/PLMC9.md b/website/messages/PLMC9.md deleted file mode 100644 index fe8818b5..00000000 --- a/website/messages/PLMC9.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -layout: default -title: Message detail for PLMC9 -toc: false ---- - -Example Message ---------------- - - Expired Message: message 8b4fe522f0d0541dabe83ec10b7fa446 from cert=client@node created at 1358840888 is 653 seconds old, TTL is 60 - -Additional Information ----------------------- - -Requests sent from clients to servers all have a creation time and a maximum validity time called a TTL. - -This message indicates that a message was received from the network but that it was determined to be too based on the TTL settings. - -Usually this happens because your clocks are not in sync - something that can be fixed by rolling out a tool like ntp across your server estate. - -It might also happen during very slow network conditions or when the TTL is set too low for your general network latency.