blackbox 1.0.1 → 1.1.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/.gitattributes +2 -0
- data/Guardfile +16 -0
- data/Makefile +24 -0
- data/blackbox.gemspec +4 -0
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +171 -2
- data/coverage/index.html +1064 -34
- data/doc/BB.html +5 -5
- data/doc/BB/Crypto.html +21 -21
- data/doc/BB/Hash.html +4 -4
- data/doc/BB/String.html +2 -2
- data/doc/_index.html +17 -2
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +2 -2
- data/doc/index.html +2 -2
- data/doc/method_list.html +24 -0
- data/doc/top-level-namespace.html +2 -2
- data/lib/blackbox/crypto.rb +24 -24
- data/lib/blackbox/number.rb +167 -0
- data/lib/blackbox/version.rb +1 -1
- data/spec/blackbox_spec.rb +1 -1
- data/spec/crypto_spec.rb +4 -4
- data/spec/hash_spec.rb +4 -4
- data/spec/number_spec.rb +93 -0
- data/spec/string_spec.rb +1 -1
- metadata +65 -3
data/lib/blackbox/version.rb
CHANGED
data/spec/blackbox_spec.rb
CHANGED
data/spec/crypto_spec.rb
CHANGED
@@ -28,25 +28,25 @@ describe BB::Crypto do
|
|
28
28
|
it "can decrypt what it encrypted (short string, random iv)" do
|
29
29
|
ct = BB::Crypto.send(m_enc, TEST_TEXT_SHORT, TEST_KEY, cipher)
|
30
30
|
pt = BB::Crypto.send(m_dec, ct, TEST_KEY, cipher)
|
31
|
-
pt.
|
31
|
+
expect(pt).to eq(TEST_TEXT_SHORT)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "can decrypt what it encrypted (long string, random iv)" do
|
35
35
|
ct = BB::Crypto.send(m_enc, TEST_TEXT_LONG, TEST_KEY, cipher)
|
36
36
|
pt = BB::Crypto.send(m_dec, ct, TEST_KEY, cipher)
|
37
|
-
pt.
|
37
|
+
expect(pt).to eq(TEST_TEXT_LONG)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "can decrypt what it encrypted (long string, static iv)" do
|
41
41
|
ct = BB::Crypto.send(m_enc, TEST_TEXT_LONG, TEST_KEY, cipher, TEST_IV)
|
42
42
|
pt = BB::Crypto.send(m_dec, ct, TEST_KEY, cipher, TEST_IV)
|
43
|
-
pt.
|
43
|
+
expect(pt).to eq(TEST_TEXT_LONG)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "returns consistent output with static iv" do
|
47
47
|
a = BB::Crypto.send(m_enc, TEST_TEXT_SHORT, TEST_KEY, cipher, TEST_IV)
|
48
48
|
b = BB::Crypto.send(m_enc, TEST_TEXT_SHORT, TEST_KEY, cipher, TEST_IV)
|
49
|
-
a.
|
49
|
+
expect(a).to eq(b)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
data/spec/hash_spec.rb
CHANGED
@@ -6,14 +6,14 @@ describe BB::Hash do
|
|
6
6
|
it "turns all keys into symbols" do
|
7
7
|
have = { 'foo' => 1, :bar => 2, 'batz' => 3 }
|
8
8
|
want = { :foo => 1, :bar => 2, :batz => 3 }
|
9
|
-
BB::Hash.symbolize_keys(have).
|
9
|
+
expect(BB::Hash.symbolize_keys(have)).to eq(want)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "raises NoMethodError when #to_sym fails for a key" do
|
13
|
-
|
13
|
+
expect {
|
14
14
|
have = { 'foo' => 1, 2 => 2, :bar => 3 }
|
15
15
|
BB::Hash.symbolize_keys(have)
|
16
|
-
}.
|
16
|
+
}.to raise_error NoMethodError
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -44,7 +44,7 @@ describe BB::Hash do
|
|
44
44
|
"nested_with_array.b.bb"=>"a,b,3",
|
45
45
|
"nested_with_array.c.cc"=>"a,b,3"
|
46
46
|
}
|
47
|
-
BB::Hash::flatten_prop_style(have).
|
47
|
+
expect(BB::Hash::flatten_prop_style(have)).to eq(want)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/spec/number_spec.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'blackbox/number'
|
3
|
+
|
4
|
+
describe BB::Number do
|
5
|
+
|
6
|
+
describe '.with_delimiter' do
|
7
|
+
it "delimits" do
|
8
|
+
have = 98765432.98
|
9
|
+
want = "98A765A432B98"
|
10
|
+
expect(BB::Number.with_delimiter(have, :delimiter => 'A', :separator => 'B' )).to eq(want)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.with_precision' do
|
15
|
+
it "precises" do
|
16
|
+
have = 1111.2345
|
17
|
+
want = "1A111B23"
|
18
|
+
expect(BB::Number.with_precision(have, :precision => 2, :delimiter => 'A', :separator => 'B' )).to eq(want)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.to_human_size' do
|
23
|
+
|
24
|
+
it "passes through values < base" do
|
25
|
+
have = 1023
|
26
|
+
want = "1023"
|
27
|
+
expect(BB::Number.to_human_size(have)).to eq(want)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "humanizes a kilobyte" do
|
31
|
+
have = 1024
|
32
|
+
want = "1k"
|
33
|
+
expect(BB::Number.to_human_size(have)).to eq(want)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "humanizes a megabyte" do
|
37
|
+
have = 1048576
|
38
|
+
want = "1M"
|
39
|
+
expect(BB::Number.to_human_size(have)).to eq(want)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "humanizes a megabyte (base 1000)" do
|
43
|
+
have = 1000000
|
44
|
+
want = "1M"
|
45
|
+
expect(BB::Number.to_human_size(have, :kilo => 1000)).to eq(want)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "humanizes a gigabyte" do
|
49
|
+
have = 1024*1024*1024
|
50
|
+
want = "1G"
|
51
|
+
expect(BB::Number.to_human_size(have)).to eq(want)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "humanizes a terabyte" do
|
55
|
+
have = 1024*1024*1024*1024
|
56
|
+
want = "1T"
|
57
|
+
expect(BB::Number.to_human_size(have)).to eq(want)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "humanizes a petabyte" do
|
61
|
+
have = 1024*1024*1024*1024*1024
|
62
|
+
want = "1P"
|
63
|
+
expect(BB::Number.to_human_size(have)).to eq(want)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "humanizes a exabyte" do
|
67
|
+
have = 1024*1024*1024*1024*1024*1024
|
68
|
+
want = "1E"
|
69
|
+
expect(BB::Number.to_human_size(have)).to eq(want)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "humanizes a zettabyte" do
|
73
|
+
have = 1024*1024*1024*1024*1024*1024*1024
|
74
|
+
want = "1Z"
|
75
|
+
expect(BB::Number.to_human_size(have)).to eq(want)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "humanizes a yottabyte" do
|
79
|
+
have = 1024*1024*1024*1024*1024*1024*1024*1024
|
80
|
+
want = "1Y"
|
81
|
+
expect(BB::Number.to_human_size(have)).to eq(want)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "humanizes 1024.42 yottabytes" do
|
85
|
+
have = 1024*1024*1024*1024*1024*1024*1024*1024*1024.42
|
86
|
+
want = "1024.42Y"
|
87
|
+
expect(BB::Number.to_human_size(have, :precision => 2)).to eq(want)
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
data/spec/string_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,6 +80,62 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bump
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: fuubar
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
83
139
|
description: Various little helpers
|
84
140
|
email:
|
85
141
|
- moe@busyloop.net
|
@@ -87,10 +143,13 @@ executables: []
|
|
87
143
|
extensions: []
|
88
144
|
extra_rdoc_files: []
|
89
145
|
files:
|
146
|
+
- ".gitattributes"
|
90
147
|
- ".gitignore"
|
91
148
|
- ".rspec"
|
92
149
|
- Gemfile
|
150
|
+
- Guardfile
|
93
151
|
- LICENSE.txt
|
152
|
+
- Makefile
|
94
153
|
- README.md
|
95
154
|
- Rakefile
|
96
155
|
- blackbox.gemspec
|
@@ -158,11 +217,13 @@ files:
|
|
158
217
|
- lib/blackbox.rb
|
159
218
|
- lib/blackbox/crypto.rb
|
160
219
|
- lib/blackbox/hash.rb
|
220
|
+
- lib/blackbox/number.rb
|
161
221
|
- lib/blackbox/string.rb
|
162
222
|
- lib/blackbox/version.rb
|
163
223
|
- spec/blackbox_spec.rb
|
164
224
|
- spec/crypto_spec.rb
|
165
225
|
- spec/hash_spec.rb
|
226
|
+
- spec/number_spec.rb
|
166
227
|
- spec/spec_helper.rb
|
167
228
|
- spec/string_spec.rb
|
168
229
|
homepage: https://github.com/busyloop/blackbox
|
@@ -185,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
246
|
version: '0'
|
186
247
|
requirements: []
|
187
248
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
249
|
+
rubygems_version: 2.4.5
|
189
250
|
signing_key:
|
190
251
|
specification_version: 4
|
191
252
|
summary: Various little helpers
|
@@ -193,6 +254,7 @@ test_files:
|
|
193
254
|
- spec/blackbox_spec.rb
|
194
255
|
- spec/crypto_spec.rb
|
195
256
|
- spec/hash_spec.rb
|
257
|
+
- spec/number_spec.rb
|
196
258
|
- spec/spec_helper.rb
|
197
259
|
- spec/string_spec.rb
|
198
260
|
has_rdoc:
|