alt159-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,3 +1,18 @@
1
- = alt159-rails
1
+ # alt159-rails
2
2
 
3
- This project rocks and uses MIT-LICENSE.
3
+ ## Hooray for Saturdays!!
4
+
5
+ Do you want all of ALT159's goodness in your rails app? _Of course you
6
+ do!!_ Good news! We made it really simple.
7
+
8
+ # Gemfile
9
+ gem 'alt159-rails'
10
+
11
+ Wow, that was almost too easy... Oh wait it was, one more step, add
12
+ ALT159 to your application manifest.
13
+
14
+ # app/assets/javascripts/application.js
15
+ //= ALT159
16
+
17
+ This is a coffeescript only module, so if you need it in plain js, do
18
+ the normal thing. Download the `js` file and add it to your app.
@@ -1,3 +1,3 @@
1
1
  module Alt159Rails
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,2 +1,5 @@
1
- #= require ./alt159/src/ALT159
2
- #= require ./alt159/src/types/stringy
1
+ #= require ./alt159/lib/ALT159
2
+ #= require ./alt159/lib/types/stringy
3
+ #= require ./alt159/lib/types/datey
4
+ #= require ./alt159/lib/types/numbery
5
+ #= require ./alt159/lib/types/langniappe
@@ -1,17 +1,12 @@
1
1
  {exec} = require 'child_process'
2
2
 
3
- #task 'build', 'Build project from src/*.coffee to build/*.js', ->
4
- # exec 'coffee --compile --output ./ src/ALT159.coffee', (err, stdout, stderr) ->
5
- # throw err if err
6
- # console.log stdout + stderr
7
-
8
- task 'print', 'Build project from src/*.coffee to build/*.js', ->
9
- exec 'coffee --compile --print src/ALT159.coffee', (err, stdout, stderr) ->
3
+ task 'print', 'Build project from lib/*.coffee to build/*.js', ->
4
+ exec 'coffee --compile --print lib/ALT159.js.coffee', (err, stdout, stderr) ->
10
5
  throw err if err
11
6
  console.log stdout + stderr
12
7
 
13
8
  task 'build', 'Build project from src/*.coffee to build/*.js', ->
14
- exec 'coffee --join ./src/ALT159.js --compile src/types src/ALT159', (err, stdout, stderr) ->
9
+ exec 'coffee --join bin/ALT159.js --compile lib/types lib', (err, stdout, stderr) ->
15
10
  throw err if err
16
11
  console.log stdout + stderr
17
12
 
@@ -4,21 +4,21 @@
4
4
  <head>
5
5
  <title>Jasmine Spec Runner</title>
6
6
 
7
- <link rel="shortcut icon" type="image/png" href="lib/jasmine-1.1.0/jasmine_favicon.png">
7
+ <link rel="shortcut icon" type="image/png" href="../vendor/jasmine-1.1.0/jasmine_favicon.png">
8
8
 
9
- <link rel="stylesheet" type="text/css" href="lib/jasmine-1.1.0/jasmine.css">
10
- <script type="text/javascript" src="lib/jasmine-1.1.0/jasmine.js"></script>
11
- <script type="text/javascript" src="lib/jasmine-1.1.0/jasmine-html.js"></script>
9
+ <link rel="stylesheet" type="text/css" href="../vendor/jasmine-1.1.0/jasmine.css">
10
+ <script type="text/javascript" src="../vendor/jasmine-1.1.0/jasmine.js"></script>
11
+ <script type="text/javascript" src="../vendor/jasmine-1.1.0/jasmine-html.js"></script>
12
12
 
13
13
  <!-- include spec files here... -->
14
- <script type="text/javascript" src="spec/SpecHelper.js"></script>
15
- <script type="text/javascript" src="spec/LagniappeSpec.js"></script>
16
- <script type="text/javascript" src="spec/DateSpec.js"></script>
17
- <script type="text/javascript" src="spec/NumberSpec.js"></script>
18
- <script type="text/javascript" src="spec/StringySpec.js"></script>
14
+ <script type="text/javascript" src="SpecHelper.js"></script>
15
+ <script type="text/javascript" src="LagniappeSpec.js"></script>
16
+ <script type="text/javascript" src="DateSpec.js"></script>
17
+ <script type="text/javascript" src="NumberSpec.js"></script>
18
+ <script type="text/javascript" src="StringySpec.js"></script>
19
19
 
20
20
  <!-- include source files here... -->
21
- <script type="text/javascript" src="src/ALT159.js"></script>
21
+ <script type="text/javascript" src="../bin/ALT159.js"></script>
22
22
 
23
23
  <script type="text/javascript">
24
24
  (function() {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alt159-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70366693168660 !ruby/object:Gem::Requirement
16
+ requirement: &70354823712340 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70366693168660
24
+ version_requirements: *70354823712340
25
25
  description: Easily Add ALT159 to a rails app
26
26
  email:
27
27
  - micahwoods@gmail.com
@@ -30,29 +30,26 @@ extensions: []
30
30
  extra_rdoc_files: []
31
31
  files:
32
32
  - vendor/assets/javascripts/alt159/Cakefile
33
- - vendor/assets/javascripts/alt159/index.html
34
- - vendor/assets/javascripts/alt159/lib/jasmine-1.1.0/jasmine-html.js
35
- - vendor/assets/javascripts/alt159/lib/jasmine-1.1.0/jasmine.css
36
- - vendor/assets/javascripts/alt159/lib/jasmine-1.1.0/jasmine.js
37
- - vendor/assets/javascripts/alt159/lib/jasmine-1.1.0/jasmine_favicon.png
38
- - vendor/assets/javascripts/alt159/lib/jasmine-1.1.0/MIT.LICENSE
33
+ - vendor/assets/javascripts/alt159/lib/ALT159.js.coffee
34
+ - vendor/assets/javascripts/alt159/lib/types/datey.js.coffee
35
+ - vendor/assets/javascripts/alt159/lib/types/langniappe.js.coffee
36
+ - vendor/assets/javascripts/alt159/lib/types/numbery.js.coffee
37
+ - vendor/assets/javascripts/alt159/lib/types/stringy.js.coffee
39
38
  - vendor/assets/javascripts/alt159/README.md
40
39
  - vendor/assets/javascripts/alt159/spec/DateSpec.js
41
40
  - vendor/assets/javascripts/alt159/spec/LagniappeSpec.js
42
41
  - vendor/assets/javascripts/alt159/spec/NumberSpec.js
43
42
  - vendor/assets/javascripts/alt159/spec/SpecHelper.js
43
+ - vendor/assets/javascripts/alt159/spec/SpecRunner.html
44
44
  - vendor/assets/javascripts/alt159/spec/StringySpec.js
45
- - vendor/assets/javascripts/alt159/SpecRunner.html
46
- - vendor/assets/javascripts/alt159/src/ALT159.coffee
47
- - vendor/assets/javascripts/alt159/src/ALT159.js
48
- - vendor/assets/javascripts/alt159/src/types/datey.coffee
49
- - vendor/assets/javascripts/alt159/src/types/langniappe.coffee
50
- - vendor/assets/javascripts/alt159/src/types/numbery.coffee
51
- - vendor/assets/javascripts/alt159/src/types/stringy.coffee
45
+ - vendor/assets/javascripts/alt159/vendor/jasmine-1.1.0/jasmine-html.js
46
+ - vendor/assets/javascripts/alt159/vendor/jasmine-1.1.0/jasmine.css
47
+ - vendor/assets/javascripts/alt159/vendor/jasmine-1.1.0/jasmine.js
48
+ - vendor/assets/javascripts/alt159/vendor/jasmine-1.1.0/jasmine_favicon.png
49
+ - vendor/assets/javascripts/alt159/vendor/jasmine-1.1.0/MIT.LICENSE
52
50
  - vendor/assets/javascripts/ALT159.js.coffee
53
51
  - lib/alt159-rails/version.rb
54
52
  - lib/alt159-rails.rb
55
- - lib/tasks/alt159-rails_tasks.rake
56
53
  - MIT-LICENSE
57
54
  - README.md
58
55
  homepage: https://github.com/mwoods79/ALT159-rails
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :alt159-rails do
3
- # # Task goes here
4
- # end
@@ -1,196 +0,0 @@
1
- <!DOCTYPE>
2
- <html>
3
- <head>
4
- <title>ALT159.js</title>
5
- <link href='http://fonts.googleapis.com/css?family=Buenard&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
6
-
7
- <style>
8
- /* color theme: #7D2A35 #CC9258 #917A56 #B4BA6C #FEFFC2 */
9
-
10
- html { background-color:#917A56}
11
- .nav { background-color:#CC9258}
12
- .functions > div { background-color:#7D2A35}
13
- .example { background-color:#B4BA6C}
14
- h1 {
15
- background-color:#7D2A35;
16
- background: -moz-linear-gradient(top, #a53845 0%, #7d2a35 100%);
17
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a53845), color-stop(100%,#7d2a35));
18
- background: -webkit-linear-gradient(top, #a53845 0%,#7d2a35 100%);
19
- background: -o-linear-gradient(top, #a53845 0%,#7d2a35 100%);
20
- background: -ms-linear-gradient(top, #a53845 0%,#7d2a35 100%);
21
- background: linear-gradient(top, #a53845 0%,#7d2a35 100%);
22
- background-color:#7D2A35
23
- }
24
-
25
- .functions > div,
26
- .example { border:1px solid #333}
27
- body { color:#FEFFC2}
28
- .example { color:#7D2A35}
29
- a, a:visited { color:#FEFFC2}
30
- a:hover { color:#7D2A35}
31
- a { text-decoration:none}
32
- .nav a { display:inline-block}
33
- h1 { text-shadow:5px 5px 2px #333}
34
- h2 { text-shadow:3px 3px 2px #333}
35
- .nav a { line-height:1.5em }
36
- body,h1,h2 { font-family: 'Buenard', serif; }
37
- h1 { font-style:italic}
38
- html,.group { font-size:1.5em}
39
- .nav { font-size:1.2em}
40
- h1 { font-size:8em}
41
- h2 { font-size:0.9em}
42
- h1 { padding:0.1em}
43
- .functions > div { padding:1em}
44
- h1 { padding-left:0.4em}
45
- h1 { padding-bottom:0.2em}
46
- .nav,.about,
47
- .functions .example { padding:1em}
48
- body { margin:0}
49
- h1 { margin:0}
50
- .content { margin-left:14em}
51
- .group,h3 { margin-left:-0.5em}
52
- .example { margin-top:0.5em}
53
- .functions > div { margin-right:1em}
54
- .functions > div { margin-bottom:1em}
55
- h4 { margin:0 0 0.5em -0.5em}
56
- h2 { position:absolute}
57
- .nav.fixed { position:fixed}
58
- .nav.fixed { top:0}
59
- .nav.fixed { bottom:0}
60
- h2 { top:8em}
61
- h2 { left:18em}
62
- .nav { float:left}
63
- .nav { height:30em}
64
- .nav.fixed { height:auto}
65
- .nav { width:8em}
66
- .nav { overflow-y:scroll}
67
- .nav { overflow-x:hidden}
68
- h1 { box-shadow:3px 3px 3px #333}
69
- .functions > div { box-shadow:3px 3px 3px #333}
70
- .functions > div,
71
- .example { border-radius: 5px}
72
- .example { box-shadow:inset 2px 2px 2px #333}
73
-
74
-
75
- </style>
76
- </head>
77
- <body>
78
- <h1>�( )</h1>
79
- <h2>ALT159.js - A Javascript library for basic types</h2>
80
- <div class='nav' id='nav'>
81
-
82
- <a class='group' href='#string' >String</a>
83
- <a href='#capitalize' >.capitalize()</a>
84
- <a href='#numbers' >.numbers()</a>
85
- <a href='#format' >.format(x)</a>
86
- <a href='#underscore' >.underscore()</a>
87
- <a href='#humanize' >.humanize()</a>
88
- <a href='#pluralize' >.pluralize()</a>
89
- <a href='#singularize' >.singularize()</a>
90
-
91
- </div>
92
- <div class='content'>
93
-
94
- <div class='about'>
95
- <p>If you have ever worked with javascript, you probable found the methods on basic type lacking. ALT159 aims to fix this providing a simple to use collection of functions for your basic type.</p>
96
- <p>ALT159 can be accessed by using the Javascrpit Function ALT159() or one of its two shortcuts f() or the windows key combination ALT+159
97
- to get =&gt; �</p>
98
- <p>All source code for ALT159 can be found on <a href='https://github.com/mwoods79/ALT159'>Github</a> </p>
99
- </div>
100
-
101
-
102
- <div class='functions'>
103
- <h3 id='string'>String functions</h3>
104
-
105
- <div id="capitalize">
106
- <h4>capitalize</h4>
107
- <div>capitalize the words in a string</div>
108
- <div class='example'>�('bacon').capitalize() =&gt; 'Bacon'</div>
109
- </div>
110
-
111
- <div id="numbers">
112
- <h4>numbers</h4>
113
- <div>returns only the number in a string</div>
114
- <div class='example'>�('the meening of life: 42').numbers() =&gt; 42</div>
115
- </div>
116
-
117
- <div id="format">
118
- <h4>format</h4>
119
- <div>a C style format method</div>
120
- <div class='example'>�('my name is {0}').format('Blarg') =&gt; 'my name is Blarg'</div>
121
- </div>
122
-
123
- <div id="underscore">
124
- <h4>underscore</h4>
125
- <div>formats a string with underscores</div>
126
- <div class='example'>�('HoneyBadger dont care').underscore() =&gt; 'honey_badger_dont_care'</div>
127
- </div>
128
-
129
- <div id="humanize">
130
- <h4>humanize</h4>
131
- <div>converts a string to be read by a human</div>
132
- <div class='example'>
133
- �('FluxCapacitor').humanize() =&gt; 'Flux Capacitor'
134
- <br>
135
- �('1.21_giga_watts').humanize() =&gt; '1.21 giga watts'
136
- </div>
137
- </div>
138
-
139
- <div id="pluralize">
140
- <h4>pluralize</h4>
141
- <div>takes a word and pluralizes it</div>
142
- <div class='example'>
143
- �('person').pluralize() =&gt; 'people'
144
- <br>
145
- �('Jelly Bean').pluralize() =&gt; 'Jelly Beans'
146
- <br>
147
- �('mouse').pluralize() =&gt; 'mice'
148
- <br>
149
- �('rice').pluralize() =&gt; 'rice'
150
- </div>
151
- </div>
152
-
153
- <div id="singularize">
154
- <h4>singularize</h4>
155
- <div>takes a word and singularizes it</div>
156
- <div class='example'>
157
- �('kine').singularize() =&gt; 'cow'
158
- <br>
159
- �('women').singularize() =&gt; 'woman'
160
- <br>
161
- �('matches').singularize() =&gt; 'match'
162
- <br>
163
- �('goats').singularize() =&gt; 'goat'
164
- </div>
165
- </div>
166
-
167
- </div>
168
-
169
- </div>
170
- </body>
171
-
172
-
173
- <script type="text/javascript" src="src/ALT159.js"></script>
174
-
175
- <script type='text/javascript'>
176
- (function(){
177
- var nav = document.getElementById('nav');
178
- var html = document.getElementsByTagName('html')[0];
179
- var body = document.getElementsByTagName('body')[0];
180
- var onScroll = function(e){
181
- if(html.scrollTop >= 308 || body.scrollTop >= 308)
182
- nav.className = "nav fixed";
183
- else
184
- nav.className = "nav";
185
- };
186
- if( document.addEventListener != void 0)
187
- document.addEventListener("scroll", onScroll, true);
188
- else
189
- window.onscroll = onScroll;
190
- //#document.attachEvent("onscroll", onScroll);
191
-
192
- })();
193
- </script>
194
-
195
- </html>
196
-
@@ -1,360 +0,0 @@
1
- (function() {
2
- var Datey, Lagniappe, Numbery, Stringy, inflect, rules;
3
-
4
- Lagniappe = function() {};
5
-
6
- Lagniappe.prototype = {
7
- extendPrototypes: function() {
8
- var addFunction, unnicer;
9
- addFunction = function(obj, func, key) {
10
- return obj.prototype[key] = function() {
11
- return func.apply({
12
- value: this
13
- }, arguments);
14
- };
15
- };
16
- unnicer = function(obj, to_add) {
17
- var key, _results;
18
- _results = [];
19
- for (key in to_add.prototype) {
20
- if (!obj.prototype[key]) {
21
- _results.push(addFunction(obj, to_add.prototype[key], key));
22
- } else {
23
- _results.push(void 0);
24
- }
25
- }
26
- return _results;
27
- };
28
- unnicer(String, Stringy);
29
- return unnicer(Number, Numbery);
30
- },
31
- chain: function(value, type) {
32
- f().extendPrototypes();
33
- return value;
34
- },
35
- reloadStylesheets: function() {
36
- var i, links, queryString;
37
- queryString = "?reload=" + new Date().getTime();
38
- links = document.getElementsByTagName("link");
39
- i = 0;
40
- while (i < links.length) {
41
- if (links[i] && links[i].ref === "stylesheet") {
42
- links[i].href = links[i].href.replace(/\?.*|$/, queryString);
43
- }
44
- i++;
45
- }
46
- return true;
47
- }
48
- };
49
-
50
- Numbery = function(val) {
51
- return this.value = val;
52
- };
53
-
54
- Numbery.prototype = {
55
- isEven: function() {
56
- return this.value % 2 === 0;
57
- },
58
- isOdd: function() {
59
- return this.value % 2 === 1;
60
- }
61
- };
62
-
63
- Datey = function() {};
64
-
65
- rules = {
66
- plural: [],
67
- singular: [],
68
- irregular: [],
69
- uncountable: []
70
- };
71
-
72
- inflect = {
73
- plural: function(matcher, suffix) {
74
- return rules.plural.push([matcher, suffix]);
75
- },
76
- singular: function(matcher, suffix) {
77
- return rules.singular.push([matcher, suffix]);
78
- },
79
- irregular: function(matcher, suffix) {
80
- return rules.irregular.push([matcher, suffix]);
81
- },
82
- uncountable: function(words) {
83
- return rules.uncountable = words;
84
- }
85
- };
86
-
87
- inflect.plural(/$/, 's');
88
-
89
- inflect.plural(/s$/i, 's');
90
-
91
- inflect.plural(/^(ax|test)is$/i, '$1es');
92
-
93
- inflect.plural(/(octop|vir)us$/i, '$1i');
94
-
95
- inflect.plural(/(octop|vir)i$/i, '$1i');
96
-
97
- inflect.plural(/(alias|status)$/i, '$1es');
98
-
99
- inflect.plural(/(bu)s$/i, '$1ses');
100
-
101
- inflect.plural(/(buffal|tomat)o$/i, '$1oes');
102
-
103
- inflect.plural(/([ti])um$/i, '$1a');
104
-
105
- inflect.plural(/([ti])a$/i, '$1a');
106
-
107
- inflect.plural(/sis$/i, 'ses');
108
-
109
- inflect.plural(/(?:([^f])fe|([lr])f)$/i, '$1$2ves');
110
-
111
- inflect.plural(/(hive)$/i, '$1s');
112
-
113
- inflect.plural(/([^aeiouy]|qu)y$/i, '$1ies');
114
-
115
- inflect.plural(/(x|ch|ss|sh)$/i, '$1es');
116
-
117
- inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '$1ices');
118
-
119
- inflect.plural(/(m|l)ouse$/i, '$1ice');
120
-
121
- inflect.plural(/(m|l)ice$/i, '$1ice');
122
-
123
- inflect.plural(/^(ox)$/i, '$1en');
124
-
125
- inflect.plural(/^(oxen)$/i, '$1');
126
-
127
- inflect.plural(/(quiz)$/i, '$1zes');
128
-
129
- inflect.singular(/s$/i, '');
130
-
131
- inflect.singular(/(ss)$/i, '$1');
132
-
133
- inflect.singular(/(n)ews$/i, '$1ews');
134
-
135
- inflect.singular(/([ti])a$/i, '$1um');
136
-
137
- inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1$2sis');
138
-
139
- inflect.singular(/(^analy)(sis|ses)$/i, '$1sis');
140
-
141
- inflect.singular(/([^f])ves$/i, '$1fe');
142
-
143
- inflect.singular(/(hive)s$/i, '$1');
144
-
145
- inflect.singular(/(tive)s$/i, '$1');
146
-
147
- inflect.singular(/([lr])ves$/i, '$1f');
148
-
149
- inflect.singular(/([^aeiouy]|qu)ies$/i, '$1y');
150
-
151
- inflect.singular(/(s)eries$/i, '$1eries');
152
-
153
- inflect.singular(/(m)ovies$/i, '$1ovie');
154
-
155
- inflect.singular(/(x|ch|ss|sh)es$/i, '$1');
156
-
157
- inflect.singular(/(m|l)ice$/i, '$1ouse');
158
-
159
- inflect.singular(/(bus)(es)?$/i, '$1');
160
-
161
- inflect.singular(/(o)es$/i, '$1');
162
-
163
- inflect.singular(/(shoe)s$/i, '$1');
164
-
165
- inflect.singular(/(cris|test)(is|es)$/i, '$1is');
166
-
167
- inflect.singular(/^(a)x[ie]s$/i, '$1xis');
168
-
169
- inflect.singular(/(octop|vir)(us|i)$/i, '$1us');
170
-
171
- inflect.singular(/(alias|status)(es)?$/i, '$1');
172
-
173
- inflect.singular(/^(ox)en/i, '$1');
174
-
175
- inflect.singular(/(vert|ind)ices$/i, '$1ex');
176
-
177
- inflect.singular(/(matr)ices$/i, '$1ix');
178
-
179
- inflect.singular(/(quiz)zes$/i, '$1');
180
-
181
- inflect.singular(/(database)s$/i, '$1');
182
-
183
- inflect.irregular('person', 'people');
184
-
185
- inflect.irregular('man', 'men');
186
-
187
- inflect.irregular('woman', 'women');
188
-
189
- inflect.irregular('child', 'children');
190
-
191
- inflect.irregular('sex', 'sexes');
192
-
193
- inflect.irregular('move', 'moves');
194
-
195
- inflect.irregular('cow', 'kine');
196
-
197
- inflect.irregular('zombie', 'zombies');
198
-
199
- inflect.uncountable(['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans', 'bacon']);
200
-
201
- Stringy = function(obj) {
202
- return this.value = obj;
203
- };
204
-
205
- Stringy.prototype = {
206
- capitalize: function() {
207
- var lowerCased, word;
208
- if (this.value === '') return this.value;
209
- lowerCased = this.value.toLowerCase();
210
- word = lowerCased[0].toUpperCase() + lowerCased.substring(1);
211
- return word;
212
- },
213
- numbers: function() {
214
- return parseFloat(this.value.replace(/[^0-9.-]+/g, ""));
215
- },
216
- underscore: function() {
217
- var ch, underscored;
218
- underscored = [];
219
- for (ch in this.value.split("")) {
220
- if (ch !== 0 && this.value[ch].match(/[A-Z|\s]/)) underscored.push("_");
221
- if (!this.value[ch].match(/\s/)) {
222
- underscored.push(this.value[ch].toLowerCase());
223
- }
224
- }
225
- underscored = underscored.join("");
226
- return underscored.replace(/^_?/, "");
227
- },
228
- camel: function() {
229
- return f(f(this.value).underscore()).titleize().replace(RegExp(" ", "g"), "");
230
- },
231
- humanize: function() {
232
- var ch, humanized;
233
- humanized = [];
234
- for (ch in this.value.split("")) {
235
- if (ch !== 0 && this.value[ch].match(/[A-Z]/)) humanized.push("_");
236
- if (!this.value[ch].match(/\-/)) humanized.push(this.value[ch]);
237
- }
238
- humanized = humanized.join("").split("_");
239
- humanized[0] = f(humanized[0]).capitalize();
240
- return humanized.join(" ").trim();
241
- },
242
- pluralize: function() {
243
- var i, r;
244
- if (rules.uncountable.indexOf(this.value) > 0) return this.value;
245
- i = rules.irregular.length;
246
- while (i > 0) {
247
- r = rules.irregular[i - 1];
248
- if (this.value === r[0]) return r[1];
249
- i--;
250
- }
251
- i = rules.plural.length;
252
- while (i > 0) {
253
- r = rules.plural[i - 1];
254
- if (this.value.match(r[0])) return this.value.replace(r[0], r[1]);
255
- i--;
256
- }
257
- },
258
- singularize: function() {
259
- var i, r;
260
- if (rules.uncountable.indexOf(this.value) > 0) return this.value;
261
- i = rules.irregular.length;
262
- while (i > 0) {
263
- r = rules.irregular[i - 1];
264
- if (this.value === r[1]) return r[0];
265
- i--;
266
- }
267
- i = rules.singular.length;
268
- while (i > 0) {
269
- r = rules.singular[i - 1];
270
- if (this.value.match(r[0])) return this.value.replace(r[0], r[1]);
271
- i--;
272
- }
273
- },
274
- money: function(options) {
275
- var defaults, first, i, j, last, middle, prop, sign, val;
276
- options || (options = {});
277
- defaults = {
278
- precision: 2,
279
- symbol: "$",
280
- dot: ".",
281
- seperator: ",",
282
- "default": "-"
283
- };
284
- for (prop in defaults) {
285
- (options[prop] !== void 0) || (options[prop] = defaults[prop]);
286
- }
287
- if (!this.value) {
288
- return options.defaults;
289
- } else {
290
- val = parseFloat(this.value);
291
- sign = (val < 0 ? "-" : "");
292
- i = parseInt(val = Math.abs(+val || 0).toFixed(options.precision)) + "";
293
- j = ((j = i.length) > 3 ? j % 3 : 0);
294
- first = sign + options.symbol + (j ? i.substr(0, j) + options.seperator : "");
295
- middle = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + options.seperator);
296
- last = (options.precision ? options.dot + Math.abs(val - i).toFixed(options.precision).slice(2) : "");
297
- return first + middle + last;
298
- }
299
- },
300
- number: function(opts) {
301
- opts = opts || {};
302
- opts.symbol = "";
303
- return f(this.value).money(opts);
304
- },
305
- titleize: function() {
306
- var parts, word;
307
- parts = this.value.split(RegExp('[ _]'));
308
- parts = (function() {
309
- var _i, _len, _results;
310
- _results = [];
311
- for (_i = 0, _len = parts.length; _i < _len; _i++) {
312
- word = parts[_i];
313
- _results.push(f(word).capitalize());
314
- }
315
- return _results;
316
- })();
317
- return parts.join(" ");
318
- },
319
- isBlank: function() {
320
- var clean;
321
- clean = this.value || "";
322
- clean = clean.replace(RegExp(' ', 'g'), "");
323
- return clean === "";
324
- },
325
- truncate: function(amount, tail) {
326
- var parts, str;
327
- if (tail == null) tail = "...";
328
- parts = [];
329
- parts = (function() {
330
- var _i, _len, _ref, _results;
331
- _ref = this.value;
332
- _results = [];
333
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
334
- str = _ref[_i];
335
- if (_i < amount) _results.push(str);
336
- }
337
- return _results;
338
- }).call(this);
339
- return parts.join("") + tail;
340
- }
341
- };
342
-
343
- window.ALT159 = window.f = (function(obj) {
344
- var ALT159;
345
- ALT159 = function(obj) {
346
- if (typeof obj === "string") return new Stringy(obj);
347
- if (toString.call(obj) === "[object Number]") return new Numbery(obj);
348
- if (toString.call(obj) === "[object Date]") return new Datey(obj);
349
- if (obj === void 0) return new Lagniappe();
350
- return null;
351
- };
352
- ALT159.types = {
353
- Stringy: Stringy,
354
- Numbery: Numbery,
355
- Datey: Datey
356
- };
357
- return ALT159;
358
- })();
359
-
360
- }).call(this);