pad_utils 1.6.0 → 1.7.0

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: 58ba3d3b2eea40a399913261cc63c6fa6673fd95
4
- data.tar.gz: 9d80db089a6ffbb0f1152abda5f30a027da35ec4
3
+ metadata.gz: 2c866ba52f08ad70ea12b0849da51eb48827e26d
4
+ data.tar.gz: 03d9dbcfae5e000085c01fcff96d8a572bd04daa
5
5
  SHA512:
6
- metadata.gz: 4947d63a00f1f86f74a5c6adedc4173d9dfc8d413e8714dd3bcb520077f6363379044156ea5b982db035a18b98f4450e7b92daf6adb64e6b455e25c2b7db41bc
7
- data.tar.gz: 185c906198551cbe36130f59d604c76227c6119173c1205c11a24691152015867b4474433b1699507f61ca9e925ab7a03dfa93071245f4ff4a865f9737630a4b
6
+ metadata.gz: efea21ea946d55293fec6049bc1c28122efb8a70034553293fcc3593b635ad51881452a3e90739a75c5b53f1593a485b790b68ad0079401ddc34f6e33358acc4
7
+ data.tar.gz: df46586ba70a4e931bd39daa5e759b0257cfbb04ba4a620da7e8831905eef0f3bbccc6eb4655b689c0d891ac8b7b0c1f357f4eeb0484126d99cbba037a7b6d42
@@ -1,3 +1,4 @@
1
+ require 'securerandom'
1
2
  module PadUtils
2
3
 
3
4
  # Converts a Ruby filename to a class name
@@ -28,4 +29,22 @@ module PadUtils
28
29
  Object.const_get(class_name)
29
30
  end
30
31
 
32
+ # Generate UUID's.
33
+ #
34
+ # @param count [Int] how many uuid's to generate
35
+ # @return [String, Array<String>] if only one uuid generated, returns a `String`. If not, an `Array`.
36
+ # @example
37
+ # PadUtils.uuid(2) # => ["96b0a57c-d9ae-453f-b56f-3b154eb10cda", "332a0fa3-7b07-41e1-9fc8-ef804a377e4e"]
38
+ def self.uuid(count = 1)
39
+ if count == 1
40
+ SecureRandom.uuid
41
+ else
42
+ result = []
43
+ (1..count).each do
44
+ result << SecureRandom.uuid
45
+ end
46
+ result
47
+ end
48
+ end
49
+
31
50
  end
@@ -6,9 +6,9 @@ module PadUtils
6
6
  #
7
7
  # @param question [String] the question to ask
8
8
  # @param default [String] the default answer as `"y"` or `"n"` - (*default: `"y"`*)
9
- # @return [String] the answer as `"y"` or `"n"`
9
+ # @return [Boolean] `true` if `yes`, `false` for anything else
10
10
  # @example
11
- # PadUtils.yes_no_menu("Is it cold outside?", default: "n")
11
+ # PadUtils.yes_no_menu(question: "Is it cold outside?", default: "n")
12
12
  def self.yes_no_menu(question: "Question?", default: "y")
13
13
  default_answer = default == "y" ? "(Y/n)" : "(y/N)"
14
14
  STDOUT.print "#{question} #{default_answer}: "
@@ -1,4 +1,4 @@
1
1
  module PadUtils
2
2
  # PadUtils version number
3
- VERSION = "1.6.0"
3
+ VERSION = "1.7.0"
4
4
  end
data/lib/pad_utils.rb CHANGED
@@ -15,10 +15,19 @@ require_relative "pad_utils/pad_code"
15
15
  # PadUtils.some_method(param)
16
16
  module PadUtils
17
17
 
18
- # Entry point for the executable. Not really useful.
18
+ # Entry point for the executable.
19
19
  def self.main(arg)
20
+ if arg[0] == '-u'
21
+ PadUtils.puts_c PadUtils.uuid, :blue
22
+ else
23
+ help
24
+ end
25
+ end
26
+
27
+ # Display version of PadUtils if no switches are passed.
28
+ def self.help
20
29
  puts
21
- puts "PadUtils v.#{PadUtils::VERSION}"
30
+ PadUtils.puts_c "PadUtils v.#{PadUtils::VERSION}", :green
22
31
  puts
23
32
  puts "Part of the Padstone app builder (http://padstone.io)"
24
33
  puts
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pad_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Schuele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-03 00:00:00.000000000 Z
11
+ date: 2016-03-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: PadUtils is a simple gem containing common utilities and shortcuts. It
14
14
  is used in the [Padstone](http://padstone.io) app builder but can be embedded in