]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Prep for stdlib merge
authorKen Barber <ken@bob.sh>
Fri, 5 Aug 2011 07:25:03 +0000 (08:25 +0100)
committerKen Barber <ken@bob.sh>
Fri, 5 Aug 2011 07:25:03 +0000 (08:25 +0100)
* Renamed load_yaml & load_json to parseyaml & parsejson
* Renamed is_valid_* functions and remove the 'valid_'

lib/puppet/parser/functions/is_domain_name.rb [moved from lib/puppet/parser/functions/is_valid_domain_name.rb with 73% similarity]
lib/puppet/parser/functions/is_ip_address.rb [moved from lib/puppet/parser/functions/is_valid_ip_address.rb with 72% similarity]
lib/puppet/parser/functions/is_mac_address.rb [moved from lib/puppet/parser/functions/is_valid_mac_address.rb with 72% similarity]
lib/puppet/parser/functions/parsejson.rb [moved from lib/puppet/parser/functions/load_json.rb with 72% similarity]
lib/puppet/parser/functions/parseyaml.rb [moved from lib/puppet/parser/functions/load_yaml.rb with 71% similarity]
spec/unit/parser/functions/is_domain_name_spec.rb [moved from spec/unit/parser/functions/is_valid_domain_name_spec.rb with 55% similarity]
spec/unit/parser/functions/is_ip_address_spec.rb [moved from spec/unit/parser/functions/is_valid_ip_address_spec.rb with 55% similarity]
spec/unit/parser/functions/is_mac_address_spec.rb [moved from spec/unit/parser/functions/is_valid_mac_address_spec.rb with 54% similarity]
spec/unit/parser/functions/parsejson_spec.rb [moved from spec/unit/parser/functions/load_json_spec.rb with 66% similarity]
spec/unit/parser/functions/parseyaml_spec.rb [moved from spec/unit/parser/functions/load_yaml_spec.rb with 66% similarity]

similarity index 73%
rename from lib/puppet/parser/functions/is_valid_domain_name.rb
rename to lib/puppet/parser/functions/is_domain_name.rb
index 7dd9c0be64f508fae3658e935216d7894e7fcbb8..4e9293972b9d4805d4abfb3710ef6024345e38b0 100644 (file)
@@ -1,15 +1,15 @@
 #
-# is_valid_domain_name.rb
+# is_domain_name.rb
 #
 
 module Puppet::Parser::Functions
-  newfunction(:is_valid_domain_name, :type => :rvalue, :doc => <<-EOS
+  newfunction(:is_domain_name, :type => :rvalue, :doc => <<-EOS
 Returns true if the string passed to this function is a valid IP address. Support for IPv4 and IPv6 address types is included.
     EOS
   ) do |arguments|
 
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "is_valid_domain_name(): Wrong number of arguments "+
+      raise(Puppet::ParseError, "is_domain_name(): Wrong number of arguments "+
         "given #{arguments.size} for 1")
     end
 
similarity index 72%
rename from lib/puppet/parser/functions/is_valid_ip_address.rb
rename to lib/puppet/parser/functions/is_ip_address.rb
index 604d93897455956328b36ace82b4b93f1288cb00..b4a9a15dd32bda74aee61a64bc36b1729d28b235 100644 (file)
@@ -1,9 +1,9 @@
 #
-# is_valid_ip_address.rb
+# is_ip_address.rb
 #
 
 module Puppet::Parser::Functions
-  newfunction(:is_valid_ip_address, :type => :rvalue, :doc => <<-EOS
+  newfunction(:is_ip_address, :type => :rvalue, :doc => <<-EOS
 Returns true if the string passed to this function is a valid IP address.
     EOS
   ) do |arguments|
@@ -11,7 +11,7 @@ Returns true if the string passed to this function is a valid IP address.
     require 'ipaddr'
 
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "is_valid_ip_address(): Wrong number of arguments "+
+      raise(Puppet::ParseError, "is_ip_address(): Wrong number of arguments "+
         "given #{arguments.size} for 1")
     end
 
similarity index 72%
rename from lib/puppet/parser/functions/is_valid_mac_address.rb
rename to lib/puppet/parser/functions/is_mac_address.rb
index 53199b64af2d1653dce772223a0257469b0a2a41..1b3088a26aaa461d7e32c8db08f24f1bab4f159d 100644 (file)
@@ -1,15 +1,15 @@
 #
-# is_valid_mac_address.rb
+# is_mac_address.rb
 #
 
 module Puppet::Parser::Functions
-  newfunction(:is_valid_mac_address, :type => :rvalue, :doc => <<-EOS
+  newfunction(:is_mac_address, :type => :rvalue, :doc => <<-EOS
 Returns true if the string passed to this function is a valid mac address.
     EOS
   ) do |arguments|
 
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "is_valid_mac_address(): Wrong number of arguments "+
+      raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments "+
         "given #{arguments.size} for 1")
     end
 
similarity index 72%
rename from lib/puppet/parser/functions/load_json.rb
rename to lib/puppet/parser/functions/parsejson.rb
index 333cf11aa2bbb4de83f7d5a2827bf46dd3a9af7b..cf3b12c5c1315c22e94b2e7668b4eb60363d6e7d 100644 (file)
@@ -1,16 +1,16 @@
 #
-# load_json.rb
+# parsejson.rb
 #
 
 module Puppet::Parser::Functions
-  newfunction(:load_json, :type => :rvalue, :doc => <<-EOS
+  newfunction(:parsejson, :type => :rvalue, :doc => <<-EOS
 This function accepts JSON as a string and converts into the correct Puppet
 structure.
     EOS
   ) do |arguments|
 
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "load_json(): Wrong number of arguments "+
+      raise(Puppet::ParseError, "parsejson(): Wrong number of arguments "+
         "given #{arguments.size} for 1")
     end
 
similarity index 71%
rename from lib/puppet/parser/functions/load_yaml.rb
rename to lib/puppet/parser/functions/parseyaml.rb
index 26832772ea0b71914aad378dd93a8646fbd17fc0..e8ac8a4cb950e41a374d8247fb5df9be49ed09fb 100644 (file)
@@ -1,16 +1,16 @@
 #
-# load_yaml.rb
+# parseyaml.rb
 #
 
 module Puppet::Parser::Functions
-  newfunction(:load_yaml, :type => :rvalue, :doc => <<-EOS
+  newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS
 This function accepts YAML as a string and converts it into the correct 
 Puppet structure.
     EOS
   ) do |arguments|
 
     if (arguments.size != 1) then
-      raise(Puppet::ParseError, "load_yaml(): Wrong number of arguments "+
+      raise(Puppet::ParseError, "parseyaml(): Wrong number of arguments "+
         "given #{arguments.size} for 1")
     end
 
similarity index 55%
rename from spec/unit/parser/functions/is_valid_domain_name_spec.rb
rename to spec/unit/parser/functions/is_domain_name_spec.rb
index 3339447fef0b4ee1e7b21ac937888a57eea2b548..ec7c7f5decafbb5d873a0a25ada37435e331d529 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env rspec
 require 'spec_helper'
 
-describe "the is_valid_domain_name function" do
+describe "the is_domain_name function" do
   before :all do
     Puppet::Parser::Functions.autoloader.loadall
   end
@@ -11,45 +11,45 @@ describe "the is_valid_domain_name function" do
   end
 
   it "should exist" do
-    Puppet::Parser::Functions.function("is_valid_domain_name").should == "function_is_valid_domain_name"
+    Puppet::Parser::Functions.function("is_domain_name").should == "function_is_domain_name"
   end
 
   it "should raise a ParseError if there is less than 1 arguments" do
-    lambda { @scope.function_is_valid_domain_name([]) }.should( raise_error(Puppet::ParseError))
+    lambda { @scope.function_is_domain_name([]) }.should( raise_error(Puppet::ParseError))
   end
 
   it "should return true if a valid domain name" do
-    result = @scope.function_is_valid_domain_name(["foo.bar.com"])
+    result = @scope.function_is_domain_name(["foo.bar.com"])
     result.should(be_true)
   end
 
   it "should allow domain parts to start with numbers" do
-    result = @scope.function_is_valid_domain_name(["3foo.2bar.com"])
+    result = @scope.function_is_domain_name(["3foo.2bar.com"])
     result.should(be_true)
   end
 
   it "should allow domain to end with a dot" do
-    result = @scope.function_is_valid_domain_name(["3foo.2bar.com."])
+    result = @scope.function_is_domain_name(["3foo.2bar.com."])
     result.should(be_true)
   end
 
   it "should allow a single part domain" do
-    result = @scope.function_is_valid_domain_name(["orange"])
+    result = @scope.function_is_domain_name(["orange"])
     result.should(be_true)
   end
 
   it "should return false if domain parts start with hyphens" do
-    result = @scope.function_is_valid_domain_name(["-3foo.2bar.com"])
+    result = @scope.function_is_domain_name(["-3foo.2bar.com"])
     result.should(be_false)
   end
 
   it "should return true if domain contains hyphens" do
-    result = @scope.function_is_valid_domain_name(["3foo-bar.2bar-fuzz.com"])
+    result = @scope.function_is_domain_name(["3foo-bar.2bar-fuzz.com"])
     result.should(be_true)
   end
 
   it "should return false if domain name contains spaces" do
-    result = @scope.function_is_valid_domain_name(["not valid"])
+    result = @scope.function_is_domain_name(["not valid"])
     result.should(be_false)
   end
 
similarity index 55%
rename from spec/unit/parser/functions/is_valid_ip_address_spec.rb
rename to spec/unit/parser/functions/is_ip_address_spec.rb
index 2883aaa33ecd0fbab612ee610f40328a06269d28..98ce8283a941e8709e35299bd006f7adc3af68de 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env rspec
 require 'spec_helper'
 
-describe "the is_valid_ip_address function" do
+describe "the is_ip_address function" do
   before :all do
     Puppet::Parser::Functions.autoloader.loadall
   end
@@ -11,35 +11,35 @@ describe "the is_valid_ip_address function" do
   end
 
   it "should exist" do
-    Puppet::Parser::Functions.function("is_valid_ip_address").should == "function_is_valid_ip_address"
+    Puppet::Parser::Functions.function("is_ip_address").should == "function_is_ip_address"
   end
 
   it "should raise a ParseError if there is less than 1 arguments" do
-    lambda { @scope.function_is_valid_ip_address([]) }.should( raise_error(Puppet::ParseError))
+    lambda { @scope.function_is_ip_address([]) }.should( raise_error(Puppet::ParseError))
   end
 
   it "should return true if an IPv4 address" do
-    result = @scope.function_is_valid_ip_address(["1.2.3.4"])
+    result = @scope.function_is_ip_address(["1.2.3.4"])
     result.should(eq(true))
   end
 
   it "should return true if a full IPv6 address" do
-    result = @scope.function_is_valid_ip_address(["fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"])
+    result = @scope.function_is_ip_address(["fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"])
     result.should(eq(true))
   end
 
   it "should return true if a compressed IPv6 address" do
-    result = @scope.function_is_valid_ip_address(["fe00::1"])
+    result = @scope.function_is_ip_address(["fe00::1"])
     result.should(eq(true))
   end
 
   it "should return false if not valid" do
-    result = @scope.function_is_valid_ip_address(["asdf"])
+    result = @scope.function_is_ip_address(["asdf"])
     result.should(eq(false))
   end
 
   it "should return false if IP octets out of range" do
-    result = @scope.function_is_valid_ip_address(["1.1.1.300"])
+    result = @scope.function_is_ip_address(["1.1.1.300"])
     result.should(eq(false))
   end
 end
similarity index 54%
rename from spec/unit/parser/functions/is_valid_mac_address_spec.rb
rename to spec/unit/parser/functions/is_mac_address_spec.rb
index 62e6fee6799042c8d8221940e18f9731a6aa6c75..c9b963791c8132088babb3492e2e906ac1e39b88 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env rspec
 require 'spec_helper'
 
-describe "the is_valid_mac_address function" do
+describe "the is_mac_address function" do
   before :all do
     Puppet::Parser::Functions.autoloader.loadall
   end
@@ -11,25 +11,25 @@ describe "the is_valid_mac_address function" do
   end
 
   it "should exist" do
-    Puppet::Parser::Functions.function("is_valid_mac_address").should == "function_is_valid_mac_address"
+    Puppet::Parser::Functions.function("is_mac_address").should == "function_is_mac_address"
   end
 
   it "should raise a ParseError if there is less than 1 arguments" do
-    lambda { @scope.function_is_valid_mac_address([]) }.should( raise_error(Puppet::ParseError))
+    lambda { @scope.function_is_mac_address([]) }.should( raise_error(Puppet::ParseError))
   end
 
   it "should return true if a valid mac address" do
-    result = @scope.function_is_valid_mac_address(["00:a0:1f:12:7f:a0"])
+    result = @scope.function_is_mac_address(["00:a0:1f:12:7f:a0"])
     result.should(eq(true))
   end
 
   it "should return false if octets are out of range" do
-    result = @scope.function_is_valid_mac_address(["00:a0:1f:12:7f:g0"])
+    result = @scope.function_is_mac_address(["00:a0:1f:12:7f:g0"])
     result.should(eq(false))
   end
 
   it "should return false if not valid" do
-    result = @scope.function_is_valid_mac_address(["not valid"])
+    result = @scope.function_is_mac_address(["not valid"])
     result.should(eq(false))
   end
 
similarity index 66%
rename from spec/unit/parser/functions/load_json_spec.rb
rename to spec/unit/parser/functions/parsejson_spec.rb
index 73a4566180fcdf4efc8c786ffc516f6558f26a55..26eea360353658741ca75a8bbe8a7590a22c96de 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env rspec
 require 'spec_helper'
 
-describe "the load_json function" do
+describe "the parsejson function" do
   before :all do
     Puppet::Parser::Functions.autoloader.loadall
   end
@@ -11,18 +11,18 @@ describe "the load_json function" do
   end
 
   it "should exist" do
-    Puppet::Parser::Functions.function("load_json").should == "function_load_json"
+    Puppet::Parser::Functions.function("parsejson").should == "function_parsejson"
   end
 
   it "should raise a ParseError if there is less than 1 arguments" do
-    lambda { @scope.function_load_json([]) }.should( raise_error(Puppet::ParseError))
+    lambda { @scope.function_parsejson([]) }.should( raise_error(Puppet::ParseError))
   end
 
   it "should convert JSON to a data structure" do
     json = <<-EOS
 ["aaa","bbb","ccc"]
 EOS
-    result = @scope.function_load_json([json])
+    result = @scope.function_parsejson([json])
     result.should(eq(['aaa','bbb','ccc']))
   end
 
similarity index 66%
rename from spec/unit/parser/functions/load_yaml_spec.rb
rename to spec/unit/parser/functions/parseyaml_spec.rb
index 2498d121e45a1771bbe47ec8b438f75f3c3199d1..f9cb049038bc0592f75a4c55c5cd92c3ba51c2be 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env rspec
 require 'spec_helper'
 
-describe "the load_yaml function" do
+describe "the parseyaml function" do
   before :all do
     Puppet::Parser::Functions.autoloader.loadall
   end
@@ -11,11 +11,11 @@ describe "the load_yaml function" do
   end
 
   it "should exist" do
-    Puppet::Parser::Functions.function("load_yaml").should == "function_load_yaml"
+    Puppet::Parser::Functions.function("parseyaml").should == "function_parseyaml"
   end
 
   it "should raise a ParseError if there is less than 1 arguments" do
-    lambda { @scope.function_load_yaml([]) }.should( raise_error(Puppet::ParseError))
+    lambda { @scope.function_parseyaml([]) }.should( raise_error(Puppet::ParseError))
   end
 
   it "should convert YAML to a data structure" do
@@ -24,7 +24,7 @@ describe "the load_yaml function" do
 - bbb
 - ccc
 EOS
-    result = @scope.function_load_yaml([yaml])
+    result = @scope.function_parseyaml([yaml])
     result.should(eq(['aaa','bbb','ccc']))
   end