nifty-utils 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/nifty/utils/extensions/core.rb +1 -0
- data/lib/nifty/utils/extensions/string.rb +23 -0
- data/lib/nifty/utils/random_string.rb +24 -0
- data/lib/nifty/utils/version.rb +1 -1
- metadata +11 -10
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 61f1b29fd9276ea82cfc8697f2edf4997fde60d5
|
4
|
+
data.tar.gz: 80f6dac96f0c1f5b974b3c982a34736dfc7355f4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8f39e49f37f9ecf11b553d73dc1f04356ad2144edc48bc072ae535b138fb106eeb79d1d1d37634f0203c222a757cf2ada2041bcabfa1cfc2d218a4dffe509884
|
7
|
+
data.tar.gz: ae4513211f907dddc6de87bf779e62d3afb9881ccdca019c8b0beb95e39239ae3dc9a43e1912e2da7a8304ed26fdd99563e284a8e5e19c695c8df6439fd8549a
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'nifty/utils/extensions/string'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class String
|
2
|
+
|
3
|
+
def self.random(options = {})
|
4
|
+
Nifty::Utils::RandomString.generate(options)
|
5
|
+
end
|
6
|
+
|
7
|
+
def ansi(code)
|
8
|
+
"\e[#{code.to_s}m#{self}\e[0m"
|
9
|
+
end
|
10
|
+
|
11
|
+
def red
|
12
|
+
self.ansi(31)
|
13
|
+
end
|
14
|
+
|
15
|
+
def green
|
16
|
+
self.ansi(32)
|
17
|
+
end
|
18
|
+
|
19
|
+
def yello
|
20
|
+
self.ansi(33)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Nifty
|
2
|
+
module Utils
|
3
|
+
class RandomString
|
4
|
+
|
5
|
+
LETTERS = ('A'..'Z').to_a + ('a'..'z').to_a
|
6
|
+
NUMBERS = (0..9).to_a
|
7
|
+
WORD_CHARS = LETTERS + NUMBERS
|
8
|
+
SYMBOLS = ['-', '!', '_', '@', '+', '*', '?', '%', '&', '/']
|
9
|
+
|
10
|
+
def self.generate(options = {})
|
11
|
+
options[:length] ||= 30
|
12
|
+
options[:symbols] ||= false
|
13
|
+
chars = WORD_CHARS
|
14
|
+
chars += SYMBOLS if options[:symbols]
|
15
|
+
(
|
16
|
+
[LETTERS[rand(LETTERS.size)]] +
|
17
|
+
(0...options[:length]-2).map{ chars[rand(chars.size)] } +
|
18
|
+
[LETTERS[rand(LETTERS.size)]]
|
19
|
+
).join
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/nifty/utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nifty-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Adam Cooke
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: A set of useful utilties for Rails applications
|
15
14
|
email:
|
@@ -18,34 +17,36 @@ executables: []
|
|
18
17
|
extensions: []
|
19
18
|
extra_rdoc_files: []
|
20
19
|
files:
|
20
|
+
- lib/nifty/utils.rb
|
21
21
|
- lib/nifty/utils/active_record.rb
|
22
|
+
- lib/nifty/utils/extensions/core.rb
|
23
|
+
- lib/nifty/utils/extensions/string.rb
|
22
24
|
- lib/nifty/utils/railtie.rb
|
25
|
+
- lib/nifty/utils/random_string.rb
|
23
26
|
- lib/nifty/utils/version.rb
|
24
27
|
- lib/nifty/utils/view_helpers.rb
|
25
|
-
- lib/nifty/utils.rb
|
26
28
|
homepage: https://github.com/niftyware/utils
|
27
29
|
licenses: []
|
30
|
+
metadata: {}
|
28
31
|
post_install_message:
|
29
32
|
rdoc_options: []
|
30
33
|
require_paths:
|
31
34
|
- lib
|
32
35
|
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
36
|
requirements:
|
35
|
-
- -
|
37
|
+
- - ">="
|
36
38
|
- !ruby/object:Gem::Version
|
37
39
|
version: '0'
|
38
40
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
41
|
requirements:
|
41
|
-
- -
|
42
|
+
- - ">="
|
42
43
|
- !ruby/object:Gem::Version
|
43
44
|
version: '0'
|
44
45
|
requirements: []
|
45
46
|
rubyforge_project:
|
46
|
-
rubygems_version:
|
47
|
+
rubygems_version: 2.2.2
|
47
48
|
signing_key:
|
48
|
-
specification_version:
|
49
|
+
specification_version: 4
|
49
50
|
summary: A set of useful utilties for Rails applications
|
50
51
|
test_files: []
|
51
52
|
has_rdoc:
|