ultimate-helpers 0.2.0 → 0.2.2
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/Gemfile +1 -1
- data/app/assets/javascripts/ultimate/{helpers.js.coffee → helpers.js.coffee.erb} +3 -3
- data/app/assets/javascripts/ultimate/jquery.base.js.coffee +0 -2
- data/app/assets/javascripts/ultimate/underscore/underscore.outcasts.js.coffee +48 -3
- data/lib/ultimate/helpers/version.rb +1 -1
- metadata +3 -3
data/Gemfile
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
* global front-end js helpers
|
3
3
|
###
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
window.DEBUG_MODE ?= <%= Rails.env.development? %>
|
6
|
+
window.TEST_MODE ?= <%= Rails.env.test? %>
|
7
|
+
window.LOG_TODO ?= DEBUG_MODE
|
8
8
|
|
9
9
|
@cout = =>
|
10
10
|
args = _.toArray(arguments)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
###
|
2
2
|
Underscore.outcasts
|
3
|
-
(c) 2012 Dmitry Karpunin <koderfunk aet gmail dot com>
|
3
|
+
(c) 2012-2013 Dmitry Karpunin <koderfunk aet gmail dot com>
|
4
4
|
Underscore.outcasts is freely distributable under the terms of the MIT license.
|
5
5
|
Documentation: https://github.com/KODerFunk/underscore.outcasts
|
6
6
|
Some code is borrowed from outcasts pull requests to Underscore.
|
7
|
-
Version '0.1.
|
7
|
+
Version '0.1.5'
|
8
8
|
###
|
9
9
|
|
10
10
|
'use strict'
|
@@ -15,7 +15,7 @@
|
|
15
15
|
|
16
16
|
UnderscoreOutcasts =
|
17
17
|
|
18
|
-
VERSION: '0.1.
|
18
|
+
VERSION: '0.1.5'
|
19
19
|
|
20
20
|
delete: (object, key) ->
|
21
21
|
value = object[key]
|
@@ -133,6 +133,51 @@ UnderscoreOutcasts =
|
|
133
133
|
array.push(fillWith) while padding-- > 0
|
134
134
|
@eachSlice array, number, @blockGiven(arguments)
|
135
135
|
|
136
|
+
###
|
137
|
+
Splits or iterates over the array in +number+ of groups, padding any
|
138
|
+
remaining slots with +fill_with+ unless it is +false+.
|
139
|
+
|
140
|
+
%w(1 2 3 4 5 6 7 8 9 10).in_groups(3) {|group| p group}
|
141
|
+
["1", "2", "3", "4"]
|
142
|
+
["5", "6", "7", nil]
|
143
|
+
["8", "9", "10", nil]
|
144
|
+
|
145
|
+
%w(1 2 3 4 5 6 7 8 9 10).in_groups(3, ' ') {|group| p group}
|
146
|
+
["1", "2", "3", "4"]
|
147
|
+
["5", "6", "7", " "]
|
148
|
+
["8", "9", "10", " "]
|
149
|
+
|
150
|
+
%w(1 2 3 4 5 6 7).in_groups(3, false) {|group| p group}
|
151
|
+
["1", "2", "3"]
|
152
|
+
["4", "5"]
|
153
|
+
["6", "7"]
|
154
|
+
###
|
155
|
+
# TODO tests
|
156
|
+
inGroups: (array, number, fillWith = null) ->
|
157
|
+
# size / number gives minor group size;
|
158
|
+
# size % number gives how many objects need extra accommodation;
|
159
|
+
# each group hold either division or division + 1 items.
|
160
|
+
division = Math.floor(array.length / number)
|
161
|
+
modulo = array.length % number
|
162
|
+
|
163
|
+
# create a new array avoiding dup
|
164
|
+
groups = []
|
165
|
+
start = 0
|
166
|
+
|
167
|
+
for index in [0...number]
|
168
|
+
length = division + (if modulo > 0 and modulo > index then 1 else 0)
|
169
|
+
groups.push last_group = array.slice(start, start + length)
|
170
|
+
if fillWith isnt false and modulo > 0 and length is division
|
171
|
+
last_group.push fillWith
|
172
|
+
start += length
|
173
|
+
|
174
|
+
if block = @blockGiven(arguments)
|
175
|
+
_.map groups, block
|
176
|
+
else
|
177
|
+
groups
|
178
|
+
|
179
|
+
|
180
|
+
|
136
181
|
exports: ->
|
137
182
|
result = {}
|
138
183
|
for prop of @
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ultimate-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -73,7 +73,7 @@ files:
|
|
73
73
|
- README.md
|
74
74
|
- Rakefile
|
75
75
|
- app/assets/javascripts/ultimate/base.js.coffee
|
76
|
-
- app/assets/javascripts/ultimate/helpers.js.coffee
|
76
|
+
- app/assets/javascripts/ultimate/helpers.js.coffee.erb
|
77
77
|
- app/assets/javascripts/ultimate/helpers/asset_tag.js.coffee
|
78
78
|
- app/assets/javascripts/ultimate/helpers/base.js.coffee
|
79
79
|
- app/assets/javascripts/ultimate/helpers/decor.js.coffee
|