right_support 2.13.3 → 2.14.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.
- checksums.yaml +4 -4
- data/lib/right_support/crypto/signed_hash.rb +30 -9
- data/lib/right_support/notifiers/airbrake.rb +1 -0
- data/lib/right_support/validation/openssl.rb +5 -3
- data/lib/right_support/version.rb +4 -0
- data/right_support.gemspec +20 -129
- metadata +8 -84
- data/CHANGELOG.rdoc +0 -37
- data/LICENSE +0 -76
- data/README.md +0 -192
- data/Rakefile +0 -85
- data/VERSION +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e82daed673214599b4e0206f8a766ba400d06ac
|
4
|
+
data.tar.gz: e6d9f64f58a4b3932e725dbbdaf071a094c4b4de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76d3073f77651f586ae49aa3f956498512945584abe938baaa0e3ce8e0c68c94ed90ede39316aae6551c33f49957c3b06a0cd0a545b8f35ed8c29e18d1dc2511
|
7
|
+
data.tar.gz: b72d3a15b6cea55871a7a1f8a0ff7709aed8bba348bae85bb279d66b937be26f6edea2b49ae5a426f8d19aa161d7b9699803a82c8ab106b48c6ab546c0764142
|
@@ -41,7 +41,7 @@ module RightSupport::Crypto
|
|
41
41
|
# a 512-bit RSA key would not be sufficiently long to create signatures of a SHA3-512 hash
|
42
42
|
# due to the mathematical underpinnings of the RSA cipher. In practice this is not an issue,
|
43
43
|
# because you should be using strong RSA keys (2048 bit or higher) for security reasons,
|
44
|
-
# and even the strongest hash algorithms do not exceed 512-bit output.
|
44
|
+
# and even the strongest hash algorithms do not exceed 512-bit output.
|
45
45
|
#
|
46
46
|
# SignedHash provides reasonable defaults for the other three factors:
|
47
47
|
# - JSON for message encoding (Yajl gem, JSON gem, Oj gem or built-in Ruby 1.9 JSON)
|
@@ -128,8 +128,13 @@ module RightSupport::Crypto
|
|
128
128
|
|
129
129
|
if @envelope
|
130
130
|
digest = DIGEST_MAP[@digest].new(encoded)
|
131
|
-
|
132
|
-
|
131
|
+
if @private_key.respond_to?(:dsa_sign_asn1)
|
132
|
+
# DSA signature with ASN.1 encoding
|
133
|
+
@private_key.dsa_sign_asn1(digest.digest)
|
134
|
+
else
|
135
|
+
# RSA/DSA signature as specified in PKCS #1 v1.5
|
136
|
+
@private_key.sign(digest, encoded)
|
137
|
+
end
|
133
138
|
else
|
134
139
|
digest = @digest.new.update(encoded).digest
|
135
140
|
@private_key.private_encrypt(digest)
|
@@ -153,7 +158,13 @@ module RightSupport::Crypto
|
|
153
158
|
|
154
159
|
if @envelope
|
155
160
|
digest = DIGEST_MAP[@digest].new
|
156
|
-
|
161
|
+
if @public_key.respond_to?(:moo)
|
162
|
+
# DSA signature with ASN.1 encoding
|
163
|
+
@private_key.dsa_verify_asn1(digest.digest, signature)
|
164
|
+
else
|
165
|
+
# RSA/DSA signature as specified in PKCS #1 v1.5
|
166
|
+
result = @public_key.verify(digest, signature, plaintext)
|
167
|
+
end
|
157
168
|
raise InvalidSignature, "Signature verification failed" unless true == result
|
158
169
|
else
|
159
170
|
expected = @digest.new.update(plaintext).digest
|
@@ -203,11 +214,21 @@ module RightSupport::Crypto
|
|
203
214
|
unless @encoding.respond_to?(str_or_symb('dump'))
|
204
215
|
raise ArgumentError, "Encoding class/module/object must respond to .dump method"
|
205
216
|
end
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
217
|
+
|
218
|
+
if @envelope
|
219
|
+
if @public_key && !@public_key.respond_to?(str_or_symb('verify'))
|
220
|
+
raise ArgumentError, "Public key must respond to :verify"
|
221
|
+
end
|
222
|
+
if @private_key && !@private_key.respond_to?(str_or_symb('sign'))
|
223
|
+
raise ArgumentError, "Private key must respond to :sign"
|
224
|
+
end
|
225
|
+
else
|
226
|
+
if @public_key && !@public_key.respond_to?(str_or_symb('public_decrypt'))
|
227
|
+
raise ArgumentError, "Public key must respond to :public_decrypt"
|
228
|
+
end
|
229
|
+
if @private_key && !@private_key.respond_to?(str_or_symb('private_encrypt'))
|
230
|
+
raise ArgumentError, "Private key must respond to :private_encrypt"
|
231
|
+
end
|
211
232
|
end
|
212
233
|
end
|
213
234
|
|
@@ -66,7 +66,8 @@ module RightSupport::Validation
|
|
66
66
|
return false unless alg
|
67
67
|
key = alg.new(key_material, passphrase || 'dummy passphrase, should never work')
|
68
68
|
key.to_der #make sure it's valid in addition to being well formed
|
69
|
-
|
69
|
+
# deal with varying interfaces between RSA/DSA/EC
|
70
|
+
return (key.private? rescue false) || (key.private_key? rescue false)
|
70
71
|
rescue ::OpenSSL::PKey::PKeyError, NotImplementedError
|
71
72
|
return false
|
72
73
|
end
|
@@ -84,9 +85,10 @@ module RightSupport::Validation
|
|
84
85
|
return false unless alg
|
85
86
|
key = alg.new(key_material)
|
86
87
|
key.to_der #make sure it's valid in addition to being well formed
|
87
|
-
|
88
|
+
# deal with varying interfaces between RSA/DSA/EC
|
89
|
+
return (key.public? rescue false) || (key.public_key? rescue false)
|
88
90
|
rescue ::OpenSSL::PKey::PKeyError, NotImplementedError
|
89
91
|
return false
|
90
92
|
end
|
91
93
|
end
|
92
|
-
end
|
94
|
+
end
|
data/right_support.gemspec
CHANGED
@@ -1,134 +1,25 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# stub: right_support 2.13.3 ruby lib
|
1
|
+
# encoding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'right_support/version'
|
6
5
|
|
7
|
-
Gem::Specification.new do |
|
8
|
-
|
9
|
-
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "right_support"
|
8
|
+
spec.version = RightSupport::VERSION
|
9
|
+
spec.authors = ["Tony Spataro", "Sergey Sergyenko", "Ryan Williamson", "Lee Kirchhoff", "Alexey Karpik", "Scott Messier"]
|
10
|
+
spec.email = "support@rightscale.com"
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
s.description = "A toolkit of useful, reusable foundation code created by RightScale."
|
16
|
-
s.email = "support@rightscale.com"
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"LICENSE",
|
19
|
-
"README.md"
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
"CHANGELOG.rdoc",
|
23
|
-
"LICENSE",
|
24
|
-
"README.md",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"lib/right_support.rb",
|
28
|
-
"lib/right_support/ci.rb",
|
29
|
-
"lib/right_support/ci/java_cucumber_formatter.rb",
|
30
|
-
"lib/right_support/ci/java_spec_formatter.rb",
|
31
|
-
"lib/right_support/ci/rake_task.rb",
|
32
|
-
"lib/right_support/config.rb",
|
33
|
-
"lib/right_support/config/feature_set.rb",
|
34
|
-
"lib/right_support/config/recursive_true_class.rb",
|
35
|
-
"lib/right_support/config/yaml_config.rb",
|
36
|
-
"lib/right_support/crypto.rb",
|
37
|
-
"lib/right_support/crypto/signed_hash.rb",
|
38
|
-
"lib/right_support/data.rb",
|
39
|
-
"lib/right_support/data/hash_tools.rb",
|
40
|
-
"lib/right_support/data/mash.rb",
|
41
|
-
"lib/right_support/data/serializer.rb",
|
42
|
-
"lib/right_support/data/token.rb",
|
43
|
-
"lib/right_support/data/unknown_type.rb",
|
44
|
-
"lib/right_support/data/uuid.rb",
|
45
|
-
"lib/right_support/db.rb",
|
46
|
-
"lib/right_support/db/cassandra_model.rb",
|
47
|
-
"lib/right_support/deployment.rb",
|
48
|
-
"lib/right_support/deployment/info.rb",
|
49
|
-
"lib/right_support/log.rb",
|
50
|
-
"lib/right_support/log/exception_logger.rb",
|
51
|
-
"lib/right_support/log/filter_logger.rb",
|
52
|
-
"lib/right_support/log/mixin.rb",
|
53
|
-
"lib/right_support/log/multiplexer.rb",
|
54
|
-
"lib/right_support/log/null_logger.rb",
|
55
|
-
"lib/right_support/log/step_level_logger.rb",
|
56
|
-
"lib/right_support/log/syslog/remote.rb",
|
57
|
-
"lib/right_support/log/system_logger.rb",
|
58
|
-
"lib/right_support/net.rb",
|
59
|
-
"lib/right_support/net/address_helper.rb",
|
60
|
-
"lib/right_support/net/dns.rb",
|
61
|
-
"lib/right_support/net/http_client.rb",
|
62
|
-
"lib/right_support/net/lb.rb",
|
63
|
-
"lib/right_support/net/lb/base.rb",
|
64
|
-
"lib/right_support/net/lb/health_check.rb",
|
65
|
-
"lib/right_support/net/lb/round_robin.rb",
|
66
|
-
"lib/right_support/net/lb/sticky.rb",
|
67
|
-
"lib/right_support/net/request_balancer.rb",
|
68
|
-
"lib/right_support/net/s3_helper.rb",
|
69
|
-
"lib/right_support/net/ssl.rb",
|
70
|
-
"lib/right_support/net/ssl/open_ssl_patch.rb",
|
71
|
-
"lib/right_support/net/string_encoder.rb",
|
72
|
-
"lib/right_support/notifiers.rb",
|
73
|
-
"lib/right_support/notifiers/airbrake.rb",
|
74
|
-
"lib/right_support/notifiers/base.rb",
|
75
|
-
"lib/right_support/notifiers/blacklisters.rb",
|
76
|
-
"lib/right_support/notifiers/blacklisters/base.rb",
|
77
|
-
"lib/right_support/notifiers/blacklisters/canonical.rb",
|
78
|
-
"lib/right_support/notifiers/blacklisters/regular_expression.rb",
|
79
|
-
"lib/right_support/notifiers/blacklisters/simple.rb",
|
80
|
-
"lib/right_support/notifiers/blacklisters/snake_case.rb",
|
81
|
-
"lib/right_support/notifiers/blacklisters/wildcard.rb",
|
82
|
-
"lib/right_support/notifiers/logger.rb",
|
83
|
-
"lib/right_support/notifiers/notification.rb",
|
84
|
-
"lib/right_support/notifiers/utilities.rb",
|
85
|
-
"lib/right_support/notifiers/utilities/backtrace_decoder.rb",
|
86
|
-
"lib/right_support/rack.rb",
|
87
|
-
"lib/right_support/rack/log_setter.rb",
|
88
|
-
"lib/right_support/rack/request_logger.rb",
|
89
|
-
"lib/right_support/rack/request_tracker.rb",
|
90
|
-
"lib/right_support/rack/runtime.rb",
|
91
|
-
"lib/right_support/rack/shared_environment.rb",
|
92
|
-
"lib/right_support/ruby.rb",
|
93
|
-
"lib/right_support/ruby/easy_singleton.rb",
|
94
|
-
"lib/right_support/ruby/object_extensions.rb",
|
95
|
-
"lib/right_support/ruby/string_extensions.rb",
|
96
|
-
"lib/right_support/stats.rb",
|
97
|
-
"lib/right_support/stats/activity.rb",
|
98
|
-
"lib/right_support/stats/exceptions.rb",
|
99
|
-
"lib/right_support/stats/helpers.rb",
|
100
|
-
"lib/right_support/validation.rb",
|
101
|
-
"lib/right_support/validation/openssl.rb",
|
102
|
-
"lib/right_support/validation/ssh.rb",
|
103
|
-
"right_support.gemspec"
|
104
|
-
]
|
105
|
-
s.homepage = "https://github.com/rightscale/right_support"
|
106
|
-
s.licenses = ["MIT"]
|
107
|
-
s.rubygems_version = "2.2.5"
|
108
|
-
s.summary = "Reusable foundation code."
|
12
|
+
spec.summary = "Reusable foundation code."
|
13
|
+
spec.description = "A toolkit of useful, reusable foundation code created by RightScale."
|
14
|
+
spec.homepage = "https://github.com/rightscale/right_support"
|
15
|
+
spec.license = "MIT"
|
109
16
|
|
110
|
-
|
111
|
-
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r{lib/|gemspec}) }
|
18
|
+
spec.require_paths = ['lib']
|
112
19
|
|
113
|
-
|
114
|
-
s.add_development_dependency(%q<rake>, ["~> 10.0"])
|
115
|
-
s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
|
116
|
-
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
117
|
-
s.add_development_dependency(%q<pry>, [">= 0"])
|
118
|
-
s.add_development_dependency(%q<pry-byebug>, [">= 0"])
|
119
|
-
else
|
120
|
-
s.add_dependency(%q<rake>, ["~> 10.0"])
|
121
|
-
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
122
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
123
|
-
s.add_dependency(%q<pry>, [">= 0"])
|
124
|
-
s.add_dependency(%q<pry-byebug>, [">= 0"])
|
125
|
-
end
|
126
|
-
else
|
127
|
-
s.add_dependency(%q<rake>, ["~> 10.0"])
|
128
|
-
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
129
|
-
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
130
|
-
s.add_dependency(%q<pry>, [">= 0"])
|
131
|
-
s.add_dependency(%q<pry-byebug>, [">= 0"])
|
132
|
-
end
|
133
|
-
end
|
20
|
+
spec.required_ruby_version = Gem::Requirement.new('~> 2.1')
|
134
21
|
|
22
|
+
# RightSupport has no mandatory dependencies. It has some optional
|
23
|
+
# dependencies (i.e. gems that it will require and use if they are present).
|
24
|
+
# For more information, refer right_support/Gemfile.
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: right_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Spataro
|
@@ -13,91 +13,14 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2016-
|
17
|
-
dependencies:
|
18
|
-
- !ruby/object:Gem::Dependency
|
19
|
-
name: rake
|
20
|
-
requirement: !ruby/object:Gem::Requirement
|
21
|
-
requirements:
|
22
|
-
- - "~>"
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: '10.0'
|
25
|
-
type: :development
|
26
|
-
prerelease: false
|
27
|
-
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
requirements:
|
29
|
-
- - "~>"
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version: '10.0'
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
name: jeweler
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
35
|
-
requirements:
|
36
|
-
- - "~>"
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: '2.0'
|
39
|
-
type: :development
|
40
|
-
prerelease: false
|
41
|
-
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
requirements:
|
43
|
-
- - "~>"
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '2.0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: ruby-debug
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
requirements:
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '0'
|
53
|
-
type: :development
|
54
|
-
prerelease: false
|
55
|
-
version_requirements: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '0'
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: pry
|
62
|
-
requirement: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - ">="
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '0'
|
67
|
-
type: :development
|
68
|
-
prerelease: false
|
69
|
-
version_requirements: !ruby/object:Gem::Requirement
|
70
|
-
requirements:
|
71
|
-
- - ">="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '0'
|
74
|
-
- !ruby/object:Gem::Dependency
|
75
|
-
name: pry-byebug
|
76
|
-
requirement: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - ">="
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '0'
|
81
|
-
type: :development
|
82
|
-
prerelease: false
|
83
|
-
version_requirements: !ruby/object:Gem::Requirement
|
84
|
-
requirements:
|
85
|
-
- - ">="
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '0'
|
16
|
+
date: 2016-12-14 00:00:00.000000000 Z
|
17
|
+
dependencies: []
|
88
18
|
description: A toolkit of useful, reusable foundation code created by RightScale.
|
89
19
|
email: support@rightscale.com
|
90
20
|
executables: []
|
91
21
|
extensions: []
|
92
|
-
extra_rdoc_files:
|
93
|
-
- LICENSE
|
94
|
-
- README.md
|
22
|
+
extra_rdoc_files: []
|
95
23
|
files:
|
96
|
-
- CHANGELOG.rdoc
|
97
|
-
- LICENSE
|
98
|
-
- README.md
|
99
|
-
- Rakefile
|
100
|
-
- VERSION
|
101
24
|
- lib/right_support.rb
|
102
25
|
- lib/right_support/ci.rb
|
103
26
|
- lib/right_support/ci/java_cucumber_formatter.rb
|
@@ -174,6 +97,7 @@ files:
|
|
174
97
|
- lib/right_support/validation.rb
|
175
98
|
- lib/right_support/validation/openssl.rb
|
176
99
|
- lib/right_support/validation/ssh.rb
|
100
|
+
- lib/right_support/version.rb
|
177
101
|
- right_support.gemspec
|
178
102
|
homepage: https://github.com/rightscale/right_support
|
179
103
|
licenses:
|
@@ -185,9 +109,9 @@ require_paths:
|
|
185
109
|
- lib
|
186
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
187
111
|
requirements:
|
188
|
-
- - "
|
112
|
+
- - "~>"
|
189
113
|
- !ruby/object:Gem::Version
|
190
|
-
version: '
|
114
|
+
version: '2.1'
|
191
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
116
|
requirements:
|
193
117
|
- - ">="
|
@@ -195,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
119
|
version: '0'
|
196
120
|
requirements: []
|
197
121
|
rubyforge_project:
|
198
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.4.5
|
199
123
|
signing_key:
|
200
124
|
specification_version: 4
|
201
125
|
summary: Reusable foundation code.
|
data/CHANGELOG.rdoc
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
== 2.0
|
2
|
-
|
3
|
-
=== Interface-breaking changes
|
4
|
-
|
5
|
-
* Changed some of the more esoteric options of RequestBalancer
|
6
|
-
* Removed TagLogger and CustomLogger middlwares
|
7
|
-
* Renamed Balancing module to LB
|
8
|
-
* Renamed StickyPolicy class to Sticky
|
9
|
-
* Removed Object#if_require_succeeds(&block); too dangerous -- use
|
10
|
-
Object#require_succeeds instead!
|
11
|
-
|
12
|
-
=== New functionality
|
13
|
-
|
14
|
-
* Several new Rack middlewares for request logging & tracking
|
15
|
-
* Statistics gathering, string extensions,
|
16
|
-
* HTTPClient methods can accept query-strings (:query) and/or request body
|
17
|
-
(:payload)
|
18
|
-
|
19
|
-
== 1.0
|
20
|
-
|
21
|
-
=== Interface-breaking changes
|
22
|
-
|
23
|
-
* Moved logging classes (FilterLogger, SystemLogger, TagLogger) into RightSupport::Log namespace
|
24
|
-
* Moved CassandraModel into RightSupport::DB
|
25
|
-
* Removed RightSupport::REST module entirely. Replaced by RightSupport::Net::HTTPClient class.
|
26
|
-
|
27
|
-
=== New functionality
|
28
|
-
|
29
|
-
* RequestBalancer now capable of using multiple policies for endpoint selection.
|
30
|
-
Default is RoundRobin (previously the only option); now you can choose HealthCheck
|
31
|
-
in addition. See rdoc for more info.
|
32
|
-
* RequestBalancer can accept a logger as a class attribute. If supplied, any failed requests
|
33
|
-
will be logged with the error severity, including detailed information about exception type,
|
34
|
-
retryability, etc.
|
35
|
-
* HTTPClient object is a thin wrapper around RestClient that adds some default timeouts.
|
36
|
-
It's appropriate for low-latency REST requests to nearby services; by tweaking the
|
37
|
-
defaults, you can use it for various other scenarios.
|
data/LICENSE
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
Copyright (c) 2009-2014 RightScale, Inc.
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
'Software'), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
-
|
22
|
-
---
|
23
|
-
---
|
24
|
-
|
25
|
-
Some portions of lib/right_support/data/mash.rb and spec/data/mash_spec.rb
|
26
|
-
are modified versions of the extlib library, which is licensed under the
|
27
|
-
MIT license. That license, plus the license of the code from which extlib
|
28
|
-
was derived, is included below:
|
29
|
-
|
30
|
-
Copyright (c) 2010 Dan Kubb
|
31
|
-
|
32
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
33
|
-
a copy of this software and associated documentation files (the
|
34
|
-
"Software"), to deal in the Software without restriction, including
|
35
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
36
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
37
|
-
permit persons to whom the Software is furnished to do so, subject to
|
38
|
-
the following conditions:
|
39
|
-
|
40
|
-
The above copyright notice and this permission notice shall be
|
41
|
-
included in all copies or substantial portions of the Software.
|
42
|
-
|
43
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
44
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
45
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
46
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
47
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
48
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
49
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
50
|
-
|
51
|
-
---
|
52
|
-
---
|
53
|
-
|
54
|
-
Some portions of blank.rb and mash.rb are verbatim copies of software
|
55
|
-
licensed under the MIT license. That license is included below:
|
56
|
-
|
57
|
-
Copyright (c) 2005-2008 David Heinemeier Hansson
|
58
|
-
|
59
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
60
|
-
a copy of this software and associated documentation files (the
|
61
|
-
"Software"), to deal in the Software without restriction, including
|
62
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
63
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
64
|
-
permit persons to whom the Software is furnished to do so, subject to
|
65
|
-
the following conditions:
|
66
|
-
|
67
|
-
The above copyright notice and this permission notice shall be
|
68
|
-
included in all copies or substantial portions of the Software.
|
69
|
-
|
70
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
71
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
72
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
73
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
74
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
75
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
76
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,192 +0,0 @@
|
|
1
|
-
# RightSupport
|
2
|
-
|
3
|
-
This is a library of reusable, unit- and functional-tested Ruby code that RightScale has found broadly useful.
|
4
|
-
|
5
|
-
[](https://travis-ci.org/rightscale/right_support)
|
6
|
-
|
7
|
-
[](https://coveralls.io/r/rightscale/right_support?branch=master)
|
8
|
-
|
9
|
-
Maintained by the RightScale Technicolor Team
|
10
|
-
|
11
|
-
# What Does It Do?
|
12
|
-
|
13
|
-
## Logging
|
14
|
-
|
15
|
-
SystemLogger is a rewrite of the seattle.rb SyslogLogger class that features the following improvements:
|
16
|
-
* Contains several bugfixes vs. SyslogLogger 1.4.0
|
17
|
-
* Inherits from standard Ruby Logger class for guaranteed compatibility
|
18
|
-
* Can be configured with options about how to handle newlines, ANSI escape codes, etc
|
19
|
-
|
20
|
-
We also provide Log::Mixin, a powerful tool that lets you sprinkle a logger
|
21
|
-
into any object or class, and supports per-class or per-instance custom
|
22
|
-
loggers!
|
23
|
-
|
24
|
-
class Jet < Aircraft
|
25
|
-
include RightSupport::Log.Mixin
|
26
|
-
end
|
27
|
-
|
28
|
-
#most jets log to the syslog
|
29
|
-
Jet.logger = RightSupport::Log::SystemLogger.new('black box',
|
30
|
-
:facility=>'local0')
|
31
|
-
|
32
|
-
#but MY jet
|
33
|
-
@my_jet.logger = Logger.new(StringIO.new)
|
34
|
-
|
35
|
-
### Logging for Rack Applications
|
36
|
-
|
37
|
-
RightSupport also provides Rack middleware that allows a Rack app to use any log sink it wishes. The
|
38
|
-
stock Rack logger middleware is inflexible and gives the end user no control over which logger is used
|
39
|
-
or where the log entries go. Example of usage on Sinatra based application:
|
40
|
-
|
41
|
-
class MyApp < Sinatra::Base
|
42
|
-
...
|
43
|
-
# Specify which logger will be used as default logger
|
44
|
-
LOGGER =\
|
45
|
-
if ENV['RACK_ENV'].downcase == 'development'
|
46
|
-
Logger.new(STDOUT)
|
47
|
-
else
|
48
|
-
RightSupport::Log::SystemLogger.new("MyApp", {:facility => "local0"})
|
49
|
-
end
|
50
|
-
|
51
|
-
# use the RequestLogger via LogSetter to log requests for application
|
52
|
-
use RightSupport::Rack::LogSetter, {:logger => LOGGER}
|
53
|
-
use RightSupport::Rack::RequestLogger
|
54
|
-
|
55
|
-
# set logger and mix Log::Mixin
|
56
|
-
RightSupport::Log::Mixin.default_logger = LOGGER
|
57
|
-
include RightSupport::Log::Mixin
|
58
|
-
...
|
59
|
-
end
|
60
|
-
|
61
|
-
After that all rack requests to MyApp will be logged, and since we mixed Log::Mixin we can use:
|
62
|
-
|
63
|
-
logger.info "Hello world\nThis will appear on separate lines\nand without \e[33;0mbeautiful colors"
|
64
|
-
|
65
|
-
## Networking Stuff
|
66
|
-
|
67
|
-
### HTTP Client
|
68
|
-
|
69
|
-
We provide a very thin wrapper around the rest-client gem that enables simple but
|
70
|
-
robust rest requests with a timeout, headers, etc.
|
71
|
-
|
72
|
-
HTTPClient is interface-compatible with the RestClient module, but allows an
|
73
|
-
optional timeout to be specified as an extra parameter.
|
74
|
-
|
75
|
-
# Create a wrapper object
|
76
|
-
@client = RightSupport::Net::HTTPClient.new
|
77
|
-
|
78
|
-
# Default timeout is 5 seconds
|
79
|
-
@client.get('http://localhost')
|
80
|
-
|
81
|
-
# Make sure the HTTPClient request fails after 1 second so we can report an error
|
82
|
-
# and move on!
|
83
|
-
@client.get('http://localhost', {:headers => {'X-Hello'=>'hi!'}, :timeout => 1)}
|
84
|
-
|
85
|
-
# HTTPClient transforms String or Hash :query into query string, for example;
|
86
|
-
@client.get('http://localhost/moo', {:query=>{:a=>{:b=>:c}}} )
|
87
|
-
# the url that would be requested is http://localhost/moo?a[b]=c
|
88
|
-
|
89
|
-
### Client-Side Load Balancer
|
90
|
-
|
91
|
-
RequestBalancer randomly chooses endpoints for a network request, which lets
|
92
|
-
you perform easy client-side load balancing:
|
93
|
-
|
94
|
-
include RightSupport::Net
|
95
|
-
|
96
|
-
urls = ['http://localhost', 'http://otherhost']
|
97
|
-
RequestBalancer.request(urls, :fatal=>RestClient::ResourceNotFound) do |url|
|
98
|
-
REST.get(url)
|
99
|
-
end
|
100
|
-
|
101
|
-
The balancer will keep trying requests until one of them succeeds without
|
102
|
-
throwing any exceptions. (NB: a nil return value counts as success!!)
|
103
|
-
|
104
|
-
### HTTP Request Tracking for Rack
|
105
|
-
|
106
|
-
Correlate data flows across your entire architecture with the RequestTracker
|
107
|
-
middleware, which uses custom HTTP headers to "tag" every Web request with
|
108
|
-
a UUID, and works with RequestLogger to log "begin" and "end" lines containing
|
109
|
-
the UUID.
|
110
|
-
|
111
|
-
If your app consumes the UUID and passes it on to HTTP services that it
|
112
|
-
invokes, the same request UUID will appear in all logs and you can grep for
|
113
|
-
the "big picture" instead of wasting time paging between logs.
|
114
|
-
|
115
|
-
To use this functionality you need:
|
116
|
-
|
117
|
-
use RightSupport::Rack::RequestTracker
|
118
|
-
|
119
|
-
## Statistics Gathering
|
120
|
-
|
121
|
-
Profile your compute-heavy and network activities using a Stats::Activity counter.
|
122
|
-
|
123
|
-
stats = RightSupport::Stats::Activity.new
|
124
|
-
|
125
|
-
puts 'enter 5 lines:'
|
126
|
-
5.times do
|
127
|
-
stats.update(:read_input)
|
128
|
-
line = STDIN.readline
|
129
|
-
stats.finish
|
130
|
-
end
|
131
|
-
|
132
|
-
puts "Only %.1f lines/sec? You are a slow typist!" % [stats.avg_rate]
|
133
|
-
|
134
|
-
## Input Validation
|
135
|
-
|
136
|
-
Validation contains several format-checkers that can be used to validate your
|
137
|
-
web app's models before saving, check for preconditions in your controllers,
|
138
|
-
and so forth.
|
139
|
-
|
140
|
-
You can use it as a mixin by including the appropriate child module of
|
141
|
-
RightSupport::Validation.
|
142
|
-
|
143
|
-
class AwesomenessGenerator < ActiveRecord::Base
|
144
|
-
include RightSupport::Validation::OpenSSL
|
145
|
-
|
146
|
-
before_save do |record|
|
147
|
-
errors[:foo] = 'Hey, that's not a key!' unless pem_public_key?(record.foo)
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
But you really don't want to do that, do you? Instead, you want to call the module
|
152
|
-
methods of RightSupport::Validation, which contains all of the same mixin methods,
|
153
|
-
but does not pollute the dispatch table of your application classes.
|
154
|
-
|
155
|
-
the_key = STDIN.read
|
156
|
-
raise ArgumentError unless RightSupport::Validation.ssh_public_key?(the_key)
|
157
|
-
|
158
|
-
## String Manipulation
|
159
|
-
|
160
|
-
StringExtensions contains String#camelize, which is only defined if the
|
161
|
-
ActiveSupport gem cannot be loaded. It also has some RightScale-specific
|
162
|
-
methods:
|
163
|
-
* String#snake_case
|
164
|
-
* String#to_const
|
165
|
-
* String#to_const_path
|
166
|
-
|
167
|
-
Net::StringEncoder applies and removes URL-escape, base64 and other encodings.
|
168
|
-
|
169
|
-
## Configuration
|
170
|
-
|
171
|
-
RightSupport::Config contains functionality, which provides possibility
|
172
|
-
to use human-readable yaml configuration files. For example, you have following yaml
|
173
|
-
file '/tmp/features_config.yml', with content:
|
174
|
-
|
175
|
-
eat:
|
176
|
-
khlav kalash: YES!
|
177
|
-
speak:
|
178
|
-
klingonese: false
|
179
|
-
belarusian: true
|
180
|
-
|
181
|
-
Then, if you would add configuration in you class, like:
|
182
|
-
|
183
|
-
class SweetestClass
|
184
|
-
CONFIG = RightSupport::Config.features('/tmp/features_config.yml')
|
185
|
-
end
|
186
|
-
|
187
|
-
* RightSupport::Config.features receives file` path, io or string.
|
188
|
-
|
189
|
-
Now you can call CONFIG['feature_group']['feature'], like:
|
190
|
-
|
191
|
-
* SweetestClass::CONFIG['eat']['khlav kalash'] would return 'YES!'
|
192
|
-
* SweetestClass::CONFIG['speak']['belarusian'] would return true
|
data/Rakefile
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
# -*-ruby-*-
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bundler/setup'
|
4
|
-
|
5
|
-
require 'rake'
|
6
|
-
require 'rubygems/package_task'
|
7
|
-
|
8
|
-
require 'rake/clean'
|
9
|
-
require 'rspec/core/rake_task'
|
10
|
-
require 'cucumber/rake/task'
|
11
|
-
|
12
|
-
# These dependencies can be omitted using "bundle install --without"; tolerate their absence.
|
13
|
-
['rdoc/task', 'jeweler', 'coveralls/rake/task'].each do |optional|
|
14
|
-
begin
|
15
|
-
require optional
|
16
|
-
rescue LoadError
|
17
|
-
# ignore
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# But, we have a very special need, because OUR Cucumbers need to run with a pristine
|
22
|
-
# environment that isn't polluted by RVM or RubyGems or anyone else, in order to validate
|
23
|
-
# that RightSupport's CI harness doesn't break your app if those gems are unavailable.
|
24
|
-
# Thus when our own Rake task runs spec or cucumber as a subprocess, we need to give it
|
25
|
-
# a pristine non-bundled environment, so it can use Bundler.with_clean_env to launch
|
26
|
-
# subprocesses.
|
27
|
-
require File.expand_path('../features/support/file_utils_bundler_mixin', __FILE__)
|
28
|
-
|
29
|
-
desc "Run unit tests"
|
30
|
-
task :default => :spec
|
31
|
-
|
32
|
-
desc "Run unit tests"
|
33
|
-
RSpec::Core::RakeTask.new do |t|
|
34
|
-
t.pattern = Dir['**/*_spec.rb']
|
35
|
-
end
|
36
|
-
|
37
|
-
desc "Run functional tests"
|
38
|
-
Cucumber::Rake::Task.new do |t|
|
39
|
-
t.cucumber_opts = %w{--color --format pretty}
|
40
|
-
end
|
41
|
-
|
42
|
-
if defined?(Rake::RDocTask)
|
43
|
-
desc 'Generate documentation for the right_support gem.'
|
44
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
45
|
-
rdoc.rdoc_dir = 'doc'
|
46
|
-
rdoc.title = 'RightSupport'
|
47
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
48
|
-
rdoc.rdoc_files.include('README.rdoc')
|
49
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
-
rdoc.rdoc_files.exclude('features/**/*')
|
51
|
-
rdoc.rdoc_files.exclude('spec/**/*')
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
if defined?(Jeweler)
|
56
|
-
tasks = Jeweler::Tasks.new do |gem|
|
57
|
-
# gem is a Gem::Specification; see http://docs.rubygems.org/read/chapter/20 for more options
|
58
|
-
gem.name = "right_support"
|
59
|
-
gem.homepage = "https://github.com/rightscale/right_support"
|
60
|
-
gem.license = "MIT"
|
61
|
-
gem.summary = %Q{Reusable foundation code.}
|
62
|
-
gem.description = %Q{A toolkit of useful, reusable foundation code created by RightScale.}
|
63
|
-
gem.email = "support@rightscale.com"
|
64
|
-
gem.authors = ['Tony Spataro', 'Sergey Sergyenko', 'Ryan Williamson', 'Lee Kirchhoff', 'Alexey Karpik', 'Scott Messier']
|
65
|
-
gem.files.exclude "Gemfile*"
|
66
|
-
gem.files.exclude ".*"
|
67
|
-
gem.files.exclude "features/**/*"
|
68
|
-
gem.files.exclude "spec/**/*"
|
69
|
-
end
|
70
|
-
|
71
|
-
# Never auto-commit during operations that change the repository. Allows developers to decide on their own commit comment
|
72
|
-
# and/or aggregate version bumps into other fixes.
|
73
|
-
tasks.jeweler.commit = false
|
74
|
-
|
75
|
-
Jeweler::RubygemsDotOrgTasks.new
|
76
|
-
end
|
77
|
-
|
78
|
-
if defined?(Coveralls)
|
79
|
-
Coveralls::RakeTask.new
|
80
|
-
end
|
81
|
-
|
82
|
-
CLEAN.include('pkg')
|
83
|
-
|
84
|
-
require 'right_develop'
|
85
|
-
RightDevelop::CI::RakeTask.new
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.13.3
|