uglifier 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of uglifier might be problematic. Click here for more details.
- data/.travis.yml +0 -1
- data/README.md +2 -2
- data/VERSION +1 -1
- data/lib/uglify.js +20 -7
- data/spec/uglifier_spec.rb +7 -4
- data/uglifier.gemspec +2 -2
- metadata +3 -3
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -4,11 +4,11 @@ Ruby wrapper for [UglifyJS](https://github.com/mishoo/UglifyJS) JavaScript compr
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
Uglifier is available as ruby gem.
|
7
|
+
Uglifier is available as a ruby gem.
|
8
8
|
|
9
9
|
$ gem install uglifier
|
10
10
|
|
11
|
-
Ensure that your environment has a JavaScript interpreter supported by [ExecJS](https://github.com/sstephenson/execjs).
|
11
|
+
Ensure that your environment has a JavaScript interpreter supported by [ExecJS](https://github.com/sstephenson/execjs). Installing `therubyracer` gem is a safe choice and having `node` in `PATH` works too.
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.6
|
data/lib/uglify.js
CHANGED
@@ -2,19 +2,19 @@
|
|
2
2
|
(function(/*! Stitch !*/) {
|
3
3
|
if (!this.require) {
|
4
4
|
var modules = {}, cache = {}, require = function(name, root) {
|
5
|
-
var path = expand(root, name),
|
5
|
+
var module = cache[name], path = expand(root, name), fn;
|
6
6
|
if (module) {
|
7
|
-
return module
|
7
|
+
return module;
|
8
8
|
} else if (fn = modules[path] || modules[path = expand(path, './index')]) {
|
9
|
-
module = {id:
|
9
|
+
module = {id: name, exports: {}};
|
10
10
|
try {
|
11
|
-
cache[
|
11
|
+
cache[name] = module.exports;
|
12
12
|
fn(module.exports, function(name) {
|
13
13
|
return require(name, dirname(path));
|
14
14
|
}, module);
|
15
|
-
return module.exports;
|
15
|
+
return cache[name] = module.exports;
|
16
16
|
} catch (err) {
|
17
|
-
delete cache[
|
17
|
+
delete cache[name];
|
18
18
|
throw err;
|
19
19
|
}
|
20
20
|
} else {
|
@@ -2627,6 +2627,8 @@ exports.KEYWORDS = KEYWORDS;
|
|
2627
2627
|
exports.ATOMIC_START_TOKEN = ATOMIC_START_TOKEN;
|
2628
2628
|
exports.OPERATORS = OPERATORS;
|
2629
2629
|
exports.is_alphanumeric_char = is_alphanumeric_char;
|
2630
|
+
exports.is_identifier_start = is_identifier_start;
|
2631
|
+
exports.is_identifier_char = is_identifier_char;
|
2630
2632
|
exports.set_logger = function(logger) {
|
2631
2633
|
warn = logger;
|
2632
2634
|
};
|
@@ -2693,6 +2695,7 @@ exports.set_logger = function(logger) {
|
|
2693
2695
|
var jsp = require("./parse-js"),
|
2694
2696
|
slice = jsp.slice,
|
2695
2697
|
member = jsp.member,
|
2698
|
+
is_identifier_char = jsp.is_identifier_char,
|
2696
2699
|
PRECEDENCE = jsp.PRECEDENCE,
|
2697
2700
|
OPERATORS = jsp.OPERATORS;
|
2698
2701
|
|
@@ -4149,6 +4152,15 @@ function gen_code(ast, options) {
|
|
4149
4152
|
finally { indentation -= incr; }
|
4150
4153
|
};
|
4151
4154
|
|
4155
|
+
function last_char(str) {
|
4156
|
+
str = str.toString();
|
4157
|
+
return str.charAt(str.length - 1);
|
4158
|
+
};
|
4159
|
+
|
4160
|
+
function first_char(str) {
|
4161
|
+
return str.toString().charAt(0);
|
4162
|
+
};
|
4163
|
+
|
4152
4164
|
function add_spaces(a) {
|
4153
4165
|
if (beautify)
|
4154
4166
|
return a.join(" ");
|
@@ -4157,7 +4169,8 @@ function gen_code(ast, options) {
|
|
4157
4169
|
var next = a[i + 1];
|
4158
4170
|
b.push(a[i]);
|
4159
4171
|
if (next &&
|
4160
|
-
((
|
4172
|
+
((is_identifier_char(last_char(a[i])) && (is_identifier_char(first_char(next))
|
4173
|
+
|| first_char(next) == "\\")) ||
|
4161
4174
|
(/[\+\-]$/.test(a[i].toString()) && /^[\+\-]/.test(next.toString())))) {
|
4162
4175
|
b.push(" ");
|
4163
4176
|
}
|
data/spec/uglifier_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
+
require 'stringio'
|
2
3
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
3
4
|
|
4
5
|
describe "Uglifier" do
|
5
6
|
it "minifies JS" do
|
6
|
-
source = File.open("
|
7
|
+
source = File.open("lib/uglify.js", "r:UTF-8").read
|
7
8
|
minified = Uglifier.new.compile(source)
|
8
9
|
minified.length.should < source.length
|
9
10
|
lambda {
|
@@ -120,15 +121,17 @@ describe "Uglifier" do
|
|
120
121
|
end
|
121
122
|
|
122
123
|
describe "Input Formats" do
|
124
|
+
let(:code) { "function hello() { return 'hello world'; }" }
|
125
|
+
|
123
126
|
it "handles strings" do
|
124
127
|
lambda {
|
125
|
-
Uglifier.new.compile(
|
128
|
+
Uglifier.new.compile(code).should_not be_empty
|
126
129
|
}.should_not raise_error
|
127
130
|
end
|
128
131
|
|
129
|
-
it "handles
|
132
|
+
it "handles IO objects" do
|
130
133
|
lambda {
|
131
|
-
Uglifier.new.compile(
|
134
|
+
Uglifier.new.compile(StringIO.new(code)).should_not be_empty
|
132
135
|
}.should_not raise_error
|
133
136
|
end
|
134
137
|
end
|
data/uglifier.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "uglifier"
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ville Lautanala"]
|
12
|
-
s.date = "2012-06-
|
12
|
+
s.date = "2012-06-28"
|
13
13
|
s.email = "lautis@gmail.com"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.txt",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uglifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: execjs
|
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
segments:
|
147
147
|
- 0
|
148
|
-
hash:
|
148
|
+
hash: 1608746242454897319
|
149
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
150
|
none: false
|
151
151
|
requirements:
|