esperanto-source 0.6.17.2 → 0.6.17.3
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.
- checksums.yaml +4 -4
- data/lib/esperanto/source/version.rb +1 -1
- data/lib/esperanto/source.rb +5 -0
- data/test/test_esperanto_source.rb +2 -2
- data/vendor/base64.js +61 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecd2bf61c210c71df7894596a99f4c52c4ac4dc2
|
4
|
+
data.tar.gz: 87b8156755993f74fb3fda718e5e831e740b8521
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5387f60e65537808181490ab8f5ae47bc91c7721198ea73f3d607866afad5110814a832ae66f390ceb8b2d5c3c7fd59644e5b0cac43750bfdd49318a3a70654
|
7
|
+
data.tar.gz: fa197e602ec49f6292292c8c710a3449e406675e464275cfbce7100a6ff5fff325a0ff4c6ad0662cceee8a206ad5f265b2eb0ea25ce06b2cf7b139bcc9948279
|
data/lib/esperanto/source.rb
CHANGED
@@ -11,9 +11,14 @@ module Esperanto
|
|
11
11
|
%w(
|
12
12
|
acorn.js
|
13
13
|
estraverse.js
|
14
|
+
base64.js
|
14
15
|
esperanto.browser.js
|
15
16
|
).map {|js| bundled_path_for(js) }
|
16
17
|
end
|
18
|
+
|
19
|
+
def bundled_source
|
20
|
+
'var window = this; ' + bundled_paths.map {|path| File.read(path) }.join
|
21
|
+
end
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
@@ -22,8 +22,8 @@ class TestEsperantoSource < MiniTest::Test
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_bundled_files_executable
|
25
|
-
source = Esperanto::Source.
|
26
|
-
context = ExecJS
|
25
|
+
source = Esperanto::Source.bundled_source
|
26
|
+
context = ExecJS.compile(source)
|
27
27
|
|
28
28
|
assert { context.eval('typeof esperanto') == 'object' }
|
29
29
|
end
|
data/vendor/base64.js
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
;(function () {
|
2
|
+
|
3
|
+
var object = typeof exports != 'undefined' ? exports : this; // #8: web workers
|
4
|
+
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
5
|
+
|
6
|
+
function InvalidCharacterError(message) {
|
7
|
+
this.message = message;
|
8
|
+
}
|
9
|
+
InvalidCharacterError.prototype = new Error;
|
10
|
+
InvalidCharacterError.prototype.name = 'InvalidCharacterError';
|
11
|
+
|
12
|
+
// encoder
|
13
|
+
// [https://gist.github.com/999166] by [https://github.com/nignag]
|
14
|
+
object.btoa || (
|
15
|
+
object.btoa = function (input) {
|
16
|
+
var str = String(input);
|
17
|
+
for (
|
18
|
+
// initialize result and counter
|
19
|
+
var block, charCode, idx = 0, map = chars, output = '';
|
20
|
+
// if the next str index does not exist:
|
21
|
+
// change the mapping table to "="
|
22
|
+
// check if d has no fractional digits
|
23
|
+
str.charAt(idx | 0) || (map = '=', idx % 1);
|
24
|
+
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
|
25
|
+
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
|
26
|
+
) {
|
27
|
+
charCode = str.charCodeAt(idx += 3/4);
|
28
|
+
if (charCode > 0xFF) {
|
29
|
+
throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
|
30
|
+
}
|
31
|
+
block = block << 8 | charCode;
|
32
|
+
}
|
33
|
+
return output;
|
34
|
+
});
|
35
|
+
|
36
|
+
// decoder
|
37
|
+
// [https://gist.github.com/1020396] by [https://github.com/atk]
|
38
|
+
object.atob || (
|
39
|
+
object.atob = function (input) {
|
40
|
+
var str = String(input).replace(/=+$/, '');
|
41
|
+
if (str.length % 4 == 1) {
|
42
|
+
throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
|
43
|
+
}
|
44
|
+
for (
|
45
|
+
// initialize result and counters
|
46
|
+
var bc = 0, bs, buffer, idx = 0, output = '';
|
47
|
+
// get next character
|
48
|
+
buffer = str.charAt(idx++);
|
49
|
+
// character found in table? initialize bit storage and add its ascii value;
|
50
|
+
~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
|
51
|
+
// and if not first of each 4 characters,
|
52
|
+
// convert the first 8 bits to one ascii character
|
53
|
+
bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
|
54
|
+
) {
|
55
|
+
// try to find character in table (0-63, not found => -1)
|
56
|
+
buffer = chars.indexOf(buffer);
|
57
|
+
}
|
58
|
+
return output;
|
59
|
+
});
|
60
|
+
|
61
|
+
}());
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esperanto-source
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.17.
|
4
|
+
version: 0.6.17.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryunosuke SATO
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- lib/esperanto/source/version.rb
|
99
99
|
- test/test_esperanto_source.rb
|
100
100
|
- vendor/acorn.js
|
101
|
+
- vendor/base64.js
|
101
102
|
- vendor/esperanto.browser.js
|
102
103
|
- vendor/esperanto.js
|
103
104
|
- vendor/estraverse.js
|