vault-tools 0.3.9 → 0.3.10
Sign up to get free protection for your applications and to get access to all the features.
- data/.ruby-version +1 -1
- data/lib/vault-tools.rb +1 -0
- data/lib/vault-tools/text_processor.rb +48 -0
- data/lib/vault-tools/version.rb +1 -1
- data/test/text_processor_test.rb +31 -0
- data/vault-tools.gemspec +1 -0
- metadata +22 -4
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.3-p429
|
data/lib/vault-tools.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'fernet'
|
2
|
+
|
3
|
+
module Vault::Tools
|
4
|
+
module TextEnc
|
5
|
+
FERNET_ENCODE = lambda { |string|
|
6
|
+
secret = ENV['FERNET_SECRET']
|
7
|
+
Fernet.generate(secret, string)
|
8
|
+
}
|
9
|
+
|
10
|
+
FERNET_DECODE = lambda { |token|
|
11
|
+
secret = ENV['FERNET_SECRET']
|
12
|
+
verifier = Fernet.verifier(secret, token)
|
13
|
+
verifier.message
|
14
|
+
}
|
15
|
+
|
16
|
+
DEFLATE = lambda { |string|
|
17
|
+
z = Zlib::Deflate.new
|
18
|
+
dst = z.deflate(string, Zlib::FINISH)
|
19
|
+
z.close
|
20
|
+
dst
|
21
|
+
}
|
22
|
+
|
23
|
+
INFLATE = lambda { |string|
|
24
|
+
z = Zlib::Inflate.new
|
25
|
+
dst = z.inflate(string)
|
26
|
+
z.close
|
27
|
+
dst
|
28
|
+
}
|
29
|
+
|
30
|
+
class Write < Vault::Pipeline
|
31
|
+
use DEFLATE
|
32
|
+
use FERNET_ENCODE
|
33
|
+
end
|
34
|
+
|
35
|
+
class Read < Vault::Pipeline
|
36
|
+
use FERNET_DECODE
|
37
|
+
use INFLATE
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.write(string)
|
41
|
+
Write.process(string)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.read(string)
|
45
|
+
Read.process(string)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/vault-tools/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TextProcessorTest < Vault::TestCase
|
4
|
+
def setup
|
5
|
+
set_env 'FERNET_SECRET', 'Mcdej7RFV/yHDrs1P8mrYP9zcw4JxSyReqYyELDrRPY='
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_roundtrip
|
9
|
+
string = 'foo'
|
10
|
+
write = Vault::Tools::TextEnc::Write.process(string)
|
11
|
+
read = Vault::Tools::TextEnc::Read.process(write)
|
12
|
+
assert_equal string, read
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_roundtrip2
|
16
|
+
string = 'foo'
|
17
|
+
write = Vault::Tools::TextEnc.write(string)
|
18
|
+
read = Vault::Tools::TextEnc.read(write)
|
19
|
+
assert_equal string, read
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_write_is_smaller_size
|
23
|
+
string = 'foo' * 100
|
24
|
+
write = Vault::Tools::TextEnc::Write.process(string)
|
25
|
+
assert string.size > write.size, "Written String should be smaller than raw string"
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_easy_named_functions
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
data/vault-tools.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vault-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-10-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: scrolls
|
@@ -92,6 +92,22 @@ dependencies:
|
|
92
92
|
- - ! '>='
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: fernet
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - '='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.0.rc2
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.0.rc2
|
95
111
|
description: Basic tools for Heroku Vault's Ruby projects
|
96
112
|
email:
|
97
113
|
- christopher.continanza@gmail.com
|
@@ -120,6 +136,7 @@ files:
|
|
120
136
|
- lib/vault-tools/product.rb
|
121
137
|
- lib/vault-tools/shushu_db_tasks.rb
|
122
138
|
- lib/vault-tools/sinatra_helpers/html_serializer.rb
|
139
|
+
- lib/vault-tools/text_processor.rb
|
123
140
|
- lib/vault-tools/user.rb
|
124
141
|
- lib/vault-tools/version.rb
|
125
142
|
- lib/vault-tools/web.rb
|
@@ -130,6 +147,7 @@ files:
|
|
130
147
|
- test/log_test.rb
|
131
148
|
- test/pipeline_test.rb
|
132
149
|
- test/product_test.rb
|
150
|
+
- test/text_processor_test.rb
|
133
151
|
- test/time_test.rb
|
134
152
|
- test/user_test.rb
|
135
153
|
- test/web_test.rb
|
@@ -148,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
166
|
version: '0'
|
149
167
|
segments:
|
150
168
|
- 0
|
151
|
-
hash:
|
169
|
+
hash: 3536867358711533404
|
152
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
171
|
none: false
|
154
172
|
requirements:
|
@@ -157,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
175
|
version: '0'
|
158
176
|
segments:
|
159
177
|
- 0
|
160
|
-
hash:
|
178
|
+
hash: 3536867358711533404
|
161
179
|
requirements: []
|
162
180
|
rubyforge_project:
|
163
181
|
rubygems_version: 1.8.23
|