opto 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +2 -2
- data/lib/opto/types/string.rb +26 -0
- data/lib/opto/version.rb +1 -1
- data/opto.gemspec +1 -3
- metadata +4 -9
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d82cd3ad90a9906318aca7572db5f59d1c094dbf
|
4
|
+
data.tar.gz: e0930a914e3616434c14fe4e281efbebf7c427ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf04300dadf14338bc74a33f05ffe418ddc42dc722c0e8fd4210d52af763b292edc1a2fd8d758ff4d70207cc32e4d431c6f8d69decd817008b5ccd3bce9ce3dc
|
7
|
+
data.tar.gz: d3a66ceed430d6588534c8a223c50c6aa88bf1816633249fa6731d5274969e02e6800a9a6746c9fa9cbc58d153576142f2f5ffd979d3da11214501f7fad43562
|
data/.travis.yml
CHANGED
@@ -4,6 +4,9 @@ rvm:
|
|
4
4
|
- 2.1.8
|
5
5
|
- 2.2.3
|
6
6
|
- 2.3.1
|
7
|
+
- 2.3.3
|
8
|
+
- 2.4.0-preview3
|
9
|
+
- jruby-9.1.5.0
|
7
10
|
env:
|
8
11
|
- secure: "bCu1bVzr6SP+gAbMo88GvcHHbhO3LcnJtWp+YuSZ5qW4EHhdBw+DOQeOlzoKHtYhNhptmb/65pZZctRTE6jOOSZzpOUHaeqaqHZpELldkCMu7rE8bXuCV4OfhG0CKWvURS0x5p5F5onEx1a1sjiu+MVEUqktAPDAcdTBNBW1irRwvnSifgjcZRLzfm1aRs1fqzBJpHaAXyD++2GQaWyXDtQsEsc/Eyhmnkac5Y2cTeQiYlDluqBeB885q9K16ruLp2NWx/rnR8RGMP1LSnrye/GEo2mRWOWy1MyIEwNDcVaA6MVDY2GBIQUoXg4PBrZAleVIsO3LzwR4oorFCaSgWxzqYI67g5Kb2zn8fW9Yu5lDcFEJKIHQAwBrlq3n3Mi5it/IxGQDWXQ/2fjBxCwuilvI0WTzOH0m4g8Uf6jHaQLFC6ahdWDjfs6aCzdPpbJls26/r39NIB5k/6ZO29NZkxGBsQ7E7m4wurr7a9ksLODgPOyPiB8/4Txu35Llp+IuJpbshrlkRIMwEIFVWiLi6MZhRBkxaRzlkJQ0bS3RD9W4z9UJyoBujmgXMrv0eHNTGCOC+/4tvrA+pXzJwmFQJA6TnenoDl9hc6o03gyfH/YvmMgrtJLbJ8rGoLRaY8HsQwHWgimpCl1o043kO8/UkhhS7J4wyQXYwqGnA2PC/j0="
|
9
12
|
before_install: gem install bundler -v 1.12.5
|
data/Gemfile
CHANGED
data/lib/opto/types/string.rb
CHANGED
@@ -23,6 +23,7 @@ module Opto
|
|
23
23
|
# - strip: set to true to remove leading and trailing whitespace
|
24
24
|
# - chomp: set to true to remove trailing linefeed
|
25
25
|
# - capitalize: set to true to upcase the first letter
|
26
|
+
# - hexdigest: valid options: md5, sha1, sha256, sha384, sha512 and nil/false. generate an md5/sha1/etc hexdigest from the value.
|
26
27
|
class String < Opto::Type
|
27
28
|
using Opto::Extension::HashStringOrSymbolKey unless RUBY_VERSION < '2.1'
|
28
29
|
|
@@ -32,6 +33,7 @@ module Opto
|
|
32
33
|
min_length: nil,
|
33
34
|
max_length: nil,
|
34
35
|
empty_is_nil: true,
|
36
|
+
hexdigest: false,
|
35
37
|
encode_64: false,
|
36
38
|
decode_64: false
|
37
39
|
}.merge(Hash[*TRANSFORMATIONS.flat_map {|tr| [tr, false]}])
|
@@ -45,6 +47,30 @@ module Opto
|
|
45
47
|
(options[:decode_64] && value) ? Base64.decode64(value) : value
|
46
48
|
end
|
47
49
|
|
50
|
+
sanitizer :hexdigest do |value|
|
51
|
+
case options[:hexdigest]
|
52
|
+
when 'md5'
|
53
|
+
require 'digest/md5'
|
54
|
+
Digest::MD5.hexdigest(value)
|
55
|
+
when 'sha1'
|
56
|
+
require 'digest/sha1'
|
57
|
+
Digest::SHA1.hexdigest(value)
|
58
|
+
when 'sha256'
|
59
|
+
require 'digest/sha2'
|
60
|
+
Digest::SHA256.hexdigest(value)
|
61
|
+
when 'sha384'
|
62
|
+
require 'digest/sha2'
|
63
|
+
Digest::SHA384.hexdigest(value)
|
64
|
+
when 'sha512'
|
65
|
+
require 'digest/sha2'
|
66
|
+
Digest::SHA512.hexdigest(value)
|
67
|
+
when NilClass, FalseClass
|
68
|
+
value
|
69
|
+
else
|
70
|
+
raise TypeError, "Invalid hexdigest, valid options: md5, sha1, sha256, sha384, sha512 and nil/false"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
48
74
|
TRANSFORMATIONS.each do |transform|
|
49
75
|
sanitizer transform do |value|
|
50
76
|
(options[transform] && value.respond_to?(transform)) ? value.send(transform) : value
|
data/lib/opto/version.rb
CHANGED
data/opto.gemspec
CHANGED
@@ -10,12 +10,10 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["info@kontena.io"]
|
11
11
|
|
12
12
|
spec.summary = "Option validator / resolver"
|
13
|
-
spec.description = "Create validatable and resolvable options from hashes or YAML
|
13
|
+
spec.description = "Create validatable and resolvable options from hashes or YAML"
|
14
14
|
spec.homepage = "https://github.com/kontena/opto"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir = "bin"
|
18
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
17
|
spec.require_paths = ["lib"]
|
20
18
|
|
21
19
|
spec.add_development_dependency "bundler", "~> 1.12"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kimmo Lehto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,13 +52,10 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description:
|
56
|
-
Opto.new(type: :string, name: ''FOO'', min_length: 20, from: :env).valid?'
|
55
|
+
description: Create validatable and resolvable options from hashes or YAML
|
57
56
|
email:
|
58
57
|
- info@kontena.io
|
59
|
-
executables:
|
60
|
-
- console
|
61
|
-
- setup
|
58
|
+
executables: []
|
62
59
|
extensions: []
|
63
60
|
extra_rdoc_files: []
|
64
61
|
files:
|
@@ -69,8 +66,6 @@ files:
|
|
69
66
|
- LICENSE.txt
|
70
67
|
- README.md
|
71
68
|
- Rakefile
|
72
|
-
- bin/console
|
73
|
-
- bin/setup
|
74
69
|
- lib/opto.rb
|
75
70
|
- lib/opto/extensions/hash_string_or_symbol_key.rb
|
76
71
|
- lib/opto/extensions/snake_case.rb
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "opto"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|