common_view_helpers 0.2.0 → 0.3.0
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.
- data/README.rdoc +6 -2
- data/VERSION +1 -1
- data/lib/common_view_helpers.rb +9 -0
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Common View Helpers
|
2
2
|
|
3
|
-
A set of view helpers Gemini uses in all of our Rails applications.
|
3
|
+
A lightweight set of view helpers Gemini uses in all of our Rails applications.
|
4
4
|
|
5
5
|
== Installation
|
6
6
|
|
@@ -39,7 +39,11 @@ A set of view helpers Gemini uses in all of our Rails applications.
|
|
39
39
|
|
40
40
|
# Generates a URL and automatically adds http:// if not already there
|
41
41
|
# Useful alongside link() when linking to user submitted addresses
|
42
|
-
|
42
|
+
urlify(address)
|
43
|
+
|
44
|
+
# Breaks up a BigNum, FixNum or Float with commas
|
45
|
+
# e.g., 532566 => 532,566 and 79593255.66 => 79,593,255.66
|
46
|
+
commify(num)
|
43
47
|
|
44
48
|
== Copyright & Licensing
|
45
49
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/common_view_helpers.rb
CHANGED
@@ -113,6 +113,15 @@ module CommonViewHelpers
|
|
113
113
|
def urlify(addr)
|
114
114
|
(addr.blank? || addr.starts_with?('http')) ? addr : "http://#{addr}"
|
115
115
|
end
|
116
|
+
|
117
|
+
# Breaks up a BigNum, FixNum or Float with commas
|
118
|
+
# e.g., 532566 => 532,566 and 79593255.66 => 79,593,255.66
|
119
|
+
def commify(num)
|
120
|
+
num.to_s =~ /([^\.]*)(\..*)?/
|
121
|
+
int, dec = $1.reverse, $2 ? $2 : ""
|
122
|
+
while int.gsub!(/(,|\.|^)(\d{3})(\d)/, '\1\2,\3'); end
|
123
|
+
int.reverse + dec
|
124
|
+
end
|
116
125
|
|
117
126
|
end
|
118
127
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: common_view_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zeke Sikelianos
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-07-
|
19
|
+
date: 2010-07-30 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|