shoes 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (275) hide show
  1. data/.gitignore +12 -0
  2. data/CHANGELOG +29 -0
  3. data/COPYING +30 -0
  4. data/README.md +76 -0
  5. data/README.old +117 -0
  6. data/Rakefile +130 -0
  7. data/Rakefile.bk +651 -0
  8. data/app.yaml +7 -0
  9. data/bin/main.skel +104 -0
  10. data/bugs/issue-012e9468ddc7b0cb7e1503413a8a11c4f8707b67.yaml +21 -0
  11. data/bugs/issue-0711ff8b67baa63586f11d0096fee9dd4436bf58.yaml +23 -0
  12. data/bugs/issue-07f87998d93eb401e22395c11085676389b935c4.yaml +22 -0
  13. data/bugs/issue-0bff2d80008803cbc7efbcdacdc60ef2163664d2.yaml +22 -0
  14. data/bugs/issue-0c66f223d19efbca7b692f3b91961f407ad7abec.yaml +24 -0
  15. data/bugs/issue-183bc3c7a8f575aff2b24e0bf22aa0dfcc8e4fc2.yaml +29 -0
  16. data/bugs/issue-1bad1e60a04cb3adb6a8f3ded128af2e16b56ffe.yaml +18 -0
  17. data/bugs/issue-1f1d43f76bf4de79d7f94adbae6dd506a9d81633.yaml +41 -0
  18. data/bugs/issue-320924117cadb045cc91f2a6fca922b4d81d4bb5.yaml +20 -0
  19. data/bugs/issue-33e5c8355fbf65252ea9e939714651df8bd8cb3b.yaml +25 -0
  20. data/bugs/issue-36f7c8262a72bcd5e28cfa4ed29328b8237ea79b.yaml +20 -0
  21. data/bugs/issue-39bf04ee50c3bef67b89b8e9beb28657805587ce.yaml +18 -0
  22. data/bugs/issue-3e28ba7754f73d02ef416eef989af707a8c00f01.yaml +23 -0
  23. data/bugs/issue-3f638cc03f41f9c3fdf217355321f1563f8fee45.yaml +22 -0
  24. data/bugs/issue-41e48e14f1ef4f6deb69be68165d7dd3ffd99156.yaml +22 -0
  25. data/bugs/issue-4c9408166a2aa5dd333bbb05520deebf4ded08e0.yaml +22 -0
  26. data/bugs/issue-55c687e108ecd5aeb8e0d0aeb4294984f84acd3e.yaml +18 -0
  27. data/bugs/issue-5811d34692cc292717a58ec1df1f8948cf30d826.yaml +28 -0
  28. data/bugs/issue-5a7c1f59a0526f9cea7fb366867cf1e6ed8ef69d.yaml +22 -0
  29. data/bugs/issue-688a2c2566bef6a03efa57a4ae1f7cfa8fc74444.yaml +21 -0
  30. data/bugs/issue-78b16c7988ade2ef96e716fa8cb9a004bd4ced65.yaml +33 -0
  31. data/bugs/issue-804ee49f9800154eddf0650690c7a9bb5626253f.yaml +27 -0
  32. data/bugs/issue-807dd1c610b2e941a5d454e26b2eac27e89a0ab4.yaml +22 -0
  33. data/bugs/issue-822ee33ec11ebd25f90ea86e8438de7891e63aee.yaml +18 -0
  34. data/bugs/issue-82ff7152cebb8a1cb065b864cb4fe22de2328146.yaml +29 -0
  35. data/bugs/issue-856afbdcdd4970ad54b8ce4a6c017fbaab45f49d.yaml +31 -0
  36. data/bugs/issue-8d49e32fb21522651c67490adb4d80076dbb14e1.yaml +24 -0
  37. data/bugs/issue-91583359653a9d530c1e32be72d874d847a306e7.yaml +21 -0
  38. data/bugs/issue-af41a5229613172764e7d3c98431172db337053d.yaml +20 -0
  39. data/bugs/issue-bd9856b3788dd429c998a5af1b2aae8221cb80b7.yaml +28 -0
  40. data/bugs/issue-be22aef5c564fb7b5e9938343136a9cd6a2edb7b.yaml +22 -0
  41. data/bugs/issue-bf8697523c77c326e7e35fc82cf3dd739ae92310.yaml +27 -0
  42. data/bugs/issue-cdd4b4795f34d6ff46e56ece10f8216a4a5456b2.yaml +25 -0
  43. data/bugs/issue-d9bfb5581d745ef9deb3b9b2e08ef74d1cd43082.yaml +20 -0
  44. data/bugs/issue-e0ce2f687cc096f35715d28b0af88589f4ab6cc6.yaml +18 -0
  45. data/bugs/issue-e4b0aca4a10a574b333aeaecaaf221dbc5ed22c6.yaml +38 -0
  46. data/bugs/issue-f263746594b95ba778455730478ee8df60ee639d.yaml +22 -0
  47. data/bugs/project.yaml +72 -0
  48. data/builddeps.sh +102 -0
  49. data/fonts/Coolvetica.ttf +0 -0
  50. data/fonts/Lacuna.ttf +0 -0
  51. data/gemlib/shoes.rb +1 -0
  52. data/lib/shoes.rb +548 -0
  53. data/lib/shoes/cache.rb +54 -0
  54. data/lib/shoes/chipmunk.rb +35 -0
  55. data/lib/shoes/data.rb +39 -0
  56. data/lib/shoes/help.rb +468 -0
  57. data/lib/shoes/image.rb +25 -0
  58. data/lib/shoes/inspect.rb +128 -0
  59. data/lib/shoes/log.rb +48 -0
  60. data/lib/shoes/minitar.rb +986 -0
  61. data/lib/shoes/override.rb +38 -0
  62. data/lib/shoes/pack.rb +543 -0
  63. data/lib/shoes/search.rb +46 -0
  64. data/lib/shoes/setup.rb +329 -0
  65. data/lib/shoes/shy.rb +131 -0
  66. data/lib/shoes/shybuilder.rb +44 -0
  67. data/lib/shoes/version.rb +3 -0
  68. data/make/darwin/deps.vlc +12 -0
  69. data/make/darwin/dylibs.shoes +22 -0
  70. data/make/darwin/dylibs.video +11 -0
  71. data/make/darwin/env.rb +81 -0
  72. data/make/darwin/tasks.rb +105 -0
  73. data/make/linux/env.rb +65 -0
  74. data/make/linux/tasks.rb +61 -0
  75. data/make/make.rb +85 -0
  76. data/make/mingw/dlls +19 -0
  77. data/make/mingw/env.rb +69 -0
  78. data/make/mingw/tasks.rb +70 -0
  79. data/make/rakefile_common.rb +8 -0
  80. data/manual-snapshots/class-book.png +0 -0
  81. data/manual-snapshots/expert-definr.png +0 -0
  82. data/manual-snapshots/expert-funnies.png +0 -0
  83. data/manual-snapshots/expert-irb.png +0 -0
  84. data/manual-snapshots/expert-minesweeper.png +0 -0
  85. data/manual-snapshots/expert-othello.png +0 -0
  86. data/manual-snapshots/expert-pong.png +0 -0
  87. data/manual-snapshots/expert-tankspank.png +0 -0
  88. data/manual-snapshots/good-arc.png +0 -0
  89. data/manual-snapshots/good-clock.png +0 -0
  90. data/manual-snapshots/good-follow.png +0 -0
  91. data/manual-snapshots/good-reminder.png +0 -0
  92. data/manual-snapshots/good-vjot.png +0 -0
  93. data/manual-snapshots/simple-accordion.png +0 -0
  94. data/manual-snapshots/simple-anim-shapes.png +0 -0
  95. data/manual-snapshots/simple-anim-text.png +0 -0
  96. data/manual-snapshots/simple-arc.png +0 -0
  97. data/manual-snapshots/simple-bounce.png +0 -0
  98. data/manual-snapshots/simple-calc.png +0 -0
  99. data/manual-snapshots/simple-chipmunk.png +0 -0
  100. data/manual-snapshots/simple-control-sizes.png +0 -0
  101. data/manual-snapshots/simple-curve.png +0 -0
  102. data/manual-snapshots/simple-dialogs.png +0 -0
  103. data/manual-snapshots/simple-downloader.png +0 -0
  104. data/manual-snapshots/simple-draw.png +0 -0
  105. data/manual-snapshots/simple-editor.png +0 -0
  106. data/manual-snapshots/simple-form.png +0 -0
  107. data/manual-snapshots/simple-mask.png +0 -0
  108. data/manual-snapshots/simple-menu.png +0 -0
  109. data/manual-snapshots/simple-menu1.png +0 -0
  110. data/manual-snapshots/simple-rubygems.png +0 -0
  111. data/manual-snapshots/simple-slide.png +0 -0
  112. data/manual-snapshots/simple-sphere.png +0 -0
  113. data/manual-snapshots/simple-sqlite3.png +0 -0
  114. data/manual-snapshots/simple-timer.png +0 -0
  115. data/manual-snapshots/simple-video.png +0 -0
  116. data/platform/mac/Info.plist +55 -0
  117. data/platform/mac/build-deps.sh +658 -0
  118. data/platform/mac/command-manual.rb +1 -0
  119. data/platform/mac/deps-osx.patch +159 -0
  120. data/platform/mac/dmg_ds_store +0 -0
  121. data/platform/mac/pangorc +2 -0
  122. data/platform/mac/pkg-dmg +1447 -0
  123. data/platform/mac/shoes +31 -0
  124. data/platform/mac/shoes-launch +7 -0
  125. data/platform/mac/stub.m +178 -0
  126. data/platform/mac/version.plist +14 -0
  127. data/platform/msw/base.nsi +644 -0
  128. data/platform/msw/installer-1.bmp +0 -0
  129. data/platform/msw/installer-2.bmp +0 -0
  130. data/platform/msw/shoes.exe.manifest +17 -0
  131. data/platform/msw/shoes.ico +0 -0
  132. data/platform/msw/stub-inject.c +59 -0
  133. data/platform/msw/stub.c +271 -0
  134. data/platform/msw/stub32.h +14 -0
  135. data/platform/msw/stub32.rc +16 -0
  136. data/platform/nix/INSTALL +56 -0
  137. data/platform/nix/Makefile +144 -0
  138. data/platform/nix/shoes.launch +20 -0
  139. data/platform/skel.rb +27 -0
  140. data/rakefile_darwin.rb +7 -0
  141. data/rakefile_linux.rb +3 -0
  142. data/rakefile_mingw.rb +7 -0
  143. data/samples/class-book.rb +43 -0
  144. data/samples/class-book.yaml +387 -0
  145. data/samples/expert-definr.rb +23 -0
  146. data/samples/expert-funnies.rb +51 -0
  147. data/samples/expert-irb.rb +112 -0
  148. data/samples/expert-minesweeper.rb +267 -0
  149. data/samples/expert-othello.rb +319 -0
  150. data/samples/expert-pong.rb +62 -0
  151. data/samples/expert-tankspank.rb +385 -0
  152. data/samples/good-arc.rb +37 -0
  153. data/samples/good-clock.rb +51 -0
  154. data/samples/good-follow.rb +26 -0
  155. data/samples/good-reminder.rb +174 -0
  156. data/samples/good-vjot.rb +56 -0
  157. data/samples/simple-accordion.rb +75 -0
  158. data/samples/simple-anim-shapes.rb +17 -0
  159. data/samples/simple-anim-text.rb +13 -0
  160. data/samples/simple-arc.rb +23 -0
  161. data/samples/simple-bounce.rb +24 -0
  162. data/samples/simple-calc.rb +70 -0
  163. data/samples/simple-chipmunk.rb +26 -0
  164. data/samples/simple-control-sizes.rb +24 -0
  165. data/samples/simple-curve.rb +26 -0
  166. data/samples/simple-dialogs.rb +29 -0
  167. data/samples/simple-downloader.rb +27 -0
  168. data/samples/simple-draw.rb +13 -0
  169. data/samples/simple-editor.rb +28 -0
  170. data/samples/simple-form.rb +28 -0
  171. data/samples/simple-form.shy +0 -0
  172. data/samples/simple-mask.rb +21 -0
  173. data/samples/simple-menu.rb +31 -0
  174. data/samples/simple-menu1.rb +35 -0
  175. data/samples/simple-rubygems.rb +29 -0
  176. data/samples/simple-slide.rb +45 -0
  177. data/samples/simple-sphere.rb +28 -0
  178. data/samples/simple-sqlite3.rb +13 -0
  179. data/samples/simple-timer.rb +13 -0
  180. data/samples/simple-video.rb +13 -0
  181. data/shoes.gemspec +21 -0
  182. data/shoes/app.c +591 -0
  183. data/shoes/app.h +110 -0
  184. data/shoes/appwin32.h +13 -0
  185. data/shoes/appwin32.rc +28 -0
  186. data/shoes/canvas.c +2202 -0
  187. data/shoes/canvas.h +682 -0
  188. data/shoes/code.h +14 -0
  189. data/shoes/config.h +232 -0
  190. data/shoes/effects.c +243 -0
  191. data/shoes/effects.h +7 -0
  192. data/shoes/http.h +44 -0
  193. data/shoes/http/common.h +86 -0
  194. data/shoes/http/curl.c +259 -0
  195. data/shoes/http/nsurl.m +274 -0
  196. data/shoes/http/windownload.c +114 -0
  197. data/shoes/http/winhttp.c +216 -0
  198. data/shoes/http/winhttp.h +19 -0
  199. data/shoes/image.c +1020 -0
  200. data/shoes/internal.c +46 -0
  201. data/shoes/internal.h +63 -0
  202. data/shoes/native.h +110 -0
  203. data/shoes/native/cocoa.h +105 -0
  204. data/shoes/native/cocoa.m +1557 -0
  205. data/shoes/native/gtk.c +1257 -0
  206. data/shoes/native/windows.c +2392 -0
  207. data/shoes/ruby.c +5221 -0
  208. data/shoes/ruby.h +299 -0
  209. data/shoes/world.c +243 -0
  210. data/shoes/world.h +63 -0
  211. data/static/Shoes.icns +0 -0
  212. data/static/avatar.png +0 -0
  213. data/static/code_highlighter.js +188 -0
  214. data/static/code_highlighter_ruby.js +26 -0
  215. data/static/icon-debug.png +0 -0
  216. data/static/icon-error.png +0 -0
  217. data/static/icon-info.png +0 -0
  218. data/static/icon-warn.png +0 -0
  219. data/static/listbox_button1.png +0 -0
  220. data/static/listbox_button2.png +0 -0
  221. data/static/man-app.png +0 -0
  222. data/static/man-builds.png +0 -0
  223. data/static/man-builds1.png +0 -0
  224. data/static/man-editor-notepad.png +0 -0
  225. data/static/man-editor-osx.png +0 -0
  226. data/static/man-ele-background.png +0 -0
  227. data/static/man-ele-border.png +0 -0
  228. data/static/man-ele-button.png +0 -0
  229. data/static/man-ele-check.png +0 -0
  230. data/static/man-ele-editbox.png +0 -0
  231. data/static/man-ele-editline.png +0 -0
  232. data/static/man-ele-image.png +0 -0
  233. data/static/man-ele-listbox.png +0 -0
  234. data/static/man-ele-progress.png +0 -0
  235. data/static/man-ele-radio.png +0 -0
  236. data/static/man-ele-shape.png +0 -0
  237. data/static/man-ele-textblock.png +0 -0
  238. data/static/man-ele-video.png +0 -0
  239. data/static/man-intro-dmg.png +0 -0
  240. data/static/man-intro-exe.png +0 -0
  241. data/static/man-look-tiger.png +0 -0
  242. data/static/man-look-ubuntu.png +0 -0
  243. data/static/man-look-vista.png +0 -0
  244. data/static/man-run-osx.png +0 -0
  245. data/static/man-run-vista.png +0 -0
  246. data/static/man-run-xp.png +0 -0
  247. data/static/man-shot1.png +0 -0
  248. data/static/manual-en.txt +3531 -0
  249. data/static/manual-ja.txt +2825 -0
  250. data/static/manual.css +167 -0
  251. data/static/menu-corner1.png +0 -0
  252. data/static/menu-corner2.png +0 -0
  253. data/static/menu-gray.png +0 -0
  254. data/static/menu-left.png +0 -0
  255. data/static/menu-right.png +0 -0
  256. data/static/menu-top.png +0 -0
  257. data/static/shoes-dmg.jpg +0 -0
  258. data/static/shoes-icon-blue.png +0 -0
  259. data/static/shoes-icon.png +0 -0
  260. data/static/shoes-manual-apps.gif +0 -0
  261. data/static/shoes_main_window.png +0 -0
  262. data/static/stripe.png +0 -0
  263. data/static/stubs/blank.exe +0 -0
  264. data/static/stubs/blank.hfz +0 -0
  265. data/static/stubs/blank.run +375 -0
  266. data/static/stubs/cocoa-install +0 -0
  267. data/static/stubs/sh-install +49 -0
  268. data/static/stubs/shoes-stub-inject.exe +0 -0
  269. data/static/stubs/shoes-stub.exe +0 -0
  270. data/static/tutor-back.png +0 -0
  271. data/test/shoes_test.rb +8 -0
  272. data/test/test_helper.rb +25 -0
  273. data/use-deps +12 -0
  274. data/use-tmp-dep +8 -0
  275. metadata +509 -0
@@ -0,0 +1,46 @@
1
+ require 'ftsearch/fragment_writer'
2
+ require 'ftsearch/analysis/simple_identifier_analyzer'
3
+ #require 'ftsearchrt'
4
+
5
+ class Shoes::Search
6
+ include FTSearch
7
+ attr_reader :index
8
+ def initialize fields = [:uri, :body]
9
+ field_infos = FTSearch::FieldInfos.new
10
+ fields.each do |name|
11
+ field_infos.add_field :name => name,
12
+ :analyzer => FTSearch::Analysis::SimpleIdentifierAnalyzer.new
13
+ end
14
+ @index = FTSearch::FragmentWriter.new :path => nil, :field_infos => field_infos
15
+ end
16
+ def add_document hsh
17
+ @index.add_document hsh
18
+ end
19
+ def finish!
20
+ @index.finish!
21
+
22
+ @ft = FulltextReader.new :io => StringIO.new(@index.fulltext_writer.data)
23
+ @sa = SuffixArrayReader.new @ft, nil, :io => StringIO.new(@index.suffix_array_writer.data)
24
+ @dm = DocumentMapReader.new :io => StringIO.new(@index.doc_map_writer.data)
25
+ end
26
+ def find_all terms, show = 20, prob_sort = false
27
+ h = Hash.new{|h,k| h[k] = 0}
28
+ weights = Hash.new(1.0)
29
+ weights[0] = 10000000 # :uri
30
+ weights[1] = 10000000 # :body
31
+ hits = @sa.find_all terms
32
+ size = hits.size
33
+ if prob_sort && size > 10000
34
+ iterations = 50 * Math.sqrt(size)
35
+ offsets = @sa.lazyhits_to_offsets(hits)
36
+ weight_arr = weights.sort_by{|id,w| id}.map{|_,v| v}
37
+ sorted = @dm.rank_offsets_probabilistic(offsets, weight_arr, iterations)
38
+ else
39
+ offsets = @sa.lazyhits_to_offsets(hits)
40
+ sorted = @dm.rank_offsets(offsets, weights.sort_by{|id,w| id}.map{|_,v| v})
41
+ end
42
+ sorted[0..show].map do |doc_id, count|
43
+ [@dm.document_id_to_uri(doc_id), count]
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,329 @@
1
+ require 'rubygems'
2
+ require 'rubygems/dependency_installer'
3
+ module Gem
4
+ @ruby = (File.join(Config::CONFIG['bindir'], 'shoes') + Config::CONFIG['EXEEXT']).
5
+ sub(/.*\s.*/m, '"\&"') + " --ruby"
6
+ end
7
+ class << Gem::Ext::ExtConfBuilder
8
+ alias_method :make__, :make
9
+ def make(dest_path, results)
10
+ raise unless File.exist?('Makefile')
11
+ mf = File.read('Makefile')
12
+ mf = mf.gsub(/^INSTALL\s*=\s*.*$/, "INSTALL = $(RUBY) -run -e install -- -vp")
13
+ mf = mf.gsub(/^INSTALL_PROG\s*=\s*.*$/, "INSTALL_PROG = $(INSTALL) -m 0755")
14
+ mf = mf.gsub(/^INSTALL_DATA\s*=\s*.*$/, "INSTALL_DATA = $(INSTALL) -m 0644")
15
+ File.open('Makefile', 'wb') {|f| f.print mf}
16
+ make__(dest_path, results)
17
+ end
18
+ end
19
+
20
+ # STDIN.reopen("/dev/tty") if STDIN.eof?
21
+ class NotSupportedByShoes < Exception; end
22
+
23
+ class Shoes::Setup
24
+
25
+ def self.init
26
+ gem_reset
27
+ install_sources if Gem.source_index.find_name('sources').empty?
28
+ end
29
+
30
+ def self.gem_reset
31
+ Gem.use_paths(GEM_DIR, [GEM_DIR, GEM_CENTRAL_DIR])
32
+ Gem.source_index.refresh!
33
+ end
34
+
35
+ def self.setup_app(setup)
36
+ appt = "Setting up for #{setup.script}"
37
+ Shoes.app :width => 370, :height => 158, :resizable => false, :title => appt do
38
+ background "#EEE".."#9AA"
39
+ image :top => 0, :left => 0 do
40
+ stroke "#FFF"; strokewidth 0.1
41
+ (0..158).step(3) { |i| line 0, i, 370, i }
42
+ end
43
+ @pulse = stack :top => 0, :left => 0
44
+ @logo = image "#{DIR}/static/shoes-icon-blue.png", :top => -20, :right => -20
45
+ stack :margin => 18 do
46
+ title "Shoes Setup", :size => 12, :weight => "bold", :margin => 0
47
+ para "Preparing #{setup.script}", :size => 8, :margin => 0, :margin_top => 8, :width => 220
48
+ @pr = progress :width => 1.0, :top => 70, :height => 20
49
+ button "Cancel", :top => 98, :left => 0.4 do
50
+ self.close
51
+ end
52
+
53
+ start do
54
+ @th =
55
+ Thread.start(self.app) do |app|
56
+ begin
57
+ setup.start(app)
58
+ rescue => e
59
+ puts e.message
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ animate 10 do |i|
66
+ i %= 10
67
+ @pulse.clear do
68
+ fill black(0.2 - (i * 0.02))
69
+ strokewidth(3.0 - (i * 0.2))
70
+ stroke rgb(0.7, 0.7, 0.9, 1.0 - (i * 0.1))
71
+ oval(@logo.left - i, @logo.top - i, @logo.width + (i * 2))
72
+ end
73
+ @pr.fraction = $fraction
74
+ if @script
75
+ Shoes.visit(@script)
76
+ close
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ attr_accessor :steps, :script
83
+
84
+ def initialize(script, &blk)
85
+ @steps = []
86
+ @script = script
87
+ instance_eval &blk
88
+ unless no_steps?
89
+ app = self.class.setup_app(self)
90
+ end
91
+ end
92
+
93
+ def no_steps?
94
+ (@steps.map { |s| s[0] }.uniq - [:source]).empty?
95
+ end
96
+
97
+ def gem name, version = nil
98
+ arg = "#{name} #{version}".strip
99
+ name, version = arg.split(/\s+/, 2)
100
+ if Gem.source_index.find_name(name, version).empty?
101
+ @steps << [:gem, arg]
102
+ else
103
+ activate_gem(name, version)
104
+ end
105
+ end
106
+
107
+ def source uri
108
+ @steps << [:source, uri]
109
+ end
110
+
111
+ def activate_gem(name, version)
112
+ gem = Gem.source_index.find_name(name, version).first
113
+ Gem.activate(gem.name, "= #{gem.version}")
114
+ end
115
+
116
+ def start(app)
117
+ old_ui = Gem::DefaultUserInteraction.ui
118
+ ui = Gem::DefaultUserInteraction.ui = Gem::ShoesFace.new(app)
119
+ count, total = 0.5, @steps.length
120
+ ui.progress count, total
121
+
122
+ steps.each do |act, arg|
123
+ case act
124
+ when :gem
125
+ name, version = arg.split(/\s+/, 2)
126
+ count += 1
127
+ ui.say "Looking for #{name}"
128
+ if Gem.source_index.find_name(name, version).empty?
129
+ ui.title "Installing #{name}"
130
+ installer = Gem::DependencyInstaller.new
131
+ begin
132
+ installer.install(name, version || Gem::Requirement.default)
133
+ self.class.gem_reset
134
+ activate_gem(name, version)
135
+ ui.say "Finished installing #{name}"
136
+ rescue Object => e
137
+ ui.error "while installing #{name}", e
138
+ raise e
139
+ end
140
+ end
141
+ when :source
142
+ ui.title "Switching Gem servers"
143
+ ui.say "Pulling from #{arg}"
144
+ Gem.sources.clear << arg
145
+ self.class.gem_reset
146
+ end
147
+ ui.progress count, total
148
+ end
149
+ Gem::DefaultUserInteraction.ui = old_ui
150
+ app.instance_variable_set("@script", @script)
151
+ end
152
+
153
+ def svn(dir, save_as = nil, &blk)
154
+ dir.gsub! /(.)\/*$/, '\1/'
155
+ if save_as.nil? or save_as.empty?
156
+ save_as = File.join(GEM_DIR, 'svn', '1')
157
+ save_as.succ! while File.exists? save_as
158
+ elsif save_as.index(GEM_DIR) != 0
159
+ save_as = File.join(GEM_DIR, 'svn', save_as)
160
+ end
161
+ mkdir_p(save_as)
162
+ puts "** Pulling down #{dir}..."
163
+ svnuri = URI.parse(dir)
164
+ case svnuri.scheme
165
+ when "http", "https"
166
+ REXML::Document.new(svnuri.open { |f| f.read }).
167
+ each_element("/svn/index/*") do |ele|
168
+ fname, href = ele.attributes['name'], ele.attributes['href']
169
+ case ele.name
170
+ when "file"
171
+ puts "- #{dir}#{href}"
172
+ URI.parse("#{dir}#{href}").open do |f|
173
+ File.open(File.join(save_as, fname), 'wb') do |f2|
174
+ f2 << f.read(16384) until f.eof?
175
+ end
176
+ end
177
+ when "dir"
178
+ svn("#{dir}#{href}", File.join(save_as, fname))
179
+ end
180
+ end
181
+ else
182
+ raise NotSupportedByShoes, "Only HTTP addresses are supported by Shoes's Subversion module."
183
+ end
184
+ if blk
185
+ Dir.chdir(save_as, &blk)
186
+ end
187
+ end
188
+
189
+ def self.install_sources
190
+ require 'base64'
191
+ sources_gem = File.join(LIB_DIR, "sources-0.0.1.gem")
192
+ File.open(sources_gem, "wb") do |f|
193
+ f << Base64.decode64( <<-GEM.gsub(/^ +/, '') )
194
+ ZGF0YS50YXIuZ3oAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
259
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
260
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
261
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
262
+ AAAAAAAAAAAAAAAA
263
+ GEM
264
+ end
265
+ Gem::Installer.new(sources_gem).install()
266
+ end
267
+ end
268
+
269
+ class Gem::ShoesFace
270
+ class ProgressReporter
271
+ attr_reader :count
272
+
273
+ def initialize(prog, status, size, initial_message,
274
+ terminal_message = "complete")
275
+ @prog = prog
276
+ (@status = status).replace initial_message
277
+ @total = size
278
+ @count = 0.0
279
+ end
280
+
281
+ def updated(message)
282
+ @count += 1.0
283
+ @prog.fraction = (@count / @total.to_f) * 0.5
284
+ end
285
+
286
+ def done
287
+ end
288
+ end
289
+
290
+ def initialize app
291
+ @title, @status, @prog, = app.slot.contents[-1].contents
292
+ end
293
+ def title msg
294
+ @title.replace msg
295
+ end
296
+ def progress count, total
297
+ #@prog.fraction = count.to_f / total.to_f
298
+ $fraction = count.to_f / total.to_f
299
+ end
300
+ def ask_yes_no msg
301
+ Kernel.confirm(msg)
302
+ end
303
+ def ask msg
304
+ Kernel.ask(msg)
305
+ end
306
+ def error msg, e
307
+ stat = @status
308
+ stat.app do
309
+ error(e)
310
+ stat.replace link("Error") { Shoes.show_log }, " ", msg
311
+ end
312
+ end
313
+ def say msg
314
+ @status.replace msg
315
+ end
316
+ def alert msg, quiz=nil
317
+ say(msg)
318
+ ask(quiz) if quiz
319
+ end
320
+ def progress_reporter(*args)
321
+ ProgressReporter.new(@prog, @status, *args)
322
+ end
323
+ def method_missing(*args)
324
+ p args
325
+ nil
326
+ end
327
+ end
328
+
329
+ Shoes::Setup.init
@@ -0,0 +1,131 @@
1
+ #
2
+ # lib/shoes/shy.rb
3
+ # Shy, the Shoes YAML archive format
4
+ #
5
+ require 'digest/md5'
6
+ require 'zlib'
7
+ require 'shoes/minitar'
8
+ require 'find'
9
+ require 'tmpdir'
10
+ require 'yaml'
11
+
12
+ class Shy
13
+ VERSION = 0x0001
14
+ MAGIC = "_shy".freeze
15
+ LAYOUT = "A4vV".freeze #Force to Little Endian for all platforms
16
+
17
+ yaml_as 'tag:hackety.org,2007:shy'
18
+ attr_accessor :name, :creator, :version, :launch
19
+
20
+ def self.launchable(d)
21
+ if File.directory? d
22
+ Dir["#{d}/**/*.rb"].map do |path|
23
+ path.gsub(%r!#{Regexp::quote(d)}/!, '')
24
+ end
25
+ else
26
+ [File.basename(d)]
27
+ end
28
+ end
29
+
30
+ def self.__hdr__(f)
31
+ hdr = f.read(10).unpack(LAYOUT)
32
+ raise IOError, "Invalid header" if hdr[0] != MAGIC and hdr[1] > VERSION
33
+ YAML.load(f.read(hdr[2]))
34
+ end
35
+
36
+
37
+ def self.du(root)
38
+ size = 0
39
+ Find.find(root) do |path|
40
+ if FileTest.directory?(path)
41
+ if File.basename(path)[0] == ?.
42
+ Find.prune
43
+ else
44
+ next
45
+ end
46
+ else
47
+ size += FileTest.size(path)
48
+ end
49
+ end
50
+ size
51
+ end
52
+
53
+ def self.meta(path, d = ".")
54
+ File.open(path, 'rb') do |f|
55
+ shy = __hdr__(f)
56
+ end
57
+ end
58
+
59
+ def self.x(path, d = ".")
60
+ File.open(path, 'rb') do |f|
61
+ shy = __hdr__(f)
62
+ inp = Zlib::GzipReader.new(f)
63
+ Archive::Tar::Minitar.unpack(inp, d)
64
+ shy
65
+ end
66
+ end
67
+
68
+ def self.c(path, shy, d, &blk)
69
+ path = File.expand_path(path)
70
+ meta = shy.to_yaml
71
+ File.open(path, "wb") do |f|
72
+ f << [MAGIC, VERSION, meta.length].pack(LAYOUT)
73
+ f << meta
74
+ self.czf(f, d, &blk)
75
+ end
76
+ end
77
+
78
+ def self.progress(total, &blk)
79
+ if blk
80
+ last, left = 0.0, total
81
+ proc do |action, name, stats|
82
+ if action == :file_progress
83
+ left -= stats[:currinc]
84
+ prg = 1.0 - (left.to_f / total.to_f)
85
+ blk[name, (last = prg), left] if prg - last > 0.02
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ def self.czf(f, d, &blk)
92
+ total = du(d)
93
+ out = Zlib::GzipWriter.new(f)
94
+ files = ["."]
95
+ unless File.directory? d
96
+ files = [File.basename(d)]
97
+ d = File.dirname(d)
98
+ end
99
+ Dir.chdir(d) do
100
+ Archive::Tar::Minitar.pack(files, out, &blk)
101
+ end
102
+ end
103
+
104
+ def self.xzf(f, d, &blk)
105
+ gz = Zlib::GzipReader.new(f)
106
+ Archive::Tar::Minitar.unpack(gz, d, &blk)
107
+ end
108
+
109
+ def self.md5sum(path)
110
+ digest = Digest::MD5.new
111
+ File.open(path, "rb") do |f|
112
+ digest.update f.read(8192) until f.eof
113
+ end
114
+ digest.hexdigest
115
+ end
116
+
117
+ def self.hrun(f)
118
+ b, i = 0, 1
119
+ last = 65535
120
+ while i < last
121
+ case f.readline
122
+ when /OLDSKIP=(\d+)/
123
+ last = $1.to_i
124
+ when /FULLSIZE=(\d+)/
125
+ b = $1.to_i
126
+ end
127
+ i += 1
128
+ end
129
+ b
130
+ end
131
+ end