glowing-archer 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/glowing-archer.rb +9 -14
- data/lib/glowing-archer/rails/string.rb +13 -0
- data/lib/glowing-archer/version.rb +1 -1
- metadata +3 -3
data/lib/glowing-archer.rb
CHANGED
@@ -1,29 +1,24 @@
|
|
1
1
|
module Glowing
|
2
2
|
module Archer
|
3
3
|
|
4
|
-
# generate
|
5
|
-
def bootstrap_badges(badges, style = "")
|
6
|
-
style = (" " + style) unless style.nil_or_empty?
|
7
|
-
html = ""
|
8
|
-
badges.split(",").each do |badge|
|
9
|
-
badge = badge.strip
|
10
|
-
html << "<span class=\"label#{style}\">#{badge.html_safe!}</span> " unless badge.nil_or_empty?
|
11
|
-
end
|
12
|
-
return html.html_safe
|
13
|
-
end
|
14
|
-
|
15
|
-
# generate invite code http://railscasts.com/episodes/124-beta-invitations
|
4
|
+
# generate invite code #1 http://railscasts.com/episodes/124-beta-invitations
|
16
5
|
# => "bf35184b0e7ebb5baad116bfe4a8dbdfb58277d2"
|
17
|
-
def
|
6
|
+
def self.build_invite
|
18
7
|
Digest::SHA1.hexdigest([Time.now, rand].join)
|
19
8
|
end
|
20
9
|
|
21
10
|
# generate random key #2 http://stackoverflow.com/questions/6021372/best-way-to-create-unique-token-in-rails
|
22
11
|
# => "Sk349WNovoUDRZ930Uha"
|
23
|
-
def
|
12
|
+
def self.build_key(length = 15)
|
24
13
|
SecureRandom.base64(length).tr('+/=', '0aZ').strip.delete("\n")
|
25
14
|
end
|
26
15
|
|
16
|
+
# generate secure random guid #3 http://rubydoc.info/stdlib/securerandom/1.9.2/SecureRandom#uuid-class_method
|
17
|
+
# => "ee705896-1d41-415c-a152-55687d0bc8c9"
|
18
|
+
def self.guid
|
19
|
+
SecureRandom.uuid
|
20
|
+
end
|
21
|
+
|
27
22
|
end
|
28
23
|
end
|
29
24
|
|
@@ -1,4 +1,17 @@
|
|
1
1
|
String.class_eval do
|
2
|
+
|
3
|
+
# generate html for bootstrap badges (tags)
|
4
|
+
def bootstrap_badges(style = "")
|
5
|
+
badges = self
|
6
|
+
style = (" " + style) unless style.nil_or_empty?
|
7
|
+
html = ""
|
8
|
+
badges.split(",").each do |badge|
|
9
|
+
badge = badge.strip
|
10
|
+
html << "<span class=\"label#{style}\">#{badge.html_safe!}</span> " unless badge.nil_or_empty?
|
11
|
+
end
|
12
|
+
return html.html_safe
|
13
|
+
end
|
14
|
+
|
2
15
|
def to_bool
|
3
16
|
return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
|
4
17
|
return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glowing-archer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -61,7 +61,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
61
|
version: '0'
|
62
62
|
segments:
|
63
63
|
- 0
|
64
|
-
hash:
|
64
|
+
hash: 3315372235594486216
|
65
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
66
|
none: false
|
67
67
|
requirements:
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
version: '0'
|
71
71
|
segments:
|
72
72
|
- 0
|
73
|
-
hash:
|
73
|
+
hash: 3315372235594486216
|
74
74
|
requirements: []
|
75
75
|
rubyforge_project:
|
76
76
|
rubygems_version: 1.8.23
|