underscore_extensions 0.0.1
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/.gitignore +5 -0
- data/.rvmrc +1 -0
- data/Gemfile +6 -0
- data/README.markdown +14 -0
- data/Rakefile +18 -0
- data/app/assets/javascripts/underscore.extensions.js +60 -0
- data/app/assets/javascripts/underscore.js +999 -0
- data/app/assets/javascripts/underscore.string.js +480 -0
- data/config/jshint.yml +92 -0
- data/lib/underscore_extensions.rb +6 -0
- data/lib/underscore_extensions/version.rb +3 -0
- data/spec/javascripts/support/jasmine.yml +11 -0
- data/spec/javascripts/support/spec_helper.js +2 -0
- data/spec/javascripts/underscore.extensions_spec.js +68 -0
- data/underscore_extensions.gemspec +27 -0
- metadata +169 -0
data/config/jshint.yml
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# ------------ rake task options ------------
|
2
|
+
|
3
|
+
# JS files to check by default, if no parameters are passed to rake jshint
|
4
|
+
# (you may want to limit this only to your own scripts and exclude any external scripts and frameworks)
|
5
|
+
|
6
|
+
# this can be overridden by adding 'paths' and 'exclude_paths' parameter to rake command:
|
7
|
+
# rake jshint paths=path1,path2,... exclude_paths=library1,library2,...
|
8
|
+
|
9
|
+
paths:
|
10
|
+
- assets/javascripts/**/*.js
|
11
|
+
|
12
|
+
exclude_paths:
|
13
|
+
- vendor/assets/**/*.js
|
14
|
+
|
15
|
+
|
16
|
+
# ------------ jshint options ------------
|
17
|
+
# visit http://jshint.com/ for complete documentation
|
18
|
+
|
19
|
+
# "enforce" type options (true means potentially more warnings)
|
20
|
+
|
21
|
+
adsafe: false # true if ADsafe rules should be enforced. See http://www.ADsafe.org/
|
22
|
+
bitwise: true # true if bitwise operators should not be allowed
|
23
|
+
newcap: true # true if Initial Caps must be used with constructor functions
|
24
|
+
eqeqeq: true # true if === should be required (for ALL equality comparisons)
|
25
|
+
immed: false # true if immediate function invocations must be wrapped in parens
|
26
|
+
nomen: false # true if initial or trailing underscore in identifiers should be forbidden
|
27
|
+
onevar: false # true if only one var statement per function should be allowed
|
28
|
+
plusplus: false # true if ++ and -- should not be allowed
|
29
|
+
regexp: false # true if . and [^...] should not be allowed in RegExp literals
|
30
|
+
safe: false # true if the safe subset rules are enforced (used by ADsafe)
|
31
|
+
strict: false # true if the ES5 "use strict"; pragma is required
|
32
|
+
undef: true # true if variables must be declared before used
|
33
|
+
white: false # true if strict whitespace rules apply (see also 'indent' option)
|
34
|
+
|
35
|
+
# "allow" type options (false means potentially more warnings)
|
36
|
+
|
37
|
+
cap: false # true if upper case HTML should be allowed
|
38
|
+
css: false # true if CSS workarounds should be tolerated
|
39
|
+
debug: false # true if debugger statements should be allowed (set to false before going into production)
|
40
|
+
es5: false # true if ECMAScript 5 syntax should be allowed
|
41
|
+
evil: false # true if eval should be allowed
|
42
|
+
forin: false # true if unfiltered 'for in' statements should be allowed
|
43
|
+
fragment: false # true if HTML fragments should be allowed
|
44
|
+
laxbreak: false # true if statement breaks should not be checked
|
45
|
+
on: false # true if HTML event handlers (e.g. onclick="...") should be allowed
|
46
|
+
sub: false # true if subscript notation may be used for expressions better expressed in dot notation
|
47
|
+
|
48
|
+
# other options
|
49
|
+
|
50
|
+
maxlen: 160 # Maximum line length
|
51
|
+
indent: 2 # Number of spaces that should be used for indentation - used only if 'white' option is set
|
52
|
+
maxerr: 50 # The maximum number of warnings reported (per file)
|
53
|
+
passfail: false # true if the scan should stop on first error (per file)
|
54
|
+
# following are relevant only if undef = true
|
55
|
+
predef: '' # Names of predefined global variables - comma-separated string or a YAML array
|
56
|
+
browser: true # true if the standard browser globals should be predefined
|
57
|
+
rhino: false # true if the Rhino environment globals should be predefined
|
58
|
+
windows: false # true if Windows-specific globals should be predefined
|
59
|
+
widget: false # true if the Yahoo Widgets globals should be predefined
|
60
|
+
devel: false # true if functions like alert, confirm, console, prompt etc. are predefined
|
61
|
+
|
62
|
+
# jshint options
|
63
|
+
loopfunc: true # true if functions should be allowed to be defined within loops
|
64
|
+
asi: true # true if automatic semicolon insertion should be tolerated
|
65
|
+
boss: true # true if advanced usage of assignments and == should be allowed
|
66
|
+
couch: true # true if CouchDB globals should be predefined
|
67
|
+
curly: false # true if curly braces around blocks should be required (even in if/for/while)
|
68
|
+
noarg: true # true if arguments.caller and arguments.callee should be disallowed
|
69
|
+
node: true # true if the Node.js environment globals should be predefined
|
70
|
+
noempty: true # true if empty blocks should be disallowed
|
71
|
+
nonew: true # true if using `new` for side-effects should be disallowed
|
72
|
+
|
73
|
+
|
74
|
+
# ------------ jshint_on_rails custom lint options (switch to true to disable some annoying warnings) ------------
|
75
|
+
|
76
|
+
# ignores "missing semicolon" warning at the end of a function; this lets you write one-liners
|
77
|
+
# like: x.map(function(i) { return i + 1 }); without having to put a second semicolon inside the function
|
78
|
+
lastsemic: false
|
79
|
+
|
80
|
+
# allows you to use the 'new' expression as a statement (without assignment)
|
81
|
+
# so you can call e.g. new Ajax.Request(...), new Effect.Highlight(...) without assigning to a dummy variable
|
82
|
+
newstat: false
|
83
|
+
|
84
|
+
# ignores the "Expected an assignment or function call and instead saw an expression" warning,
|
85
|
+
# if the expression contains a proper statement and makes sense; this lets you write things like:
|
86
|
+
# element && element.show();
|
87
|
+
# valid || other || lastChance || alert('OMG!');
|
88
|
+
# selected ? show() : hide();
|
89
|
+
# although these will still cause a warning:
|
90
|
+
# element && link;
|
91
|
+
# selected ? 5 : 10;
|
92
|
+
statinexp: false
|
@@ -0,0 +1,11 @@
|
|
1
|
+
src_files:
|
2
|
+
- app/assets/javascripts/underscore.js
|
3
|
+
- app/assets/javascripts/underscore.string.js
|
4
|
+
- app/assets/javascripts/underscore.extensions.js
|
5
|
+
stylesheets:
|
6
|
+
helpers:
|
7
|
+
- support/**/*.js
|
8
|
+
spec_files:
|
9
|
+
- '**/*[sS]pec.js'
|
10
|
+
src_dir:
|
11
|
+
spec_dir: spec/javascripts
|
@@ -0,0 +1,68 @@
|
|
1
|
+
describe('_', function() {
|
2
|
+
describe('#classify', function() {
|
3
|
+
it('should return a string camelized with capital letters', function() {
|
4
|
+
expect(_('the_quick_brown_fox').classify()).toEqual('TheQuickBrownFox');
|
5
|
+
});
|
6
|
+
});
|
7
|
+
|
8
|
+
describe('#except', function() {
|
9
|
+
it('should return the object without the keys specified', function() {
|
10
|
+
expect(_({a: 'a', b: 'b', c: 'c'}).except('b', 'c')).toEqual({a: 'a'});
|
11
|
+
});
|
12
|
+
|
13
|
+
describe('when the keys are specified as an array', function() {
|
14
|
+
it('should return the object without the keys specified', function() {
|
15
|
+
expect(_({a: 'a', b: 'b', c: 'c'}).except(['b', 'c'])).toEqual({a: 'a'});
|
16
|
+
});
|
17
|
+
});
|
18
|
+
});
|
19
|
+
|
20
|
+
describe('#namespace', function() {
|
21
|
+
it('should create the namespace', function() {
|
22
|
+
var result = {};
|
23
|
+
baz = _(result).namespace('foo.bar.baz');
|
24
|
+
baz.property = 'property';
|
25
|
+
expect(result.foo.bar.baz).toBeDefined();
|
26
|
+
expect(result.foo.bar.baz.property).toBeDefined();
|
27
|
+
});
|
28
|
+
|
29
|
+
it('should not overwrite existing namespaces', function() {
|
30
|
+
var result = { foo: {a: 'b'}};
|
31
|
+
baz = _(result).namespace('foo.bar.baz');
|
32
|
+
expect(result.foo.bar.baz).toBeDefined();
|
33
|
+
expect(result.foo.a).toEqual('b');
|
34
|
+
});
|
35
|
+
});
|
36
|
+
|
37
|
+
describe('#only', function() {
|
38
|
+
it('should return an empty object if no keys are specified', function() {
|
39
|
+
expect(_({a: 'a', b: 'b', c: 'c'}).only()).toEqual({});
|
40
|
+
});
|
41
|
+
|
42
|
+
it('should return the object only the keys specified', function() {
|
43
|
+
expect(_({a: 'aa', b: 'bb', c: 'cc'}).only('a', 'c')).toEqual({a: 'aa', c: 'cc'});
|
44
|
+
});
|
45
|
+
|
46
|
+
describe('when the keys are specified as an array', function() {
|
47
|
+
it('should return an empty object if no keys are specified', function() {
|
48
|
+
expect(_({a: 'a', b: 'b', c: 'c'}).only([])).toEqual({});
|
49
|
+
});
|
50
|
+
|
51
|
+
it('should return the object only the keys specified', function() {
|
52
|
+
expect(_({a: 'aa', b: 'bb', c: 'cc'}).only(['a', 'c'])).toEqual({a: 'aa', c: 'cc'});
|
53
|
+
});
|
54
|
+
});
|
55
|
+
});
|
56
|
+
|
57
|
+
describe('#pluralize', function() {
|
58
|
+
it('should use a space when includeSpace is passed in the options', function() {
|
59
|
+
expect(_('point').pluralize(2, {includeSpace: true})).toEqual('2 points');
|
60
|
+
});
|
61
|
+
|
62
|
+
it('should return a pluralized string based on the number', function() {
|
63
|
+
expect(_('point').pluralize(0)).toEqual('0points');
|
64
|
+
expect(_('point').pluralize(1)).toEqual('1point');
|
65
|
+
expect(_('point').pluralize(2)).toEqual('2points');
|
66
|
+
});
|
67
|
+
});
|
68
|
+
});
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'underscore_extensions/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'underscore_extensions'
|
7
|
+
s.version = UnderscoreExtensions::VERSION
|
8
|
+
s.authors = ['Ryan Dy']
|
9
|
+
s.email = ['ryan.dy@gmail.com']
|
10
|
+
s.homepage = 'http://github.com/rdy/underscore_extensions'
|
11
|
+
s.summary = %q{Extensions to underscore javascript library as a rails engine}
|
12
|
+
s.description = %q{Adds extensions to the underscore javascript library. It adds the javascript as a rails engine to be included in to a Rails 3+ project. To use it make sure require underscore, underscore.string and underscore.extensions.}
|
13
|
+
|
14
|
+
s.rubyforge_project = 'underscore_extensions'
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency 'fuubar'
|
22
|
+
s.add_development_dependency 'jasmine'
|
23
|
+
s.add_development_dependency 'jshint'
|
24
|
+
s.add_development_dependency 'thin'
|
25
|
+
s.add_runtime_dependency 'rails', '>= 3.1'
|
26
|
+
s.add_runtime_dependency 'rails', '>= 3.1'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: underscore_extensions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Ryan Dy
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-02-26 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: fuubar
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: jasmine
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: jshint
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: thin
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
type: :development
|
76
|
+
version_requirements: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: rails
|
79
|
+
prerelease: false
|
80
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 5
|
86
|
+
segments:
|
87
|
+
- 3
|
88
|
+
- 1
|
89
|
+
version: "3.1"
|
90
|
+
type: :runtime
|
91
|
+
version_requirements: *id005
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: rails
|
94
|
+
prerelease: false
|
95
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
hash: 5
|
101
|
+
segments:
|
102
|
+
- 3
|
103
|
+
- 1
|
104
|
+
version: "3.1"
|
105
|
+
type: :runtime
|
106
|
+
version_requirements: *id006
|
107
|
+
description: Adds extensions to the underscore javascript library. It adds the javascript as a rails engine to be included in to a Rails 3+ project. To use it make sure require underscore, underscore.string and underscore.extensions.
|
108
|
+
email:
|
109
|
+
- ryan.dy@gmail.com
|
110
|
+
executables: []
|
111
|
+
|
112
|
+
extensions: []
|
113
|
+
|
114
|
+
extra_rdoc_files: []
|
115
|
+
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- .rvmrc
|
119
|
+
- Gemfile
|
120
|
+
- README.markdown
|
121
|
+
- Rakefile
|
122
|
+
- app/assets/javascripts/underscore.extensions.js
|
123
|
+
- app/assets/javascripts/underscore.js
|
124
|
+
- app/assets/javascripts/underscore.string.js
|
125
|
+
- config/jshint.yml
|
126
|
+
- lib/underscore_extensions.rb
|
127
|
+
- lib/underscore_extensions/version.rb
|
128
|
+
- spec/javascripts/support/jasmine.yml
|
129
|
+
- spec/javascripts/support/spec_helper.js
|
130
|
+
- spec/javascripts/underscore.extensions_spec.js
|
131
|
+
- underscore_extensions.gemspec
|
132
|
+
has_rdoc: true
|
133
|
+
homepage: http://github.com/rdy/underscore_extensions
|
134
|
+
licenses: []
|
135
|
+
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
hash: 3
|
147
|
+
segments:
|
148
|
+
- 0
|
149
|
+
version: "0"
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
hash: 3
|
156
|
+
segments:
|
157
|
+
- 0
|
158
|
+
version: "0"
|
159
|
+
requirements: []
|
160
|
+
|
161
|
+
rubyforge_project: underscore_extensions
|
162
|
+
rubygems_version: 1.6.2
|
163
|
+
signing_key:
|
164
|
+
specification_version: 3
|
165
|
+
summary: Extensions to underscore javascript library as a rails engine
|
166
|
+
test_files:
|
167
|
+
- spec/javascripts/support/jasmine.yml
|
168
|
+
- spec/javascripts/support/spec_helper.js
|
169
|
+
- spec/javascripts/underscore.extensions_spec.js
|