knife-google 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. data/.gitignore +22 -0
  2. data/CONTRIB.md +64 -0
  3. data/Gemfile +11 -0
  4. data/README.md +287 -0
  5. data/Rakefile +53 -0
  6. data/knife-google.gemspec +26 -0
  7. data/lib/chef/knife/google_base.rb +39 -68
  8. data/lib/chef/knife/google_disk_create.rb +60 -0
  9. data/lib/chef/knife/google_disk_delete.rb +60 -0
  10. data/lib/chef/knife/google_disk_list.rb +75 -0
  11. data/lib/chef/knife/google_server_create.rb +273 -184
  12. data/lib/chef/knife/google_server_delete.rb +74 -32
  13. data/lib/chef/knife/google_server_list.rb +45 -64
  14. data/lib/chef/knife/google_setup.rb +31 -0
  15. data/lib/chef/knife/google_zone_list.rb +78 -0
  16. data/lib/google/compute.rb +46 -0
  17. data/lib/google/compute/client.rb +188 -0
  18. data/lib/google/compute/config.rb +23 -0
  19. data/lib/google/compute/creatable_resource_collection.rb +38 -0
  20. data/lib/google/compute/deletable_resource_collection.rb +51 -0
  21. data/lib/google/compute/disk.rb +40 -0
  22. data/lib/google/compute/exception.rb +28 -0
  23. data/lib/google/compute/firewall.rb +65 -0
  24. data/lib/google/compute/global_operation.rb +60 -0
  25. data/lib/google/compute/image.rb +30 -0
  26. data/lib/google/compute/kernel.rb +20 -0
  27. data/lib/google/compute/listable_resource_collection.rb +33 -0
  28. data/lib/google/compute/machine_type.rb +36 -0
  29. data/lib/google/compute/mixins/utils.rb +58 -0
  30. data/lib/google/compute/network.rb +29 -0
  31. data/lib/google/compute/project.rb +76 -0
  32. data/lib/google/compute/resource.rb +81 -0
  33. data/lib/google/compute/resource_collection.rb +78 -0
  34. data/lib/google/compute/server.rb +87 -0
  35. data/lib/google/compute/server/attached_disk.rb +39 -0
  36. data/lib/google/compute/server/network_interface.rb +38 -0
  37. data/lib/google/compute/server/network_interface/access_config.rb +35 -0
  38. data/lib/google/compute/server/serial_port_output.rb +31 -0
  39. data/lib/google/compute/snapshot.rb +30 -0
  40. data/lib/google/compute/version.rb +19 -0
  41. data/lib/google/compute/zone.rb +32 -0
  42. data/lib/google/compute/zone_operation.rb +60 -0
  43. data/lib/knife-google/version.rb +18 -2
  44. data/spec/chef/knife/google_base_spec.rb +46 -0
  45. data/spec/chef/knife/google_disk_create_spec.rb +36 -0
  46. data/spec/chef/knife/google_disk_delete_spec.rb +65 -0
  47. data/spec/chef/knife/google_disk_list_spec.rb +36 -0
  48. data/spec/chef/knife/google_server_create_spec.rb +84 -0
  49. data/spec/chef/knife/google_server_delete_spec.rb +105 -0
  50. data/spec/chef/knife/google_server_list_spec.rb +39 -0
  51. data/spec/chef/knife/google_setup_spec.rb +25 -0
  52. data/spec/chef/knife/google_zone_list_spec.rb +32 -0
  53. data/spec/data/client.json +14 -0
  54. data/spec/data/compute-v1beta14.json +3386 -0
  55. data/spec/data/disk.json +15 -0
  56. data/spec/data/firewall.json +13 -0
  57. data/spec/data/global_operation.json +36 -0
  58. data/spec/data/image.json +12 -0
  59. data/spec/data/kernel.json +15 -0
  60. data/spec/data/machine_type.json +24 -0
  61. data/spec/data/network.json +10 -0
  62. data/spec/data/project.json +21 -0
  63. data/spec/data/serial_port_output.json +5 -0
  64. data/spec/data/server.json +46 -0
  65. data/spec/data/snapshot.json +12 -0
  66. data/spec/data/zone.json +30 -0
  67. data/spec/data/zone_operation.json +36 -0
  68. data/spec/google/compute/disk_spec.rb +105 -0
  69. data/spec/google/compute/firewall_spec.rb +128 -0
  70. data/spec/google/compute/global_operation_spec.rb +62 -0
  71. data/spec/google/compute/image_spec.rb +75 -0
  72. data/spec/google/compute/kernel_spec.rb +49 -0
  73. data/spec/google/compute/machine_type_spec.rb +53 -0
  74. data/spec/google/compute/network_spec.rb +68 -0
  75. data/spec/google/compute/project_spec.rb +71 -0
  76. data/spec/google/compute/server_spec.rb +125 -0
  77. data/spec/google/compute/snapshot_spec.rb +69 -0
  78. data/spec/google/compute/zone_operation_spec.rb +62 -0
  79. data/spec/google/compute/zone_spec.rb +50 -0
  80. data/spec/spec_helper.rb +44 -0
  81. data/spec/support/mocks.rb +62 -0
  82. data/spec/support/resource_examples.rb +70 -0
  83. data/spec/support/spec_google_base.rb +56 -0
  84. metadata +121 -31
  85. data/README.rdoc +0 -96
@@ -0,0 +1,23 @@
1
+ # Copyright 2013 Google Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'mixlib/config'
16
+
17
+ module Google
18
+ module Compute
19
+ class Config
20
+ extend Mixlib::Config
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,38 @@
1
+ # Copyright 2013 Google Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless autoload :d by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Compute
17
+ class CreatableResourceCollection < DeletableResourceCollection
18
+
19
+ def create(options={})
20
+ if ["Server", "Disk"].include? self.resource_class_name
21
+ data = @dispatcher.dispatch(:api_method => api_resource.insert,
22
+ :parameters=>{:project=>project, :zone=>options[:zone]},
23
+ :body_object => options )
24
+ ZoneOperation.new(data.merge!(:dispatcher=>@dispatcher))
25
+ else
26
+ data = @dispatcher.dispatch(:api_method => api_resource.insert,
27
+ :parameters=>{:project=>project},
28
+ :body_object => options )
29
+ GlobalOperation.new(data.merge!(:dispatcher=>@dispatcher))
30
+ end
31
+ end
32
+
33
+ def insert(options={})
34
+ create(options)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,51 @@
1
+ # Copyright 2013 Google Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'google/compute/listable_resource_collection'
16
+
17
+ module Google
18
+ module Compute
19
+ class DeletableResourceCollection < ListableResourceCollection
20
+
21
+ def initialize(options)
22
+ super(options)
23
+ options[:resource_class].class_eval do
24
+ def delete!
25
+ options={type=>name}
26
+ data = @dispatcher.dispatch(:api_method => api_resource.delete, :parameters=>options)
27
+ if ["Server", "Disk"].include? self.resource_class_name
28
+ ZoneOperation.new(data.merge!(:dispatcher=>@dispatcher)) unless data.nil?
29
+ else
30
+ GlobalOperation.new(data.merge!(:dispatcher=>@dispatcher)) unless data.nil?
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ def delete(options)
37
+ if options.is_a?(Resource)
38
+ options = name_to_hash(options.name)
39
+ elsif options.is_a?(String)
40
+ options = name_to_hash(options)
41
+ end
42
+ data = @dispatcher.dispatch(:api_method => api_resource.delete, :parameters=>options)
43
+ if ["Server", "Disk"].include? self.resource_class_name
44
+ ZoneOperation.new(data.merge!(:dispatcher=>@dispatcher)) unless data.nil?
45
+ else
46
+ GlobalOperation.new(data.merge!(:dispatcher=>@dispatcher)) unless data.nil?
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,40 @@
1
+ # Copyright 2013 Google Inc. All Rights Reserved.
2
+ #
3
+ # Copyright 2013 Google Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'google/compute/resource'
18
+ require 'google/compute/zone'
19
+
20
+ module Google
21
+ module Compute
22
+ class Disk < Resource
23
+
24
+ attr_reader :zone, :size_gb, :status, :options
25
+ attr_reader :source_snapshot, :source_snapshot_id
26
+ attr_reader :source_image
27
+
28
+ def from_hash(disk_data)
29
+ super(disk_data)
30
+ @zone = disk_data["zone"]
31
+ @size_gb = disk_data["sizeGb"]
32
+ @status = disk_data["status"]
33
+ @options = disk_data["options"]
34
+ @source_snapshot = disk_data["sourceSnapshot"]
35
+ @source_snapshot_id = disk_data["sourceSnapshotId"]
36
+ @source_image = disk_data["sourceImage"]
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,28 @@
1
+ # Copyright 2013 Google Inc. All Rights Reserved.
2
+ #
3
+ # Copyright 2013 Google Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ module Google
18
+ module Compute
19
+ class ParameterValidation < ArgumentError; end
20
+ class BadRequest < RuntimeError; end
21
+ class MethodNotOverridden < RuntimeError; end
22
+ class ClientUnitialized < RuntimeError; end
23
+ class OperationTimeout < RuntimeError; end
24
+ class HashConvert < RuntimeError; end
25
+ class ResourceNotFound < RuntimeError; end
26
+ end
27
+ end
28
+
@@ -0,0 +1,65 @@
1
+ # Copyright 2013 Google Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Compute
17
+ class Firewall < Resource
18
+
19
+ attr_reader :network, :source_ranges, :source_tags
20
+ attr_reader :target_tags, :allowed
21
+
22
+ def source_tags=(tags)
23
+ raise ParameterValidation, " tags must be an array of words" unless tags.is_a?(Array)
24
+ patch(:sourceTags=>tags)
25
+ update!
26
+ end
27
+
28
+ def target_tags=(tags)
29
+ raise ParameterValidation, " tags must be an array of words" unless tags.is_a?(Array)
30
+ patch(:targetTags=>tags)
31
+ update!
32
+ end
33
+
34
+ def source_ranges=(ranges)
35
+ raise ParameterValidation, " source ranges must be an array of words" unless ranges.is_a?(Array)
36
+ patch(:sourceRanges => ranges)
37
+ update!
38
+ end
39
+
40
+ def allowed=(allowed)
41
+ raise ParameterValidation, "allowed ingress rules must be an array of hashes" unless allowed.is_a?(Array)
42
+ patch(:allowed => allowed)
43
+ update!
44
+ end
45
+
46
+ def from_hash(data)
47
+ super(data)
48
+ @network = data["network"]
49
+ @source_ranges = data["sourceRanges"]
50
+ @source_tags = data["sourceTags"]
51
+ @target_tags = data["targetTags"]
52
+ @allowed = data["allowed"]
53
+ end
54
+
55
+ def patch(body_object)
56
+ body_object[:name] = name unless body_object.has_key?(:name)
57
+ body_object[:network] = network unless body_object.has_key?(:network)
58
+ data = @dispatcher.dispatch(:api_method => api_resource.patch,
59
+ :parameters=>{:firewall => name },
60
+ :body_object => body_object)
61
+ GlobalOperation.new(data.merge!(:dispatcher=>@dispatcher))
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,60 @@
1
+ # Copyright 2013 Google Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # Google compute engine, operation resource reference
16
+
17
+ require 'timeout'
18
+
19
+ module Google
20
+ module Compute
21
+ class GlobalOperation < Resource
22
+
23
+ attr_reader :target_link, :target_id, :client_operation_id
24
+ attr_reader :status, :status_message, :user, :progress
25
+ attr_reader :insert_time, :start_time, :end_time
26
+ attr_reader :http_error_status_code, :http_error_message
27
+ attr_reader :error, :warnings, :operation_type, :zone
28
+
29
+ def from_hash(data)
30
+ super(data)
31
+ @target_link= data["targetLink"]
32
+ @target_id = data["targetId"]
33
+ @client_operation_id = data["clientOperationId"]
34
+ @status = data["status"]
35
+ @status_message = data["statusMessage"]
36
+ @user = data["user"]
37
+ @progress = data["progress"]
38
+ @insert_time = Time.parse( data["insertTime"] )
39
+ @start_time = Time.parse( data["startTime"] )
40
+ @end_time = Time.parse( data["endTime"] ) if data.key?("endTime")
41
+ @http_error_status_code = data["httpErrorMessage"]
42
+ @http_error_message = data["httpErrorMessage"]
43
+ @error = data["error"]
44
+ @warnings = data["warnings"]
45
+ @operation_type = data["operationType"]
46
+ @zone = data["zone"]
47
+ end
48
+
49
+ def wait_for_completion!(options={})
50
+ timeout = options[:timeout] || 60
51
+ status = Timeout::timeout(timeout, OperationTimeout) do
52
+ until progress==100
53
+ sleep 2
54
+ progress= get_self.progress
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,30 @@
1
+ # Copyright 2013 Google Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Compute
17
+ class Image < Resource
18
+
19
+ attr_reader :source_type, :preferred_kernel, :raw_disk, :deprecated
20
+
21
+ def from_hash(data)
22
+ super(data)
23
+ @source_type = data["sourceType"]
24
+ @preferred_kernel = data["preferredKernel"]
25
+ @raw_disk = data["rawDisk"]
26
+ @deprecated = data["deprecated"]
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ # Copyright 2013 Google Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Compute
17
+ class Kernel < Resource
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,33 @@
1
+ # Copyright 2013 Google Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless autoload :d by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'google/compute/resource_collection'
16
+
17
+ module Google
18
+ module Compute
19
+ class ListableResourceCollection < ResourceCollection
20
+
21
+ def list(options={})
22
+ data = @dispatcher.dispatch(:api_method => api_resource.list, :parameters=>options)
23
+ items = []
24
+ if data.has_key?("items")
25
+ data["items"].each do |item|
26
+ items << @resource_class.new(item.merge!(:dispatcher=>@dispatcher))
27
+ end
28
+ end
29
+ items
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,36 @@
1
+ # Copyright 2013 Google Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Google
16
+ module Compute
17
+ class MachineType < Resource
18
+
19
+ attr_reader :memory_mb, :image_space_gb, :available_zone, :maximum_persistent_disks
20
+ attr_reader :guest_cpus, :ephemeral_disks, :maximum_persistent_disks_size_gb
21
+ attr_reader :deprecated
22
+
23
+ def from_hash(data)
24
+ super(data)
25
+ @memory_mb = data["memoryMb"]
26
+ @image_space_gb = data["imageSpaceGb"]
27
+ @available_zone = data["availableZone"]
28
+ @maximum_persistent_disks = data["maximumPersistentDisks"]
29
+ @guest_cpus = data["guestCpus"].to_i
30
+ @ephemeral_disks = data["ephemeralDisks"]
31
+ @maximum_persistent_disks_size_gb = data["maximumPersistentDisksSizeGb"]
32
+ @deprecated = data["deprecated"]
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,58 @@
1
+ # Copyright 2013 Google Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ require 'multi_json'
15
+ require 'google/compute/exception'
16
+
17
+ module Google
18
+ module Compute
19
+ module Utils
20
+
21
+ def first_letter_lowercase_camelize(word)
22
+ first, *rest = word.split('_')
23
+ first + rest.map(&:capitalize).join
24
+ end
25
+
26
+ def to_hash
27
+ hash={}
28
+ instance_variables.each do |variable|
29
+ variable_name = first_letter_lowercase_camelize( variable.to_s.sub(/^@/,'') )
30
+ next if variable_name == 'dispatcher'
31
+ variable_value = instance_variable_get(variable)
32
+ if variable_value.is_a?(String)
33
+ hash[variable_name] = variable_value
34
+ elsif variable_value.is_a?(Array)
35
+ hash[variable_name] = variable_value.collect{|v|
36
+ v.respond_to?(:to_hash) ? v.to_hash : v
37
+ }
38
+ elsif variable_value.is_a?(Hash)
39
+ hash[variable_name] = Hash[variable_value.collect{ |k,v|
40
+ [k, v.respond_to?(:to_hash) ? v.to_hash : v ]}
41
+ ]
42
+ elsif variable_value.is_a?(Time)
43
+ hash[variable_name] = variable_value.to_s
44
+ elsif variable_value.respond_to?(:to_hash)
45
+ hash[variable_name] = variable_value.to_hash
46
+ else
47
+ hash[variable_name] = variable_value.to_s
48
+ end
49
+ end
50
+ hash
51
+ end
52
+
53
+ def to_json
54
+ MultiJson.dump(to_hash)
55
+ end
56
+ end
57
+ end
58
+ end