right_support 1.1.0 → 1.1.1

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.
@@ -1,10 +1,10 @@
1
- require 'json'
1
+ require 'yajl'
2
2
 
3
3
  module RightSupport::Crypto
4
4
  class SignedHash
5
5
  DEFAULT_OPTIONS = {
6
6
  :digest => Digest::SHA1,
7
- :encoding => JSON
7
+ :encoding => Yajl
8
8
  }
9
9
 
10
10
  def initialize(hash={}, options={})
@@ -23,7 +23,10 @@
23
23
  require 'set'
24
24
 
25
25
  module RightSupport::Net::Balancing
26
-
26
+
27
+ # TODO refactor this class. We store too much unstructured data about EPs; should have a simple
28
+ # class representing EP state, and then perhaps move what logic remains into the HealthCheck class
29
+ # instead of putting it here.
27
30
  class EndpointsStack
28
31
  DEFAULT_YELLOW_STATES = 4
29
32
  DEFAULT_RESET_TIME = 300
@@ -111,9 +114,17 @@ module RightSupport::Net::Balancing
111
114
  @counter += 1 unless endpoints.size < @last_size
112
115
  @counter = 0 if @counter == endpoints.size
113
116
  @last_size = endpoints.size
114
-
115
- # Returns false or true, depending on whether EP is yellow or not
116
- [ endpoints[@counter][0], endpoints[@counter][1][:n_level] != 0 ]
117
+
118
+ # Hash#select returns a Hash in ruby1.9, but an Array of pairs in ruby1.8.
119
+ # This should really be encapsulated in EndpointsStack...
120
+ if RUBY_VERSION >= '1.9'
121
+ key = endpoints.keys[@counter]
122
+ next_endpoint = [ key, endpoints[key][:n_level] != 0 ]
123
+ else
124
+ next_endpoint = [ endpoints[@counter][0], endpoints[@counter][1][:n_level] != 0 ]
125
+ end
126
+
127
+ next_endpoint
117
128
  end
118
129
 
119
130
  def good(endpoint, t0, t1)
@@ -23,18 +23,34 @@ require 'cgi'
23
23
  require 'base64'
24
24
  require 'zlib'
25
25
 
26
- #
27
- # A tool that encodes (binary or ASCII) strings into 7-bit ASCII
28
- # using one or more encoding algorithms which are applied sequentially.
29
- # The order of algorithms is reversed on decode, naturally!
30
- #
31
- # This class is designed to be used with network protocols implemented
32
- # on top of HTTP, where binary data needs to be encapsulated in URL query
33
- # strings, request bodies or other textual payloads. Sometimes multiple
34
- # encodings are necessary in order to prevent unnecessary expansion of
35
- # the encoded text.
36
- #
37
26
  module RightSupport::Net
27
+ #
28
+ # A tool that encodes (binary or ASCII) strings into 7-bit ASCII
29
+ # using one or more encoding algorithms which are applied sequentially.
30
+ # The order of algorithms is reversed on decode, naturally!
31
+ #
32
+ # This class is designed to be used with network protocols implemented
33
+ # on top of HTTP, where binary data needs to be encapsulated in URL query
34
+ # strings, request bodies or other textual payloads. Sometimes multiple
35
+ # encodings are necessary in order to prevent unnecessary expansion of
36
+ # the encoded text.
37
+ #
38
+ # == Ruby 1.9 and Character Encodings
39
+ #
40
+ # === Input Strings
41
+ # The #encode and #decode methods accept strings with any encoding, and do not perform
42
+ # any conversion or coercion between encodings. Strings are passed unmodified to the
43
+ # underlying encoding libraries.
44
+ #
45
+ # === Output Strings
46
+ # The #encode method always returns strings with an encoding of US-ASCII, because the
47
+ # output of all encodings is guaranteed to be 7-bit ASCII.
48
+ #
49
+ # The #decode method always returns strings with an encoding of ASCII-8BIT (aka BINARY)
50
+ # because there is no way to determine the correct encoding. The caller of #decode
51
+ # should use String#force_encoding to coerce the output value to an appropriate encoding
52
+ # before displaying or manipulating the output.
53
+ #
38
54
  class StringEncoder
39
55
  ENCODINGS = [:base64, :url]
40
56
  ENCODINGS.freeze
@@ -93,7 +109,7 @@ module RightSupport::Net
93
109
  end
94
110
  end
95
111
 
96
- value
112
+ value.force_encoding(Encoding::ASCII_8BIT)
97
113
  end
98
114
  end
99
115
  end
@@ -7,8 +7,8 @@ spec = Gem::Specification.new do |s|
7
7
  s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
8
8
 
9
9
  s.name = 'right_support'
10
- s.version = '1.1.0'
11
- s.date = '2011-11-03'
10
+ s.version = '1.1.1'
11
+ s.date = '2011-11-17'
12
12
 
13
13
  s.authors = ['Tony Spataro', 'Sergey Sergyenko', 'Ryan Williamson']
14
14
  s.email = 'support@rightscale.com'
@@ -17,7 +17,7 @@ spec = Gem::Specification.new do |s|
17
17
  s.summary = %q{Reusable foundation code.}
18
18
  s.description = %q{A toolkit of useful, reusable foundation code created by RightScale.}
19
19
 
20
- s.add_dependency('json', ['~> 1.4'])
20
+ s.add_dependency('yajl-ruby', ['~> 1.1'])
21
21
 
22
22
  basedir = File.dirname(__FILE__)
23
23
  candidates = ['right_support.gemspec', 'LICENSE', 'README.rdoc'] + Dir['lib/**/*']
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_support
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Spataro
@@ -17,22 +17,22 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-11-03 00:00:00 -07:00
20
+ date: 2011-11-17 00:00:00 -08:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
- name: json
24
+ name: yajl-ruby
25
25
  prerelease: false
26
26
  requirement: &id001 !ruby/object:Gem::Requirement
27
27
  none: false
28
28
  requirements:
29
29
  - - ~>
30
30
  - !ruby/object:Gem::Version
31
- hash: 7
31
+ hash: 13
32
32
  segments:
33
33
  - 1
34
- - 4
35
- version: "1.4"
34
+ - 1
35
+ version: "1.1"
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  description: A toolkit of useful, reusable foundation code created by RightScale.