sproutcore 1.0.1003 → 1.0.1008

Sign up to get free protection for your applications and to get access to all the features.
Files changed (276) hide show
  1. data/Buildfile +15 -3
  2. data/Rakefile +3 -7
  3. data/VERSION.yml +2 -2
  4. data/buildtasks/manifest.rake +2 -0
  5. data/frameworks/sproutcore/Buildfile +2 -0
  6. data/frameworks/sproutcore/HISTORY +218 -203
  7. data/frameworks/sproutcore/README +47 -6
  8. data/frameworks/sproutcore/apps/tests/english.lproj/main_page.css +4 -0
  9. data/frameworks/sproutcore/design/Design Charts.graffle +2945 -4332
  10. data/frameworks/sproutcore/frameworks/bootstrap/README +9 -0
  11. data/frameworks/sproutcore/frameworks/bootstrap/core.js +7 -0
  12. data/frameworks/sproutcore/frameworks/bootstrap/setup_body_class_names.js +10 -0
  13. data/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +28 -0
  14. data/frameworks/sproutcore/frameworks/bootstrap/system/loader.js +45 -0
  15. data/frameworks/sproutcore/frameworks/datastore/models/many_attribute.js +9 -8
  16. data/frameworks/sproutcore/frameworks/datastore/models/record.js +49 -9
  17. data/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +9 -0
  18. data/frameworks/sproutcore/frameworks/datastore/models/single_attribute.js +3 -2
  19. data/frameworks/sproutcore/frameworks/datastore/system/nested_store.js +81 -8
  20. data/frameworks/sproutcore/frameworks/datastore/system/query.js +26 -5
  21. data/frameworks/sproutcore/frameworks/datastore/system/record_array.js +47 -0
  22. data/frameworks/sproutcore/frameworks/datastore/system/store.js +164 -32
  23. data/frameworks/sproutcore/frameworks/datastore/tests/models/many_attribute.js +32 -4
  24. data/frameworks/sproutcore/frameworks/datastore/tests/models/record/error_methods.js +56 -0
  25. data/frameworks/sproutcore/frameworks/datastore/tests/models/record/normalize.js +1 -1
  26. data/frameworks/sproutcore/frameworks/datastore/tests/models/record/unknownProperty.js +15 -0
  27. data/frameworks/sproutcore/frameworks/datastore/tests/models/record/writeAttribute.js +16 -1
  28. data/frameworks/sproutcore/frameworks/datastore/tests/models/record_attribute.js +1 -1
  29. data/frameworks/sproutcore/frameworks/datastore/tests/models/single_attribute.js +22 -1
  30. data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/chain.js +32 -1
  31. data/frameworks/sproutcore/frameworks/datastore/tests/system/nested_store/core_methods.js +70 -0
  32. data/frameworks/sproutcore/frameworks/datastore/tests/system/query/evaluation.js +12 -0
  33. data/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/error_methods.js +50 -0
  34. data/frameworks/sproutcore/frameworks/datastore/tests/system/store/commitRecord.js +9 -9
  35. data/frameworks/sproutcore/frameworks/datastore/tests/system/store/core_methods.js +8 -1
  36. data/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataHashDidChange.js +79 -0
  37. data/frameworks/sproutcore/frameworks/datastore/tests/system/store/dataSourceCallbacks.js +24 -0
  38. data/frameworks/sproutcore/frameworks/datastore/tests/system/store/error_methods.js +62 -0
  39. data/frameworks/sproutcore/frameworks/datastore/tests/system/store/init.js +2 -0
  40. data/frameworks/sproutcore/frameworks/debug/core.js +10 -6
  41. data/frameworks/sproutcore/frameworks/designer/controllers/page_design.js +43 -18
  42. data/frameworks/sproutcore/frameworks/designer/core.js +10 -0
  43. data/frameworks/sproutcore/frameworks/designer/english.lproj/selection_handles.css +58 -0
  44. data/frameworks/sproutcore/frameworks/designer/{views/mixins → mixins}/button.js +0 -0
  45. data/frameworks/sproutcore/frameworks/designer/views/{controls/button.js → button.js} +6 -2
  46. data/frameworks/sproutcore/frameworks/designer/views/designer.js +566 -136
  47. data/frameworks/sproutcore/frameworks/designer/views/selection_handles.js +77 -0
  48. data/frameworks/sproutcore/frameworks/desktop/core.js +12 -0
  49. data/frameworks/sproutcore/frameworks/desktop/english.lproj/alert.css +1 -1
  50. data/frameworks/sproutcore/frameworks/desktop/english.lproj/drag.css +3 -2
  51. data/frameworks/sproutcore/frameworks/desktop/english.lproj/list_item.css +0 -36
  52. data/frameworks/sproutcore/frameworks/desktop/english.lproj/menu.css +14 -0
  53. data/frameworks/sproutcore/frameworks/desktop/english.lproj/modal.css +4 -0
  54. data/frameworks/sproutcore/frameworks/desktop/english.lproj/slider.css +2 -0
  55. data/frameworks/sproutcore/frameworks/desktop/english.lproj/tab.css +0 -4
  56. data/frameworks/sproutcore/frameworks/desktop/mixins/collection_view_delegate.js +8 -5
  57. data/frameworks/sproutcore/frameworks/desktop/panes/alert.js +2 -2
  58. data/frameworks/sproutcore/frameworks/desktop/panes/menu.js +100 -111
  59. data/frameworks/sproutcore/frameworks/desktop/panes/panel.js +1 -1
  60. data/frameworks/sproutcore/frameworks/desktop/panes/picker.js +51 -13
  61. data/frameworks/sproutcore/frameworks/desktop/panes/{drop_down.js → select_button.js} +70 -109
  62. data/frameworks/sproutcore/frameworks/desktop/panes/sheet.js +8 -0
  63. data/frameworks/sproutcore/frameworks/desktop/system/root_responder.js +69 -23
  64. data/frameworks/sproutcore/frameworks/desktop/system/undo_manager.js +4 -4
  65. data/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/methods.js +2 -0
  66. data/frameworks/sproutcore/frameworks/desktop/tests/panes/{dropDown → select_button}/methods.js +15 -11
  67. data/frameworks/sproutcore/frameworks/desktop/tests/panes/{dropDown → select_button}/ui.js +22 -22
  68. data/frameworks/sproutcore/frameworks/desktop/tests/views/button/methods.js +1 -1
  69. data/frameworks/sproutcore/frameworks/desktop/tests/views/checkbox/methods.js +0 -1
  70. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/deleteSelection.js +1 -1
  71. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/deselect.js +19 -3
  72. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/itemViewForContentIndex.js +1 -1
  73. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/mouse.js +53 -28
  74. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/select.js +6 -6
  75. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/selectNextItem.js +23 -9
  76. data/frameworks/sproutcore/frameworks/desktop/tests/views/collection/selectPreviousItem.js +24 -10
  77. data/frameworks/sproutcore/frameworks/desktop/tests/views/list/rowHeightForContentIndex.js +1 -1
  78. data/frameworks/sproutcore/frameworks/desktop/tests/views/list/ui_row_heights.js +1 -1
  79. data/frameworks/sproutcore/frameworks/desktop/tests/views/progress/ui.js +10 -3
  80. data/frameworks/sproutcore/frameworks/desktop/tests/views/radio/methods.js +1 -1
  81. data/frameworks/sproutcore/frameworks/desktop/tests/views/scroll/ui.js +50 -28
  82. data/frameworks/sproutcore/frameworks/desktop/tests/views/scroller/methods.js +6 -6
  83. data/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/methods.js +3 -3
  84. data/frameworks/sproutcore/frameworks/desktop/tests/views/segmented/ui.js +8 -8
  85. data/frameworks/sproutcore/frameworks/desktop/tests/views/select_field/methods.js +1 -1
  86. data/frameworks/sproutcore/frameworks/desktop/tests/views/tab/methods.js +1 -1
  87. data/frameworks/sproutcore/frameworks/desktop/views/button.js +5 -3
  88. data/frameworks/sproutcore/frameworks/desktop/views/checkbox.js +4 -3
  89. data/frameworks/sproutcore/frameworks/desktop/views/collection.js +125 -96
  90. data/frameworks/sproutcore/frameworks/desktop/views/grid.js +1 -0
  91. data/frameworks/sproutcore/frameworks/desktop/views/list.js +68 -18
  92. data/frameworks/sproutcore/frameworks/desktop/views/list_item.js +134 -56
  93. data/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +18 -11
  94. data/frameworks/sproutcore/frameworks/desktop/views/menu_scroll.js +562 -2
  95. data/frameworks/sproutcore/frameworks/desktop/views/popup_button.js +13 -0
  96. data/frameworks/sproutcore/frameworks/desktop/views/progress.js +11 -8
  97. data/frameworks/sproutcore/frameworks/desktop/views/radio.js +7 -7
  98. data/frameworks/sproutcore/frameworks/desktop/views/scroll.js +99 -33
  99. data/frameworks/sproutcore/frameworks/desktop/views/scroller.js +3 -7
  100. data/frameworks/sproutcore/frameworks/desktop/views/segmented.js +0 -7
  101. data/frameworks/sproutcore/frameworks/desktop/views/separator.js +2 -3
  102. data/frameworks/sproutcore/frameworks/desktop/views/slider.js +0 -8
  103. data/frameworks/sproutcore/frameworks/desktop/views/source_list_group.js +1 -1
  104. data/frameworks/sproutcore/frameworks/desktop/views/split.js +27 -7
  105. data/frameworks/sproutcore/frameworks/desktop/views/tab.js +2 -6
  106. data/frameworks/sproutcore/frameworks/foundation/controllers/array.js +15 -10
  107. data/frameworks/sproutcore/frameworks/foundation/controllers/tree.js +20 -1
  108. data/frameworks/sproutcore/frameworks/foundation/debug/control_test_pane.js +1 -1
  109. data/frameworks/sproutcore/frameworks/foundation/english.lproj/bootstrap.rhtml +3 -6
  110. data/frameworks/sproutcore/frameworks/foundation/english.lproj/button_view.css +3 -0
  111. data/frameworks/sproutcore/frameworks/foundation/english.lproj/core.css +8 -0
  112. data/frameworks/sproutcore/frameworks/foundation/english.lproj/inline_editor.css +12 -0
  113. data/frameworks/sproutcore/frameworks/foundation/english.lproj/label.css +11 -0
  114. data/frameworks/sproutcore/frameworks/foundation/english.lproj/text_field.css +13 -0
  115. data/frameworks/sproutcore/frameworks/foundation/mixins/button.js +1 -2
  116. data/frameworks/sproutcore/frameworks/foundation/mixins/inline_text_field.js +70 -21
  117. data/frameworks/sproutcore/frameworks/foundation/mixins/selection_support.js +88 -54
  118. data/frameworks/sproutcore/frameworks/foundation/mixins/static_layout.js +0 -25
  119. data/frameworks/sproutcore/frameworks/foundation/mixins/string.js +23 -2
  120. data/frameworks/sproutcore/frameworks/foundation/panes/pane.js +34 -23
  121. data/frameworks/sproutcore/frameworks/foundation/private/tree_item_observer.js +20 -0
  122. data/frameworks/sproutcore/frameworks/foundation/system/benchmark.js +32 -23
  123. data/frameworks/sproutcore/frameworks/foundation/system/browser.js +2 -2
  124. data/frameworks/sproutcore/frameworks/foundation/system/bundle.js +77 -15
  125. data/frameworks/sproutcore/frameworks/foundation/system/core_query.js +5 -4
  126. data/frameworks/sproutcore/frameworks/foundation/system/cursor.js +1 -1
  127. data/frameworks/sproutcore/frameworks/foundation/system/render_context.js +22 -7
  128. data/frameworks/sproutcore/frameworks/foundation/system/request.js +466 -309
  129. data/frameworks/sproutcore/frameworks/foundation/system/responder.js +2 -1
  130. data/frameworks/sproutcore/frameworks/foundation/system/response.js +457 -0
  131. data/frameworks/sproutcore/frameworks/foundation/system/root_responder.js +66 -15
  132. data/frameworks/sproutcore/frameworks/foundation/system/routes.js +4 -4
  133. data/frameworks/sproutcore/frameworks/foundation/system/timer.js +6 -4
  134. data/frameworks/sproutcore/frameworks/foundation/system/utils.js +46 -8
  135. data/frameworks/sproutcore/frameworks/foundation/tests/controllers/array/array_case.js +17 -0
  136. data/frameworks/sproutcore/frameworks/foundation/tests/controllers/array/enum_case.js +18 -5
  137. data/frameworks/sproutcore/frameworks/foundation/tests/controllers/array/null_case.js +1 -1
  138. data/frameworks/sproutcore/frameworks/foundation/tests/mixins/staticLayout.js +0 -2
  139. data/frameworks/sproutcore/frameworks/foundation/tests/mixins/string.js +11 -0
  140. data/frameworks/sproutcore/frameworks/foundation/tests/private/tree_item_observer/group_case.js +14 -14
  141. data/frameworks/sproutcore/frameworks/foundation/tests/system/builder.js +2 -2
  142. data/frameworks/sproutcore/frameworks/foundation/tests/system/core_query/jquery_core.js +15 -3
  143. data/frameworks/sproutcore/frameworks/foundation/tests/system/datetime.js +1 -1
  144. data/frameworks/sproutcore/frameworks/foundation/tests/system/locale.js +8 -7
  145. data/frameworks/sproutcore/frameworks/foundation/tests/system/render_context/tag.js +3 -2
  146. data/frameworks/sproutcore/frameworks/foundation/tests/system/request.js +51 -44
  147. data/frameworks/sproutcore/frameworks/foundation/tests/system/root_responder/targetForAction.js +2 -2
  148. data/frameworks/sproutcore/frameworks/foundation/tests/system/timer/isPaused.js +4 -4
  149. data/frameworks/sproutcore/frameworks/foundation/tests/system/timer/performAction.js +2 -0
  150. data/frameworks/sproutcore/frameworks/foundation/tests/validators/credit_card.js +9 -9
  151. data/frameworks/sproutcore/frameworks/foundation/tests/validators/number.js +2 -2
  152. data/frameworks/sproutcore/frameworks/foundation/tests/views/container/ui.js +3 -3
  153. data/frameworks/sproutcore/frameworks/foundation/tests/views/image/ui.js +10 -3
  154. data/frameworks/sproutcore/frameworks/foundation/tests/views/label/ui.js +2 -2
  155. data/frameworks/sproutcore/frameworks/foundation/tests/views/pane/append_remove.js +14 -0
  156. data/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/methods.js +5 -5
  157. data/frameworks/sproutcore/frameworks/foundation/tests/views/text_field/ui.js +1 -11
  158. data/frameworks/sproutcore/frameworks/foundation/tests/views/view/clippingFrame.js +2 -2
  159. data/frameworks/sproutcore/frameworks/foundation/tests/views/view/destroyLayer.js +2 -4
  160. data/frameworks/sproutcore/frameworks/foundation/tests/views/view/findLayerInParentLayer.js +2 -4
  161. data/frameworks/sproutcore/frameworks/foundation/tests/views/view/insertBefore.js +1 -1
  162. data/frameworks/sproutcore/frameworks/foundation/tests/views/view/layoutStyle.js +0 -2
  163. data/frameworks/sproutcore/frameworks/foundation/validators/password.js +5 -5
  164. data/frameworks/sproutcore/frameworks/foundation/validators/validator.js +4 -2
  165. data/frameworks/sproutcore/frameworks/foundation/views/field.js +5 -8
  166. data/frameworks/sproutcore/frameworks/foundation/views/label.js +21 -5
  167. data/frameworks/sproutcore/frameworks/foundation/views/text_field.js +112 -69
  168. data/frameworks/sproutcore/frameworks/foundation/views/view.js +67 -6
  169. data/frameworks/sproutcore/frameworks/runtime/core.js +51 -2
  170. data/frameworks/sproutcore/frameworks/runtime/mixins/observable.js +4 -1
  171. data/frameworks/sproutcore/frameworks/runtime/system/binding.js +2 -1
  172. data/frameworks/sproutcore/frameworks/runtime/system/enumerator.js +5 -4
  173. data/frameworks/sproutcore/frameworks/runtime/system/index_set.js +6 -1
  174. data/frameworks/sproutcore/frameworks/runtime/system/logger.js +408 -0
  175. data/frameworks/sproutcore/frameworks/runtime/system/object.js +15 -4
  176. data/frameworks/sproutcore/frameworks/runtime/system/selection_set.js +30 -2
  177. data/frameworks/sproutcore/frameworks/runtime/tests/core/IsEqual.js +5 -1
  178. data/frameworks/sproutcore/frameworks/runtime/tests/core/beget.js +1 -1
  179. data/frameworks/sproutcore/frameworks/runtime/tests/core/compare.js +3 -3
  180. data/frameworks/sproutcore/frameworks/runtime/tests/core/guidFor.js +2 -0
  181. data/frameworks/sproutcore/frameworks/runtime/tests/core/isArray.js +1 -1
  182. data/frameworks/sproutcore/frameworks/runtime/tests/core/itemType.js +2 -1
  183. data/frameworks/sproutcore/frameworks/runtime/tests/core/tupleForPropertyPath.js +2 -2
  184. data/frameworks/sproutcore/frameworks/runtime/tests/mixins/observable/propertyChanges.js +1 -1
  185. data/frameworks/sproutcore/frameworks/runtime/tests/mixins/propertyChanges.js +1 -0
  186. data/frameworks/sproutcore/frameworks/runtime/tests/system/binding.js +11 -7
  187. data/frameworks/sproutcore/frameworks/runtime/tests/system/error.js +3 -2
  188. data/frameworks/sproutcore/frameworks/runtime/tests/system/index_set/add.js +18 -1
  189. data/frameworks/sproutcore/frameworks/runtime/tests/system/index_set/remove.js +1 -1
  190. data/frameworks/sproutcore/frameworks/runtime/tests/system/logger.js +165 -0
  191. data/frameworks/sproutcore/frameworks/runtime/tests/system/object/bindings.js +3 -0
  192. data/frameworks/sproutcore/frameworks/runtime/tests/system/selection_set/copy.js +1 -1
  193. data/frameworks/sproutcore/frameworks/runtime/tests/system/selection_set/indexSetForSource.js +13 -0
  194. data/frameworks/sproutcore/frameworks/runtime/tests/system/selection_set/remove.js +24 -0
  195. data/frameworks/sproutcore/frameworks/runtime/tests/system/sparse_array.js +32 -13
  196. data/frameworks/sproutcore/frameworks/testing/english.lproj/runner.css +2 -2
  197. data/frameworks/sproutcore/frameworks/testing/english.lproj/testsuite.css +7 -2
  198. data/frameworks/sproutcore/lib/index.rhtml +6 -20
  199. data/frameworks/sproutcore/themes/standard_theme/Source/sc-theme-repeat-x.psd +0 -0
  200. data/frameworks/sproutcore/themes/standard_theme/english.lproj/button.css +0 -1
  201. data/frameworks/sproutcore/themes/standard_theme/english.lproj/checkbox.css +5 -4
  202. data/frameworks/sproutcore/themes/standard_theme/english.lproj/collection.css +4 -3
  203. data/frameworks/sproutcore/themes/standard_theme/english.lproj/disclosure.css +7 -7
  204. data/frameworks/sproutcore/themes/standard_theme/english.lproj/images/sc-theme-repeat-x.png +0 -0
  205. data/frameworks/sproutcore/themes/standard_theme/english.lproj/list_item.css +38 -0
  206. data/frameworks/sproutcore/themes/standard_theme/english.lproj/menu.css +20 -0
  207. data/frameworks/sproutcore/themes/standard_theme/english.lproj/progress.css +1 -0
  208. data/frameworks/sproutcore/themes/standard_theme/english.lproj/radio.css +3 -1
  209. data/frameworks/sproutcore/themes/standard_theme/english.lproj/segmented.css +1 -0
  210. data/frameworks/sproutcore/themes/standard_theme/english.lproj/split_view.css +1 -1
  211. data/frameworks/sproutcore/themes/standard_theme/english.lproj/text_field.css +0 -15
  212. data/gen/data-source/Buildfile +18 -0
  213. data/gen/data-source/README +1 -0
  214. data/gen/data-source/USAGE +15 -0
  215. data/gen/data-source/templates/data_sources/@filename@.js +64 -0
  216. data/lib/sproutcore/builders/combine.rb +23 -0
  217. data/lib/sproutcore/builders/javascript.rb +27 -2
  218. data/lib/sproutcore/buildfile/task.rb +1 -1
  219. data/lib/sproutcore/helpers/entry_sorter.rb +2 -2
  220. data/lib/sproutcore/helpers/static_helper.rb +79 -0
  221. data/lib/sproutcore/models/manifest.rb +2 -2
  222. data/lib/sproutcore/models/target.rb +1 -1
  223. data/lib/sproutcore/tools/build.rb +1 -1
  224. data/lib/sproutcore/tools/docs.rb +3 -3
  225. data/lib/sproutcore/tools/gen.rb +17 -15
  226. data/lib/sproutcore/tools/manifest.rb +9 -9
  227. data/lib/sproutcore/tools/server.rb +3 -3
  228. data/lib/sproutcore/tools.rb +259 -250
  229. data/lib/sproutcore.rb +9 -1
  230. data/spec/buildtasks/manifest/prepare_build_tasks/combine_spec.rb +2 -2
  231. data/spec/fixtures/entry_for_project/frameworks/unrelated/PLACEHOLDER +0 -0
  232. data/spec/fixtures/ordered_entries/apps/no_requires/{lproj → english.lproj}/strings.js +0 -0
  233. data/spec/fixtures/ordered_entries/apps/no_requires/main.js +1 -0
  234. data/spec/fixtures/ordered_entries/apps/no_requires/resources/main_page.js +1 -0
  235. data/spec/fixtures/ordered_entries/apps/no_requires/t.js +1 -0
  236. data/spec/lib/models/manifest/find_entry.rb +12 -0
  237. data/spec/lib/tools/gen_spec.rb +1 -0
  238. data/spec/lib/tools/tools_spec.rb +1 -0
  239. data/sproutcore-abbot.gemspec +36 -44
  240. metadata +43 -44
  241. data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/indicator.gif +0 -0
  242. data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/sc-theme-sprite.png +0 -0
  243. data/frameworks/sproutcore/frameworks/desktop/english.lproj/images/sticky-note.png +0 -0
  244. data/frameworks/sproutcore/frameworks/desktop/views/form.js +0 -594
  245. data/frameworks/sproutcore/themes/standard_theme/english.lproj/images/sc-theme-sprite.png +0 -0
  246. data/lib/thor/CHANGELOG.rdoc +0 -52
  247. data/lib/thor/LICENSE +0 -20
  248. data/lib/thor/README.markdown +0 -76
  249. data/lib/thor/Rakefile +0 -6
  250. data/lib/thor/Thorfile +0 -45
  251. data/lib/thor/bin/rake2thor +0 -83
  252. data/lib/thor/bin/thor +0 -7
  253. data/lib/thor/lib/thor/error.rb +0 -3
  254. data/lib/thor/lib/thor/options.rb +0 -267
  255. data/lib/thor/lib/thor/ordered_hash.rb +0 -64
  256. data/lib/thor/lib/thor/runner.rb +0 -305
  257. data/lib/thor/lib/thor/task.rb +0 -83
  258. data/lib/thor/lib/thor/task_hash.rb +0 -22
  259. data/lib/thor/lib/thor/tasks/package.rb +0 -18
  260. data/lib/thor/lib/thor/tasks.rb +0 -77
  261. data/lib/thor/lib/thor/util.rb +0 -75
  262. data/lib/thor/lib/thor.rb +0 -170
  263. data/lib/thor/script/destroy +0 -14
  264. data/lib/thor/script/generate +0 -14
  265. data/lib/thor/spec/fixtures/task.thor +0 -10
  266. data/lib/thor/spec/options_spec.rb +0 -271
  267. data/lib/thor/spec/ordered_hash_spec.rb +0 -84
  268. data/lib/thor/spec/spec.opts +0 -1
  269. data/lib/thor/spec/spec_helper.rb +0 -30
  270. data/lib/thor/spec/task_spec.rb +0 -11
  271. data/lib/thor/spec/tasks_spec.rb +0 -28
  272. data/lib/thor/spec/thor_runner_spec.rb +0 -194
  273. data/lib/thor/spec/thor_spec.rb +0 -206
  274. data/lib/thor/spec/util_spec.rb +0 -99
  275. data/lib/thor/task.thor +0 -15
  276. data/lib/thor/thor.gemspec +0 -29
@@ -1,76 +0,0 @@
1
- thor
2
- ====
3
-
4
- Map options to a class. Simply create a class with the appropriate annotations, and have options automatically map
5
- to functions and parameters.
6
-
7
- Example:
8
-
9
- class MyApp < Thor # [1]
10
- map "-L" => :list # [2]
11
-
12
- desc "install APP_NAME", "install one of the available apps" # [3]
13
- method_options :force => :boolean, :alias => :optional # [4]
14
- def install(name)
15
- user_alias = options[:alias]
16
- if options.force?
17
- # do something
18
- end
19
- # ... other code ...
20
- end
21
-
22
- desc "list [SEARCH]", "list all of the available apps, limited by SEARCH"
23
- def list(search = "")
24
- # list everything
25
- end
26
- end
27
-
28
- Thor automatically maps commands as such:
29
-
30
- app install myname --force
31
-
32
- That gets converted to:
33
-
34
- MyApp.new.install("myname")
35
- # with {'force' => true} as options hash
36
-
37
- 1. Inherit from Thor to turn a class into an option mapper
38
- 2. Map additional non-valid identifiers to specific methods. In this case,
39
- convert -L to :list
40
- 3. Describe the method immediately below. The first parameter is the usage information,
41
- and the second parameter is the description.
42
- 4. Provide any additional options. These will be marshaled from `--` and `-` params.
43
- In this case, a `--force` and a `-f` option is added.
44
-
45
- Types for `method_options`
46
- --------------------------
47
-
48
- <dl>
49
- <dt><code>:boolean</code></dt>
50
- <dd>true if the option is passed</dd>
51
- <dt><code>true or false</code></dt>
52
- <dd>same as <code>:boolean</code>, but fall back to given boolean as default value</dd>
53
- <dt><code>:required</code></dt>
54
- <dd>the value for this option MUST be provided</dd>
55
- <dt><code>:optional</code></dt>
56
- <dd>the value for this option MAY be provided</dd>
57
- <dt><code>:numeric</code></dt>
58
- <dd>the value MAY be provided, but MUST be in numeric form</dd>
59
- <dt>a String or Numeric</dt>
60
- <dd>same as <code>:optional</code>, but fall back to the given object as default value</dd>
61
- </dl>
62
-
63
- In case of unsatisfied requirements, `Thor::Options::Error` is raised.
64
-
65
- Examples of option parsing:
66
-
67
- # let's say this is how we defined options for a method:
68
- method_options(:force => :boolean, :retries => :numeric)
69
-
70
- # here is how the following command-line invocations would be parsed:
71
-
72
- command -f --retries 5 # => {'force' => true, 'retries' => 5}
73
- command --force -r=5 # => {'force' => true, 'retries' => 5}
74
- command -fr 5 # => {'force' => true, 'retries' => 5}
75
- command --retries=5 # => {'retries' => 5}
76
- command -r5 # => {'retries' => 5}
data/lib/thor/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- task :default => :install
2
-
3
- desc "install the gem locally"
4
- task :install do
5
- sh %{ruby "#{File.dirname(__FILE__)}/bin/thor" :install}
6
- end
data/lib/thor/Thorfile DELETED
@@ -1,45 +0,0 @@
1
- require 'rubygems'
2
- require 'rubygems/specification'
3
- require 'thor/tasks'
4
-
5
- GEM = "thor"
6
- GEM_VERSION = "0.9.9"
7
- AUTHOR = "Yehuda Katz"
8
- EMAIL = "wycats@gmail.com"
9
- HOMEPAGE = "http://yehudakatz.com"
10
- SUMMARY = "A gem that maps options to a class"
11
- PROJECT = "thor"
12
-
13
- SPEC = Gem::Specification.new do |s|
14
- s.name = GEM
15
- s.version = GEM_VERSION
16
- s.platform = Gem::Platform::RUBY
17
- s.has_rdoc = true
18
- s.extra_rdoc_files = ["README.markdown", "LICENSE", "CHANGELOG.rdoc"]
19
- s.summary = SUMMARY
20
- s.description = s.summary
21
- s.author = AUTHOR
22
- s.email = EMAIL
23
- s.homepage = HOMEPAGE
24
- s.rubyforge_project = PROJECT
25
-
26
- s.require_path = 'lib'
27
- s.bindir = "bin"
28
- s.executables = %w( thor rake2thor )
29
- s.files = s.extra_rdoc_files + %w(Rakefile) + Dir.glob("{bin,lib,specs}/**/*")
30
- end
31
-
32
- class Default < Thor
33
- # Set up standard Thortasks
34
- spec_task(Dir["spec/**/*_spec.rb"])
35
- spec_task(Dir["spec/**/*_spec.rb"], :name => "rcov", :rcov =>
36
- {:exclude => %w(spec /Library /Users task.thor lib/getopt.rb)})
37
- install_task SPEC
38
-
39
- desc "gemspec", "make a gemspec file"
40
- def gemspec
41
- File.open("#{GEM}.gemspec", "w") do |file|
42
- file.puts SPEC.to_ruby
43
- end
44
- end
45
- end
@@ -1,83 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
4
- require 'ruby2ruby'
5
- require 'rake'
6
-
7
- input = ARGV[0] || 'Rakefile'
8
- output = ARGV[1] || 'Thorfile'
9
-
10
- $requires = []
11
-
12
- module Kernel
13
- def require_with_record(file)
14
- $requires << file if caller[1] =~ /rake2thor:/
15
- require_without_record file
16
- end
17
- alias_method :require_without_record, :require
18
- alias_method :require, :require_with_record
19
- end
20
-
21
- load input
22
-
23
- @private_methods = []
24
-
25
- def file_task_name(name)
26
- "compile_" + name.gsub('/', '_slash_').gsub('.', '_dot_').gsub(/\W/, '_')
27
- end
28
-
29
- def method_for_task(task)
30
- file_task = task.is_a?(Rake::FileTask)
31
- comment = task.instance_variable_get('@comment')
32
- prereqs = task.instance_variable_get('@prerequisites').select(&Rake::Task.method(:task_defined?))
33
- actions = task.instance_variable_get('@actions')
34
- name = task.name.gsub(/^([^:]+:)+/, '')
35
- name = file_task_name(name) if file_task
36
- meth = ''
37
-
38
- meth << "desc #{name.inspect}, #{comment.inspect}\n" if comment
39
- meth << "def #{name}\n"
40
-
41
- meth << prereqs.map do |pre|
42
- pre = pre.to_s
43
- pre = file_task_name(pre) if Rake::Task[pre].is_a?(Rake::FileTask)
44
- ' ' + pre
45
- end.join("\n")
46
-
47
- meth << "\n\n" unless prereqs.empty? || actions.empty?
48
-
49
- meth << actions.map do |act|
50
- act = act.to_ruby
51
- unless act.gsub!(/^proc \{ \|(\w+)\|\n/,
52
- " \\1 = Struct.new(:name).new(#{name.inspect}) # A crude mock Rake::Task object\n")
53
- act.gsub!(/^proc \{\n/, '')
54
- end
55
- act.gsub(/\n\}$/, '')
56
- end.join("\n")
57
-
58
- meth << "\nend"
59
-
60
- if file_task
61
- @private_methods << meth
62
- return
63
- end
64
-
65
- meth
66
- end
67
-
68
- body = Rake::Task.tasks.map(&method(:method_for_task)).compact.map { |meth| meth.gsub(/^/, ' ') }.join("\n\n")
69
-
70
- unless @private_methods.empty?
71
- body << "\n\n private\n\n"
72
- body << @private_methods.map { |meth| meth.gsub(/^/, ' ') }.join("\n\n")
73
- end
74
-
75
- requires = $requires.map { |r| "require #{r.inspect}" }.join("\n")
76
-
77
- File.open(output, 'w') { |f| f.write(<<END.lstrip) }
78
- #{requires}
79
-
80
- class Default < Thor
81
- #{body}
82
- end
83
- END
data/lib/thor/bin/thor DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # -*- mode: ruby -*-
3
-
4
- require File.dirname(__FILE__) + "/../lib/thor"
5
- require 'thor/runner'
6
-
7
- Thor::Runner.start
@@ -1,3 +0,0 @@
1
- class Thor
2
- class Error < Exception; end
3
- end
@@ -1,267 +0,0 @@
1
- # This is a modified version of Daniel Berger's Getopt::Long class,
2
- # licensed under Ruby's license.
3
-
4
- class Thor
5
- class Options
6
- class Error < StandardError; end
7
-
8
- # simple Hash with indifferent access
9
- class Hash < ::Hash
10
- def initialize(hash)
11
- super()
12
- update hash
13
- end
14
-
15
- def [](key)
16
- super convert_key(key)
17
- end
18
-
19
- def values_at(*indices)
20
- indices.collect { |key| self[convert_key(key)] }
21
- end
22
-
23
- protected
24
- def convert_key(key)
25
- key.kind_of?(Symbol) ? key.to_s : key
26
- end
27
-
28
- # Magic predicates. For instance:
29
- # options.force? # => !!options['force']
30
- def method_missing(method, *args, &block)
31
- method = method.to_s
32
- if method =~ /^(\w+)=$/
33
- self[$1] = args.first
34
- elsif method =~ /^(\w+)\?$/
35
- !!self[$1]
36
- else
37
- self[method]
38
- end
39
- end
40
- end
41
-
42
- NUMERIC = /(\d*\.\d+|\d+)/
43
- LONG_RE = /^(--\w+[-\w+]*)$/
44
- SHORT_RE = /^(-[a-z])$/i
45
- EQ_RE = /^(--\w+[-\w+]*|-[a-z])=(.*)$/i
46
- SHORT_SQ_RE = /^-([a-z]{2,})$/i # Allow either -x -v or -xv style for single char args
47
- SHORT_NUM = /^(-[a-z])#{NUMERIC}$/i
48
-
49
- attr_reader :leading_non_opts, :trailing_non_opts
50
-
51
- def non_opts
52
- leading_non_opts + trailing_non_opts
53
- end
54
-
55
- # Takes an array of switches. Each array consists of up to three
56
- # elements that indicate the name and type of switch. Returns a hash
57
- # containing each switch name, minus the '-', as a key. The value
58
- # for each key depends on the type of switch and/or the value provided
59
- # by the user.
60
- #
61
- # The long switch _must_ be provided. The short switch defaults to the
62
- # first letter of the short switch. The default type is :boolean.
63
- #
64
- # Example:
65
- #
66
- # opts = Thor::Options.new(
67
- # "--debug" => true,
68
- # ["--verbose", "-v"] => true,
69
- # ["--level", "-l"] => :numeric
70
- # ).parse(args)
71
- #
72
- def initialize(switches)
73
- @defaults = {}
74
- @shorts = {}
75
-
76
- @leading_non_opts, @trailing_non_opts = [], []
77
-
78
- @switches = switches.inject({}) do |mem, (name, type)|
79
- if name.is_a?(Array)
80
- name, *shorts = name
81
- else
82
- name = name.to_s
83
- shorts = []
84
- end
85
- # we need both nice and dasherized form of switch name
86
- if name.index('-') == 0
87
- nice_name = undasherize name
88
- else
89
- nice_name = name
90
- name = dasherize name
91
- end
92
- # if there are no shortcuts specified, generate one using the first character
93
- shorts << "-" + nice_name[0,1] if shorts.empty? and nice_name.length > 1
94
- shorts.each { |short| @shorts[short] = name }
95
-
96
- # normalize type
97
- case type
98
- when TrueClass
99
- @defaults[nice_name] = true
100
- type = :boolean
101
- when FalseClass
102
- @defaults[nice_name] = false
103
- type = :boolean
104
- when String
105
- @defaults[nice_name] = type
106
- type = :optional
107
- when Numeric
108
- @defaults[nice_name] = type
109
- type = :numeric
110
- end
111
-
112
- mem[name] = type
113
- mem
114
- end
115
-
116
- # remove shortcuts that happen to coincide with any of the main switches
117
- @shorts.keys.each do |short|
118
- @shorts.delete(short) if @switches.key?(short)
119
- end
120
- end
121
-
122
- def parse(args, skip_leading_non_opts = true)
123
- @args = args
124
- # start with Thor::Options::Hash pre-filled with defaults
125
- hash = Hash.new @defaults
126
-
127
- @leading_non_opts = []
128
- if skip_leading_non_opts
129
- @leading_non_opts << shift until current_is_option? || @args.empty?
130
- end
131
-
132
- while current_is_option?
133
- case shift
134
- when SHORT_SQ_RE
135
- unshift $1.split('').map { |f| "-#{f}" }
136
- next
137
- when EQ_RE, SHORT_NUM
138
- unshift $2
139
- switch = $1
140
- when LONG_RE, SHORT_RE
141
- switch = $1
142
- end
143
-
144
- switch = normalize_switch(switch)
145
- nice_name = undasherize(switch)
146
- type = switch_type(switch)
147
-
148
- case type
149
- when :required
150
- assert_value!(switch)
151
- raise Error, "cannot pass switch '#{peek}' as an argument" if valid?(peek)
152
- hash[nice_name] = shift
153
- when :optional
154
- hash[nice_name] = peek.nil? || valid?(peek) || shift
155
- when :boolean
156
- if !@switches.key?(switch) && nice_name =~ /^no-(\w+)$/
157
- hash[$1] = false
158
- else
159
- hash[nice_name] = true
160
- end
161
-
162
- when :numeric
163
- assert_value!(switch)
164
- unless peek =~ NUMERIC and $& == peek
165
- raise Error, "expected numeric value for '#{switch}'; got #{peek.inspect}"
166
- end
167
- hash[nice_name] = $&.index('.') ? shift.to_f : shift.to_i
168
- end
169
- end
170
-
171
- @trailing_non_opts = @args
172
-
173
- check_required! hash
174
- hash.freeze
175
- hash
176
- end
177
-
178
- def formatted_usage
179
- return "" if @switches.empty?
180
- @switches.map do |opt, type|
181
- case type
182
- when :boolean
183
- "[#{opt}]"
184
- when :required
185
- opt + "=" + opt.gsub(/\-/, "").upcase
186
- else
187
- sample = @defaults[undasherize(opt)]
188
- sample ||= case type
189
- when :optional then undasherize(opt).gsub(/\-/, "_").upcase
190
- when :numeric then "N"
191
- end
192
- "[" + opt + "=" + sample.to_s + "]"
193
- end
194
- end.join(" ")
195
- end
196
-
197
- alias :to_s :formatted_usage
198
-
199
- private
200
-
201
- def assert_value!(switch)
202
- raise Error, "no value provided for argument '#{switch}'" if peek.nil?
203
- end
204
-
205
- def undasherize(str)
206
- str.sub(/^-{1,2}/, '')
207
- end
208
-
209
- def dasherize(str)
210
- (str.length > 1 ? "--" : "-") + str
211
- end
212
-
213
- def peek
214
- @args.first
215
- end
216
-
217
- def shift
218
- @args.shift
219
- end
220
-
221
- def unshift(arg)
222
- unless arg.kind_of?(Array)
223
- @args.unshift(arg)
224
- else
225
- @args = arg + @args
226
- end
227
- end
228
-
229
- def valid?(arg)
230
- if arg.to_s =~ /^--no-(\w+)$/
231
- @switches.key?(arg) or (@switches["--#{$1}"] == :boolean)
232
- else
233
- @switches.key?(arg) or @shorts.key?(arg)
234
- end
235
- end
236
-
237
- def current_is_option?
238
- case peek
239
- when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM
240
- valid?($1)
241
- when SHORT_SQ_RE
242
- $1.split('').any? { |f| valid?("-#{f}") }
243
- end
244
- end
245
-
246
- def normalize_switch(switch)
247
- @shorts.key?(switch) ? @shorts[switch] : switch
248
- end
249
-
250
- def switch_type(switch)
251
- if switch =~ /^--no-(\w+)$/
252
- @switches[switch] || @switches["--#{$1}"]
253
- else
254
- @switches[switch]
255
- end
256
- end
257
-
258
- def check_required!(hash)
259
- for name, type in @switches
260
- if type == :required and !hash[undasherize(name)]
261
- raise Error, "no value provided for required argument '#{name}'"
262
- end
263
- end
264
- end
265
-
266
- end
267
- end
@@ -1,64 +0,0 @@
1
- class Thor
2
- # This class is based on the Ruby 1.9 ordered hashes.
3
- # It keeps the semantics and most of the efficiency of normal hashes
4
- # while also keeping track of the order in which elements were set.
5
- class OrderedHash
6
- Node = Struct.new(:key, :value, :next, :prev)
7
- include Enumerable
8
-
9
- def initialize
10
- @hash = {}
11
- end
12
-
13
- def initialize_copy(other)
14
- @hash = other.instance_variable_get('@hash').clone
15
- end
16
-
17
- def [](key)
18
- @hash[key] && @hash[key].value
19
- end
20
-
21
- def []=(key, value)
22
- node = Node.new(key, value)
23
-
24
- if old = @hash[key]
25
- if old.prev
26
- old.prev.next = old.next
27
- else # old is @first and @last
28
- @first = @last = nil
29
- end
30
- end
31
-
32
- if @first.nil?
33
- @first = @last = node
34
- else
35
- node.prev = @last
36
- @last.next = node
37
- @last = node
38
- end
39
-
40
- @hash[key] = node
41
- value
42
- end
43
-
44
- def each
45
- return unless @first
46
- yield [@first.key, @first.value]
47
- node = @first
48
- yield [node.key, node.value] while node = node.next
49
- self
50
- end
51
-
52
- def values
53
- self.map { |k, v| v }
54
- end
55
-
56
- def +(other)
57
- new = clone
58
- other.each do |key, value|
59
- new[key] = value unless self[key]
60
- end
61
- new
62
- end
63
- end
64
- end