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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b14c43a8bb5fd247a9055fad5a034cdf105a105
4
- data.tar.gz: 609d7736dd12d4122767c805a6a6f359ccdee237
3
+ metadata.gz: d82cd3ad90a9906318aca7572db5f59d1c094dbf
4
+ data.tar.gz: e0930a914e3616434c14fe4e281efbebf7c427ea
5
5
  SHA512:
6
- metadata.gz: 7252a233ceb798d1215494de81c07c8b578022126afc092273ee1f5a71fa22f3c1fdec8ed80d4f801194c308e62b1e6dd6e56c77425aece2230db952ab174d6a
7
- data.tar.gz: c71d75fed79a2123c5848a742e77d108fe8d5287cc24516bd29680f40d75f5d83acb8d459ee4f763214012fb037ba00bf43f5d99786b76c86409e48c1e99dc99
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
@@ -4,6 +4,6 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :development do
7
- gem 'byebug', require: false
8
- gem 'simplecov', require: false
7
+ gem 'byebug', require: false, platforms: :ruby
8
+ gem 'simplecov', require: false, platforms: :ruby
9
9
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Opto
2
- VERSION = "1.5.0"
2
+ VERSION = "1.5.1"
3
3
  end
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. Example: Opto.new(type: :string, name: 'FOO', min_length: 20, from: :env).valid?"
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.0
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-28 00:00:00.000000000 Z
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: 'Create validatable and resolvable options from hashes or YAML. Example:
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
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here