exercism-analysis 0.1.1

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 (579) hide show
  1. checksums.yaml +7 -0
  2. data/exercism-analysis.gemspec +30 -0
  3. data/lib/exercism-analysis.rb +38 -0
  4. data/lib/exercism-analysis/adapters/adapter.rb +23 -0
  5. data/lib/exercism-analysis/adapters/clojure.rb +13 -0
  6. data/lib/exercism-analysis/adapters/go.rb +19 -0
  7. data/lib/exercism-analysis/adapters/javascript.rb +13 -0
  8. data/lib/exercism-analysis/adapters/python.rb +13 -0
  9. data/lib/exercism-analysis/adapters/ruby.rb +19 -0
  10. data/lib/exercism-analysis/analysis.rb +18 -0
  11. data/lib/exercism-analysis/analyzers/analyzer.rb +54 -0
  12. data/lib/exercism-analysis/analyzers/clojure/kibit.rb +25 -0
  13. data/lib/exercism-analysis/analyzers/go/golint.rb +23 -0
  14. data/lib/exercism-analysis/analyzers/javascript/jslint.rb +24 -0
  15. data/lib/exercism-analysis/analyzers/python/pylint.rb +24 -0
  16. data/lib/exercism-analysis/analyzers/ruby/control_flow.rb +21 -0
  17. data/lib/exercism-analysis/analyzers/ruby/enumerable_condition.rb +21 -0
  18. data/lib/exercism-analysis/analyzers/ruby/for_loop.rb +29 -0
  19. data/lib/exercism-analysis/analyzers/ruby/indentation.rb +21 -0
  20. data/lib/exercism-analysis/analyzers/ruby/iter_mutation.rb +37 -0
  21. data/lib/exercism-analysis/analyzers/ruby/output.rb +20 -0
  22. data/lib/exercism-analysis/analyzers/ruby/range.rb +28 -0
  23. data/lib/exercism-analysis/analyzers/ruby/roodi.rb +19 -0
  24. data/lib/exercism-analysis/analyzers/ruby/send.rb +25 -0
  25. data/lib/exercism-analysis/analyzers/ruby/shebang.rb +23 -0
  26. data/lib/exercism-analysis/analyzers/ruby/tab.rb +38 -0
  27. data/lib/exercism-analysis/processors/call_processor.rb +39 -0
  28. data/lib/exercism-analysis/processors/control_flow_processor.rb +27 -0
  29. data/lib/exercism-analysis/processors/enumerable_condition_processor.rb +31 -0
  30. data/lib/exercism-analysis/processors/for_loop_processor.rb +21 -0
  31. data/lib/exercism-analysis/processors/indentation_processor.rb +69 -0
  32. data/lib/exercism-analysis/processors/iter_mutation_processor.rb +50 -0
  33. data/lib/exercism-analysis/processors/processor.rb +34 -0
  34. data/lib/exercism-analysis/processors/range_processor.rb +23 -0
  35. data/lib/exercism-analysis/processors/send_processor.rb +23 -0
  36. data/lib/exercism-analysis/templates/each_to_map.rb +29 -0
  37. data/lib/exercism-analysis/templates/each_to_select.rb +31 -0
  38. data/lib/exercism-analysis/templates/range_exclusive.rb +19 -0
  39. data/lib/exercism-analysis/templates/template.rb +29 -0
  40. data/vendor/clojure/kibit-runner/LICENSE +214 -0
  41. data/vendor/clojure/kibit-runner/project.clj +10 -0
  42. data/vendor/clojure/kibit-runner/src/kibit_runner/core.clj +17 -0
  43. data/vendor/clojure/kibit-runner/target/kibit-runner-0.1.0-SNAPSHOT-standalone.jar +0 -0
  44. data/vendor/clojure/kibit-runner/target/kibit-runner-0.1.0-SNAPSHOT.jar +0 -0
  45. data/vendor/clojure/kibit-runner/target/stale/extract-native.dependencies +1 -0
  46. data/vendor/go/src/github.com/golang/lint/LICENSE +27 -0
  47. data/vendor/go/src/github.com/golang/lint/README +59 -0
  48. data/vendor/go/src/github.com/golang/lint/golint/golint.go +67 -0
  49. data/vendor/go/src/github.com/golang/lint/lint.go +1061 -0
  50. data/vendor/go/src/runner/golint_runner.go +23 -0
  51. data/vendor/javascript/jshint_runner.js +6 -0
  52. data/vendor/javascript/node_modules/jshint/README.md +47 -0
  53. data/vendor/javascript/node_modules/jshint/bin/apply +6 -0
  54. data/vendor/javascript/node_modules/jshint/bin/build +36 -0
  55. data/vendor/javascript/node_modules/jshint/bin/changelog +36 -0
  56. data/vendor/javascript/node_modules/jshint/bin/jshint +3 -0
  57. data/vendor/javascript/node_modules/jshint/bin/land +34 -0
  58. data/vendor/javascript/node_modules/jshint/data/ascii-identifier-data.js +22 -0
  59. data/vendor/javascript/node_modules/jshint/data/non-ascii-identifier-part-only.js +1570 -0
  60. data/vendor/javascript/node_modules/jshint/data/non-ascii-identifier-start.js +48477 -0
  61. data/vendor/javascript/node_modules/jshint/dist/jshint-rhino.js +60642 -0
  62. data/vendor/javascript/node_modules/jshint/dist/jshint.js +60525 -0
  63. data/vendor/javascript/node_modules/jshint/node_modules/cli/README.md +196 -0
  64. data/vendor/javascript/node_modules/jshint/node_modules/cli/cli.js +1139 -0
  65. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/cat.js +17 -0
  66. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/command.js +16 -0
  67. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/echo.js +54 -0
  68. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/glob.js +6 -0
  69. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/long_desc.js +20 -0
  70. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/progress.js +11 -0
  71. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/sort.js +18 -0
  72. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/spinner.js +9 -0
  73. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/static.coffee +27 -0
  74. data/vendor/javascript/node_modules/jshint/node_modules/cli/examples/static.js +25 -0
  75. data/vendor/javascript/node_modules/jshint/node_modules/cli/index.js +1 -0
  76. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/LICENSE +27 -0
  77. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/README.md +250 -0
  78. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/examples/g.js +9 -0
  79. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/examples/usr-local.js +9 -0
  80. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/glob.js +728 -0
  81. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/LICENSE +16 -0
  82. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/README.md +42 -0
  83. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/inherits.js +1 -0
  84. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
  85. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/package.json +51 -0
  86. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/node_modules/inherits/test.js +25 -0
  87. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/package.json +58 -0
  88. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/00-setup.js +176 -0
  89. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/bash-comparison.js +63 -0
  90. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/bash-results.json +351 -0
  91. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/cwd-test.js +55 -0
  92. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/globstar-match.js +19 -0
  93. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/mark.js +118 -0
  94. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/new-glob-optional-options.js +10 -0
  95. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/nocase-nomagic.js +113 -0
  96. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/pause-resume.js +73 -0
  97. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/readme-issue.js +36 -0
  98. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/root-nomount.js +39 -0
  99. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/root.js +46 -0
  100. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/stat.js +32 -0
  101. data/vendor/javascript/node_modules/jshint/node_modules/cli/node_modules/glob/test/zz-cleanup.js +11 -0
  102. data/vendor/javascript/node_modules/jshint/node_modules/cli/package.json +70 -0
  103. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/LICENCE +19 -0
  104. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/README.md +33 -0
  105. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/index.js +86 -0
  106. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/LICENCE +19 -0
  107. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/README.md +45 -0
  108. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/index.js +5 -0
  109. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/package.json +89 -0
  110. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/seed.js +16 -0
  111. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/test/index.js +28 -0
  112. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/node_modules/date-now/test/static/index.html +10 -0
  113. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/package.json +88 -0
  114. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/test/index.js +67 -0
  115. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/test/static/index.html +12 -0
  116. data/vendor/javascript/node_modules/jshint/node_modules/console-browserify/test/static/test-adapter.js +53 -0
  117. data/vendor/javascript/node_modules/jshint/node_modules/exit/Gruntfile.js +48 -0
  118. data/vendor/javascript/node_modules/jshint/node_modules/exit/LICENSE-MIT +22 -0
  119. data/vendor/javascript/node_modules/jshint/node_modules/exit/README.md +75 -0
  120. data/vendor/javascript/node_modules/jshint/node_modules/exit/lib/exit.js +41 -0
  121. data/vendor/javascript/node_modules/jshint/node_modules/exit/package.json +69 -0
  122. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/exit_test.js +121 -0
  123. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/10-stderr.txt +10 -0
  124. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/10-stdout-stderr.txt +20 -0
  125. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/10-stdout.txt +10 -0
  126. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/100-stderr.txt +100 -0
  127. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/100-stdout-stderr.txt +200 -0
  128. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/100-stdout.txt +100 -0
  129. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/1000-stderr.txt +1000 -0
  130. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/1000-stdout-stderr.txt +2000 -0
  131. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/1000-stdout.txt +1000 -0
  132. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/create-files.sh +8 -0
  133. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/log-broken.js +23 -0
  134. data/vendor/javascript/node_modules/jshint/node_modules/exit/test/fixtures/log.js +25 -0
  135. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/LICENSE +18 -0
  136. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/README.md +83 -0
  137. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/CollectingHandler.js +55 -0
  138. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/FeedHandler.js +95 -0
  139. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/Parser.js +337 -0
  140. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/ProxyHandler.js +27 -0
  141. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/Stream.js +35 -0
  142. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/Tokenizer.js +891 -0
  143. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/WritableStream.js +21 -0
  144. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/lib/index.js +68 -0
  145. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/LICENSE +11 -0
  146. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/index.js +14 -0
  147. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/package.json +40 -0
  148. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domelementtype/readme.md +1 -0
  149. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/LICENSE +11 -0
  150. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/index.js +211 -0
  151. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/package.json +68 -0
  152. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/readme.md +102 -0
  153. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/01-basic.json +57 -0
  154. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/02-single_tag_1.json +21 -0
  155. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/03-single_tag_2.json +21 -0
  156. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/04-unescaped_in_script.json +27 -0
  157. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/05-tags_in_comment.json +18 -0
  158. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/06-comment_in_script.json +18 -0
  159. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/07-unescaped_in_style.json +20 -0
  160. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/08-extra_spaces_in_tag.json +20 -0
  161. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/09-unquoted_attrib.json +20 -0
  162. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/10-singular_attribute.json +15 -0
  163. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/11-text_outside_tags.json +40 -0
  164. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/12-text_only.json +11 -0
  165. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/13-comment_in_text.json +19 -0
  166. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/14-comment_in_text_in_script.json +18 -0
  167. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/15-non-verbose.json +22 -0
  168. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/16-normalize_whitespace.json +47 -0
  169. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/17-xml_namespace.json +18 -0
  170. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/18-enforce_empty_tags.json +16 -0
  171. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/19-ignore_empty_tags.json +20 -0
  172. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/20-template_script_tags.json +20 -0
  173. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/21-conditional_comments.json +15 -0
  174. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/22-lowercase_tags.json +41 -0
  175. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/cases/23-dom-lvl1.json +121 -0
  176. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domhandler/test/tests.js +58 -0
  177. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/LICENSE +11 -0
  178. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/index.js +14 -0
  179. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/helpers.js +141 -0
  180. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/legacy.js +87 -0
  181. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/manipulation.js +77 -0
  182. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/querying.js +94 -0
  183. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/stringify.js +93 -0
  184. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/lib/traversal.js +24 -0
  185. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/package.json +71 -0
  186. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/readme.md +1 -0
  187. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/fixture.js +6 -0
  188. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/tests/helpers.js +89 -0
  189. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/tests/legacy.js +119 -0
  190. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/domutils/test/utils.js +9 -0
  191. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/LICENSE +11 -0
  192. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/index.js +31 -0
  193. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/lib/decode.js +72 -0
  194. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/lib/decode_codepoint.js +26 -0
  195. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/lib/encode.js +48 -0
  196. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/decode.json +1 -0
  197. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/entities.json +1 -0
  198. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/legacy.json +1 -0
  199. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/maps/xml.json +1 -0
  200. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/package.json +79 -0
  201. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/readme.md +31 -0
  202. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/test/mocha.opts +2 -0
  203. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/entities/test/test.js +150 -0
  204. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/LICENSE +18 -0
  205. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/README.md +15 -0
  206. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/duplex.js +1 -0
  207. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/float.patch +923 -0
  208. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_duplex.js +89 -0
  209. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_passthrough.js +46 -0
  210. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_readable.js +944 -0
  211. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_transform.js +209 -0
  212. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/lib/_stream_writable.js +472 -0
  213. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/README.md +3 -0
  214. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/float.patch +604 -0
  215. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/lib/util.js +107 -0
  216. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/package.json +53 -0
  217. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/core-util-is/util.js +106 -0
  218. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/LICENSE +16 -0
  219. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/README.md +42 -0
  220. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/inherits.js +1 -0
  221. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/inherits_browser.js +23 -0
  222. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/package.json +51 -0
  223. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/inherits/test.js +25 -0
  224. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/README.md +54 -0
  225. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/build/build.js +209 -0
  226. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/component.json +19 -0
  227. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/index.js +3 -0
  228. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/isarray/package.json +54 -0
  229. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/LICENSE +20 -0
  230. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/README.md +7 -0
  231. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/index.js +200 -0
  232. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/node_modules/string_decoder/package.json +53 -0
  233. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/package.json +68 -0
  234. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/passthrough.js +1 -0
  235. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/readable.js +7 -0
  236. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/transform.js +1 -0
  237. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/node_modules/readable-stream/writable.js +1 -0
  238. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/package.json +90 -0
  239. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/01-events.js +9 -0
  240. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/02-stream.js +23 -0
  241. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/03-feed.js +19 -0
  242. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/Atom_Example.xml +25 -0
  243. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/Attributes.html +16 -0
  244. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/Basic.html +1 -0
  245. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/RDF_Example.xml +63 -0
  246. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Documents/RSS_Example.xml +48 -0
  247. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/01-simple.json +44 -0
  248. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/02-template.json +63 -0
  249. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/03-lowercase_tags.json +46 -0
  250. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/04-cdata.json +50 -0
  251. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/05-cdata-special.json +35 -0
  252. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/06-leading-lt.json +16 -0
  253. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/07-self-closing.json +67 -0
  254. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/08-implicit-close-tags.json +59 -0
  255. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/09-attributes.json +68 -0
  256. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/10-crazy-attrib.json +52 -0
  257. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/11-script_in_script.json +54 -0
  258. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/12-long-comment-end.json +20 -0
  259. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/13-long-cdata-end.json +22 -0
  260. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/14-implicit-open-tags.json +27 -0
  261. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/15-lt-whitespace.json +16 -0
  262. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/16-double_attribs.json +45 -0
  263. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/17-numeric_entities.json +16 -0
  264. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/18-legacy_entities.json +16 -0
  265. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/19-named_entities.json +16 -0
  266. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/20-xml_entities.json +16 -0
  267. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/21-entity_in_attribute.json +38 -0
  268. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/22-double_brackets.json +41 -0
  269. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/23-legacy_entity_fail.json +16 -0
  270. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/24-special_special.json +133 -0
  271. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/25-empty_tag_name.json +13 -0
  272. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/26-not-quite-closed.json +35 -0
  273. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/27-entities_in_attributes.json +62 -0
  274. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/28-cdata_in_html.json +9 -0
  275. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/29-comment_edge-cases.json +18 -0
  276. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Events/30-cdata_edge-cases.json +22 -0
  277. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Feeds/01-rss.js +34 -0
  278. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Feeds/02-atom.js +18 -0
  279. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Feeds/03-rdf.js +20 -0
  280. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/01-basic.json +83 -0
  281. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/02-RSS.json +1093 -0
  282. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/03-Atom.json +644 -0
  283. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/04-RDF.json +1399 -0
  284. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/Stream/05-Attributes.json +354 -0
  285. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/api.js +63 -0
  286. data/vendor/javascript/node_modules/jshint/node_modules/htmlparser2/test/test-helper.js +83 -0
  287. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/LICENSE +23 -0
  288. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/README.md +218 -0
  289. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/minimatch.js +1061 -0
  290. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS +14 -0
  291. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/LICENSE +23 -0
  292. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/README.md +97 -0
  293. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +252 -0
  294. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/package.json +50 -0
  295. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/test/basic.js +369 -0
  296. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/test/foreach.js +52 -0
  297. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js +50 -0
  298. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/LICENSE +27 -0
  299. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/README.md +53 -0
  300. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/bench.js +283 -0
  301. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/package.json +58 -0
  302. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/sigmund.js +39 -0
  303. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/node_modules/sigmund/test/basic.js +24 -0
  304. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/package.json +57 -0
  305. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/basic.js +399 -0
  306. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/brace-expand.js +33 -0
  307. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/caching.js +14 -0
  308. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/defaults.js +274 -0
  309. data/vendor/javascript/node_modules/jshint/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
  310. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/LICENSE +26 -0
  311. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/README.md +569 -0
  312. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/bin/shjs +51 -0
  313. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/global.js +3 -0
  314. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/make.js +47 -0
  315. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/package.json +61 -0
  316. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/scripts/generate-docs.js +21 -0
  317. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/scripts/run-tests.js +50 -0
  318. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/shell.js +157 -0
  319. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/cat.js +43 -0
  320. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/cd.js +19 -0
  321. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/chmod.js +208 -0
  322. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/common.js +203 -0
  323. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/cp.js +201 -0
  324. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/dirs.js +191 -0
  325. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/echo.js +20 -0
  326. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/error.js +10 -0
  327. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/exec.js +181 -0
  328. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/find.js +51 -0
  329. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/grep.js +52 -0
  330. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/ln.js +53 -0
  331. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/ls.js +126 -0
  332. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/mkdir.js +68 -0
  333. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/mv.js +80 -0
  334. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/popd.js +1 -0
  335. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/pushd.js +1 -0
  336. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/pwd.js +11 -0
  337. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/rm.js +145 -0
  338. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/sed.js +43 -0
  339. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/tempdir.js +56 -0
  340. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/test.js +85 -0
  341. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/to.js +29 -0
  342. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/toEnd.js +29 -0
  343. data/vendor/javascript/node_modules/jshint/node_modules/shelljs/src/which.js +83 -0
  344. data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/cli.js +41 -0
  345. data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/package.json +76 -0
  346. data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/readme.md +74 -0
  347. data/vendor/javascript/node_modules/jshint/node_modules/strip-json-comments/strip-json-comments.js +64 -0
  348. data/vendor/javascript/node_modules/jshint/node_modules/underscore/LICENSE +23 -0
  349. data/vendor/javascript/node_modules/jshint/node_modules/underscore/README.md +22 -0
  350. data/vendor/javascript/node_modules/jshint/node_modules/underscore/package.json +66 -0
  351. data/vendor/javascript/node_modules/jshint/node_modules/underscore/underscore-min.js +6 -0
  352. data/vendor/javascript/node_modules/jshint/node_modules/underscore/underscore.js +1343 -0
  353. data/vendor/javascript/node_modules/jshint/package.json +80 -0
  354. data/vendor/javascript/node_modules/jshint/src/cli.js +731 -0
  355. data/vendor/javascript/node_modules/jshint/src/jshint.js +5023 -0
  356. data/vendor/javascript/node_modules/jshint/src/lex.js +1650 -0
  357. data/vendor/javascript/node_modules/jshint/src/messages.js +223 -0
  358. data/vendor/javascript/node_modules/jshint/src/platforms/rhino.js +115 -0
  359. data/vendor/javascript/node_modules/jshint/src/reg.js +38 -0
  360. data/vendor/javascript/node_modules/jshint/src/reporters/checkstyle.js +81 -0
  361. data/vendor/javascript/node_modules/jshint/src/reporters/default.js +34 -0
  362. data/vendor/javascript/node_modules/jshint/src/reporters/jslint_xml.js +57 -0
  363. data/vendor/javascript/node_modules/jshint/src/reporters/non_error.js +52 -0
  364. data/vendor/javascript/node_modules/jshint/src/state.js +28 -0
  365. data/vendor/javascript/node_modules/jshint/src/style.js +143 -0
  366. data/vendor/javascript/node_modules/jshint/src/vars.js +658 -0
  367. data/vendor/python/astroid/COPYING +339 -0
  368. data/vendor/python/astroid/COPYING.LESSER +510 -0
  369. data/vendor/python/astroid/ChangeLog +574 -0
  370. data/vendor/python/astroid/MANIFEST.in +9 -0
  371. data/vendor/python/astroid/README +56 -0
  372. data/vendor/python/astroid/README.Python3 +26 -0
  373. data/vendor/python/astroid/__init__.py +118 -0
  374. data/vendor/python/astroid/__init__.pyc +0 -0
  375. data/vendor/python/astroid/__pkginfo__.py +48 -0
  376. data/vendor/python/astroid/__pkginfo__.pyc +0 -0
  377. data/vendor/python/astroid/announce.txt +23 -0
  378. data/vendor/python/astroid/as_string.py +496 -0
  379. data/vendor/python/astroid/as_string.pyc +0 -0
  380. data/vendor/python/astroid/bases.py +618 -0
  381. data/vendor/python/astroid/bases.pyc +0 -0
  382. data/vendor/python/astroid/brain/py2gi.py +159 -0
  383. data/vendor/python/astroid/brain/py2gi.pyc +0 -0
  384. data/vendor/python/astroid/brain/py2mechanize.py +20 -0
  385. data/vendor/python/astroid/brain/py2mechanize.pyc +0 -0
  386. data/vendor/python/astroid/brain/py2qt4.py +25 -0
  387. data/vendor/python/astroid/brain/py2qt4.pyc +0 -0
  388. data/vendor/python/astroid/brain/py2stdlib.py +252 -0
  389. data/vendor/python/astroid/brain/py2stdlib.pyc +0 -0
  390. data/vendor/python/astroid/builder.py +238 -0
  391. data/vendor/python/astroid/builder.pyc +0 -0
  392. data/vendor/python/astroid/exceptions.py +51 -0
  393. data/vendor/python/astroid/exceptions.pyc +0 -0
  394. data/vendor/python/astroid/inference.py +393 -0
  395. data/vendor/python/astroid/inference.pyc +0 -0
  396. data/vendor/python/astroid/inspector.py +275 -0
  397. data/vendor/python/astroid/manager.py +336 -0
  398. data/vendor/python/astroid/manager.pyc +0 -0
  399. data/vendor/python/astroid/mixins.py +122 -0
  400. data/vendor/python/astroid/mixins.pyc +0 -0
  401. data/vendor/python/astroid/node_classes.py +928 -0
  402. data/vendor/python/astroid/node_classes.pyc +0 -0
  403. data/vendor/python/astroid/nodes.py +73 -0
  404. data/vendor/python/astroid/nodes.pyc +0 -0
  405. data/vendor/python/astroid/protocols.py +322 -0
  406. data/vendor/python/astroid/protocols.pyc +0 -0
  407. data/vendor/python/astroid/raw_building.py +361 -0
  408. data/vendor/python/astroid/raw_building.pyc +0 -0
  409. data/vendor/python/astroid/rebuilder.py +954 -0
  410. data/vendor/python/astroid/rebuilder.pyc +0 -0
  411. data/vendor/python/astroid/scoped_nodes.py +1118 -0
  412. data/vendor/python/astroid/scoped_nodes.pyc +0 -0
  413. data/vendor/python/astroid/setup.py +184 -0
  414. data/vendor/python/astroid/tox.ini +10 -0
  415. data/vendor/python/astroid/utils.py +236 -0
  416. data/vendor/python/astroid/utils.pyc +0 -0
  417. data/vendor/python/logilab/__init__.py +0 -0
  418. data/vendor/python/logilab/__init__.pyc +0 -0
  419. data/vendor/python/logilab/common/COPYING +339 -0
  420. data/vendor/python/logilab/common/COPYING.LESSER +510 -0
  421. data/vendor/python/logilab/common/ChangeLog +1517 -0
  422. data/vendor/python/logilab/common/MANIFEST.in +13 -0
  423. data/vendor/python/logilab/common/README +185 -0
  424. data/vendor/python/logilab/common/README.Python3 +29 -0
  425. data/vendor/python/logilab/common/__init__.py +171 -0
  426. data/vendor/python/logilab/common/__init__.pyc +0 -0
  427. data/vendor/python/logilab/common/__pkginfo__.py +53 -0
  428. data/vendor/python/logilab/common/__pkginfo__.pyc +0 -0
  429. data/vendor/python/logilab/common/announce.txt +25 -0
  430. data/vendor/python/logilab/common/bin/pytest +7 -0
  431. data/vendor/python/logilab/common/bin/pytest.bat +17 -0
  432. data/vendor/python/logilab/common/cache.py +114 -0
  433. data/vendor/python/logilab/common/changelog.py +236 -0
  434. data/vendor/python/logilab/common/changelog.pyc +0 -0
  435. data/vendor/python/logilab/common/clcommands.py +332 -0
  436. data/vendor/python/logilab/common/cli.py +208 -0
  437. data/vendor/python/logilab/common/compat.py +243 -0
  438. data/vendor/python/logilab/common/compat.pyc +0 -0
  439. data/vendor/python/logilab/common/configuration.py +1094 -0
  440. data/vendor/python/logilab/common/configuration.pyc +0 -0
  441. data/vendor/python/logilab/common/contexts.py +5 -0
  442. data/vendor/python/logilab/common/corbautils.py +117 -0
  443. data/vendor/python/logilab/common/daemon.py +100 -0
  444. data/vendor/python/logilab/common/date.py +333 -0
  445. data/vendor/python/logilab/common/dbf.py +229 -0
  446. data/vendor/python/logilab/common/debugger.py +210 -0
  447. data/vendor/python/logilab/common/decorators.py +281 -0
  448. data/vendor/python/logilab/common/decorators.pyc +0 -0
  449. data/vendor/python/logilab/common/deprecation.py +188 -0
  450. data/vendor/python/logilab/common/deprecation.pyc +0 -0
  451. data/vendor/python/logilab/common/fileutils.py +402 -0
  452. data/vendor/python/logilab/common/graph.py +276 -0
  453. data/vendor/python/logilab/common/graph.pyc +0 -0
  454. data/vendor/python/logilab/common/hg.py +130 -0
  455. data/vendor/python/logilab/common/interface.py +71 -0
  456. data/vendor/python/logilab/common/interface.pyc +0 -0
  457. data/vendor/python/logilab/common/logging_ext.py +193 -0
  458. data/vendor/python/logilab/common/modutils.py +695 -0
  459. data/vendor/python/logilab/common/modutils.pyc +0 -0
  460. data/vendor/python/logilab/common/optik_ext.py +391 -0
  461. data/vendor/python/logilab/common/optik_ext.pyc +0 -0
  462. data/vendor/python/logilab/common/optparser.py +90 -0
  463. data/vendor/python/logilab/common/proc.py +277 -0
  464. data/vendor/python/logilab/common/pyro_ext.py +180 -0
  465. data/vendor/python/logilab/common/pytest.py +1177 -0
  466. data/vendor/python/logilab/common/python-logilab-common.spec +184 -0
  467. data/vendor/python/logilab/common/registry.py +1113 -0
  468. data/vendor/python/logilab/common/setup.cfg +3 -0
  469. data/vendor/python/logilab/common/setup.py +189 -0
  470. data/vendor/python/logilab/common/shellutils.py +455 -0
  471. data/vendor/python/logilab/common/sphinx_ext.py +87 -0
  472. data/vendor/python/logilab/common/sphinxutils.py +122 -0
  473. data/vendor/python/logilab/common/table.py +925 -0
  474. data/vendor/python/logilab/common/tasksqueue.py +100 -0
  475. data/vendor/python/logilab/common/textutils.py +534 -0
  476. data/vendor/python/logilab/common/textutils.pyc +0 -0
  477. data/vendor/python/logilab/common/tree.py +369 -0
  478. data/vendor/python/logilab/common/tree.pyc +0 -0
  479. data/vendor/python/logilab/common/umessage.py +190 -0
  480. data/vendor/python/logilab/common/ureports/__init__.py +174 -0
  481. data/vendor/python/logilab/common/ureports/__init__.pyc +0 -0
  482. data/vendor/python/logilab/common/ureports/docbook_writer.py +139 -0
  483. data/vendor/python/logilab/common/ureports/html_writer.py +131 -0
  484. data/vendor/python/logilab/common/ureports/html_writer.pyc +0 -0
  485. data/vendor/python/logilab/common/ureports/nodes.py +201 -0
  486. data/vendor/python/logilab/common/ureports/nodes.pyc +0 -0
  487. data/vendor/python/logilab/common/ureports/text_writer.py +140 -0
  488. data/vendor/python/logilab/common/ureports/text_writer.pyc +0 -0
  489. data/vendor/python/logilab/common/urllib2ext.py +87 -0
  490. data/vendor/python/logilab/common/vcgutils.py +216 -0
  491. data/vendor/python/logilab/common/visitor.py +107 -0
  492. data/vendor/python/logilab/common/visitor.pyc +0 -0
  493. data/vendor/python/logilab/common/xmlrpcutils.py +131 -0
  494. data/vendor/python/logilab/common/xmlutils.py +61 -0
  495. data/vendor/python/pylint/CONTRIBUTORS.txt +38 -0
  496. data/vendor/python/pylint/COPYING +340 -0
  497. data/vendor/python/pylint/ChangeLog +1437 -0
  498. data/vendor/python/pylint/DEPENDS +3 -0
  499. data/vendor/python/pylint/MANIFEST.in +14 -0
  500. data/vendor/python/pylint/README +50 -0
  501. data/vendor/python/pylint/README.Python3 +37 -0
  502. data/vendor/python/pylint/__init__.py +44 -0
  503. data/vendor/python/pylint/__init__.pyc +0 -0
  504. data/vendor/python/pylint/__main__.py +3 -0
  505. data/vendor/python/pylint/__pkginfo__.py +74 -0
  506. data/vendor/python/pylint/__pkginfo__.pyc +0 -0
  507. data/vendor/python/pylint/bin/epylint +3 -0
  508. data/vendor/python/pylint/bin/epylint.bat +5 -0
  509. data/vendor/python/pylint/bin/pylint +3 -0
  510. data/vendor/python/pylint/bin/pylint-gui +3 -0
  511. data/vendor/python/pylint/bin/pylint-gui.bat +5 -0
  512. data/vendor/python/pylint/bin/pylint.bat +5 -0
  513. data/vendor/python/pylint/bin/pyreverse +3 -0
  514. data/vendor/python/pylint/bin/pyreverse.bat +5 -0
  515. data/vendor/python/pylint/bin/symilar +3 -0
  516. data/vendor/python/pylint/bin/symilar.bat +5 -0
  517. data/vendor/python/pylint/checkers/__init__.py +145 -0
  518. data/vendor/python/pylint/checkers/__init__.pyc +0 -0
  519. data/vendor/python/pylint/checkers/base.py +1141 -0
  520. data/vendor/python/pylint/checkers/base.pyc +0 -0
  521. data/vendor/python/pylint/checkers/classes.py +792 -0
  522. data/vendor/python/pylint/checkers/classes.pyc +0 -0
  523. data/vendor/python/pylint/checkers/design_analysis.py +367 -0
  524. data/vendor/python/pylint/checkers/design_analysis.pyc +0 -0
  525. data/vendor/python/pylint/checkers/exceptions.py +306 -0
  526. data/vendor/python/pylint/checkers/exceptions.pyc +0 -0
  527. data/vendor/python/pylint/checkers/format.py +943 -0
  528. data/vendor/python/pylint/checkers/format.pyc +0 -0
  529. data/vendor/python/pylint/checkers/imports.py +394 -0
  530. data/vendor/python/pylint/checkers/imports.pyc +0 -0
  531. data/vendor/python/pylint/checkers/logging.py +213 -0
  532. data/vendor/python/pylint/checkers/logging.pyc +0 -0
  533. data/vendor/python/pylint/checkers/misc.py +90 -0
  534. data/vendor/python/pylint/checkers/misc.pyc +0 -0
  535. data/vendor/python/pylint/checkers/newstyle.py +151 -0
  536. data/vendor/python/pylint/checkers/newstyle.pyc +0 -0
  537. data/vendor/python/pylint/checkers/raw_metrics.py +129 -0
  538. data/vendor/python/pylint/checkers/raw_metrics.pyc +0 -0
  539. data/vendor/python/pylint/checkers/similar.py +365 -0
  540. data/vendor/python/pylint/checkers/similar.pyc +0 -0
  541. data/vendor/python/pylint/checkers/stdlib.py +69 -0
  542. data/vendor/python/pylint/checkers/stdlib.pyc +0 -0
  543. data/vendor/python/pylint/checkers/strings.py +304 -0
  544. data/vendor/python/pylint/checkers/strings.pyc +0 -0
  545. data/vendor/python/pylint/checkers/typecheck.py +451 -0
  546. data/vendor/python/pylint/checkers/typecheck.pyc +0 -0
  547. data/vendor/python/pylint/checkers/utils.py +416 -0
  548. data/vendor/python/pylint/checkers/utils.pyc +0 -0
  549. data/vendor/python/pylint/checkers/variables.py +741 -0
  550. data/vendor/python/pylint/checkers/variables.pyc +0 -0
  551. data/vendor/python/pylint/config.py +156 -0
  552. data/vendor/python/pylint/config.pyc +0 -0
  553. data/vendor/python/pylint/epylint.py +175 -0
  554. data/vendor/python/pylint/gui.py +508 -0
  555. data/vendor/python/pylint/interfaces.py +72 -0
  556. data/vendor/python/pylint/interfaces.pyc +0 -0
  557. data/vendor/python/pylint/lint.py +1106 -0
  558. data/vendor/python/pylint/lint.pyc +0 -0
  559. data/vendor/python/pylint/pyreverse/__init__.py +5 -0
  560. data/vendor/python/pylint/pyreverse/diadefslib.py +233 -0
  561. data/vendor/python/pylint/pyreverse/diagrams.py +247 -0
  562. data/vendor/python/pylint/pyreverse/main.py +124 -0
  563. data/vendor/python/pylint/pyreverse/utils.py +131 -0
  564. data/vendor/python/pylint/pyreverse/writer.py +199 -0
  565. data/vendor/python/pylint/reporters/__init__.py +138 -0
  566. data/vendor/python/pylint/reporters/__init__.pyc +0 -0
  567. data/vendor/python/pylint/reporters/guireporter.py +28 -0
  568. data/vendor/python/pylint/reporters/guireporter.pyc +0 -0
  569. data/vendor/python/pylint/reporters/html.py +70 -0
  570. data/vendor/python/pylint/reporters/html.pyc +0 -0
  571. data/vendor/python/pylint/reporters/text.py +143 -0
  572. data/vendor/python/pylint/reporters/text.pyc +0 -0
  573. data/vendor/python/pylint/setup.cfg +3 -0
  574. data/vendor/python/pylint/setup.py +203 -0
  575. data/vendor/python/pylint/tox.ini +10 -0
  576. data/vendor/python/pylint/utils.py +744 -0
  577. data/vendor/python/pylint/utils.pyc +0 -0
  578. data/vendor/python/pylint_runner.py +22 -0
  579. metadata +675 -0
@@ -0,0 +1,196 @@
1
+ **cli is a toolkit for rapidly building command line apps - it includes:**
2
+
3
+ - Full featured opts/args parser
4
+ - Plugin support for adding common options and switches
5
+ - Helper methods for working with input/output and spawning child processes
6
+ - Output colored/styled messages, [progress bars](https://github.com/chriso/cli/blob/master/examples/progress.js) or [spinners](https://github.com/chriso/cli/blob/master/examples/spinner.js)
7
+ - Command [auto-completion](https://github.com/chriso/cli/blob/master/examples/command.js) and [glob support](https://github.com/chriso/cli/blob/master/examples/glob.js)
8
+
9
+ Install using `npm install cli` or just bundle [cli.js](https://github.com/chriso/cli/raw/master/cli.js) with your app.
10
+
11
+ ## Example apps
12
+
13
+ ### sort.js
14
+
15
+ ```javascript
16
+ #!/usr/bin/env node
17
+ require('cli').withStdinLines(function(lines, newline) {
18
+ this.output(lines.sort().join(newline));
19
+ });
20
+ ```
21
+
22
+ Try it out
23
+
24
+ ```bash
25
+ $ ./sort.js < input.txt
26
+ ```
27
+
28
+ Let's add support for an `-n` switch to use a numeric sort, and a `-r` switch to reverse output - only 5 extra lines of code (!)
29
+
30
+ ```javascript
31
+ var cli = require('cli'), options = cli.parse();
32
+
33
+ cli.withStdinLines(function(lines, newline) {
34
+ lines.sort(!options.n ? null : function(a, b) {
35
+ return parseInt(a) > parseInt(b);
36
+ });
37
+ if (options.r) lines.reverse();
38
+ this.output(lines.join(newline));
39
+ });
40
+ ```
41
+
42
+ ### static.js
43
+
44
+ Let's create a static file server with daemon support to see the opts parser + plugins in use - note: this requires `npm install creationix daemon`
45
+
46
+ ```javascript
47
+ var cli = require('cli').enable('daemon', 'status'); //Enable 2 plugins
48
+
49
+ cli.parse({
50
+ log: ['l', 'Enable logging'],
51
+ port: ['p', 'Listen on this port', 'number', 8080],
52
+ serve: [false, 'Serve static files from PATH', 'path', './public']
53
+ });
54
+
55
+ cli.main(function(args, options) {
56
+ var server, middleware = [];
57
+
58
+ if (options.log) {
59
+ this.debug('Enabling logging');
60
+ middleware.push(require('creationix/log')());
61
+ }
62
+
63
+ this.debug('Serving files from ' + options.serve);
64
+ middleware.push(require('creationix/static')('/', options.serve, 'index.html'));
65
+
66
+ server = this.createServer(middleware).listen(options.port);
67
+
68
+ this.ok('Listening on port ' + options.port);
69
+ });
70
+ ```
71
+
72
+ To output usage information
73
+
74
+ ```bash
75
+ $ ./static.js --help
76
+ ```
77
+
78
+ To create a daemon that serves files from */tmp*, run
79
+
80
+ ```bash
81
+ $ ./static.js -ld --serve=/tmp
82
+ ```
83
+
84
+ For more examples, see [./examples](https://github.com/chriso/cli/tree/master/examples)
85
+
86
+ ## Helper methods
87
+
88
+ cli has methods that collect stdin (newline is autodetected as \n or \r\n)
89
+
90
+ ```javascript
91
+ cli.withStdin(callback); //callback receives stdin as a string
92
+ cli.withStdinLines(callback); //callback receives stdin split into an array of lines (lines, newline)
93
+ ```
94
+
95
+ cli also has a lower level method for working with input line by line (see [./examples/cat.js](https://github.com/chriso/cli/blob/master/examples/cat.js) for an example).
96
+
97
+ ```javascript
98
+ cli.withInput(file, function (line, newline, eof) {
99
+ if (!eof) {
100
+ this.output(line + newline);
101
+ }
102
+ });
103
+ ```
104
+
105
+ *Note: `file` can be omitted if you want to work with stdin*
106
+
107
+ To output a progress bar, call
108
+
109
+ ```javascript
110
+ cli.progress(progress); //Where 0 <= progress <= 1
111
+ ```
112
+
113
+ To spawn a child process, use
114
+
115
+ ```javascript
116
+ cli.exec(cmd, callback); //callback receives the output of the process (split into lines)
117
+ ```
118
+
119
+ cli also comes bundled with kof's [node-natives](https://github.com/kof/node-natives) (access with cli.native) and creationix' [stack](https://github.com/creationix/stack) (access with cli.createServer)
120
+
121
+ ## Plugins
122
+
123
+ Plugins are a way of adding common opts and can be enabled using
124
+
125
+ ```javascript
126
+ cli.enable(plugin1, [plugin2, ...]); //To disable, use the equivalent disable() method
127
+ ```
128
+
129
+ **help** - *enabled by default*
130
+
131
+ Adds `-h,--help` to output auto-generated usage information
132
+
133
+ **version**
134
+
135
+ Adds `-v,--version` to output version information for the app. cli will attempt to locate and parse a nearby *package.json*
136
+
137
+ To set your own app name and version, use `cli.setApp(app_name, version)`
138
+
139
+ **status**
140
+
141
+ Adds options to show/hide the stylized status messages that are output to the console when using one of these methods
142
+
143
+ ```javascript
144
+ cli.debug(msg); //Only shown when using --debug
145
+ cli.error(msg);
146
+ cli.fatal(msg); //Exits the process after outputting msg
147
+ cli.info(msg);
148
+ cli.ok(msg);
149
+ ```
150
+
151
+ `-k,--no-color` will omit ANSI color escapes from the output
152
+
153
+ **glob** - *requires* `npm install glob`
154
+
155
+ Enables glob matching of arguments
156
+
157
+ **daemon** - *requires* `npm install daemon`
158
+
159
+ Adds `-d,--daemon ARG` for daemonizing the process and controlling the resulting daemon
160
+
161
+ `ARG` can be either start (default), stop, restart, pid (outputs the daemon's pid if it's running), or log (output the daemon's stdout+stderr)
162
+
163
+ **timeout**
164
+
165
+ Adds `-t,--timeout N` to exit the process after N seconds with an error
166
+
167
+ **catchall**
168
+
169
+ Adds `-c,--catch` to catch and output uncaughtExceptions and resume execution
170
+
171
+ *Note: Plugins are automatically disabled if an option or switch of the same name is already defined*
172
+
173
+ ## LICENSE
174
+
175
+ (MIT license)
176
+
177
+ Copyright (c) 2010 Chris O'Hara <cohara87@gmail.com>
178
+
179
+ Permission is hereby granted, free of charge, to any person obtaining
180
+ a copy of this software and associated documentation files (the
181
+ "Software"), to deal in the Software without restriction, including
182
+ without limitation the rights to use, copy, modify, merge, publish,
183
+ distribute, sublicense, and/or sell copies of the Software, and to
184
+ permit persons to whom the Software is furnished to do so, subject to
185
+ the following conditions:
186
+
187
+ The above copyright notice and this permission notice shall be
188
+ included in all copies or substantial portions of the Software.
189
+
190
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
191
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
192
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
193
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
194
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
195
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
196
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,1139 @@
1
+ /**
2
+ * Copyright (c) 2010 Chris O'Hara <cohara87@gmail.com>
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining
5
+ * a copy of this software and associated documentation files (the
6
+ * "Software"), to deal in the Software without restriction, including
7
+ * without limitation the rights to use, copy, modify, merge, publish,
8
+ * distribute, sublicense, and/or sell copies of the Software, and to
9
+ * permit persons to whom the Software is furnished to do so, subject to
10
+ * the following conditions:
11
+ *
12
+ * The above copyright notice and this permission notice shall be
13
+ * included in all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ //Note: cli includes kof/node-natives and creationix/stack. I couldn't find
25
+ //license information for either - contact me if you want your license added
26
+
27
+ var cli = exports,
28
+ argv, curr_opt, curr_val, full_opt, is_long,
29
+ short_tags = [], opt_list, parsed = {},
30
+ usage, argv_parsed, command_list, commands,
31
+ daemon, daemon_arg, no_color, show_debug;
32
+
33
+ cli.app = null;
34
+ cli.version = null;
35
+ cli.argv = [];
36
+ cli.argc = 0;
37
+
38
+ cli.options = {};
39
+ cli.args = [];
40
+ cli.command;
41
+
42
+ cli.width = 70;
43
+ cli.option_width = 25;
44
+
45
+ /**
46
+ * Bind kof's node-natives (https://github.com/kof/node-natives) to `cli.native`
47
+ *
48
+ * Rather than requiring node natives (e.g. var fs = require('fs')), all
49
+ * native modules can be accessed like `cli.native.fs`
50
+ */
51
+ cli.native = {};
52
+ var define_native = function (module) {
53
+ Object.defineProperty(cli.native, module, {
54
+ enumerable: true,
55
+ configurable: true,
56
+ get: function() {
57
+ delete cli.native[module];
58
+ return cli.native[module] = require(module);
59
+ }
60
+ });
61
+ };
62
+ var natives = process.binding('natives');
63
+ for (var module in natives) {
64
+ define_native(module);
65
+ }
66
+
67
+ cli.output = cli.native.util.print;
68
+ cli.exit = require('exit');
69
+
70
+ /**
71
+ * Define plugins. Plugins can be enabled and disabled by calling:
72
+ *
73
+ * `cli.enable(plugin1, [plugin2, ...])`
74
+ * `cli.disable(plugin1, [plugin2, ...])`
75
+ *
76
+ * Methods are chainable - `cli.enable(plugin).disable(plugin2)`.
77
+ *
78
+ * The 'help' plugin is enabled by default.
79
+ */
80
+ var enable = {
81
+ help: true, //Adds -h, --help
82
+ version: false, //Adds -v,--version => gets version by parsing a nearby package.json
83
+ daemon: false, //Adds -d,--daemon [ARG] => (see cli.daemon() below)
84
+ status: false, //Adds -k,--no-color & --debug => display plain status messages /display debug messages
85
+ timeout: false, //Adds -t,--timeout N => timeout the process after N seconds
86
+ catchall: false, //Adds -c,--catch => catch and output uncaughtExceptions
87
+ glob: false //Adds glob matching => use cli.glob(arg)
88
+ }
89
+ cli.enable = function (/*plugins*/) {
90
+ Array.prototype.slice.call(arguments).forEach(function (plugin) {
91
+ switch (plugin) {
92
+ case 'daemon':
93
+ try {
94
+ daemon = require('daemon');
95
+ if (typeof daemon.daemonize !== 'function') {
96
+ throw 'Invalid module';
97
+ }
98
+ } catch (e) {
99
+ cli.fatal('daemon.node not installed. Please run `npm install daemon`');
100
+ }
101
+ break;
102
+ case 'catchall':
103
+ process.on('uncaughtException', function (err) {
104
+ cli.error('Uncaught exception: ' + (err.msg || err));
105
+ });
106
+ break;
107
+ case 'help': case 'version': case 'status':
108
+ case 'autocomplete': case 'timeout':
109
+ //Just add switches.
110
+ break;
111
+ case 'glob':
112
+ cli.glob = require('glob');
113
+ break;
114
+ default:
115
+ cli.fatal('Unknown plugin "' + plugin + '"');
116
+ break;
117
+ }
118
+ enable[plugin] = true;
119
+ });
120
+ return cli;
121
+ }
122
+ cli.disable = function (/*plugins*/) {
123
+ Array.prototype.slice.call(arguments).forEach(function (plugin) {
124
+ if (enable[plugin]) {
125
+ enable[plugin] = false;
126
+ }
127
+ });
128
+ return cli;
129
+ }
130
+
131
+ /**
132
+ * Sets argv (default is process.argv).
133
+ *
134
+ * @param {Array|String} argv
135
+ * @param {Boolean} keep_arg0 (optional - default is false)
136
+ * @api public
137
+ */
138
+ cli.setArgv = function (arr, keep_arg0) {
139
+ if (typeof arr == 'string') {
140
+ arr = arr.split(' ');
141
+ } else {
142
+ arr = arr.slice();
143
+ }
144
+ cli.app = arr.shift();
145
+ // Strip off argv[0] if it's a node binary
146
+ // So this is still broken and will break if you are calling node through a
147
+ // symlink, unless you are lucky enough to have it as 'node' literal. Latter
148
+ // is a hack, but resolving abspaths/symlinks is an unportable can of worms.
149
+ if (!keep_arg0 && ('node' === cli.native.path.basename(cli.app)
150
+ || cli.native.path.basename(process.execPath) === cli.app
151
+ || process.execPath === cli.app)) {
152
+ cli.app = arr.shift();
153
+ }
154
+ cli.app = cli.native.path.basename(cli.app);
155
+ argv_parsed = false;
156
+ cli.args = cli.argv = argv = arr;
157
+ cli.argc = argv.length;
158
+ cli.options = {};
159
+ cli.command = null;
160
+ };
161
+ cli.setArgv(process.argv);
162
+
163
+ /**
164
+ * Returns the next opt, or false if no opts are found.
165
+ *
166
+ * @return {String} opt
167
+ * @api public
168
+ */
169
+ cli.next = function () {
170
+ if (!argv_parsed) {
171
+ cli.args = [];
172
+ argv_parsed = true;
173
+ }
174
+
175
+ curr_val = null;
176
+
177
+ //If we're currently in a group of short opts (e.g. -abc), return the next opt
178
+ if (short_tags.length) {
179
+ curr_opt = short_tags.shift();
180
+ full_opt = '-' + curr_opt;
181
+ return curr_opt;
182
+ }
183
+
184
+ if (!argv.length) {
185
+ return false;
186
+ }
187
+
188
+ curr_opt = argv.shift();
189
+
190
+ //If an escape sequence is found (- or --), subsequent opts are ignored
191
+ if (curr_opt === '-' || curr_opt === '--') {
192
+ while (argv.length) {
193
+ cli.args.push(argv.shift());
194
+ }
195
+ return false;
196
+ }
197
+
198
+ //If the next element in argv isn't an opt, add it to the list of args
199
+ if (curr_opt[0] !== '-') {
200
+ cli.args.push(curr_opt);
201
+ return cli.next();
202
+ } else {
203
+ //Check if the opt is short/long
204
+ is_long = curr_opt[1] === '-';
205
+ curr_opt = curr_opt.substr(is_long ? 2 : 1);
206
+ }
207
+
208
+ //Accept grouped short opts, e.g. -abc => -a -b -c
209
+ if (!is_long && curr_opt.length > 1) {
210
+ short_tags = curr_opt.split('');
211
+ return cli.next();
212
+ }
213
+
214
+ var eq, len;
215
+
216
+ //Check if the long opt is in the form --option=VALUE
217
+ if (is_long && (eq = curr_opt.indexOf('=')) >= 0) {
218
+ curr_val = curr_opt.substr(eq + 1);
219
+ curr_opt = curr_opt.substr(0, eq);
220
+ len = curr_val.length;
221
+ //Allow values to be quoted
222
+ if ((curr_val[0] === '"' && curr_val[len - 1] === '"') ||
223
+ (curr_val[0] === "'" && curr_val[len - 1] === "'"))
224
+ {
225
+ curr_val = curr_val.substr(1, len-2);
226
+ }
227
+ if (curr_val.match(/^[0-9]+$/)) {
228
+ curr_val = parseInt(curr_val, 10);
229
+ }
230
+ }
231
+
232
+ //Save the opt representation for later
233
+ full_opt = (is_long ? '--' : '-') + curr_opt;
234
+
235
+ return curr_opt;
236
+ };
237
+
238
+ /**
239
+ * Parses command line opts.
240
+ *
241
+ * `opts` must be an object with opts defined like:
242
+ * long_tag: [short_tag, description, value_type, default_value];
243
+ *
244
+ * `commands` is an optional array or object for apps that are of the form
245
+ * my_app [OPTIONS] <command> [ARGS]
246
+ * The command list is output with usage information + there is bundled
247
+ * support for auto-completion, etc.
248
+ *
249
+ * See README.md for more information.
250
+ *
251
+ * @param {Object} opts
252
+ * @param {Object} commands (optional)
253
+ * @return {Object} opts (parsed)
254
+ * @api public
255
+ */
256
+ cli.parse = function (opts, command_def) {
257
+ var default_val, i, parsed = cli.options, seen,
258
+ catch_all = !opts;
259
+ opt_list = opts || {};
260
+ commands = command_def;
261
+ command_list = commands || [];
262
+ if (commands && !Array.isArray(commands)) {
263
+ command_list = Object.keys(commands);
264
+ }
265
+ while (o = cli.next()) {
266
+ seen = false;
267
+ for (opt in opt_list) {
268
+ if (!(opt_list[opt] instanceof Array)) {
269
+ continue;
270
+ }
271
+ if (!opt_list[opt][0]) {
272
+ opt_list[opt][0] = opt;
273
+ }
274
+ if (o === opt || o === opt_list[opt][0]) {
275
+ seen = true;
276
+ if (opt_list[opt].length === 2) {
277
+ parsed[opt] = true;
278
+ break;
279
+ }
280
+ default_val = null;
281
+ if (opt_list[opt].length === 4) {
282
+ default_val = opt_list[opt][3];
283
+ }
284
+ if (opt_list[opt][2] instanceof Array) {
285
+ for (i = 0, l = opt_list[opt][2].length; i < l; i++) {
286
+ if (typeof opt_list[opt][2][i] === 'number') {
287
+ opt_list[opt][2][i] += '';
288
+ }
289
+ }
290
+ parsed[opt] = cli.getArrayValue(opt_list[opt][2], is_long ? null : default_val);
291
+ break;
292
+ }
293
+ if (opt_list[opt][2].toLowerCase) {
294
+ opt_list[opt][2] = opt_list[opt][2].toLowerCase();
295
+ }
296
+ switch (opt_list[opt][2]) {
297
+ case 'string': case 1: case true:
298
+ parsed[opt] = cli.getValue(default_val);
299
+ break;
300
+ case 'int': case 'number': case 'num':
301
+ case 'time': case 'seconds': case 'secs': case 'minutes': case 'mins':
302
+ case 'x': case 'n':
303
+ parsed[opt] = cli.getInt(default_val);
304
+ break;
305
+ case 'float': case 'decimal':
306
+ parsed[opt] = cli.getFloat(default_val);
307
+ break;
308
+ case 'path': case 'file': case 'directory': case 'dir':
309
+ parsed[opt] = cli.getPath(default_val, opt_list[opt][2]);
310
+ break;
311
+ case 'email':
312
+ parsed[opt] = cli.getEmail(default_val);
313
+ break;
314
+ case 'url': case 'uri': case 'domain': case 'host':
315
+ parsed[opt] = cli.getUrl(default_val, opt_list[opt][2]);
316
+ break;
317
+ case 'ip':
318
+ parsed[opt] = cli.getIp(default_val);
319
+ break;
320
+ case 'bool': case 'boolean': case 'on':
321
+ parsed[opt] = true;
322
+ break;
323
+ case 'false': case 'off': case false: case 0:
324
+ parsed[opt] = false;
325
+ break;
326
+ default:
327
+ cli.fatal('Unknown opt type "' + opt_list[opt][2] + '"');
328
+ }
329
+ break;
330
+ }
331
+ }
332
+ if (process.env.NODE_DISABLE_COLORS) {
333
+ no_color = true;
334
+ }
335
+ if (!seen) {
336
+ if (enable.help && (o === 'h' || o === 'help')) {
337
+ cli.getUsage();
338
+ } else if (enable.version && (o === 'v' || o === 'version')) {
339
+ if (cli.version == null) {
340
+ cli.parsePackageJson();
341
+ }
342
+ console.error(cli.app + ' v' + cli.version);
343
+ cli.exit();
344
+ break;
345
+ } else if (enable.daemon && (o === 'd' || o === 'daemon')) {
346
+ daemon_arg = cli.getArrayValue(['start','stop','restart','pid','log'], is_long ? null : 'start');
347
+ continue;
348
+ } else if (enable.catchall && (o === 'c' || o === 'catch')) {
349
+ continue;
350
+ } else if (enable.status && (o === 'k' || o === 'no-color' || o === 'debug')) {
351
+ no_color = (o === 'k' || o === 'no-color');
352
+ show_debug = o === 'debug';
353
+ continue;
354
+ } else if (enable.timeout && (o === 't' || o === 'timeout')) {
355
+ var secs = cli.getInt();
356
+ setTimeout(function () {
357
+ cli.fatal('Process timed out after ' + secs + 's');
358
+ }, secs * 1000);
359
+ continue;
360
+ } else if (catch_all) {
361
+ parsed[o] = curr_val || true;
362
+ continue;
363
+ }
364
+ cli.fatal('Unknown option ' + full_opt);
365
+ }
366
+ }
367
+ //Fill the remaining options with their default value or null
368
+ for (opt in opt_list) {
369
+ default_val = opt_list[opt].length === 4 ? opt_list[opt][3] : null;
370
+ if (!(opt_list[opt] instanceof Array)) {
371
+ parsed[opt] = opt_list[opt];
372
+ continue;
373
+ } else if (typeof parsed[opt] === 'undefined') {
374
+ parsed[opt] = default_val;
375
+ }
376
+ }
377
+ if (command_list.length) {
378
+ if (cli.args.length === 0) {
379
+ if (enable.help) {
380
+ cli.getUsage();
381
+ } else {
382
+ cli.fatal('A command is required (' + command_list.join(', ') + ').');
383
+ }
384
+ return cli.exit(1);
385
+ } else {
386
+ cli.command = cli.autocompleteCommand(cli.args.shift());
387
+ }
388
+ }
389
+ cli.argc = cli.args.length;
390
+ return parsed;
391
+ };
392
+
393
+ /**
394
+ * Helper method for matching a command from the command list.
395
+ *
396
+ * @param {String} command
397
+ * @return {String} full_command
398
+ * @api public
399
+ */
400
+ cli.autocompleteCommand = function (command) {
401
+ var list;
402
+ if (!(command_list instanceof Array)) {
403
+ list = Object.keys(command_list);
404
+ } else {
405
+ list = command_list;
406
+ }
407
+ var i, j = 0, c = command.length, tmp_list;
408
+ if (list.length === 0 || list.indexOf(command) !== -1) {
409
+ return command;
410
+ }
411
+ for (i = 0; i < c; i++) {
412
+ tmp_list = [];
413
+ l = list.length;
414
+ if (l <= 1) break;
415
+ for (j = 0; j < l; j++)
416
+ if (list[j].length >= i && list[j][i] === command[i])
417
+ tmp_list.push(list[j]);
418
+ list = tmp_list;
419
+ }
420
+ l = list.length;
421
+ if (l === 1) {
422
+ return list[0];
423
+ } else if (l === 0) {
424
+ cli.fatal('Unknown command "' + command + '"' + (enable.help ? '. Please see --help for more information' : ''));
425
+ } else {
426
+ list.sort();
427
+ cli.fatal('The command "' + command + '" is ambiguous and could mean "' + list.join('", "') + '"');
428
+ }
429
+ };
430
+
431
+ /**
432
+ * Adds methods to output styled status messages to stderr.
433
+ *
434
+ * Added methods are cli.info(msg), cli.error(msg), cli.ok(msg), and
435
+ * cli.debug(msg).
436
+ *
437
+ * To control status messages, use the 'status' plugin
438
+ * 1) debug() messages are hidden by default. Display them with
439
+ * the --debug opt.
440
+ * 2) to hide all status messages, use the -s or --silent opt.
441
+ *
442
+ * @api private
443
+ */
444
+ cli.status = function (msg, type) {
445
+ var pre;
446
+ switch (type) {
447
+ case 'info':
448
+ pre = no_color ? 'INFO:' : '\x1B[33mINFO\x1B[0m:';
449
+ break;
450
+ case 'debug':
451
+ pre = no_color ? 'DEBUG:' : '\x1B[36mDEBUG\x1B[0m:';
452
+ break;
453
+ case 'error':
454
+ case 'fatal':
455
+ pre = no_color ? 'ERROR:' : '\x1B[31mERROR\x1B[0m:';
456
+ break;
457
+ case 'ok':
458
+ pre = no_color ? 'OK:' : '\x1B[32mOK\x1B[0m:';
459
+ break;
460
+ }
461
+ msg = pre + ' ' + msg;
462
+ if (type === 'fatal') {
463
+ console.error(msg);
464
+ return cli.exit(1);
465
+ }
466
+ if (enable.status && !show_debug && type === 'debug') {
467
+ return;
468
+ }
469
+ console.error(msg);
470
+ };
471
+ ['info','error','ok','debug','fatal'].forEach(function (type) {
472
+ cli[type] = function (msg) {
473
+ cli.status(msg, type);
474
+ };
475
+ });
476
+
477
+ /**
478
+ * Sets the app name and version.
479
+ *
480
+ * Usage:
481
+ * setApp('myapp', '0.1.0');
482
+ * setApp('./package.json'); //Pull name/version from package.json
483
+ *
484
+ * @param {String} name
485
+ * @return cli (for chaining)
486
+ * @api public
487
+ */
488
+ cli.setApp = function (name, version) {
489
+ if (name.indexOf('package.json') !== -1) {
490
+ cli.parsePackageJson(name);
491
+ } else {
492
+ cli.app = name;
493
+ cli.version = version;
494
+ }
495
+ return cli;
496
+ };
497
+
498
+ /**
499
+ * Parses the version number from package.json. If no path is specified, cli
500
+ * will attempt to locate a package.json in ./, ../ or ../../
501
+ *
502
+ * @param {String} path (optional)
503
+ * @api public
504
+ */
505
+ cli.parsePackageJson = function (path) {
506
+ var parse_packagejson = function (path) {
507
+ var packagejson = JSON.parse(cli.native.fs.readFileSync(path, 'utf8'));
508
+ cli.version = packagejson.version;
509
+ cli.app = packagejson.name;
510
+ };
511
+ var try_all = function (arr, func, err) {
512
+ for (var i = 0, l = arr.length; i < l; i++) {
513
+ try {
514
+ func(arr[i]);
515
+ return;
516
+ } catch (e) {
517
+ if (i === l-1) {
518
+ cli.fatal(err);
519
+ }
520
+ }
521
+ }
522
+ };
523
+ try {
524
+ if (path) {
525
+ return parse_packagejson(path);
526
+ }
527
+ try_all([
528
+ __dirname + '/package.json',
529
+ __dirname + '/../package.json',
530
+ __dirname + '/../../package.json'
531
+ ], parse_packagejson);
532
+ } catch (e) {
533
+ cli.fatal('Could not detect ' + cli.app + ' version');
534
+ }
535
+ };
536
+
537
+ /**
538
+ * Sets the usage string - default is `app [OPTIONS] [ARGS]`.
539
+ *
540
+ * @param {String} u
541
+ * @return cli (for chaining)
542
+ * @api public
543
+ */
544
+ cli.setUsage = function (u) {
545
+ usage = u;
546
+ return cli;
547
+ };
548
+
549
+ var pad = function (str, len) {
550
+ if (typeof len === 'undefined') {
551
+ len = str;
552
+ str = '';
553
+ }
554
+ if (str.length < len) {
555
+ len -= str.length;
556
+ while (len--) str += ' ';
557
+ }
558
+ return str;
559
+ };
560
+
561
+ /**
562
+ * Automatically build usage information from the opts list. If the help
563
+ * plugin is enabled (default), this info is displayed with -h, --help.
564
+ *
565
+ * @api public
566
+ */
567
+ cli.getUsage = function (code) {
568
+ var short, desc, optional, line, seen_opts = [],
569
+ switch_pad = cli.option_width;
570
+
571
+ var trunc_desc = function (pref, desc, len) {
572
+ var pref_len = pref.length,
573
+ desc_len = cli.width - pref_len,
574
+ truncated = '';
575
+ if (desc.length <= desc_len) {
576
+ return desc;
577
+ }
578
+ var desc_words = (desc+'').split(' '), chars = 0, word;
579
+ while (desc_words.length) {
580
+ truncated += (word = desc_words.shift()) + ' ';
581
+ chars += word.length;
582
+ if (desc_words.length && chars + desc_words[0].length > desc_len) {
583
+ truncated += '\n' + pad(pref_len);
584
+ chars = 0;
585
+ }
586
+ }
587
+ return truncated;
588
+ };
589
+
590
+ usage = usage || cli.app + ' [OPTIONS]' + (command_list.length ? ' <command>' : '') + ' [ARGS]';
591
+ if (no_color) {
592
+ console.error('Usage:\n ' + usage);
593
+ console.error('Options: ');
594
+ } else {
595
+ console.error('\x1b[1mUsage\x1b[0m:\n ' + usage);
596
+ console.error('\n\x1b[1mOptions\x1b[0m: ');
597
+ }
598
+ for (opt in opt_list) {
599
+
600
+ if (opt.length === 1) {
601
+ long = opt_list[opt][0];
602
+ short = opt;
603
+ } else {
604
+ long = opt;
605
+ short = opt_list[opt][0];
606
+ }
607
+
608
+ //Parse opt_list
609
+ desc = opt_list[opt][1].trim();
610
+ type = opt_list[opt].length >= 3 ? opt_list[opt][2] : null;
611
+ optional = opt_list[opt].length === 4 ? opt_list[opt][3] : null;
612
+
613
+ //Build usage line
614
+ if (short === long) {
615
+ if (short.length === 1) {
616
+ line = ' -' + short;
617
+ } else {
618
+ line = ' --' + long;
619
+ }
620
+ } else if (short) {
621
+ line = ' -' + short + ', --' + long;
622
+ } else {
623
+ line = ' --' + long;
624
+ }
625
+ line += ' ';
626
+
627
+ if (type) {
628
+ if (type instanceof Array) {
629
+ desc += '. VALUE must be either [' + type.join('|') + ']';
630
+ type = 'VALUE';
631
+ }
632
+ if (type === true || type === 1) {
633
+ type = long.toUpperCase();
634
+ }
635
+ type = type.toUpperCase();
636
+ if (type === 'FLOAT' || type === 'INT') {
637
+ type = 'NUMBER';
638
+ }
639
+ line += optional ? '[' + type + ']' : type;
640
+ }
641
+ line = pad(line, switch_pad);
642
+ line += trunc_desc(line, desc);
643
+ line += optional ? ' (Default is ' + optional + ')' : '';
644
+ console.error(line.replace('%s', '%\0s'));
645
+
646
+ seen_opts.push(short);
647
+ seen_opts.push(long);
648
+ }
649
+ if (enable.timeout && seen_opts.indexOf('t') === -1 && seen_opts.indexOf('timeout') === -1) {
650
+ console.error(pad(' -t, --timeout N', switch_pad) + 'Exit if the process takes longer than N seconds');
651
+ }
652
+ if (enable.status) {
653
+ if (seen_opts.indexOf('k') === -1 && seen_opts.indexOf('no-color') === -1) {
654
+ console.error(pad(' -k, --no-color', switch_pad) + 'Omit color from output');
655
+ }
656
+ if (seen_opts.indexOf('debug') === -1) {
657
+ console.error(pad(' --debug', switch_pad) + 'Show debug information');
658
+ }
659
+ }
660
+ if (enable.catchall && seen_opts.indexOf('c') === -1 && seen_opts.indexOf('catch') === -1) {
661
+ console.error(pad(' -c, --catch', switch_pad) + 'Catch unanticipated errors');
662
+ }
663
+ if (enable.daemon && seen_opts.indexOf('d') === -1 && seen_opts.indexOf('daemon') === -1) {
664
+ console.error(pad(' -d, --daemon [ARG]', switch_pad) + 'Daemonize the process. Control the daemon using [start, stop, restart, log, pid]');
665
+ }
666
+ if (enable.version && seen_opts.indexOf('v') === -1 && seen_opts.indexOf('version') === -1) {
667
+ console.error(pad(' -v, --version', switch_pad) + 'Display the current version');
668
+ }
669
+ if (enable.help && seen_opts.indexOf('h') === -1 && seen_opts.indexOf('help') === -1) {
670
+ console.error(pad(' -h, --help', switch_pad) + 'Display help and usage details');
671
+ }
672
+ if (command_list.length) {
673
+ console.error('\n\x1b[1mCommands\x1b[0m: ');
674
+ if (!Array.isArray(commands)) {
675
+ for (var c in commands) {
676
+ line = ' ' + pad(c, switch_pad - 2);
677
+ line += trunc_desc(line, commands[c]);
678
+ console.error(line);
679
+ }
680
+ } else {
681
+ command_list.sort();
682
+ console.error(' ' + trunc_desc(' ', command_list.join(', ')));
683
+ }
684
+ }
685
+ return cli.exit(code);
686
+ };
687
+
688
+ /**
689
+ * Generates an error message when an opt is incorrectly used.
690
+ *
691
+ * @param {String} expects (e.g. 'a value')
692
+ * @param {String} type (e.g. 'VALUE')
693
+ * @api public
694
+ */
695
+ cli.getOptError = function (expects, type) {
696
+ var err = full_opt + ' expects ' + expects
697
+ + '. Use `' + cli.app + ' ' + full_opt + (is_long ? '=' : ' ') + type + '`';
698
+ return err;
699
+ };
700
+
701
+ /**
702
+ * Gets the next opt value and validates it with an optional validation
703
+ * function. If validation fails or no value can be obtained, this method
704
+ * will return the default value (if specified) or exit with err_msg.
705
+ *
706
+ * @param {String} default_val
707
+ * @param {Function} validate_func
708
+ * @param {String} err_msg
709
+ * @api public
710
+ */
711
+ cli.getValue = function (default_val, validate_func, err_msg) {
712
+ err_msg = err_msg || cli.getOptError('a value', 'VALUE');
713
+
714
+ var value;
715
+
716
+ try {
717
+ if (curr_val) {
718
+ if (validate_func) {
719
+ curr_val = validate_func(curr_val);
720
+ }
721
+ return curr_val;
722
+ }
723
+
724
+ //Grouped short opts aren't allowed to have values
725
+ if (short_tags.length) {
726
+ throw 'Short tags';
727
+ }
728
+
729
+ //If there's no args left or the next arg is an opt, return the
730
+ //default value (if specified) - otherwise fail
731
+ if (!argv.length || (argv[0].length === 1 && argv[0][0] === '-')) {
732
+ throw 'No value';
733
+ }
734
+
735
+ value = argv.shift();
736
+
737
+ if (value.match(/^[0-9]+$/)) {
738
+ value = parseInt(value, 10);
739
+ }
740
+
741
+ //Run the value through a validation/transformation function if specified
742
+ if (validate_func) {
743
+ value = validate_func(value);
744
+ }
745
+ } catch (e) {
746
+
747
+ //The value didn't pass the validation/transformation. Unshift the value and
748
+ //return the default value (if specified)
749
+ if (value) {
750
+ argv.unshift(value);
751
+ }
752
+ return default_val != null ? default_val : cli.fatal(err_msg);
753
+ }
754
+ return value;
755
+ };
756
+
757
+ cli.getInt = function (default_val) {
758
+ return cli.getValue(default_val, function (value) {
759
+ if (typeof value === 'number') return value;
760
+ if (!value.match(/^(?:-?(?:0|[1-9][0-9]*))$/)) {
761
+ throw 'Invalid int';
762
+ }
763
+ return parseInt(value);
764
+ }, cli.getOptError('a number', 'NUMBER'));
765
+ }
766
+
767
+ cli.getFloat = function (default_val) {
768
+ return cli.getValue(default_val, function (value) {
769
+ if (!value.match(/^(?:-?(?:0|[1-9][0-9]*))?(?:\.[0-9]*)?$/)) {
770
+ throw 'Invalid float';
771
+ }
772
+ return parseFloat(value, 10);
773
+ }, cli.getOptError('a number', 'NUMBER'));
774
+ }
775
+
776
+ cli.getUrl = function (default_val, identifier) {
777
+ identifier = identifier || 'url';
778
+ return cli.getValue(default_val, function (value) {
779
+ if (!value.match(/^(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?:\w+:\w+@)?((?:(?:[-\w\d{1-3}]+\.)+(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|edu|co\.uk|ac\.uk|it|fr|tv|museum|asia|local|travel|[a-z]{2})?)|((\b25[0-5]\b|\b[2][0-4][0-9]\b|\b[0-1]?[0-9]?[0-9]\b)(\.(\b25[0-5]\b|\b[2][0-4][0-9]\b|\b[0-1]?[0-9]?[0-9]\b)){3}))(?::[\d]{1,5})?(?:(?:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?:#(?:[-\w~!$ |\/.,*:;=]|%[a-f\d]{2})*)?$/i)) {
780
+ throw 'Invalid URL';
781
+ }
782
+ return value;
783
+ }, cli.getOptError('a ' + identifier, identifier.toUpperCase()));
784
+ }
785
+
786
+ cli.getEmail = function (default_val) {
787
+ return cli.getValue(default_val, function (value) {
788
+ if (!value.match(/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/)) {
789
+ throw 'Invalid email';
790
+ }
791
+ return value;
792
+ }, cli.getOptError('an email', 'EMAIL'));
793
+ }
794
+
795
+ cli.getIp = function (default_val) {
796
+ return cli.getValue(default_val, function (value) {
797
+ if (!value.match(/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/)) {
798
+ throw 'Invalid IP';
799
+ }
800
+ return value;
801
+ }, cli.getOptError('an IP', 'IP'));
802
+ }
803
+
804
+ cli.getPath = function (default_val, identifier) {
805
+ identifier = identifier || 'path';
806
+ return cli.getValue(default_val, function (value) {
807
+ if (value.match(/[?*;{}]/)) {
808
+ throw 'Invalid path';
809
+ }
810
+ return value;
811
+ }, cli.getOptError('a ' + identifier, identifier.toUpperCase()));
812
+ }
813
+
814
+ cli.getArrayValue = function (arr, default_val) {
815
+ return cli.getValue(default_val, function (value) {
816
+ if (arr.indexOf(value) === -1) {
817
+ throw 'Unexpected value';
818
+ }
819
+ return value;
820
+ }, cli.getOptError('either [' + arr.join('|') + ']', 'VALUE'));
821
+ }
822
+
823
+ /**
824
+ * Gets all data from STDIN (with optional encoding) and sends it to callback.
825
+ *
826
+ * @param {String} encoding (optional - default is 'utf8')
827
+ * @param {Function} callback
828
+ * @api public
829
+ */
830
+ cli.withStdin = function (encoding, callback) {
831
+ if (typeof encoding === 'function') {
832
+ callback = encoding;
833
+ encoding = 'utf8';
834
+ }
835
+ var stream = process.openStdin(), data = '';
836
+ stream.setEncoding(encoding);
837
+ stream.on('data', function (chunk) {
838
+ data += chunk;
839
+ });
840
+ stream.on('end', function () {
841
+ callback.apply(cli, [data]);
842
+ });
843
+ };
844
+
845
+ /**
846
+ * Gets all data from STDIN, splits the data into lines and sends it
847
+ * to callback (callback isn't called until all of STDIN is read. To
848
+ * process each line as it's received, see the method below
849
+ *
850
+ * @param {Function} callback
851
+ * @api public
852
+ */
853
+ cli.withStdinLines = function (callback) {
854
+ cli.withStdin(function (data) {
855
+ var sep = data.indexOf('\r\n') !== -1 ? '\r\n' : '\n';
856
+ callback.apply(cli, [data.split(sep), sep]);
857
+ });
858
+ };
859
+
860
+ /**
861
+ * Asynchronously reads a file line by line. When a line is received,
862
+ * callback is called with (line, sep) - when EOF is reached, callback
863
+ * receives (null, null, true)
864
+ *
865
+ * @param {String} file (optional - default is 'stdin')
866
+ * @param {String} encoding (optional - default is 'utf8')
867
+ * @param {Function} callback (line, sep, eof)
868
+ * @api public
869
+ */
870
+ cli.withInput = function (file, encoding, callback) {
871
+ if (typeof encoding === 'function') {
872
+ callback = encoding;
873
+ encoding = 'utf8';
874
+ } else if (typeof file === 'function') {
875
+ callback = file;
876
+ encoding = 'utf8';
877
+ file = 'stdin';
878
+ }
879
+ if (file === 'stdin') {
880
+ file = process.openStdin();
881
+ } else {
882
+ try {
883
+ file = cli.native.fs.createReadStream(file);
884
+ file.on('error', cli.fatal);
885
+ } catch (e) {
886
+ return cli.fatal(e);
887
+ }
888
+ }
889
+ file.setEncoding(encoding);
890
+ var lines = [], data = '', eof, sep;
891
+ file.on('data', function (chunk) {
892
+ if (eof) return;
893
+ data += chunk;
894
+ if (!sep) {
895
+ if (data.indexOf('\r\n') !== -1) {
896
+ sep = '\r\n';
897
+ } else if (data.indexOf('\n') !== -1) {
898
+ sep = '\n';
899
+ } else {
900
+ last_line = data;
901
+ return;
902
+ }
903
+ }
904
+ lines = data.split(sep);
905
+ data = eof ? null : lines.pop();
906
+ while (lines.length) {
907
+ callback.apply(cli, [lines.shift(), sep, false]);
908
+ }
909
+ });
910
+ file.on('end', function () {
911
+ eof = true;
912
+ if (data.length) {
913
+ callback.apply(cli, [data, sep || '', false]);
914
+ }
915
+ callback.apply(cli, [null, null, true]);
916
+ });
917
+ };
918
+
919
+ /**
920
+ * A method for creating and controlling a daemon.
921
+ *
922
+ * `arg` can be:
923
+ * start = daemonizes the process
924
+ * stop = stops the daemon if it is running
925
+ * restart = alias for stop -> start
926
+ * pid = outputs the daemon's PID if it is running
927
+ * log = outputs the daemon's log file (stdout + stderr)
928
+ *
929
+ * @param {String} arg (Optional - default is 'start')
930
+ * @param {Function} callback
931
+ * @api public
932
+ */
933
+ cli.daemon = function (arg, callback) {
934
+ if (typeof daemon === 'undefined') {
935
+ cli.fatal('Daemon is not initialized');
936
+ }
937
+
938
+ if (typeof arg === 'function') {
939
+ callback = arg;
940
+ arg = 'start';
941
+ }
942
+
943
+ var lock_file = '/tmp/' + cli.app + '.pid',
944
+ log_file = '/tmp/' + cli.app + '.log';
945
+
946
+ var start = function () {
947
+ daemon.daemonize(log_file, lock_file, function (err) {
948
+ if (err) return cli.error('Error starting daemon: ' + err);
949
+ callback();
950
+ });
951
+ };
952
+
953
+ var stop = function () {
954
+ try {
955
+ cli.native.fs.readFileSync(lock_file);
956
+ } catch (e) {
957
+ return cli.error('Daemon is not running');
958
+ };
959
+ daemon.kill(lock_file, function (err, pid) {
960
+ if (err && err.errno === 3) {
961
+ return cli.error('Daemon is not running');
962
+ } else if (err) {
963
+ return cli.error('Error stopping daemon: ' + err.errno);
964
+ }
965
+ cli.ok('Successfully stopped daemon with pid: ' + pid);
966
+ });
967
+ };
968
+
969
+ switch(arg) {
970
+ case 'stop':
971
+ stop();
972
+ break;
973
+ case 'restart':
974
+ daemon.stop(lock_file, function () {
975
+ start();
976
+ });
977
+ break;
978
+ case 'log':
979
+ try {
980
+ cli.native.fs.createReadStream(log_file, {encoding: 'utf8'}).pipe(process.stdout);
981
+ } catch (e) {
982
+ return cli.error('No daemon log file');
983
+ };
984
+ break;
985
+ case 'pid':
986
+ try {
987
+ var pid = cli.native.fs.readFileSync(lock_file, 'utf8');
988
+ cli.native.fs.statSync('/proc/' + pid);
989
+ cli.info(pid);
990
+ } catch (e) {
991
+ return cli.error('Daemon is not running');
992
+ };
993
+ break;
994
+ default:
995
+ start();
996
+ break;
997
+ }
998
+ }
999
+
1000
+ /**
1001
+ * The main entry method. Calling cli.main() is only necessary in
1002
+ * scripts that have daemon support enabled. `callback` receives (args, options)
1003
+ *
1004
+ * @param {Function} callback
1005
+ * @api public
1006
+ */
1007
+ cli.main = function (callback) {
1008
+ var after = function () {
1009
+ callback.apply(cli, [cli.args, cli.options]);
1010
+ };
1011
+ if (enable.daemon && daemon_arg) {
1012
+ cli.daemon(daemon_arg, after);
1013
+ } else {
1014
+ after();
1015
+ }
1016
+ }
1017
+
1018
+ /**
1019
+ * Bind creationix's stack (https://github.com/creationix/stack).
1020
+ *
1021
+ * Create a simple middleware stack by calling:
1022
+ *
1023
+ * cli.createServer(middleware).listen(port);
1024
+ *
1025
+ * @return {Server} server
1026
+ * @api public
1027
+ */
1028
+ cli.createServer = function(/*layers*/) {
1029
+ var defaultStackErrorHandler = function (req, res, err) {
1030
+ if (err) {
1031
+ console.error(err.stack);
1032
+ res.writeHead(500, {"Content-Type": "text/plain"});
1033
+ return res.end(err.stack + "\n");
1034
+ }
1035
+ res.writeHead(404, {"Content-Type": "text/plain"});
1036
+ res.end("Not Found\n");
1037
+ };
1038
+ var handle = error = defaultStackErrorHandler,
1039
+ layers = Array.prototype.slice.call(arguments);
1040
+
1041
+ //Allow createServer(a,b,c) and createServer([a,b,c])
1042
+ if (layers.length && layers[0] instanceof Array) {
1043
+ layers = layers[0];
1044
+ }
1045
+ layers.reverse().forEach(function (layer) {
1046
+ var child = handle;
1047
+ handle = function (req, res) {
1048
+ try {
1049
+ layer(req, res, function (err) {
1050
+ if (err) return error(req, res, err);
1051
+ child(req, res);
1052
+ });
1053
+ } catch (err) {
1054
+ error(req, res, err);
1055
+ }
1056
+ };
1057
+ });
1058
+ return cli.native.http.createServer(handle);
1059
+ };
1060
+
1061
+ /**
1062
+ * A wrapper for child_process.exec().
1063
+ *
1064
+ * If the child_process exits successfully, `callback` receives an array of
1065
+ * stdout lines. The current process exits if the child process has an error
1066
+ * and `errback` isn't defined.
1067
+ *
1068
+ * @param {String} cmd
1069
+ * @param {Function} callback (optional)
1070
+ * @param {Function} errback (optional)
1071
+ * @api public
1072
+ */
1073
+ cli.exec = function (cmd, callback, errback) {
1074
+ cli.native.child_process.exec(cmd, function (err, stdout, stderr) {
1075
+ err = err || stderr;
1076
+ if (err) {
1077
+ if (errback) {
1078
+ return errback(err, stdout);
1079
+ }
1080
+ return cli.fatal('exec() failed\n' + err);
1081
+ }
1082
+ if (callback) {
1083
+ callback(stdout.split('\n'));
1084
+ }
1085
+ });
1086
+ };
1087
+
1088
+ /**
1089
+ * Helper method for outputting a progress bar to the console.
1090
+ *
1091
+ * @param {Number} progress (0 <= progress <= 1)
1092
+ * @api public
1093
+ */
1094
+ var last_progress_call, progress_len = 74;
1095
+ cli.progress = function (progress, decimals) {
1096
+ if (progress < 0 || progress > 1 || isNaN(progress)) return;
1097
+ if (!decimals) decimals = 0;
1098
+ var now = (new Date()).getTime();
1099
+ if (last_progress_call && (now - last_progress_call) < 100 && progress !== 1) {
1100
+ return; //Throttle progress calls
1101
+ }
1102
+ last_progress_call = now;
1103
+
1104
+
1105
+ var barLength = Math.floor(progress_len * progress),
1106
+ str = '';
1107
+ if (barLength == 0 && progress > 0) {
1108
+ barLength = 1;
1109
+ }
1110
+ for (var i = 1; i <= progress_len; i++) {
1111
+ str += i <= barLength ? '#' : ' ';
1112
+ }
1113
+ var pwr = Math.pow(10, decimals);
1114
+ var percentage = Math.floor(progress * 100 * pwr) / pwr + '%';
1115
+ for (i = 0; i < decimals; i++) {
1116
+ percentage += ' ';
1117
+ }
1118
+ cli.native.util.print('[' + str + '] ' + percentage + (progress === 1 ? '\n' : '\u000D'));
1119
+ };
1120
+
1121
+ /**
1122
+ * Helper method for outputting a spinner to the console.
1123
+ *
1124
+ * @param {String|Boolean} prefix (optional)
1125
+ * @api public
1126
+ */
1127
+ var spinnerInterval;
1128
+ cli.spinner = function (prefix, end) {
1129
+ if (end) {
1130
+ cli.native.util.print('\u000D' + prefix);
1131
+ return clearInterval(spinnerInterval);
1132
+ }
1133
+ prefix = prefix + ' ' || '';
1134
+ var spinner = ['-','\\','|','/'], i = 0, l = spinner.length;
1135
+ spinnerInterval = setInterval(function () {
1136
+ cli.native.util.print('\u000D' + prefix + spinner[i++]);
1137
+ if (i == l) i = 0;
1138
+ }, 200);
1139
+ };