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,305 +0,0 @@
1
- require 'thor'
2
- require "thor/util"
3
- require "open-uri"
4
- require "fileutils"
5
- require "yaml"
6
- require "digest/md5"
7
- require "readline"
8
-
9
- class Thor::Runner < Thor
10
-
11
- def self.globs_for(path)
12
- ["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
13
- end
14
-
15
- map "-T" => :list, "-i" => :install, "-u" => :update
16
-
17
- desc "install NAME", "install a Thor file into your system tasks, optionally named for future updates"
18
- method_options :as => :optional, :relative => :boolean
19
- def install(name)
20
- initialize_thorfiles
21
-
22
- base = name
23
- package = :file
24
-
25
- begin
26
- if File.directory?(File.expand_path(name))
27
- base, package = File.join(name, "main.thor"), :directory
28
- contents = open(base).read
29
- else
30
- contents = open(name).read
31
- end
32
- rescue OpenURI::HTTPError
33
- raise Error, "Error opening URI `#{name}'"
34
- rescue Errno::ENOENT
35
- raise Error, "Error opening file `#{name}'"
36
- end
37
-
38
- is_uri = File.exist?(name) ? false : true
39
-
40
- puts "Your Thorfile contains: "
41
- puts contents
42
- print "Do you wish to continue [y/N]? "
43
- response = Readline.readline
44
-
45
- return false unless response =~ /^\s*y/i
46
-
47
- constants = Thor::Util.constants_in_contents(contents, base)
48
-
49
- as = options["as"] || begin
50
- first_line = contents.split("\n")[0]
51
- (match = first_line.match(/\s*#\s*module:\s*([^\n]*)/)) ? match[1].strip : nil
52
- end
53
-
54
- if !as
55
- print "Please specify a name for #{name} in the system repository [#{name}]: "
56
- as = Readline.readline
57
- as = name if as.empty?
58
- end
59
-
60
- FileUtils.mkdir_p thor_root
61
-
62
- yaml_file = File.join(thor_root, "thor.yml")
63
- FileUtils.touch(yaml_file)
64
- yaml = thor_yaml
65
-
66
- location = (options[:relative] || is_uri) ? name : File.expand_path(name)
67
- yaml[as] = {:filename => Digest::MD5.hexdigest(name + as), :location => location, :constants => constants}
68
-
69
- save_yaml(yaml)
70
-
71
- puts "Storing thor file in your system repository"
72
-
73
- destination = File.join(thor_root, yaml[as][:filename])
74
-
75
- if package == :file
76
- File.open(destination, "w") {|f| f.puts contents }
77
- else
78
- FileUtils.cp_r(name, destination)
79
- end
80
-
81
- yaml[as][:filename] # Indicate sucess
82
- end
83
-
84
- desc "uninstall NAME", "uninstall a named Thor module"
85
- def uninstall(name)
86
- yaml = thor_yaml
87
- raise Error, "Can't find module `#{name}'" unless yaml[name]
88
-
89
- puts "Uninstalling #{name}."
90
-
91
- file = File.join(thor_root, "#{yaml[name][:filename]}")
92
- FileUtils.rm_rf(file)
93
- yaml.delete(name)
94
- save_yaml(yaml)
95
-
96
- puts "Done."
97
- end
98
-
99
- desc "update NAME", "update a Thor file from its original location"
100
- def update(name)
101
- yaml = thor_yaml
102
- raise Error, "Can't find module `#{name}'" if !yaml[name] || !yaml[name][:location]
103
-
104
- puts "Updating `#{name}' from #{yaml[name][:location]}"
105
- old_filename = yaml[name][:filename]
106
- self.options = self.options.merge("as" => name)
107
- filename = install(yaml[name][:location])
108
- unless filename == old_filename
109
- File.delete(File.join(thor_root, old_filename))
110
- end
111
- end
112
-
113
- desc "installed", "list the installed Thor modules and tasks (--internal means list the built-in tasks as well)"
114
- method_options :internal => :boolean
115
- def installed
116
- thor_root_glob.each do |f|
117
- next if f =~ /thor\.yml$/
118
- load_thorfile f unless Thor.subclass_files.keys.include?(File.expand_path(f))
119
- end
120
-
121
- klasses = Thor.subclasses
122
- klasses -= [Thor, Thor::Runner] unless options['internal']
123
- display_klasses(true, klasses)
124
- end
125
-
126
- desc "list [SEARCH]", "list the available thor tasks (--substring means SEARCH can be anywhere in the module)"
127
- method_options :substring => :boolean,
128
- :group => :optional,
129
- :all => :boolean
130
- def list(search = "")
131
- initialize_thorfiles
132
- search = ".*#{search}" if options["substring"]
133
- search = /^#{search}.*/i
134
- group = options[:group] || 'standard'
135
-
136
- classes = Thor.subclasses.select do |k|
137
- (options[:all] || k.group_name == group) &&
138
- Thor::Util.constant_to_thor_path(k.name) =~ search
139
- end
140
- display_klasses(false, classes)
141
- end
142
-
143
- # Override Thor#help so we can give info about not-yet-loaded tasks
144
- def help(task = nil)
145
- initialize_thorfiles(task) if task && task.include?(?:)
146
- super
147
- end
148
-
149
- def method_missing(meth, *args)
150
- meth = meth.to_s
151
- super(meth.to_sym, *args) unless meth.include? ?:
152
-
153
- initialize_thorfiles(meth)
154
- task = Thor[meth]
155
- task.parse task.klass.new, ARGV[1..-1]
156
- end
157
-
158
- def self.thor_root
159
- File.join(ENV["HOME"] || ENV["APPDATA"], ".thor")
160
- end
161
-
162
- def self.thor_root_glob
163
- # On Windows thor_root will be something like this:
164
- #
165
- # C:\Documents and Settings\james\.thor
166
- #
167
- # If we don't #gsub the \ character, Dir.glob will fail.
168
- files = Dir["#{thor_root.gsub(/\\/, '/')}/*"]
169
- files.map! do |file|
170
- File.directory?(file) ? File.join(file, "main.thor") : file
171
- end
172
- end
173
-
174
- private
175
- def thor_root
176
- self.class.thor_root
177
- end
178
-
179
- def thor_root_glob
180
- self.class.thor_root_glob
181
- end
182
-
183
- def thor_yaml
184
- yaml_file = File.join(thor_root, "thor.yml")
185
- yaml = YAML.load_file(yaml_file) if File.exists?(yaml_file)
186
- yaml || {}
187
- end
188
-
189
- def save_yaml(yaml)
190
- yaml_file = File.join(thor_root, "thor.yml")
191
- File.open(yaml_file, "w") {|f| f.puts yaml.to_yaml }
192
- end
193
-
194
- def display_klasses(with_modules = false, klasses = Thor.subclasses)
195
- klasses -= [Thor, Thor::Runner] unless with_modules
196
- raise Error, "No Thor tasks available" if klasses.empty?
197
-
198
- if with_modules && !(yaml = thor_yaml).empty?
199
- max_name = yaml.max {|(xk,xv),(yk,yv)| xk.to_s.size <=> yk.to_s.size }.first.size
200
- modules_label = "Modules"
201
- namespaces_label = "Namespaces"
202
- column_width = [max_name + 4, modules_label.size + 1].max
203
-
204
- print "%-#{column_width}s" % modules_label
205
- puts namespaces_label
206
- print "%-#{column_width}s" % ("-" * modules_label.size)
207
- puts "-" * namespaces_label.size
208
-
209
- yaml.each do |name, info|
210
- print "%-#{column_width}s" % name
211
- puts info[:constants].map {|c| Thor::Util.constant_to_thor_path(c)}.join(", ")
212
- end
213
-
214
- puts
215
- end
216
-
217
- # Calculate the largest base class name
218
- max_base = klasses.max do |x,y|
219
- Thor::Util.constant_to_thor_path(x.name).size <=> Thor::Util.constant_to_thor_path(y.name).size
220
- end.name.size
221
-
222
- # Calculate the size of the largest option description
223
- max_left_item = klasses.max do |x,y|
224
- (x.maxima.usage + x.maxima.opt).to_i <=> (y.maxima.usage + y.maxima.opt).to_i
225
- end
226
-
227
- max_left = max_left_item.maxima.usage + max_left_item.maxima.opt
228
-
229
- unless klasses.empty?
230
- puts # add some spacing
231
- klasses.each { |k| display_tasks(k, max_base, max_left); }
232
- else
233
- puts "\033[1;34mNo Thor tasks available\033[0m"
234
- end
235
- end
236
-
237
- def display_tasks(klass, max_base, max_left)
238
- if klass.tasks.values.length > 1
239
-
240
- base = Thor::Util.constant_to_thor_path(klass.name)
241
-
242
- if base.to_a.empty?
243
- base = 'default'
244
- puts "\033[1;35m#{base}\033[0m"
245
- else
246
- puts "\033[1;34m#{base}\033[0m"
247
- end
248
- puts "-" * base.length
249
-
250
- klass.tasks.each true do |name, task|
251
- format_string = "%-#{max_left + max_base + 5}s"
252
- print format_string % task.formatted_usage(true)
253
- puts task.description
254
- end
255
-
256
- unless klass.opts.empty?
257
- puts "\nglobal options: #{Options.new(klass.opts)}"
258
- end
259
-
260
- puts # add some spacing
261
- end
262
- end
263
-
264
- def initialize_thorfiles(relevant_to = nil)
265
- thorfiles(relevant_to).each {|f| load_thorfile f unless Thor.subclass_files.keys.include?(File.expand_path(f))}
266
- end
267
-
268
- def load_thorfile(path)
269
- txt = File.read(path)
270
- begin
271
- Thor::Tasks.class_eval txt, path
272
- rescue Object => e
273
- $stderr.puts "WARNING: unable to load thorfile #{path.inspect}: #{e.message}"
274
- end
275
- end
276
-
277
- def thorfiles(relevant_to = nil)
278
- path = Dir.pwd
279
- thorfiles = []
280
-
281
- # Look for Thorfile or *.thor in the current directory or a parent directory, until the root
282
- while thorfiles.empty?
283
- thorfiles = Thor::Runner.globs_for(path).map {|g| Dir[g]}.flatten
284
- path = File.dirname(path)
285
- break if path == "/"
286
- end
287
-
288
- # We want to load system-wide Thorfiles first
289
- # so the local Thorfiles will override them.
290
- files = (relevant_to ? thorfiles_relevant_to(relevant_to) :
291
- thor_root_glob) + thorfiles - ["#{thor_root}/thor.yml"]
292
-
293
- files.map! do |file|
294
- File.directory?(file) ? File.join(file, "main.thor") : file
295
- end
296
- end
297
-
298
- def thorfiles_relevant_to(meth)
299
- klass_str = Thor::Util.to_constant(meth.split(":")[0...-1].join(":"))
300
- thor_yaml.select do |k, v|
301
- v[:constants] && v[:constants].include?(klass_str)
302
- end.map { |k, v| File.join(thor_root, "#{v[:filename]}") }
303
- end
304
-
305
- end
@@ -1,83 +0,0 @@
1
- require 'thor/error'
2
- require 'thor/util'
3
-
4
- class Thor
5
- class Task < Struct.new(:meth, :description, :usage, :opts, :klass)
6
-
7
- def self.dynamic(meth, klass)
8
- new(meth, "A dynamically-generated task", meth.to_s, nil, klass)
9
- end
10
-
11
- def initialize(*args)
12
- # keep the original opts - we need them later on
13
- @options = args[3] || {}
14
- super
15
- end
16
-
17
- def parse(obj, args)
18
- list, hash = parse_args(args)
19
- obj.options = hash
20
- run(obj, *list)
21
- end
22
-
23
- def run(obj, *params)
24
- raise NoMethodError, "the `#{meth}' task of #{obj.class} is private" if
25
- (obj.private_methods + obj.protected_methods).include?(meth)
26
-
27
- obj.invoke(meth, *params)
28
- rescue ArgumentError => e
29
-
30
- # backtrace sans anything in this file
31
- backtrace = e.backtrace.reject {|frame| frame =~ /^#{Regexp.escape(__FILE__)}/}
32
- # also nix anything in thor.rb
33
- backtrace = backtrace.reject { |frame| frame =~ /\/thor.rb/ }
34
-
35
- # and sans anything that got us here
36
- backtrace -= caller
37
- raise e unless backtrace.empty?
38
-
39
- # okay, they really did call it wrong
40
- raise Error, "`#{meth}' was called incorrectly. Call as `#{formatted_usage}'"
41
- rescue NoMethodError => e
42
- begin
43
- raise e unless e.message =~ /^undefined method `#{meth}' for #{Regexp.escape(obj.inspect)}$/
44
- rescue
45
- raise e
46
- end
47
- raise Error, "The #{namespace false} namespace doesn't have a `#{meth}' task"
48
- end
49
-
50
- def namespace(remove_default = true)
51
- Thor::Util.constant_to_thor_path(klass, remove_default)
52
- end
53
-
54
- def with_klass(klass)
55
- new = self.dup
56
- new.klass = klass
57
- new
58
- end
59
-
60
- def opts
61
- return super unless super.kind_of? Hash
62
- @_opts ||= Options.new(super)
63
- end
64
-
65
- def full_opts
66
- @_full_opts ||= Options.new((klass.opts || {}).merge(@options))
67
- end
68
-
69
- def formatted_usage(namespace = false)
70
- (namespace ? self.namespace + ':' : '') + usage +
71
- (opts ? " " + opts.formatted_usage : "")
72
- end
73
-
74
- protected
75
-
76
- def parse_args(args)
77
- return [[], {}] if args.nil?
78
- hash = full_opts.parse(args)
79
- list = full_opts.non_opts
80
- [list, hash]
81
- end
82
- end
83
- end
@@ -1,22 +0,0 @@
1
- require 'thor/ordered_hash'
2
- require 'thor/task'
3
-
4
- class Thor::TaskHash < Thor::OrderedHash
5
- def initialize(klass)
6
- super()
7
- @klass = klass
8
- end
9
-
10
- def each(local = false, &block)
11
- super() { |k, t| yield k, t.with_klass(@klass) }
12
- @klass.superclass.tasks.each { |k, t| yield k, t.with_klass(@klass) } unless local || @klass == Thor
13
- end
14
-
15
- def [](name)
16
- if task = super(name) || (@klass == Thor && @klass.superclass.tasks[name])
17
- return task.with_klass(@klass)
18
- end
19
-
20
- Thor::Task.dynamic(name, @klass)
21
- end
22
- end
@@ -1,18 +0,0 @@
1
- require "thor/task"
2
-
3
- class Thor::PackageTask < Thor::Task
4
- attr_accessor :spec
5
- attr_accessor :opts
6
-
7
- def initialize(gemspec, opts = {})
8
- super(:package, "build a gem package")
9
- @spec = gemspec
10
- @opts = {:dir => File.join(Dir.pwd, "pkg")}.merge(opts)
11
- end
12
-
13
- def run
14
- FileUtils.mkdir_p(@opts[:dir])
15
- Gem::Builder.new(spec).build
16
- FileUtils.mv(spec.file_name, File.join(@opts[:dir], spec.file_name))
17
- end
18
- end
@@ -1,77 +0,0 @@
1
- require "thor"
2
- require "fileutils"
3
-
4
- class Thor
5
- def self.package_task(spec)
6
- desc "package", "package up the gem"
7
- define_method :package do
8
- FileUtils.mkdir_p(File.join(Dir.pwd, "pkg"))
9
- Gem::Builder.new(spec).build
10
- FileUtils.mv(spec.file_name, File.join(Dir.pwd, "pkg", spec.file_name))
11
- end
12
- end
13
-
14
- def self.install_task(spec)
15
- package_task spec
16
-
17
- null, sudo, gem = RUBY_PLATFORM =~ /w(in)?32$/ ? ['NUL', '', 'gem.bat'] :
18
- ['/dev/null', 'sudo', 'gem']
19
-
20
- desc "install", "install the gem"
21
- define_method :install do
22
- old_stderr, $stderr = $stderr.dup, File.open(null, "w")
23
- package
24
- $stderr = old_stderr
25
- system %{#{sudo} #{Gem.ruby} -S #{gem} install pkg/#{spec.name}-#{spec.version} --no-rdoc --no-ri --no-update-sources}
26
- end
27
- end
28
-
29
- def self.spec_task(file_list, opts = {})
30
- name = opts.delete(:name) || "spec"
31
- rcov_dir = opts.delete(:rcov_dir) || "coverage"
32
- file_list = file_list.map {|f| %["#{f}"]}.join(" ")
33
- verbose = opts.delete(:verbose)
34
- opts = {:format => "specdoc", :color => true}.merge(opts)
35
-
36
- rcov_opts = convert_task_options(opts.delete(:rcov) || {})
37
- rcov = !rcov_opts.empty?
38
- options = convert_task_options(opts)
39
-
40
- if rcov
41
- FileUtils.rm_rf(File.join(Dir.pwd, rcov_dir))
42
- end
43
-
44
- desc(name, "spec task")
45
- define_method(name) do
46
- cmd = "ruby "
47
- if rcov
48
- cmd << "-S rcov -o #{rcov_dir} #{rcov_opts} "
49
- end
50
- cmd << `which spec`.chomp
51
- cmd << " -- " if rcov
52
- cmd << " "
53
- cmd << file_list
54
- cmd << " "
55
- cmd << options
56
- puts cmd if verbose
57
- system(cmd)
58
- exit($?.exitstatus)
59
- end
60
- end
61
-
62
- private
63
- def self.convert_task_options(opts)
64
- opts.map do |key, value|
65
- case value
66
- when true
67
- "--#{key}"
68
- when Array
69
- value.map {|v| "--#{key} #{v.inspect}"}.join(" ")
70
- when nil, false
71
- ""
72
- else
73
- "--#{key} #{value.inspect}"
74
- end
75
- end.join(" ")
76
- end
77
- end
@@ -1,75 +0,0 @@
1
- require 'thor/error'
2
-
3
- module ObjectSpace
4
-
5
- class << self
6
-
7
- # @return <Array[Class]> All the classes in the object space.
8
- def classes
9
- klasses = []
10
- ObjectSpace.each_object(Class) {|o| klasses << o}
11
- klasses
12
- end
13
- end
14
-
15
- end
16
-
17
- class Thor
18
- module Tasks; end
19
-
20
- module Util
21
-
22
- def self.full_const_get(obj, name)
23
- list = name.split("::")
24
- list.shift if list.first.empty?
25
- list.each do |x|
26
- # This is required because const_get tries to look for constants in the
27
- # ancestor chain, but we only want constants that are HERE
28
- obj = obj.const_defined?(x) ? obj.const_get(x) : obj.const_missing(x)
29
- end
30
- obj
31
- end
32
-
33
- def self.constant_to_thor_path(str, remove_default = true)
34
- str = str.to_s.gsub(/^Thor::Tasks::/, "")
35
- str = snake_case(str).squeeze(":")
36
- str.gsub!(/^default/, '') if remove_default
37
- str
38
- end
39
-
40
- def self.constant_from_thor_path(str)
41
- make_constant(to_constant(str))
42
- rescue NameError => e
43
- raise e unless e.message =~ /^uninitialized constant (.*)$/
44
- raise Error, "There was no available namespace `#{str}'."
45
- end
46
-
47
- def self.to_constant(str)
48
- str = 'default' if str.empty?
49
- str.gsub(/:(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
50
- end
51
-
52
- def self.constants_in_contents(str, file = __FILE__)
53
- klasses = ObjectSpace.classes.dup
54
- Module.new.class_eval(str, file)
55
- klasses = ObjectSpace.classes - klasses
56
- klasses = klasses.select {|k| k < Thor }
57
- klasses.map! {|k| k.to_s.gsub(/#<Module:\w+>::/, '')}
58
- end
59
-
60
- def self.make_constant(str, base = [Thor::Tasks, Object])
61
- which = base.find do |obj|
62
- full_const_get(obj, str) rescue nil
63
- end
64
- return full_const_get(which, str) if which
65
- raise NameError, "uninitialized constant #{str}"
66
- end
67
-
68
- def self.snake_case(str)
69
- return str.downcase if str =~ /^[A-Z_]+$/
70
- str.gsub(/\B[A-Z]/, '_\&').squeeze('_') =~ /_*(.*)/
71
- return $+.downcase
72
- end
73
-
74
- end
75
- end