summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Barber <ken@bob.sh>2011-08-05 08:25:03 +0100
committerKen Barber <ken@bob.sh>2011-08-05 08:25:03 +0100
commit681a1c7971d78c53dc9a0747ae4d983ff6b0d670 (patch)
tree3d56e35ffd165eb6d15bd54a06c41f8aa706fa1c
parent35fefe186546427963d8c8a446fa98875d65ccad (diff)
Prep for stdlib merge
* Renamed load_yaml & load_json to parseyaml & parsejson * Renamed is_valid_* functions and remove the 'valid_'
-rw-r--r--lib/puppet/parser/functions/is_domain_name.rb (renamed from lib/puppet/parser/functions/is_valid_domain_name.rb)6
-rw-r--r--lib/puppet/parser/functions/is_ip_address.rb (renamed from lib/puppet/parser/functions/is_valid_ip_address.rb)6
-rw-r--r--lib/puppet/parser/functions/is_mac_address.rb (renamed from lib/puppet/parser/functions/is_valid_mac_address.rb)6
-rw-r--r--lib/puppet/parser/functions/parsejson.rb (renamed from lib/puppet/parser/functions/load_json.rb)6
-rw-r--r--lib/puppet/parser/functions/parseyaml.rb (renamed from lib/puppet/parser/functions/load_yaml.rb)6
-rw-r--r--spec/unit/parser/functions/is_domain_name_spec.rb (renamed from spec/unit/parser/functions/is_valid_domain_name_spec.rb)20
-rw-r--r--spec/unit/parser/functions/is_ip_address_spec.rb (renamed from spec/unit/parser/functions/is_valid_ip_address_spec.rb)16
-rw-r--r--spec/unit/parser/functions/is_mac_address_spec.rb (renamed from spec/unit/parser/functions/is_valid_mac_address_spec.rb)12
-rw-r--r--spec/unit/parser/functions/parsejson_spec.rb (renamed from spec/unit/parser/functions/load_json_spec.rb)8
-rw-r--r--spec/unit/parser/functions/parseyaml_spec.rb (renamed from spec/unit/parser/functions/load_yaml_spec.rb)8
10 files changed, 47 insertions, 47 deletions
diff --git a/lib/puppet/parser/functions/is_valid_domain_name.rb b/lib/puppet/parser/functions/is_domain_name.rb
index 7dd9c0b..4e92939 100644
--- a/lib/puppet/parser/functions/is_valid_domain_name.rb
+++ b/lib/puppet/parser/functions/is_domain_name.rb
@@ -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
diff --git a/lib/puppet/parser/functions/is_valid_ip_address.rb b/lib/puppet/parser/functions/is_ip_address.rb
index 604d938..b4a9a15 100644
--- a/lib/puppet/parser/functions/is_valid_ip_address.rb
+++ b/lib/puppet/parser/functions/is_ip_address.rb
@@ -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
diff --git a/lib/puppet/parser/functions/is_valid_mac_address.rb b/lib/puppet/parser/functions/is_mac_address.rb
index 53199b6..1b3088a 100644
--- a/lib/puppet/parser/functions/is_valid_mac_address.rb
+++ b/lib/puppet/parser/functions/is_mac_address.rb
@@ -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
diff --git a/lib/puppet/parser/functions/load_json.rb b/lib/puppet/parser/functions/parsejson.rb
index 333cf11..cf3b12c 100644
--- a/lib/puppet/parser/functions/load_json.rb
+++ b/lib/puppet/parser/functions/parsejson.rb
@@ -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
diff --git a/lib/puppet/parser/functions/load_yaml.rb b/lib/puppet/parser/functions/parseyaml.rb
index 2683277..e8ac8a4 100644
--- a/lib/puppet/parser/functions/load_yaml.rb
+++ b/lib/puppet/parser/functions/parseyaml.rb
@@ -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
diff --git a/spec/unit/parser/functions/is_valid_domain_name_spec.rb b/spec/unit/parser/functions/is_domain_name_spec.rb
index 3339447..ec7c7f5 100644
--- a/spec/unit/parser/functions/is_valid_domain_name_spec.rb
+++ b/spec/unit/parser/functions/is_domain_name_spec.rb
@@ -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
diff --git a/spec/unit/parser/functions/is_valid_ip_address_spec.rb b/spec/unit/parser/functions/is_ip_address_spec.rb
index 2883aaa..98ce828 100644
--- a/spec/unit/parser/functions/is_valid_ip_address_spec.rb
+++ b/spec/unit/parser/functions/is_ip_address_spec.rb
@@ -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
diff --git a/spec/unit/parser/functions/is_valid_mac_address_spec.rb b/spec/unit/parser/functions/is_mac_address_spec.rb
index 62e6fee..c9b9637 100644
--- a/spec/unit/parser/functions/is_valid_mac_address_spec.rb
+++ b/spec/unit/parser/functions/is_mac_address_spec.rb
@@ -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
diff --git a/spec/unit/parser/functions/load_json_spec.rb b/spec/unit/parser/functions/parsejson_spec.rb
index 73a4566..26eea36 100644
--- a/spec/unit/parser/functions/load_json_spec.rb
+++ b/spec/unit/parser/functions/parsejson_spec.rb
@@ -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
diff --git a/spec/unit/parser/functions/load_yaml_spec.rb b/spec/unit/parser/functions/parseyaml_spec.rb
index 2498d12..f9cb049 100644
--- a/spec/unit/parser/functions/load_yaml_spec.rb
+++ b/spec/unit/parser/functions/parseyaml_spec.rb
@@ -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