]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Count functionality overlaps with size - so removing it.
authorKen Barber <ken@bob.sh>
Thu, 28 Jul 2011 20:30:02 +0000 (21:30 +0100)
committerKen Barber <ken@bob.sh>
Thu, 28 Jul 2011 20:30:02 +0000 (21:30 +0100)
lib/puppet/parser/functions/count.rb [deleted file]
spec/unit/parser/functions/count_spec.rb [deleted file]

diff --git a/lib/puppet/parser/functions/count.rb b/lib/puppet/parser/functions/count.rb
deleted file mode 100644 (file)
index c4e2283..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# count.rb
-#
-
-# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
-# TODO(Krzysztof Wilczynski): Support for hash values would be nice too ...
-
-module Puppet::Parser::Functions
-  newfunction(:count, :type => :rvalue, :doc => <<-EOS
-    EOS
-  ) do |arguments|
-
-    # Technically we support two arguments but only first is mandatory ...
-    raise(Puppet::ParseError, "count(): Wrong number of arguments " +
-      "given (#{arguments.size} for 1)") if arguments.size < 1
-
-    value = arguments[0]
-    klass = value.class
-
-    unless [Array, Hash, String].include?(klass)
-      raise(Puppet::ParseError, 'count(): Requires either ' +
-        'array, hash or string to work with')
-    end
-
-    item = arguments[1] if arguments[1]
-
-    value = value.is_a?(Hash) ? value.keys : value
-
-    # No item to look for and count?  Then just return current size ...
-    result = item ? value.count(item) : value.size
-
-    return result
-  end
-end
-
-# vim: set ts=2 sw=2 et :
diff --git a/spec/unit/parser/functions/count_spec.rb b/spec/unit/parser/functions/count_spec.rb
deleted file mode 100755 (executable)
index 62d005a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env rspec
-require 'spec_helper'
-
-describe "the count function" do
-  before :all do
-    Puppet::Parser::Functions.autoloader.loadall
-  end
-
-  before :each do
-    @scope = Puppet::Parser::Scope.new
-  end
-
-  it "should exist" do
-    Puppet::Parser::Functions.function("count").should == "function_count"
-  end
-
-  it "should raise a ParseError if there is less than 1 arguments" do
-    lambda { @scope.function_count([]) }.should( raise_error(Puppet::ParseError))
-  end
-
-  it "should return the size of an array" do
-    result = @scope.function_count([['a','c','b']])
-    result.should(eq(3))
-  end
-
-end