Permalink
Browse files

update to coffee-script 1.0 - change --now-wrap to --bare and adjust …

…tests for .call(this) at end of function wrapper
  • Loading branch information...
1 parent d2ff5de commit 19f3b8bb73693842d98097f6d4a95a2f37386ead PandaWood committed Dec 28, 2010
View
2 build.xml
@@ -20,7 +20,7 @@
<target name="build" depends="bootstrap, clean, functional-test"/>
- <property name="artifact.name" value="jcoffeescript-0.9.2-b"/>
+ <property name="artifact.name" value="jcoffeescript-1.0"/>
<import file="${basedir}/conf/build/build-bootstrap.xml"/>
<import file="${basedir}/conf/build/build-clean.xml"/>
<import file="${basedir}/conf/build/build-compile.xml"/>
View
4 src/main/java/org/jcoffeescript/Main.java
@@ -63,8 +63,8 @@ private String readSourceFrom(InputStream inputStream) {
private Collection<Option> readOptionsFrom(String[] args) {
final Collection<Option> options = new LinkedList<Option>();
- if (args.length == 1 && args[0].equals("--no-wrap")) {
- options.add(Option.NO_WRAP);
+ if (args.length == 1 && args[0].equals("--bare")) {
+ options.add(Option.BARE);
}
return options;
}
View
2 src/main/java/org/jcoffeescript/Option.java
@@ -17,5 +17,5 @@
package org.jcoffeescript;
public enum Option {
- NO_WRAP
+ BARE
}
View
62 src/main/java/org/jcoffeescript/Options.java
@@ -1,31 +1,31 @@
-/*
- * Copyright 2010 David Yeung
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jcoffeescript;
-
-import java.util.Collection;
-
-public class Options {
- private final String javaScriptOptions;
-
- public Options(Collection<Option> options) {
- javaScriptOptions = String.format("{noWrap: %b}", options.contains(Option.NO_WRAP));
- }
-
- public String toJavaScript() {
- return javaScriptOptions;
- }
-}
+/*
+ * Copyright 2010 David Yeung
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jcoffeescript;
+
+import java.util.Collection;
+
+public class Options {
+ private final String javaScriptOptions;
+
+ public Options(Collection<Option> options) {
+ javaScriptOptions = String.format("{bare: %b}", options.contains(Option.BARE));
+ }
+
+ public String toJavaScript() {
+ return javaScriptOptions;
+ }
+}
View
4 src/main/resources/org/jcoffeescript/coffee-script.js
2 additions, 2 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
10 src/unit-tests/java/org/jcoffeescript/CoffeeScriptCompilerTest.java
@@ -30,18 +30,18 @@ public void shouldCompileWithDefaultOptions() throws JCoffeeScriptCompileExcepti
assertThat(compiling("a = 1"),
allOf(
containsString("a = 1"),
- containsSafetyWrapper()
+ containsFunctionWrapper()
)
);
}
@Test
- public void shouldCompileWithoutSafetyWrapper() throws JCoffeeScriptCompileException {
- assertThat(compiling("a = 1", Option.NO_WRAP), not(containsSafetyWrapper()));
+ public void shouldCompileWithoutFunctionWrapper() throws JCoffeeScriptCompileException {
+ assertThat(compiling("a = 1", Option.BARE), not(containsFunctionWrapper()));
}
- private Matcher<String> containsSafetyWrapper() {
- return allOf(startsWith("(function() {\n"), endsWith("\n})();\n"));
+ private Matcher<String> containsFunctionWrapper() {
+ return allOf(startsWith("(function() {\n"), endsWith("\n}).call(this);\n"));
}
private String compiling(String coffeeScriptSource, Option... options) throws JCoffeeScriptCompileException {
View
2 src/unit-tests/java/org/jcoffeescript/MainTest.java
@@ -40,7 +40,7 @@ public void shouldWrapWhenNoArgs() {
@Test
public void shouldNotWrapWhenNoWrapArgsSupplied() throws IOException {
- assertThat(compilingByPiping("a = 1", "--no-wrap"), not(startsWith("(function() {")));
+ assertThat(compilingByPiping("a = 1", "--bare"), not(startsWith("(function() {")));
}
private String compilingByPiping(String input, String... args) {

0 comments on commit 19f3b8b

Please sign in to comment.