softlayer_api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,83 @@
1
+ # Copyright (c) 2010, SoftLayer Technologies, Inc. All rights reserved.
2
+ #
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions are met:
5
+ #
6
+ # * Redistributions of source code must retain the above copyright notice,
7
+ # this list of conditions and the following disclaimer.
8
+ # * Redistributions in binary form must reproduce the above copyright notice,
9
+ # this list of conditions and the following disclaimer in the documentation
10
+ # and/or other materials provided with the distribution.
11
+ # * Neither SoftLayer Technologies, Inc. nor the names of its contributors may
12
+ # be used to endorse or promote products derived from this software without
13
+ # specific prior written permission.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
+ # POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ $: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
28
+
29
+ require 'rubygems'
30
+ require 'softlayer_api'
31
+ require 'spec'
32
+ require 'spec/autorun'
33
+
34
+ describe String, "#to_sl_object_mask" do
35
+ it "should echo back a string with no base" do
36
+ "blah".to_sl_object_mask.should eql("blah")
37
+ end
38
+
39
+ it "should prepend the base with a dot if given" do
40
+ "blah".to_sl_object_mask("foo").should eql("foo.blah")
41
+ end
42
+
43
+ it "should return the empty string if given the empty string with no base" do
44
+ "".to_sl_object_mask.should eql("")
45
+ end
46
+
47
+ it "should return the base with no dot if applied to the empty string" do
48
+ "".to_sl_object_mask("foo").should eql("foo")
49
+ end
50
+ end
51
+
52
+ describe Array,"#to_sl_object_mask" do
53
+ it "should return the empty array if run on an empty array" do
54
+ [].to_sl_object_mask.should eql([])
55
+ end
56
+
57
+ it "should call to_sl_object_mask passing the base to all its elements" do
58
+ proxy = "Hello"
59
+ proxy.should_receive(:to_sl_object_mask).with("")
60
+ [proxy].to_sl_object_mask
61
+
62
+ proxy = "Hello"
63
+ proxy.should_receive(:to_sl_object_mask).with("foo")
64
+ [proxy].to_sl_object_mask('foo')
65
+ end
66
+
67
+ it "should flatten any arrays inside of itself" do
68
+ ["foo", ["bar", "baz"]].to_sl_object_mask("buz").should eql(["buz.foo", "buz.bar", "buz.baz"])
69
+ end
70
+ end
71
+
72
+ describe Hash, "#to_sl_object_mask" do
73
+ it "should call to_sl_object_mask on values with the key as the base" do
74
+ proxy = "value"
75
+ proxy.should_receive(:to_sl_object_mask).with("key").and_return("key.value")
76
+ mask_elements = {"key" => proxy}.to_sl_object_mask
77
+ mask_elements.should eql(["key.value"])
78
+ end
79
+
80
+ it "should resolve the mapped values with the base provided" do
81
+ {"top" => [ "middle1", {"middle2" => "end"}]}.to_sl_object_mask.should eql(["top.middle1", "top.middle2.end"])
82
+ end
83
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: softlayer_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - SoftLayer Development Team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-07-30 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: json
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: The softlayer_api gem offers a convenient mechanism for invoking the services of the SoftLayer API from Ruby.
26
+ email: sldn@softlayer.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - README.textile
35
+ - LICENSE.textile
36
+ - lib/softlayer/base.rb
37
+ - lib/softlayer/object_mask_helpers.rb
38
+ - lib/softlayer/service.rb
39
+ - lib/softlayer_api.rb
40
+ - test/SoftLayer_APIParameterFilter.rb
41
+ - test/SoftLayer_Service.rb
42
+ - test/SoftLayer_ToObjectMask.rb
43
+ - examples/accountInformation.rb
44
+ - examples/createTicket.rb
45
+ - examples/openTickets.rb
46
+ - examples/ticket_info.rb
47
+ has_rdoc: true
48
+ homepage: http://sldn.softlayer.com/
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options: []
53
+
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.5
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Library for accessing the SoftLayer portal API
75
+ test_files: []
76
+