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 CHANGED
@@ -5,6 +5,6 @@ gemspec
5
5
 
6
6
  gem 'quiet_assets'
7
7
  gem 'haml-rails'
8
- gem 'sass-rails', '~> 3.2.3'
8
+ gem 'sass-rails', '~> 3.2'
9
9
  gem 'qunit-rails'
10
10
  gem 'jquery-rails'
@@ -2,9 +2,9 @@
2
2
  * global front-end js helpers
3
3
  ###
4
4
 
5
- @DEBUG_MODE ?= false
6
- @TEST_MODE ?= false
7
- @LOG_TODO ?= true
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,5 +1,3 @@
1
- # TODO: register components
2
-
3
1
  do ($ = jQuery) =>
4
2
 
5
3
  $.regexp ||= {}
@@ -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.4'
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.4'
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, '&nbsp;') {|group| p group}
146
+ ["1", "2", "3", "4"]
147
+ ["5", "6", "7", "&nbsp;"]
148
+ ["8", "9", "10", "&nbsp;"]
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 @
@@ -1,5 +1,5 @@
1
1
  module Ultimate
2
2
  module Helpers
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  end
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.0
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-05-16 00:00:00.000000000 Z
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