rightresource 0.4.4 → 0.4.5

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.
@@ -42,6 +42,6 @@ require 'right_resource/macro'
42
42
  require 'right_resource/credential'
43
43
 
44
44
  module RightResource
45
- VERSION = '0.4.4'
45
+ VERSION = '0.4.5'
46
46
  API_VERSION = "1.0"
47
47
  end
@@ -4,28 +4,6 @@
4
4
  # * +id+ - RightScale deployment resource id(https://my.rightscale.com/deployments/{id})
5
5
  class Deployment < RightResource::Base
6
6
  class << self
7
- # Override RightResource::Base#index
8
- # Hash2Object of RightScale servers
9
- def index(params = {})
10
- deployments = super
11
- deployments.each do |deployment|
12
- deployment.servers
13
- end
14
-
15
- deployments
16
- end
17
-
18
- # Override RightResource::Base#show
19
- # Hash2Object of RightScale servers
20
- def show(id, params = {})
21
- deployment = super
22
- unless deployment.nil?
23
- deployment.servers
24
- end
25
-
26
- deployment
27
- end
28
-
29
7
  [:start_all, :stop_all, :duplicate].each do |act_method|
30
8
  define_method(act_method) do |id|
31
9
  path = element_path(id, act_method).sub(/\.#{format.extension}$/, '') # response empty and format xml only
@@ -33,15 +11,4 @@ class Deployment < RightResource::Base
33
11
  end
34
12
  end
35
13
  end
36
-
37
- # Convert servers
38
- def servers
39
- unless self.attributes[:servers].nil?
40
- self.attributes[:servers].map! do |record|
41
- record.is_a?(Hash) ? Server.new(record) : record
42
- end
43
- end
44
-
45
- self.attributes[:servers]
46
- end
47
14
  end
@@ -16,7 +16,7 @@ module RightResource
16
16
  end
17
17
 
18
18
  def decode(json)
19
- JSON.parse(json)
19
+ Crack::JSON.parse(json)
20
20
  end
21
21
  end
22
22
  end
@@ -115,38 +115,4 @@ class Server < RightResource::Base
115
115
  }.flatten]
116
116
  end
117
117
  end
118
-
119
- # Get Server settings with merge to instance(attributes[:settings])
120
- # === Examples
121
- # server = Server.index(:filter => "nickname=dev-001").first
122
- # Server.settings
123
- # # => Server#attributes[:settings]
124
- # # {:dns_name => "ec2-175-...", :aws_id => "i-12345", ..., :ip_address => "175...."}
125
- def settings
126
- # first access
127
- if self.attributes[:settings].nil?
128
- self.attributes[:settings] = _settings
129
- end
130
-
131
- self.attributes[:settings]
132
- end
133
-
134
- # Get Server settings with merge to instance(destructive)
135
- # === Examples
136
- # server = Server.index(:filter => "nickname=dev-001").first
137
- # Server.settings!
138
- # # => self
139
- # #
140
- # # > Server.attributes
141
- # # => [:nickname => "server1", :aws_id => "i-12345", ..., :ip_address => "175..."]
142
- def settings!
143
- self.loads(_settings)
144
-
145
- self
146
- end
147
-
148
- private
149
- def _settings
150
- self.class.settings(self.id) rescue nil
151
- end
152
118
  end
@@ -44,12 +44,6 @@ class ServerArray < RightResource::Base
44
44
  RightResource::Formats::XmlFormat.decode(action(:post, path, h)).tap {|resource| correct_attributes(resource)}
45
45
  end
46
46
 
47
- # Get Server Array instances(subresource)
48
- # === Examples
49
- # array_id = ServerArray.index.first.id
50
- # instances = ServerArray.instances(array_id)
51
- # => [{:nickname => "web #1", :resource_uid => "i-12345", ...},
52
- # {:nickname => "web #2", :resource_uid => "i-67890", ...}]
53
47
  def instances(id)
54
48
  path = element_path(id, :instances)
55
49
  format.decode(action(:get, path)).map do |instance|
@@ -57,20 +51,4 @@ class ServerArray < RightResource::Base
57
51
  end
58
52
  end
59
53
  end
60
-
61
- # Get Server Array with merge to ServerArray instance(attributes[:instances])
62
- # === Examples
63
- # array = ServerArray.index.first
64
- # array.instances
65
- # # => ServerArray#attributes[:instances]
66
- # => [{:nickname => "web #1", :resource_uid => "i-12345", ...},
67
- # {:nickname => "web #2", :resource_uid => "i-67890", ...}]
68
- def instances
69
- # first access
70
- if self.attributes[:instances].nil?
71
- self.attributes[:instances] = self.class.instances(self.id) rescue nil
72
- end
73
-
74
- self.attributes[:instances]
75
- end
76
54
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rightresource
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 4
10
- version: 0.4.4
9
+ - 5
10
+ version: 0.4.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Satoshi Ohki