numjitsu-rails 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +28 -0
- data/Rakefile +1 -0
- data/lib/numjitsu/rails.rb +8 -0
- data/lib/numjitsu/rails/engine.rb +6 -0
- data/lib/numjitsu/rails/version.rb +5 -0
- data/numjitsu-rails.gemspec +24 -0
- data/vendor/assets/javascripts/numjitsu-full.js +176 -0
- data/vendor/assets/javascripts/numjitsu-full.min.js +2 -0
- data/vendor/assets/javascripts/numjitsu-legacy.js +173 -0
- data/vendor/assets/javascripts/numjitsu-legacy.min.js +2 -0
- data/vendor/assets/javascripts/numjitsu.js +176 -0
- data/vendor/assets/javascripts/numjitsu.min.js +2 -0
- metadata +102 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Nicholas Dobie
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Numjitsu::Rails
|
2
|
+
|
3
|
+
Adds easy inclusion of the [Numjitsu JavaScript library](https://github.com/nrdobie/numjitsu) in Rails through Sproket.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'numjitsu-rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
In your `all.js` and require the version you want. We recommend including before jQuery.
|
18
|
+
|
19
|
+
```javascript
|
20
|
+
//=require numjitsu
|
21
|
+
//=require jquery
|
22
|
+
//...
|
23
|
+
```
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
This is just a distribution gem, please fork and modify the main
|
28
|
+
[Numjitsu project](https://github.com/nrdobie/numjitsu).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'numjitsu/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "numjitsu-rails"
|
8
|
+
spec.version = Numjitsu::Rails::VERSION
|
9
|
+
spec.authors = ["Nicholas Dobie"]
|
10
|
+
spec.email = ["nick@nickdobie.com"]
|
11
|
+
spec.description = %q{Numjitsu is a syntactical sugar libary for working with different types of units in JavaScript. It currently supports dates and file
|
12
|
+
size units and its syntax is based on the Ruby on Rails Number syntax.}
|
13
|
+
spec.summary = %q{For syntactically awesome numbers}
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
(function () {var ns = {},
|
2
|
+
nm = {};;ns.millisecond = function () {
|
3
|
+
return this;
|
4
|
+
};
|
5
|
+
|
6
|
+
// Alias
|
7
|
+
ns.milliseconds = ns.millisecond;
|
8
|
+
|
9
|
+
ns.second = function () {
|
10
|
+
return this * 1000;
|
11
|
+
};
|
12
|
+
|
13
|
+
// Alias
|
14
|
+
ns.seconds = ns.second;
|
15
|
+
|
16
|
+
ns.minute = function () {
|
17
|
+
return this * 60000;
|
18
|
+
};
|
19
|
+
|
20
|
+
// Alias
|
21
|
+
ns.minutes = ns.minute;
|
22
|
+
|
23
|
+
ns.hour = function () {
|
24
|
+
return this * 3600000;
|
25
|
+
};
|
26
|
+
|
27
|
+
// Alias
|
28
|
+
ns.hours = ns.hour;
|
29
|
+
|
30
|
+
ns.day = function () {
|
31
|
+
return this * 86400000;
|
32
|
+
};
|
33
|
+
|
34
|
+
// Alias
|
35
|
+
ns.days = ns.day;
|
36
|
+
|
37
|
+
ns.week = function () {
|
38
|
+
return this * 604800000;
|
39
|
+
};
|
40
|
+
|
41
|
+
// Alias
|
42
|
+
ns.weeks = ns.week;
|
43
|
+
|
44
|
+
ns.fortnight = function () {
|
45
|
+
return this * 1209600000;
|
46
|
+
};
|
47
|
+
|
48
|
+
// Alias
|
49
|
+
ns.fortnights = ns.fortnight;
|
50
|
+
|
51
|
+
ns.month = function () {
|
52
|
+
return this * 2419200000;
|
53
|
+
};
|
54
|
+
|
55
|
+
// Alias
|
56
|
+
ns.months = ns.month;
|
57
|
+
|
58
|
+
ns.year = function () {
|
59
|
+
return this * 31449600000;
|
60
|
+
};
|
61
|
+
|
62
|
+
// Alias
|
63
|
+
ns.years = ns.year;
|
64
|
+
|
65
|
+
ns.decade = function () {
|
66
|
+
return this * 314496000000;
|
67
|
+
};
|
68
|
+
|
69
|
+
// Alias
|
70
|
+
ns.decades = ns.decade;
|
71
|
+
|
72
|
+
ns.century = function () {
|
73
|
+
return this * 3144960000000;
|
74
|
+
};
|
75
|
+
|
76
|
+
// Alias
|
77
|
+
ns.centuries = ns.century;
|
78
|
+
|
79
|
+
//////////////////////////////////////
|
80
|
+
// Converters
|
81
|
+
|
82
|
+
|
83
|
+
ns.from_now = function () {
|
84
|
+
return new Date((new Date()).getTime() + this);
|
85
|
+
};
|
86
|
+
|
87
|
+
ns.ago = function () {
|
88
|
+
return new Date((new Date()).getTime() - this);
|
89
|
+
};
|
90
|
+
|
91
|
+
nm.from = function (date) {
|
92
|
+
return new Date(date.getTime() + this);
|
93
|
+
};
|
94
|
+
|
95
|
+
// Alias
|
96
|
+
nm.since = nm.from;
|
97
|
+
|
98
|
+
nm.before = function (date) {
|
99
|
+
return new Date(date.getTime() - this);
|
100
|
+
};
|
101
|
+
|
102
|
+
// Alias
|
103
|
+
nm.until = nm.before;;ns.byte = function () {
|
104
|
+
return this;
|
105
|
+
};
|
106
|
+
|
107
|
+
// Alias
|
108
|
+
ns.bytes = ns.byte;
|
109
|
+
|
110
|
+
ns.kilobyte = function () {
|
111
|
+
return this * 1024;
|
112
|
+
};
|
113
|
+
|
114
|
+
// Alias
|
115
|
+
ns.kilobytes = ns.kilobyte;
|
116
|
+
|
117
|
+
ns.megabyte = function () {
|
118
|
+
return this * 1048576;
|
119
|
+
};
|
120
|
+
|
121
|
+
// Alias
|
122
|
+
ns.megabytes = ns.megabyte;
|
123
|
+
|
124
|
+
ns.gigabyte = function () {
|
125
|
+
return this * 1073741824;
|
126
|
+
};
|
127
|
+
|
128
|
+
// Alias
|
129
|
+
ns.gigabytes = ns.gigabyte;
|
130
|
+
|
131
|
+
ns.terabyte = function () {
|
132
|
+
return this * 1099511627776;
|
133
|
+
};
|
134
|
+
|
135
|
+
// Alias
|
136
|
+
ns.terabytes = ns.terabyte;
|
137
|
+
|
138
|
+
ns.petabyte = function () {
|
139
|
+
return this * 1125899906842624;
|
140
|
+
};
|
141
|
+
|
142
|
+
// Alias
|
143
|
+
ns.petabytes = ns.petabyte;
|
144
|
+
|
145
|
+
ns.exabyte = function () {
|
146
|
+
return this * 1152921504606846976;
|
147
|
+
};
|
148
|
+
|
149
|
+
// Alias
|
150
|
+
ns.exabytes = ns.exabyte;;/**
|
151
|
+
* Adds the syntactical sugar to the Number object through define
|
152
|
+
*/
|
153
|
+
|
154
|
+
for (var syntax in ns) {
|
155
|
+
|
156
|
+
// Checks for non-Numjitsu methods.
|
157
|
+
if ( !ns.hasOwnProperty( syntax ) )
|
158
|
+
continue;
|
159
|
+
|
160
|
+
Object.defineProperty(Number.prototype, syntax, {
|
161
|
+
get: ns[syntax]
|
162
|
+
});
|
163
|
+
|
164
|
+
}
|
165
|
+
|
166
|
+
for (var syntax in nm) {
|
167
|
+
|
168
|
+
// Checks for non-Numjitsu methods.
|
169
|
+
if ( !nm.hasOwnProperty( syntax ) )
|
170
|
+
continue;
|
171
|
+
|
172
|
+
Object.defineProperty(Number.prototype, syntax, {
|
173
|
+
value: nm[syntax]
|
174
|
+
});
|
175
|
+
|
176
|
+
}})();
|
@@ -0,0 +1,2 @@
|
|
1
|
+
/*! numjitsu 2013-06-21 */
|
2
|
+
!function(){var a={},b={};a.millisecond=function(){return this},a.milliseconds=a.millisecond,a.second=function(){return 1e3*this},a.seconds=a.second,a.minute=function(){return 6e4*this},a.minutes=a.minute,a.hour=function(){return 36e5*this},a.hours=a.hour,a.day=function(){return 864e5*this},a.days=a.day,a.week=function(){return 6048e5*this},a.weeks=a.week,a.fortnight=function(){return 12096e5*this},a.fortnights=a.fortnight,a.month=function(){return 24192e5*this},a.months=a.month,a.year=function(){return 314496e5*this},a.years=a.year,a.decade=function(){return 314496e6*this},a.decades=a.decade,a.century=function(){return 314496e7*this},a.centuries=a.century,a.from_now=function(){return new Date((new Date).getTime()+this)},a.ago=function(){return new Date((new Date).getTime()-this)},b.from=function(a){return new Date(a.getTime()+this)},b.since=b.from,b.before=function(a){return new Date(a.getTime()-this)},b.until=b.before,a.byte=function(){return this},a.bytes=a.byte,a.kilobyte=function(){return 1024*this},a.kilobytes=a.kilobyte,a.megabyte=function(){return 1048576*this},a.megabytes=a.megabyte,a.gigabyte=function(){return 1073741824*this},a.gigabytes=a.gigabyte,a.terabyte=function(){return 1099511627776*this},a.terabytes=a.terabyte,a.petabyte=function(){return 0x4000000000000*this},a.petabytes=a.petabyte,a.exabyte=function(){return 0x1000000000000000*this},a.exabytes=a.exabyte;for(var c in a)a.hasOwnProperty(c)&&Object.defineProperty(Number.prototype,c,{get:a[c]});for(var c in b)b.hasOwnProperty(c)&&Object.defineProperty(Number.prototype,c,{value:b[c]})}();
|
@@ -0,0 +1,173 @@
|
|
1
|
+
(function () {var ns = {},
|
2
|
+
nm = {};;ns.millisecond = function () {
|
3
|
+
return this;
|
4
|
+
};
|
5
|
+
|
6
|
+
// Alias
|
7
|
+
ns.milliseconds = ns.millisecond;
|
8
|
+
|
9
|
+
ns.second = function () {
|
10
|
+
return this * 1000;
|
11
|
+
};
|
12
|
+
|
13
|
+
// Alias
|
14
|
+
ns.seconds = ns.second;
|
15
|
+
|
16
|
+
ns.minute = function () {
|
17
|
+
return this * 60000;
|
18
|
+
};
|
19
|
+
|
20
|
+
// Alias
|
21
|
+
ns.minutes = ns.minute;
|
22
|
+
|
23
|
+
ns.hour = function () {
|
24
|
+
return this * 3600000;
|
25
|
+
};
|
26
|
+
|
27
|
+
// Alias
|
28
|
+
ns.hours = ns.hour;
|
29
|
+
|
30
|
+
ns.day = function () {
|
31
|
+
return this * 86400000;
|
32
|
+
};
|
33
|
+
|
34
|
+
// Alias
|
35
|
+
ns.days = ns.day;
|
36
|
+
|
37
|
+
ns.week = function () {
|
38
|
+
return this * 604800000;
|
39
|
+
};
|
40
|
+
|
41
|
+
// Alias
|
42
|
+
ns.weeks = ns.week;
|
43
|
+
|
44
|
+
ns.fortnight = function () {
|
45
|
+
return this * 1209600000;
|
46
|
+
};
|
47
|
+
|
48
|
+
// Alias
|
49
|
+
ns.fortnights = ns.fortnight;
|
50
|
+
|
51
|
+
ns.month = function () {
|
52
|
+
return this * 2419200000;
|
53
|
+
};
|
54
|
+
|
55
|
+
// Alias
|
56
|
+
ns.months = ns.month;
|
57
|
+
|
58
|
+
ns.year = function () {
|
59
|
+
return this * 31449600000;
|
60
|
+
};
|
61
|
+
|
62
|
+
// Alias
|
63
|
+
ns.years = ns.year;
|
64
|
+
|
65
|
+
ns.decade = function () {
|
66
|
+
return this * 314496000000;
|
67
|
+
};
|
68
|
+
|
69
|
+
// Alias
|
70
|
+
ns.decades = ns.decade;
|
71
|
+
|
72
|
+
ns.century = function () {
|
73
|
+
return this * 3144960000000;
|
74
|
+
};
|
75
|
+
|
76
|
+
// Alias
|
77
|
+
ns.centuries = ns.century;
|
78
|
+
|
79
|
+
//////////////////////////////////////
|
80
|
+
// Converters
|
81
|
+
|
82
|
+
|
83
|
+
ns.from_now = function () {
|
84
|
+
return new Date((new Date()).getTime() + this);
|
85
|
+
};
|
86
|
+
|
87
|
+
ns.ago = function () {
|
88
|
+
return new Date((new Date()).getTime() - this);
|
89
|
+
};
|
90
|
+
|
91
|
+
nm.from = function (date) {
|
92
|
+
return new Date(date.getTime() + this);
|
93
|
+
};
|
94
|
+
|
95
|
+
// Alias
|
96
|
+
nm.since = nm.from;
|
97
|
+
|
98
|
+
nm.before = function (date) {
|
99
|
+
return new Date(date.getTime() - this);
|
100
|
+
};
|
101
|
+
|
102
|
+
// Alias
|
103
|
+
nm.until = nm.before;;ns.byte = function () {
|
104
|
+
return this;
|
105
|
+
};
|
106
|
+
|
107
|
+
// Alias
|
108
|
+
ns.bytes = ns.byte;
|
109
|
+
|
110
|
+
ns.kilobyte = function () {
|
111
|
+
return this * 1024;
|
112
|
+
};
|
113
|
+
|
114
|
+
// Alias
|
115
|
+
ns.kilobytes = ns.kilobyte;
|
116
|
+
|
117
|
+
ns.megabyte = function () {
|
118
|
+
return this * 1048576;
|
119
|
+
};
|
120
|
+
|
121
|
+
// Alias
|
122
|
+
ns.megabytes = ns.megabyte;
|
123
|
+
|
124
|
+
ns.gigabyte = function () {
|
125
|
+
return this * 1073741824;
|
126
|
+
};
|
127
|
+
|
128
|
+
// Alias
|
129
|
+
ns.gigabytes = ns.gigabyte;
|
130
|
+
|
131
|
+
ns.terabyte = function () {
|
132
|
+
return this * 1099511627776;
|
133
|
+
};
|
134
|
+
|
135
|
+
// Alias
|
136
|
+
ns.terabytes = ns.terabyte;
|
137
|
+
|
138
|
+
ns.petabyte = function () {
|
139
|
+
return this * 1125899906842624;
|
140
|
+
};
|
141
|
+
|
142
|
+
// Alias
|
143
|
+
ns.petabytes = ns.petabyte;
|
144
|
+
|
145
|
+
ns.exabyte = function () {
|
146
|
+
return this * 1152921504606846976;
|
147
|
+
};
|
148
|
+
|
149
|
+
// Alias
|
150
|
+
ns.exabytes = ns.exabyte;;/**
|
151
|
+
* Adds the syntactical sugar to the Number object through prototype.
|
152
|
+
*/
|
153
|
+
|
154
|
+
for (var syntax in ns) {
|
155
|
+
|
156
|
+
|
157
|
+
// Checks for non-Numjitsu methods.
|
158
|
+
if ( !nm.hasOwnProperty( syntax ) )
|
159
|
+
continue;
|
160
|
+
|
161
|
+
Number.prototype[syntax] = ns[syntax];
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
for (var syntax in nm) {
|
166
|
+
|
167
|
+
// Checks for non-Numjitsu methods.
|
168
|
+
if ( !nm.hasOwnProperty( syntax ) )
|
169
|
+
continue;
|
170
|
+
|
171
|
+
Number.prototype[syntax] = nm[syntax];
|
172
|
+
|
173
|
+
}})();
|
@@ -0,0 +1,2 @@
|
|
1
|
+
/*! numjitsu 2013-06-21 */
|
2
|
+
!function(){var a={},b={};a.millisecond=function(){return this},a.milliseconds=a.millisecond,a.second=function(){return 1e3*this},a.seconds=a.second,a.minute=function(){return 6e4*this},a.minutes=a.minute,a.hour=function(){return 36e5*this},a.hours=a.hour,a.day=function(){return 864e5*this},a.days=a.day,a.week=function(){return 6048e5*this},a.weeks=a.week,a.fortnight=function(){return 12096e5*this},a.fortnights=a.fortnight,a.month=function(){return 24192e5*this},a.months=a.month,a.year=function(){return 314496e5*this},a.years=a.year,a.decade=function(){return 314496e6*this},a.decades=a.decade,a.century=function(){return 314496e7*this},a.centuries=a.century,a.from_now=function(){return new Date((new Date).getTime()+this)},a.ago=function(){return new Date((new Date).getTime()-this)},b.from=function(a){return new Date(a.getTime()+this)},b.since=b.from,b.before=function(a){return new Date(a.getTime()-this)},b.until=b.before,a.byte=function(){return this},a.bytes=a.byte,a.kilobyte=function(){return 1024*this},a.kilobytes=a.kilobyte,a.megabyte=function(){return 1048576*this},a.megabytes=a.megabyte,a.gigabyte=function(){return 1073741824*this},a.gigabytes=a.gigabyte,a.terabyte=function(){return 1099511627776*this},a.terabytes=a.terabyte,a.petabyte=function(){return 0x4000000000000*this},a.petabytes=a.petabyte,a.exabyte=function(){return 0x1000000000000000*this},a.exabytes=a.exabyte;for(var c in a)b.hasOwnProperty(c)&&(Number.prototype[c]=a[c]);for(var c in b)b.hasOwnProperty(c)&&(Number.prototype[c]=b[c])}();
|
@@ -0,0 +1,176 @@
|
|
1
|
+
(function () {var ns = {},
|
2
|
+
nm = {};;ns.millisecond = function () {
|
3
|
+
return this;
|
4
|
+
};
|
5
|
+
|
6
|
+
// Alias
|
7
|
+
ns.milliseconds = ns.millisecond;
|
8
|
+
|
9
|
+
ns.second = function () {
|
10
|
+
return this * 1000;
|
11
|
+
};
|
12
|
+
|
13
|
+
// Alias
|
14
|
+
ns.seconds = ns.second;
|
15
|
+
|
16
|
+
ns.minute = function () {
|
17
|
+
return this * 60000;
|
18
|
+
};
|
19
|
+
|
20
|
+
// Alias
|
21
|
+
ns.minutes = ns.minute;
|
22
|
+
|
23
|
+
ns.hour = function () {
|
24
|
+
return this * 3600000;
|
25
|
+
};
|
26
|
+
|
27
|
+
// Alias
|
28
|
+
ns.hours = ns.hour;
|
29
|
+
|
30
|
+
ns.day = function () {
|
31
|
+
return this * 86400000;
|
32
|
+
};
|
33
|
+
|
34
|
+
// Alias
|
35
|
+
ns.days = ns.day;
|
36
|
+
|
37
|
+
ns.week = function () {
|
38
|
+
return this * 604800000;
|
39
|
+
};
|
40
|
+
|
41
|
+
// Alias
|
42
|
+
ns.weeks = ns.week;
|
43
|
+
|
44
|
+
ns.fortnight = function () {
|
45
|
+
return this * 1209600000;
|
46
|
+
};
|
47
|
+
|
48
|
+
// Alias
|
49
|
+
ns.fortnights = ns.fortnight;
|
50
|
+
|
51
|
+
ns.month = function () {
|
52
|
+
return this * 2419200000;
|
53
|
+
};
|
54
|
+
|
55
|
+
// Alias
|
56
|
+
ns.months = ns.month;
|
57
|
+
|
58
|
+
ns.year = function () {
|
59
|
+
return this * 31449600000;
|
60
|
+
};
|
61
|
+
|
62
|
+
// Alias
|
63
|
+
ns.years = ns.year;
|
64
|
+
|
65
|
+
ns.decade = function () {
|
66
|
+
return this * 314496000000;
|
67
|
+
};
|
68
|
+
|
69
|
+
// Alias
|
70
|
+
ns.decades = ns.decade;
|
71
|
+
|
72
|
+
ns.century = function () {
|
73
|
+
return this * 3144960000000;
|
74
|
+
};
|
75
|
+
|
76
|
+
// Alias
|
77
|
+
ns.centuries = ns.century;
|
78
|
+
|
79
|
+
//////////////////////////////////////
|
80
|
+
// Converters
|
81
|
+
|
82
|
+
|
83
|
+
ns.from_now = function () {
|
84
|
+
return new Date((new Date()).getTime() + this);
|
85
|
+
};
|
86
|
+
|
87
|
+
ns.ago = function () {
|
88
|
+
return new Date((new Date()).getTime() - this);
|
89
|
+
};
|
90
|
+
|
91
|
+
nm.from = function (date) {
|
92
|
+
return new Date(date.getTime() + this);
|
93
|
+
};
|
94
|
+
|
95
|
+
// Alias
|
96
|
+
nm.since = nm.from;
|
97
|
+
|
98
|
+
nm.before = function (date) {
|
99
|
+
return new Date(date.getTime() - this);
|
100
|
+
};
|
101
|
+
|
102
|
+
// Alias
|
103
|
+
nm.until = nm.before;;ns.byte = function () {
|
104
|
+
return this;
|
105
|
+
};
|
106
|
+
|
107
|
+
// Alias
|
108
|
+
ns.bytes = ns.byte;
|
109
|
+
|
110
|
+
ns.kilobyte = function () {
|
111
|
+
return this * 1024;
|
112
|
+
};
|
113
|
+
|
114
|
+
// Alias
|
115
|
+
ns.kilobytes = ns.kilobyte;
|
116
|
+
|
117
|
+
ns.megabyte = function () {
|
118
|
+
return this * 1048576;
|
119
|
+
};
|
120
|
+
|
121
|
+
// Alias
|
122
|
+
ns.megabytes = ns.megabyte;
|
123
|
+
|
124
|
+
ns.gigabyte = function () {
|
125
|
+
return this * 1073741824;
|
126
|
+
};
|
127
|
+
|
128
|
+
// Alias
|
129
|
+
ns.gigabytes = ns.gigabyte;
|
130
|
+
|
131
|
+
ns.terabyte = function () {
|
132
|
+
return this * 1099511627776;
|
133
|
+
};
|
134
|
+
|
135
|
+
// Alias
|
136
|
+
ns.terabytes = ns.terabyte;
|
137
|
+
|
138
|
+
ns.petabyte = function () {
|
139
|
+
return this * 1125899906842624;
|
140
|
+
};
|
141
|
+
|
142
|
+
// Alias
|
143
|
+
ns.petabytes = ns.petabyte;
|
144
|
+
|
145
|
+
ns.exabyte = function () {
|
146
|
+
return this * 1152921504606846976;
|
147
|
+
};
|
148
|
+
|
149
|
+
// Alias
|
150
|
+
ns.exabytes = ns.exabyte;;/**
|
151
|
+
* Adds the syntactical sugar to the Number object through define
|
152
|
+
*/
|
153
|
+
|
154
|
+
for (var syntax in ns) {
|
155
|
+
|
156
|
+
// Checks for non-Numjitsu methods.
|
157
|
+
if ( !ns.hasOwnProperty( syntax ) )
|
158
|
+
continue;
|
159
|
+
|
160
|
+
Object.defineProperty(Number.prototype, syntax, {
|
161
|
+
get: ns[syntax]
|
162
|
+
});
|
163
|
+
|
164
|
+
}
|
165
|
+
|
166
|
+
for (var syntax in nm) {
|
167
|
+
|
168
|
+
// Checks for non-Numjitsu methods.
|
169
|
+
if ( !nm.hasOwnProperty( syntax ) )
|
170
|
+
continue;
|
171
|
+
|
172
|
+
Object.defineProperty(Number.prototype, syntax, {
|
173
|
+
value: nm[syntax]
|
174
|
+
});
|
175
|
+
|
176
|
+
}})();
|
@@ -0,0 +1,2 @@
|
|
1
|
+
/*! numjitsu 2013-06-21 */
|
2
|
+
!function(){var a={},b={};a.millisecond=function(){return this},a.milliseconds=a.millisecond,a.second=function(){return 1e3*this},a.seconds=a.second,a.minute=function(){return 6e4*this},a.minutes=a.minute,a.hour=function(){return 36e5*this},a.hours=a.hour,a.day=function(){return 864e5*this},a.days=a.day,a.week=function(){return 6048e5*this},a.weeks=a.week,a.fortnight=function(){return 12096e5*this},a.fortnights=a.fortnight,a.month=function(){return 24192e5*this},a.months=a.month,a.year=function(){return 314496e5*this},a.years=a.year,a.decade=function(){return 314496e6*this},a.decades=a.decade,a.century=function(){return 314496e7*this},a.centuries=a.century,a.from_now=function(){return new Date((new Date).getTime()+this)},a.ago=function(){return new Date((new Date).getTime()-this)},b.from=function(a){return new Date(a.getTime()+this)},b.since=b.from,b.before=function(a){return new Date(a.getTime()-this)},b.until=b.before,a.byte=function(){return this},a.bytes=a.byte,a.kilobyte=function(){return 1024*this},a.kilobytes=a.kilobyte,a.megabyte=function(){return 1048576*this},a.megabytes=a.megabyte,a.gigabyte=function(){return 1073741824*this},a.gigabytes=a.gigabyte,a.terabyte=function(){return 1099511627776*this},a.terabytes=a.terabyte,a.petabyte=function(){return 0x4000000000000*this},a.petabytes=a.petabyte,a.exabyte=function(){return 0x1000000000000000*this},a.exabytes=a.exabyte;for(var c in a)a.hasOwnProperty(c)&&Object.defineProperty(Number.prototype,c,{get:a[c]});for(var c in b)b.hasOwnProperty(c)&&Object.defineProperty(Number.prototype,c,{value:b[c]})}();
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: numjitsu-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nicholas Dobie
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: ! 'Numjitsu is a syntactical sugar libary for working with different
|
47
|
+
types of units in JavaScript. It currently supports dates and file
|
48
|
+
|
49
|
+
size units and its syntax is based on the Ruby on Rails Number syntax.'
|
50
|
+
email:
|
51
|
+
- nick@nickdobie.com
|
52
|
+
executables: []
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- Gemfile
|
58
|
+
- LICENSE.txt
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- lib/numjitsu/rails.rb
|
62
|
+
- lib/numjitsu/rails/engine.rb
|
63
|
+
- lib/numjitsu/rails/version.rb
|
64
|
+
- numjitsu-rails.gemspec
|
65
|
+
- vendor/assets/javascripts/numjitsu-full.js
|
66
|
+
- vendor/assets/javascripts/numjitsu-full.min.js
|
67
|
+
- vendor/assets/javascripts/numjitsu-legacy.js
|
68
|
+
- vendor/assets/javascripts/numjitsu-legacy.min.js
|
69
|
+
- vendor/assets/javascripts/numjitsu.js
|
70
|
+
- vendor/assets/javascripts/numjitsu.min.js
|
71
|
+
homepage: ''
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
hash: 157914272500047463
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
hash: 157914272500047463
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 1.8.25
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: For syntactically awesome numbers
|
102
|
+
test_files: []
|