Module: Jsmin

Defined in:
ext/jsmin_wrap.c

Defined Under Namespace

Classes: ParseError

Class Method Summary collapse

Class Method Details

.minify(str) ⇒ String

Returns a new string object containing a minified copy of str. May raise Jsmin::ParseError if parsing fails.

Returns:

  • (String)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'ext/jsmin_wrap.c', line 22

static VALUE minify_wrap(VALUE self, VALUE arg)
{
	char *input;
	char *res;
	VALUE str, rv;

	str = StringValue(arg);
	input = RSTRING_PTR(str);

	res = minify(input);

	if (res[0] == '!') {
		rv = rb_str_new2(res+1);
		free(res);
		rb_raise(rb_eParseError, "%s", RSTRING_PTR(rv));
	}

	rv = rb_str_new2(res);
	free(res);

	return rv;
}