opts_validator 0.0.1

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/opts_validator.rb +24 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 11d3cd9d246627375ebce62a85ebfaf8b9db20c2
4
+ data.tar.gz: 4e22a6f24e11b68e5d9a5b861639074525a807e0
5
+ SHA512:
6
+ metadata.gz: 4a9d5743ce4029e4e67cc7a0618c54a86560b87768d765f12fdd15c36c9542cddaf0ed91570c5b5fbd97f8c71206e6d116eb56803a960bfc3a028e8dced46e1d
7
+ data.tar.gz: aa56cb7d35f4cfbfb7073f663cb401b7096fba886240deb29220a35f3fde86f2d0387b35c2c8e9ea8a24a6dad9544d4609bcfbf33d8071826223501014d84ee7
@@ -0,0 +1,24 @@
1
+ require 'colorize'
2
+ class OptsValidator
3
+ def initialize(options, logger = nil)
4
+ @options = options
5
+ @logger = logger
6
+ end
7
+
8
+ def validate_presence_of(symbol, description = nil, flag = nil)
9
+ if @options[symbol].nil?
10
+ if description.nil?
11
+ message = "You must provide the #{symbol} parameter"
12
+ else
13
+ message = "You must provide the #{description} parameter"
14
+ message += " (-#{flag} flag)" unless flag.nil?
15
+ end
16
+ unless @logger.nil?
17
+ @logger.error(message)
18
+ else
19
+ puts message.red
20
+ end
21
+ exit
22
+ end
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opts_validator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Giovanni Benussi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Validate the presence of cli params the easy way
14
+ email: giovanni.benussi@usach.cl
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/opts_validator.rb
20
+ homepage: http://rubygems.org/gems/opts_validator
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.4.8
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Validate the presence of cli params the easy way
44
+ test_files: []