essentials 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/essentials.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
GIT_REVISION = File.exist?('REVISION') ? File.read('REVISION') : nil
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Enumerable
|
2
|
+
# Sorts all items in this enumerable first
|
3
|
+
# by non-digits and then by digits.
|
4
|
+
#
|
5
|
+
# If a block is given, it will be invoked
|
6
|
+
# to calculate the basis for comparison.
|
7
|
+
# Otherwise, the items themselves will be
|
8
|
+
# used as the basis for comparison.
|
9
|
+
#
|
10
|
+
def smart_sort # :yields: item
|
11
|
+
sort_by do |item|
|
12
|
+
basis =
|
13
|
+
if block_given?
|
14
|
+
yield item
|
15
|
+
else
|
16
|
+
item
|
17
|
+
end.to_s
|
18
|
+
|
19
|
+
alpha = basis[/\D+/].to_s
|
20
|
+
digit = basis[/\d+/].to_i
|
21
|
+
|
22
|
+
[alpha, digit]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def dups
|
27
|
+
tmp_dups = inject({}){|h,v| h[v]=h[v].to_i+1; h}.select{|k,v| v > 1}
|
28
|
+
tmp_dups.is_a?(Hash) ? tmp_dups.keys : tmp_dups
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: essentials
|
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:
|
@@ -36,6 +36,9 @@ files:
|
|
36
36
|
- app/assets/javascripts/essentials-global.js
|
37
37
|
- lib/essentials.rb
|
38
38
|
- lib/initializers/add_deep_value_to_hash.rb
|
39
|
+
- lib/initializers/capture_git_revision.rb
|
40
|
+
- lib/initializers/enumerable_changes.rb
|
41
|
+
- lib/initializers/is_json.rb
|
39
42
|
homepage: http://rubygems.org/gems/essentials
|
40
43
|
licenses:
|
41
44
|
- MIT
|