new 0.0.1 → 0.0.2

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +16 -0
  5. data/Gemfile.lock +79 -0
  6. data/Guardfile +14 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +121 -0
  9. data/bin/new +6 -0
  10. data/lib/new/cli.rb +94 -0
  11. data/lib/new/core.rb +6 -0
  12. data/lib/new/dsl.rb +42 -0
  13. data/lib/new/interpolate.rb +100 -0
  14. data/lib/new/project.rb +34 -0
  15. data/lib/new/task.rb +41 -0
  16. data/lib/new/template.rb +64 -0
  17. data/lib/new/version.rb +41 -0
  18. data/lib/new.rb +72 -0
  19. data/new-0.0.0.gem +0 -0
  20. data/new-0.0.1.gem +0 -0
  21. data/spec/fixtures/custom/tasks/custom_bar_task/custom_bar_task.rb +3 -0
  22. data/spec/fixtures/custom/templates/custom_bar_template/custom_bar.txt +0 -0
  23. data/spec/fixtures/tasks/custom_bar_task/custom_bar_task.rb +1 -0
  24. data/spec/fixtures/tasks/foo_task/foo_task.rb +7 -0
  25. data/spec/fixtures/templates/foo_template/[FOO.BAR].txt.erb +1 -0
  26. data/spec/fixtures/templates/foo_template/nested_[FOO.BAR]/foo.txt.erb +1 -0
  27. data/spec/lib/new/cli_spec.rb +104 -0
  28. data/spec/lib/new/interpolate_spec.rb +41 -0
  29. data/spec/lib/new/project_spec.rb +30 -0
  30. data/spec/lib/new/task_spec.rb +39 -0
  31. data/spec/lib/new/template_spec.rb +59 -0
  32. data/spec/lib/new/version_spec.rb +28 -0
  33. data/spec/lib/new_spec.rb +19 -0
  34. data/spec/spec_helper.rb +26 -0
  35. data/tasks/gem/README.md +36 -0
  36. data/tasks/gem/gem.rb +122 -0
  37. data/templates/js/Gemfile +30 -0
  38. data/templates/js/Guardfile +7 -0
  39. data/templates/js/LICENSE-MIT.erb +22 -0
  40. data/templates/js/README.md.erb +61 -0
  41. data/templates/js/demo/index.html.erb +7 -0
  42. data/templates/js/lib/README.md +2 -0
  43. data/templates/js/spec/[PROJECT_NAME].spec.js.coffee.erb +1 -0
  44. data/templates/js/spec/index.html.erb +29 -0
  45. data/templates/js/spec/spec_helper.js.coffee +0 -0
  46. data/templates/js/spec/vendor/chai.js +3765 -0
  47. data/templates/js/spec/vendor/sinon-chai.js +106 -0
  48. data/templates/js/spec/vendor/sinon.js +4246 -0
  49. data/templates/js/src/README.md +3 -0
  50. data/templates/js/src/[PROJECT_NAME].js.coffee.erb +10 -0
  51. data/templates/js/testem.yml +12 -0
  52. metadata +70 -8
@@ -0,0 +1,106 @@
1
+ (function(sinonChai) {
2
+ "use strict";
3
+
4
+ // Module systems magic dance.
5
+ if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
6
+ // NodeJS
7
+ module.exports = sinonChai;
8
+ } else if (typeof define === "function" && define.amd) {
9
+ // AMD
10
+ define(function() {
11
+ return sinonChai;
12
+ });
13
+ } else {
14
+ // Other environment (usually <script> tag): plug in to global chai instance directly.
15
+ chai.use(sinonChai);
16
+ }
17
+ }(function sinonChai(chai, utils) {
18
+ "use strict";
19
+
20
+ var slice = Array.prototype.slice;
21
+
22
+ function isSpy(putativeSpy) {
23
+ return typeof putativeSpy === "function" && typeof putativeSpy.getCall === "function" && typeof putativeSpy.calledWithExactly === "function";
24
+ }
25
+
26
+ function isCall(putativeCall) {
27
+ return putativeCall && isSpy(putativeCall.proxy);
28
+ }
29
+
30
+ function assertCanWorkWith(assertion) {
31
+ if (!isSpy(assertion._obj) && !isCall(assertion._obj)) {
32
+ throw new TypeError(utils.inspect(assertion._obj) + " is not a spy or a call to a spy!");
33
+ }
34
+ }
35
+
36
+ function getMessages(spy, action, nonNegatedSuffix, always, args) {
37
+ var verbPhrase = always ? "always have " : "have ";
38
+ nonNegatedSuffix = nonNegatedSuffix || "";
39
+ if (isSpy(spy.proxy)) {
40
+ spy = spy.proxy;
41
+ }
42
+
43
+ function printfArray(array) {
44
+ return spy.printf.apply(spy, array);
45
+ }
46
+
47
+ return {
48
+ affirmative: printfArray(["expected %n to " + verbPhrase + action + nonNegatedSuffix].concat(args)),
49
+ negative: printfArray(["expected %n to not " + verbPhrase + action].concat(args))
50
+ };
51
+ }
52
+
53
+ function sinonProperty(name, action, nonNegatedSuffix) {
54
+ utils.addProperty(chai.Assertion.prototype, name, function() {
55
+ assertCanWorkWith(this);
56
+
57
+ var messages = getMessages(this._obj, action, nonNegatedSuffix, false);
58
+ this.assert(this._obj[name], messages.affirmative, messages.negative);
59
+ });
60
+ }
61
+
62
+ function createSinonMethodHandler(sinonName, action, nonNegatedSuffix) {
63
+ return function() {
64
+ assertCanWorkWith(this);
65
+
66
+ var alwaysSinonMethod = "always" + sinonName[0].toUpperCase() + sinonName.substring(1);
67
+ var shouldBeAlways = utils.flag(this, "always") && typeof this._obj[alwaysSinonMethod] === "function";
68
+ var sinonMethod = shouldBeAlways ? alwaysSinonMethod : sinonName;
69
+
70
+ var messages = getMessages(this._obj, action, nonNegatedSuffix, shouldBeAlways, slice.call(arguments));
71
+ this.assert(this._obj[sinonMethod].apply(this._obj, arguments), messages.affirmative, messages.negative);
72
+ };
73
+ }
74
+
75
+ function sinonMethodAsProperty(name, action, nonNegatedSuffix) {
76
+ var handler = createSinonMethodHandler(name, action, nonNegatedSuffix);
77
+ utils.addProperty(chai.Assertion.prototype, name, handler);
78
+ }
79
+
80
+ function exceptionalSinonMethod(chaiName, sinonName, action, nonNegatedSuffix) {
81
+ var handler = createSinonMethodHandler(sinonName, action, nonNegatedSuffix);
82
+ utils.addMethod(chai.Assertion.prototype, chaiName, handler);
83
+ }
84
+
85
+ function sinonMethod(name, action, nonNegatedSuffix) {
86
+ exceptionalSinonMethod(name, name, action, nonNegatedSuffix);
87
+ }
88
+
89
+ utils.addProperty(chai.Assertion.prototype, "always", function() {
90
+ utils.flag(this, "always", true);
91
+ });
92
+
93
+ sinonProperty("called", "been called", " at least once, but it was never called");
94
+ sinonProperty("calledOnce", "been called exactly once", ", but it was called %c%C");
95
+ sinonProperty("calledTwice", "been called exactly twice", ", but it was called %c%C");
96
+ sinonProperty("calledThrice", "been called exactly thrice", ", but it was called %c%C");
97
+ sinonMethodAsProperty("calledWithNew", "been called with new");
98
+ sinonMethod("calledBefore", "been called before %1");
99
+ sinonMethod("calledAfter", "been called after %1");
100
+ sinonMethod("calledOn", "been called with %1 as this", ", but it was called with %t instead");
101
+ sinonMethod("calledWith", "been called with arguments %*", "%C");
102
+ sinonMethod("calledWithExactly", "been called with exact arguments %*", "%C");
103
+ sinonMethod("calledWithMatch", "been called with arguments matching %*", "%C");
104
+ sinonMethod("returned", "returned %1");
105
+ exceptionalSinonMethod("thrown", "threw", "thrown %1");
106
+ }));