aliyun-ess 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 025f758c3035ddf7daae931fed705da8fccbbbb2
4
- data.tar.gz: 1890e4f10e57d42d4b8f6c22e4564e1d7ee07311
3
+ metadata.gz: 9b55fac45d4545646bdf5d05c10d6247ca88196b
4
+ data.tar.gz: 2dbdaa0905cc29d214b8feef97a35ffe10e403b3
5
5
  SHA512:
6
- metadata.gz: 2237322e9210316219024599d42dcb460117607d76ff42c6ec72cfa8641f784f117b23bd478b299d2d7fb283284044bc9fd1835fbb5499296388acad523dbf32
7
- data.tar.gz: 9914fa384832da5fd7a5c04d1fbba0be4f02360f8e631d6a34ec782ea3f3b0e62c5fe6476b619a0e23be8147892ef98bc306727479398d5fbea58cd02d6a692a
6
+ metadata.gz: 19b63079b007d1e02b93ff5b71c46063b3fd82ed0114279540b0dd82c33fc071ce05185874e5ce3ac24368a19997088255deb698e45f1316fe7020f90503f1b1
7
+ data.tar.gz: 6c10c8171b2224a7d6f32958006f73bff98b08457229c8a1bb83ae0ec546e29e572f5d67ef8ec5e89ca859ecc8a6b45b1171d0ea3a77e0debcd6a414014ef790
@@ -14,7 +14,7 @@ require 'byebug'
14
14
  $:.unshift(File.dirname(__FILE__))
15
15
 
16
16
  require 'ess/version'
17
- require 'ess/extensions' unless defined? Aliyun::OSS
17
+ require 'ess/extensions'
18
18
  require 'ess/exceptions'
19
19
  require 'ess/error'
20
20
  require 'ess/authentication'
@@ -25,6 +25,7 @@ require 'ess/service'
25
25
  require 'ess/collection'
26
26
  require 'ess/scaling_group'
27
27
  require 'ess/scaling_rule'
28
+ require 'ess/scaling_instance'
28
29
  require 'ess/response'
29
30
 
30
31
 
@@ -25,40 +25,24 @@ class String
25
25
  string
26
26
  end unless public_method_defined? :camelize
27
27
 
28
- if RUBY_VERSION >= '1.9'
29
- def valid_utf8?
30
- dup.force_encoding('UTF-8').valid_encoding?
31
- end
32
- else
33
- def valid_utf8?
34
- scan(Regexp.new('[^\x00-\xa0]', nil, 'u')) { |s| s.unpack('U') }
35
- true
36
- rescue ArgumentError
37
- false
38
- end
39
- end
28
+ def valid_utf8?
29
+ dup.force_encoding('UTF-8').valid_encoding?
30
+ end unless public_method_defined? :valid_utf8?
40
31
 
41
- # All paths in in OSS have to be valid unicode so this takes care of
32
+ # All paths in in ESS have to be valid unicode so this takes care of
42
33
  # cleaning up any strings that aren't valid utf-8 according to String#valid_utf8?
43
- if RUBY_VERSION >= '1.9'
44
- def remove_extended!
45
- sanitized_string = ''
46
- each_byte do |byte|
47
- character = byte.chr
48
- sanitized_string << character if character.ascii_only?
49
- end
50
- sanitized_string
51
- end
52
- else
53
- def remove_extended!
54
- #gsub!(/[\x80-\xFF]/) { "%02X" % $&[0] }
55
- gsub!(Regext.new('/[\x80-\xFF]')) { "%02X" % $&[0] }
34
+ def remove_extended!
35
+ sanitized_string = ''
36
+ each_byte do |byte|
37
+ character = byte.chr
38
+ sanitized_string << character if character.ascii_only?
56
39
  end
57
- end
40
+ sanitized_string
41
+ end unless public_method_defined? :remove_extended!
58
42
 
59
43
  def remove_extended
60
44
  dup.remove_extended!
61
- end
45
+ end unless public_method_defined? :remove_extended
62
46
  end
63
47
 
64
48
  class CoercibleString < String
@@ -85,7 +69,7 @@ class CoercibleString < String
85
69
  # so unless the string looks like that, don't even try, otherwise it might convert an object's
86
70
  # key from something like '03 1-2-3-Apple-Tree.mp3' to Sat Feb 03 00:00:00 CST 2001.
87
71
  def datetime_format
88
- /^\d{4}-\d{2}-\d{2}\w\d{2}:\d{2}:\d{2}/
72
+ /^\d{4}-\d{2}-\d{2}\w\d{2}:\d{2}/
89
73
  end
90
74
  end
91
75
 
@@ -169,6 +153,6 @@ module SelectiveAttributeProxy
169
153
 
170
154
  module ClassMethods
171
155
  end
172
- end
156
+ end unless defined? SelectiveAttributeProxy
173
157
 
174
158
  #:startdoc:
@@ -77,6 +77,14 @@ module Aliyun
77
77
  end
78
78
  end
79
79
  end
80
+
81
+ class ScalingInstance
82
+ class Response < Base::Response
83
+ def items
84
+ (parsed['scaling_instances'] && parsed['scaling_instances']['scaling_instance']) || []
85
+ end
86
+ end
87
+ end
80
88
 
81
89
 
82
90
  # Requests whose response code is between 300 and 599 and contain an <Error></Error> in their body
@@ -34,8 +34,20 @@ module Aliyun
34
34
  end
35
35
  end
36
36
 
37
+ def scaling_instances
38
+ @scaling_instances ||= begin
39
+ build_scaling_instances!
40
+ end
41
+ end
42
+
37
43
  private
38
44
 
45
+ def build_scaling_instances!
46
+ items = ScalingInstance.find(:scaling_group_id => id).items
47
+ items.each {|e| register(e) }
48
+ items
49
+ end
50
+
39
51
  def build_scaling_rules!
40
52
  items = ScalingRule.find(:scaling_group_id => id).items
41
53
  items.each {|e| register(e) }
@@ -0,0 +1,31 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module Aliyun
3
+ module ESS
4
+ class ScalingInstance < Base
5
+ class << self
6
+ def find(params={}, options={})
7
+ params = {'action' => 'DescribeScalingInstances', 'region_id' => 'cn-hangzhou', 'page_number' => 1}.merge params
8
+ Collection.new get('/', params, options)
9
+ end
10
+
11
+ def find_by(*args)
12
+ c = find(*args)
13
+ c.items.first
14
+ end
15
+ end
16
+
17
+ include SelectiveAttributeProxy
18
+
19
+ attr_accessor :scaling_group
20
+
21
+ def initialize(attributes = {})
22
+ super
23
+ end
24
+
25
+ def id
26
+ attributes['instance_id']
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -13,7 +13,7 @@ module Aliyun
13
13
  c.items.first
14
14
  end
15
15
 
16
- def execute(params={'ScalingRuleAri' => 'ari:acs:ess:cn-hangzhou:1358641544878377:scalingrule/duK8myelWehmcB5WH9cUTsu7'}, options={})
16
+ def execute(params={}, options={})
17
17
  params = {'Action' => 'ExecuteScalingRule'}.merge params
18
18
  get('/', params, options)
19
19
  end
@@ -4,7 +4,7 @@ module Aliyun
4
4
  module VERSION #:nodoc:
5
5
  MAJOR = '0'
6
6
  MINOR = '1'
7
- TINY = '1'
7
+ TINY = '3'
8
8
  BETA = nil
9
9
  #BETA = Time.now.to_i.to_s
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aliyun-ess
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-11 00:00:00.000000000 Z
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,6 +91,7 @@ files:
91
91
  - lib/aliyun/ess/parsing.rb
92
92
  - lib/aliyun/ess/response.rb
93
93
  - lib/aliyun/ess/scaling_group.rb
94
+ - lib/aliyun/ess/scaling_instance.rb
94
95
  - lib/aliyun/ess/scaling_rule.rb
95
96
  - lib/aliyun/ess/service.rb
96
97
  - lib/aliyun/ess/version.rb