alt159-rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Alt159Rails
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,18 @@
1
+ {exec} = require 'child_process'
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) ->
10
+ throw err if err
11
+ console.log stdout + stderr
12
+
13
+ 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) ->
15
+ throw err if err
16
+ console.log stdout + stderr
17
+
18
+
@@ -0,0 +1 @@
1
+ This is the initial version of some useful javascript extensions that do not pollute the global namespace.
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+ <html>
4
+ <head>
5
+ <title>Jasmine Spec Runner</title>
6
+
7
+ <link rel="shortcut icon" type="image/png" href="lib/jasmine-1.1.0/jasmine_favicon.png">
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>
12
+
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>
19
+
20
+ <!-- include source files here... -->
21
+ <script type="text/javascript" src="src/ALT159.js"></script>
22
+
23
+ <script type="text/javascript">
24
+ (function() {
25
+ var jasmineEnv = jasmine.getEnv();
26
+ jasmineEnv.updateInterval = 1000;
27
+
28
+ var trivialReporter = new jasmine.TrivialReporter();
29
+
30
+ jasmineEnv.addReporter(trivialReporter);
31
+
32
+ jasmineEnv.specFilter = function(spec) {
33
+ return trivialReporter.specFilter(spec);
34
+ };
35
+
36
+ var currentWindowOnload = window.onload;
37
+
38
+ window.onload = function() {
39
+ if (currentWindowOnload) {
40
+ currentWindowOnload();
41
+ }
42
+ execJasmine();
43
+ };
44
+
45
+ function execJasmine() {
46
+ jasmineEnv.execute();
47
+ }
48
+
49
+ })();
50
+ </script>
51
+
52
+ </head>
53
+
54
+ <body>
55
+ </body>
56
+ </html>
@@ -0,0 +1,196 @@
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
+
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008-2011 Pivotal Labs
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,190 @@
1
+ jasmine.TrivialReporter = function(doc) {
2
+ this.document = doc || document;
3
+ this.suiteDivs = {};
4
+ this.logRunningSpecs = false;
5
+ };
6
+
7
+ jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
8
+ var el = document.createElement(type);
9
+
10
+ for (var i = 2; i < arguments.length; i++) {
11
+ var child = arguments[i];
12
+
13
+ if (typeof child === 'string') {
14
+ el.appendChild(document.createTextNode(child));
15
+ } else {
16
+ if (child) { el.appendChild(child); }
17
+ }
18
+ }
19
+
20
+ for (var attr in attrs) {
21
+ if (attr == "className") {
22
+ el[attr] = attrs[attr];
23
+ } else {
24
+ el.setAttribute(attr, attrs[attr]);
25
+ }
26
+ }
27
+
28
+ return el;
29
+ };
30
+
31
+ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
32
+ var showPassed, showSkipped;
33
+
34
+ this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
35
+ this.createDom('div', { className: 'banner' },
36
+ this.createDom('div', { className: 'logo' },
37
+ this.createDom('span', { className: 'title' }, "Jasmine"),
38
+ this.createDom('span', { className: 'version' }, runner.env.versionString())),
39
+ this.createDom('div', { className: 'options' },
40
+ "Show ",
41
+ showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
42
+ this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
43
+ showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
44
+ this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
45
+ )
46
+ ),
47
+
48
+ this.runnerDiv = this.createDom('div', { className: 'runner running' },
49
+ this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
50
+ this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
51
+ this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
52
+ );
53
+
54
+ this.document.body.appendChild(this.outerDiv);
55
+
56
+ var suites = runner.suites();
57
+ for (var i = 0; i < suites.length; i++) {
58
+ var suite = suites[i];
59
+ var suiteDiv = this.createDom('div', { className: 'suite' },
60
+ this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
61
+ this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
62
+ this.suiteDivs[suite.id] = suiteDiv;
63
+ var parentDiv = this.outerDiv;
64
+ if (suite.parentSuite) {
65
+ parentDiv = this.suiteDivs[suite.parentSuite.id];
66
+ }
67
+ parentDiv.appendChild(suiteDiv);
68
+ }
69
+
70
+ this.startedAt = new Date();
71
+
72
+ var self = this;
73
+ showPassed.onclick = function(evt) {
74
+ if (showPassed.checked) {
75
+ self.outerDiv.className += ' show-passed';
76
+ } else {
77
+ self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
78
+ }
79
+ };
80
+
81
+ showSkipped.onclick = function(evt) {
82
+ if (showSkipped.checked) {
83
+ self.outerDiv.className += ' show-skipped';
84
+ } else {
85
+ self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
86
+ }
87
+ };
88
+ };
89
+
90
+ jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
91
+ var results = runner.results();
92
+ var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
93
+ this.runnerDiv.setAttribute("class", className);
94
+ //do it twice for IE
95
+ this.runnerDiv.setAttribute("className", className);
96
+ var specs = runner.specs();
97
+ var specCount = 0;
98
+ for (var i = 0; i < specs.length; i++) {
99
+ if (this.specFilter(specs[i])) {
100
+ specCount++;
101
+ }
102
+ }
103
+ var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
104
+ message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
105
+ this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
106
+
107
+ this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
108
+ };
109
+
110
+ jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
111
+ var results = suite.results();
112
+ var status = results.passed() ? 'passed' : 'failed';
113
+ if (results.totalCount === 0) { // todo: change this to check results.skipped
114
+ status = 'skipped';
115
+ }
116
+ this.suiteDivs[suite.id].className += " " + status;
117
+ };
118
+
119
+ jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
120
+ if (this.logRunningSpecs) {
121
+ this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
122
+ }
123
+ };
124
+
125
+ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
126
+ var results = spec.results();
127
+ var status = results.passed() ? 'passed' : 'failed';
128
+ if (results.skipped) {
129
+ status = 'skipped';
130
+ }
131
+ var specDiv = this.createDom('div', { className: 'spec ' + status },
132
+ this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
133
+ this.createDom('a', {
134
+ className: 'description',
135
+ href: '?spec=' + encodeURIComponent(spec.getFullName()),
136
+ title: spec.getFullName()
137
+ }, spec.description));
138
+
139
+
140
+ var resultItems = results.getItems();
141
+ var messagesDiv = this.createDom('div', { className: 'messages' });
142
+ for (var i = 0; i < resultItems.length; i++) {
143
+ var result = resultItems[i];
144
+
145
+ if (result.type == 'log') {
146
+ messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
147
+ } else if (result.type == 'expect' && result.passed && !result.passed()) {
148
+ messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
149
+
150
+ if (result.trace.stack) {
151
+ messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
152
+ }
153
+ }
154
+ }
155
+
156
+ if (messagesDiv.childNodes.length > 0) {
157
+ specDiv.appendChild(messagesDiv);
158
+ }
159
+
160
+ this.suiteDivs[spec.suite.id].appendChild(specDiv);
161
+ };
162
+
163
+ jasmine.TrivialReporter.prototype.log = function() {
164
+ var console = jasmine.getGlobal().console;
165
+ if (console && console.log) {
166
+ if (console.log.apply) {
167
+ console.log.apply(console, arguments);
168
+ } else {
169
+ console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
170
+ }
171
+ }
172
+ };
173
+
174
+ jasmine.TrivialReporter.prototype.getLocation = function() {
175
+ return this.document.location;
176
+ };
177
+
178
+ jasmine.TrivialReporter.prototype.specFilter = function(spec) {
179
+ var paramMap = {};
180
+ var params = this.getLocation().search.substring(1).split('&');
181
+ for (var i = 0; i < params.length; i++) {
182
+ var p = params[i].split('=');
183
+ paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
184
+ }
185
+
186
+ if (!paramMap.spec) {
187
+ return true;
188
+ }
189
+ return spec.getFullName().indexOf(paramMap.spec) === 0;
190
+ };