Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Delete RedShoes-ey files and stuff. Left in Shoesrb.com website-relat…

…ed files.
  • Loading branch information...
commit 3b1e400ac94704ce8eba83bffab4e41a9fc5d955 1 parent 8cc914b
@pjfitzgibbons pjfitzgibbons authored
Showing with 3 additions and 32,957 deletions.
  1. +3 −0  CHANGELOG
  2. +0 −7 app.yaml
  3. +0 −104 bin/main.skel
  4. +0 −1  gemlib/shoes.rb
  5. +0 −554 lib/red_shoes.rb
  6. +0 −55 lib/red_shoes/cache.rb
  7. +0 −35 lib/red_shoes/chipmunk.rb
  8. +0 −39 lib/red_shoes/data.rb
  9. +0 −468 lib/red_shoes/help.rb
  10. +0 −25 lib/red_shoes/image.rb
  11. +0 −128 lib/red_shoes/inspect.rb
  12. +0 −48 lib/red_shoes/log.rb
  13. +0 −986 lib/red_shoes/minitar.rb
  14. +0 −38 lib/red_shoes/override.rb
  15. +0 −543 lib/red_shoes/pack.rb
  16. +0 −46 lib/red_shoes/search.rb
  17. +0 −329 lib/red_shoes/setup.rb
  18. +0 −131 lib/red_shoes/shy.rb
  19. +0 −44 lib/red_shoes/shybuilder.rb
  20. +0 −3  lib/red_shoes/version.rb
  21. +0 −12 make/darwin/deps.vlc
  22. +0 −11 make/darwin/dylibs.video
  23. +0 −71 make/darwin/env.rb
  24. +0 −104 make/darwin/homebrew.rb
  25. +0 −116 make/darwin/tasks.rb
  26. +0 −49 make/linux/env.rb
  27. +0 −66 make/linux/tasks.rb
  28. +0 −85 make/make.rb
  29. +0 −19 make/mingw/dlls
  30. +0 −51 make/mingw/env.rb
  31. +0 −69 make/mingw/tasks.rb
  32. +0 −55 platform/mac/Info.plist
  33. +0 −658 platform/mac/build-deps.sh
  34. +0 −1  platform/mac/command-manual.rb
  35. +0 −159 platform/mac/deps-osx.patch
  36. BIN  platform/mac/dmg_ds_store
  37. +0 −3  platform/mac/pangorc
  38. +0 −1,447 platform/mac/pkg-dmg
  39. +0 −31 platform/mac/shoes
  40. +0 −9 platform/mac/shoes-launch
  41. +0 −178 platform/mac/stub.m
  42. +0 −14 platform/mac/version.plist
  43. +0 −644 platform/msw/base.nsi
  44. BIN  platform/msw/installer-1.bmp
  45. BIN  platform/msw/installer-2.bmp
  46. +0 −17 platform/msw/shoes.exe.manifest
  47. BIN  platform/msw/shoes.ico
  48. +0 −59 platform/msw/stub-inject.c
  49. +0 −271 platform/msw/stub.c
  50. +0 −14 platform/msw/stub32.h
  51. +0 −16 platform/msw/stub32.rc
  52. +0 −53 platform/nix/INSTALL
  53. +0 −136 platform/nix/Makefile
  54. +0 −20 platform/nix/shoes.launch
  55. +0 −27 platform/skel.rb
  56. +0 −7 rakefile_darwin.rb
  57. +0 −2  rakefile_linux.rb
  58. +0 −6 rakefile_mingw.rb
  59. +0 −674 req/binject/ext/binject_c/LICENSE
  60. +0 −187 req/binject/ext/binject_c/Makefile
  61. +0 −19 req/binject/ext/binject_c/README
  62. +0 −317 req/binject/ext/binject_c/abstractfile.c
  63. +0 −183 req/binject/ext/binject_c/base64.c
  64. +0 −889 req/binject/ext/binject_c/binject.c
  65. +0 −1,533 req/binject/ext/binject_c/btree.c
  66. +0 −1,082 req/binject/ext/binject_c/catalog.c
  67. +0 −313 req/binject/ext/binject_c/checksum.c
  68. +0 −236 req/binject/ext/binject_c/dmgfile.c
  69. +0 −455 req/binject/ext/binject_c/dmglib.c
  70. +0 −7 req/binject/ext/binject_c/extconf.rb
  71. +0 −119 req/binject/ext/binject_c/extents.c
  72. +0 −418 req/binject/ext/binject_c/fastunicodecompare.c
  73. +0 −264 req/binject/ext/binject_c/filevault.c
  74. +0 −104 req/binject/ext/binject_c/flatfile.c
  75. +0 −545 req/binject/ext/binject_c/hfslib.c
  76. +0 −70 req/binject/ext/binject_c/includes/abstractfile.h
  77. +0 −75 req/binject/ext/binject_c/includes/common.h
  78. +0 −343 req/binject/ext/binject_c/includes/dmg/dmg.h
  79. +0 −21 req/binject/ext/binject_c/includes/dmg/dmgfile.h
  80. +0 −19 req/binject/ext/binject_c/includes/dmg/dmglib.h
  81. +0 −98 req/binject/ext/binject_c/includes/dmg/filevault.h
  82. +0 −23 req/binject/ext/binject_c/includes/hfs/hfslib.h
  83. +0 −508 req/binject/ext/binject_c/includes/hfs/hfsplus.h
  84. +0 −48 req/binject/ext/binject_c/includes/xpwn/8900.h
  85. +0 −46 req/binject/ext/binject_c/includes/xpwn/ibootim.h
  86. +0 −34 req/binject/ext/binject_c/includes/xpwn/img2.h
  87. +0 −71 req/binject/ext/binject_c/includes/xpwn/img3.h
  88. +0 −5 req/binject/ext/binject_c/includes/xpwn/lzss.h
  89. +0 −27 req/binject/ext/binject_c/includes/xpwn/lzssfile.h
  90. +0 −20 req/binject/ext/binject_c/includes/xpwn/nor_files.h
  91. +0 −28 req/binject/ext/binject_c/includes/xpwn/outputstate.h
  92. +0 −70 req/binject/ext/binject_c/includes/xpwn/plist.h
  93. +0 −20 req/binject/ext/binject_c/includes/xpwn/pwnutil.h
  94. +0 −226 req/binject/ext/binject_c/io.c
  95. +0 −4 req/binject/ext/binject_c/mkhfz
  96. +0 −22 req/binject/ext/binject_c/mkmf.log
  97. +0 −788 req/binject/ext/binject_c/partition.c
  98. +0 −224 req/binject/ext/binject_c/pe.h
  99. +0 −491 req/binject/ext/binject_c/rawfile.c
  100. +0 −850 req/binject/ext/binject_c/resources.c
  101. +0 −129 req/binject/ext/binject_c/udif.c
  102. +0 −30 req/binject/ext/binject_c/utility.c
  103. +0 −162 req/binject/ext/binject_c/volume.c
  104. +0 −27 req/bloopsaphone/COPYING
  105. +0 −172 req/bloopsaphone/README
  106. +0 −504 req/bloopsaphone/c/bloopsaphone.c
  107. +0 −100 req/bloopsaphone/c/bloopsaphone.h
  108. +0 −1,209 req/bloopsaphone/c/notation.c
  109. +0 −187 req/bloopsaphone/ext/bloops/Makefile
  110. +0 −504 req/bloopsaphone/ext/bloops/bloopsaphone.c
  111. +0 −100 req/bloopsaphone/ext/bloops/bloopsaphone.h
  112. +0 −13 req/bloopsaphone/ext/bloops/extconf.rb
  113. +0 −22 req/bloopsaphone/ext/bloops/mkmf.log
  114. +0 −1,209 req/bloopsaphone/ext/bloops/notation.c
  115. +0 −314 req/bloopsaphone/ext/bloops/rubyext.c
  116. +0 −10 req/bloopsaphone/sounds/dart.blu
  117. +0 −13 req/bloopsaphone/sounds/error.blu
  118. +0 −5 req/bloopsaphone/sounds/ice.blu
  119. +0 −8 req/bloopsaphone/sounds/jump.blu
  120. +0 −19 req/bloopsaphone/sounds/pogo.blu
  121. +0 −6 req/bloopsaphone/sounds/stun.blu
  122. +0 −20 req/chipmunk/LICENSE
  123. +0 −40 req/chipmunk/README
  124. +0 −9 req/chipmunk/README_for_Shoes.txt
  125. +0 −187 req/chipmunk/ext/chipmunk/Makefile
  126. +0 −69 req/chipmunk/ext/chipmunk/chipmunk.c
  127. +0 −91 req/chipmunk/ext/chipmunk/chipmunk.h
  128. +0 −263 req/chipmunk/ext/chipmunk/cpArbiter.c
  129. +0 −85 req/chipmunk/ext/chipmunk/cpArbiter.h
  130. +0 −114 req/chipmunk/ext/chipmunk/cpArray.c
  131. +0 −45 req/chipmunk/ext/chipmunk/cpArray.h
  132. +0 −46 req/chipmunk/ext/chipmunk/cpBB.c
  133. +0 −53 req/chipmunk/ext/chipmunk/cpBB.h
  134. +0 −180 req/chipmunk/ext/chipmunk/cpBody.c
  135. +0 −132 req/chipmunk/ext/chipmunk/cpBody.h
  136. +0 −390 req/chipmunk/ext/chipmunk/cpCollision.c
  137. +0 −23 req/chipmunk/ext/chipmunk/cpCollision.h
  138. +0 −219 req/chipmunk/ext/chipmunk/cpHashSet.c
  139. +0 −79 req/chipmunk/ext/chipmunk/cpHashSet.h
  140. +0 −553 req/chipmunk/ext/chipmunk/cpJoint.c
  141. +0 −122 req/chipmunk/ext/chipmunk/cpJoint.h
  142. +0 −139 req/chipmunk/ext/chipmunk/cpPolyShape.c
  143. +0 −92 req/chipmunk/ext/chipmunk/cpPolyShape.h
  144. +0 −244 req/chipmunk/ext/chipmunk/cpShape.c
  145. +0 −141 req/chipmunk/ext/chipmunk/cpShape.h
  146. +0 −530 req/chipmunk/ext/chipmunk/cpSpace.c
  147. +0 −120 req/chipmunk/ext/chipmunk/cpSpace.h
  148. +0 −455 req/chipmunk/ext/chipmunk/cpSpaceHash.c
  149. +0 −100 req/chipmunk/ext/chipmunk/cpSpaceHash.h
  150. +0 −63 req/chipmunk/ext/chipmunk/cpVect.c
  151. +0 −106 req/chipmunk/ext/chipmunk/cpVect.h
  152. +0 −9 req/chipmunk/ext/chipmunk/extconf.rb
  153. +0 −68 req/chipmunk/ext/chipmunk/prime.h
  154. +0 −109 req/chipmunk/ext/chipmunk/rb_chipmunk.c
  155. +0 −77 req/chipmunk/ext/chipmunk/rb_chipmunk.h
  156. +0 −154 req/chipmunk/ext/chipmunk/rb_cpBB.c
  157. +0 −239 req/chipmunk/ext/chipmunk/rb_cpBody.c
  158. +0 −136 req/chipmunk/ext/chipmunk/rb_cpJoint.c
  159. +0 −292 req/chipmunk/ext/chipmunk/rb_cpShape.c
  160. +0 −330 req/chipmunk/ext/chipmunk/rb_cpSpace.c
  161. +0 −250 req/chipmunk/ext/chipmunk/rb_cpVect.c
  162. +0 −57 req/ftsearch/README
  163. +0 −187 req/ftsearch/ext/ftsearchrt/Makefile
  164. +0 −4 req/ftsearch/ext/ftsearchrt/extconf.rb
  165. +0 −532 req/ftsearch/ext/ftsearchrt/ftsearch.c
  166. +0 −16 req/ftsearch/lib/ftsearch/analysis/analyzer.rb
  167. +0 −23 req/ftsearch/lib/ftsearch/analysis/simple_identifier_analyzer.rb
  168. +0 −22 req/ftsearch/lib/ftsearch/analysis/whitespace_analyzer.rb
  169. +0 −106 req/ftsearch/lib/ftsearch/document_map_reader.rb
  170. +0 −46 req/ftsearch/lib/ftsearch/document_map_writer.rb
  171. +0 −46 req/ftsearch/lib/ftsearch/field_infos.rb
  172. +0 −114 req/ftsearch/lib/ftsearch/fragment_writer.rb
  173. +0 −52 req/ftsearch/lib/ftsearch/fulltext_reader.rb
  174. +0 −75 req/ftsearch/lib/ftsearch/fulltext_writer.rb
  175. +0 −277 req/ftsearch/lib/ftsearch/suffix_array_reader.rb
  176. +0 −99 req/ftsearch/lib/ftsearch/suffix_array_writer.rb
  177. +0 −21 req/ftsearch/lib/ftsearch/util.rb
  178. +0 −18 req/hpricot/LICENSE
  179. +0 −187 req/hpricot/ext/fast_xs/Makefile
  180. +0 −4 req/hpricot/ext/fast_xs/extconf.rb
  181. +0 −201 req/hpricot/ext/fast_xs/fast_xs.c
  182. +0 −20 req/hpricot/ext/fast_xs/mkmf.log
  183. +0 −187 req/hpricot/ext/hpricot_scan/Makefile
  184. +0 −6 req/hpricot/ext/hpricot_scan/extconf.rb
Sorry, we could not display the entire diff because too many files (302) changed.
View
3  CHANGELOG
@@ -1,3 +1,6 @@
+= BROWN SHOES NEEDS A NEW RELEASE SCHEDULE!!
+* Name Suggestions anyone?
+
= Policeman
== 17th August, 2010
* Move to Ruby 1.9.1
View
7 app.yaml
@@ -1,7 +0,0 @@
-name: Shoes
-version: 3
-release: Policeman
-icons:
- win32: platform/msw/shoes.ico
- osx: static/Shoes.icns
- gtk: static/shoes-icon.png
View
104 bin/main.skel
@@ -1,104 +0,0 @@
-//
-// main.c
-// The generic launcher for Shoes.
-//
-#include <stdio.h>
-#include "shoes/app.h"
-#include "shoes/ruby.h"
-#include "shoes/config.h"
-#include "shoes/world.h"
-#include "shoes/internal.h"
-
-#ifdef __APPLE__
-#include <crt_externs.h>
-#endif
-
-#ifdef SHOES_WIN32
-int WINAPI
-WinMain(HINSTANCE inst, HINSTANCE inst2, LPSTR arg, int style)
-#else
-int
-main(argc, argv)
- int argc;
- char *argv[];
-#endif
-{
- shoes_code code;
- char *path = NULL;
-#ifdef __APPLE__
- char **env = *_NSGetEnviron();
-#endif
-#ifdef SHOES_WIN32
- int argc;
- char **argv;
- argc = shoes_win32_cmdvector(GetCommandLine(), &argv);
-#endif
- %DEFAULTS%
-
-#ifdef SHOES_WIN32
- path = SHOE_ALLOC_N(char, SHOES_BUFSIZE);
- GetModuleFileName(NULL, (LPSTR)path, SHOES_BUFSIZE);
-#ifdef RUBY_1_9
- rb_w32_sysinit(&argc, &argv);
-#else
- NtInitialize(&argc, &argv);
-#endif
-#else
- path = argv[0];
-#endif
- if (argc > 1 && strcmp(argv[1], "--ruby") == 0)
- {
- char bootup[SHOES_BUFSIZE];
- int len = shoes_snprintf(bootup,
- SHOES_BUFSIZE,
- "begin;"
- "DIR = File.expand_path(File.dirname(%%q<%s>));"
- "$:.replace([DIR+'/ruby/lib/'+PLATFORM, DIR+'/ruby/lib', DIR+'/lib', '.']);"
- "require 'shoes/cache';"
- "DIR;"
- "rescue Object => e;"
- "puts(e.message);"
- "end",
- path);
-
- if (len < 0 || len >= SHOES_BUFSIZE)
- return 0;
-
- argc--;
- argv[1] = argv[0];
- argv = &argv[1];
- {
- RUBY_INIT_STACK
- ruby_init();
- rb_eval_string(bootup);
-#ifdef RUBY_1_9
- return ruby_run_node(ruby_options(argc, argv));
-#else
- ruby_options(argc, argv);
- ruby_run();
- return 0;
-#endif
- }
- }
-
-#ifdef SHOES_WIN32
- code = shoes_init(inst, style);
-#else
- code = shoes_init();
-#endif
- if (code != SHOES_OK)
- goto done;
-
- shoes_set_argv(argc - 1, &argv[1]);
- code = shoes_start(path, "/");
- if (code != SHOES_OK)
- goto done;
-
-done:
-#ifdef SHOES_WIN32
- if (path != NULL)
- SHOE_FREE(path);
-#endif
- shoes_final();
- return 0;
-}
View
1  gemlib/shoes.rb
@@ -1 +0,0 @@
-puts "Sorry, this gem currently does nothing. Team Shoes is working on Gemifying Shoes, and this is just a placeholder until then."
View
554 lib/red_shoes.rb
@@ -1,554 +0,0 @@
-# -*- encoding: utf-8 -*-
-#
-# lib/shoes.rb
-# The Shoes base app, both a demonstration and the learning tool for
-# using Shoes.
-#
-ARGV.delete_if { |x| x =~ /-psn_/ }
-
-class Encoding
- %w[UTF_7 UTF_16BE UTF_16LE UTF_32BE UTF_32LE].each do |enc|
- eval "class #{enc};end" unless const_defined? enc.to_sym
- end
-end
-
-require 'open-uri'
-require 'optparse'
-require 'resolv-replace' if RUBY_PLATFORM =~ /win/
-require_relative 'shoes/inspect'
-require_relative 'shoes/cache'
-if Object.const_defined? :Shoes
- require_relative 'shoes/image'
-end
-require_relative 'shoes/shybuilder'
-
-def Shoes.hook; end
-
-class Encoding
- %w[ASCII_8BIT UTF_16BE UTF_16LE UTF_32BE UTF_32LE US_ASCII].each do |ec|
- eval "#{ec} = '#{ec.sub '_', '-'}'"
- end unless RUBY_PLATFORM =~ /linux/ or RUBY_PLATFORM =~ /darwin/
-end
-
-class Range
- def rand
- conv = (Integer === self.end && Integer === self.begin ? :to_i : :to_f)
- ((Kernel.rand * (self.end - self.begin)) + self.begin).send(conv)
- end
-end
-
-unless Time.respond_to? :today
- def Time.today
- t = Time.now
- t - (t.to_i % 86400)
- end
-end
-
-class Shoes
- RELEASES = %w[Curious Raisins Policeman]
-
- NotFound = proc do
- para "404 NOT FOUND, GUYS!"
- end
-
- class << self; attr_accessor :locale, :language end
- @locale = ENV["SHOES_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
- @language = @locale[/^(\w{2})_/, 1] || "en"
-
- @mounts = []
-
- OPTS = OptionParser.new do |opts|
- opts.banner = "Usage: shoes [options] (app.rb or app.shy)"
-
- opts.on("-m", "--manual",
- "Open the built-in manual.") do
- show_manual
- end
-
- opts.on("-p", "--package",
- "Package a Shoes app for Windows, OS X and Linux.") do |s|
- make_pack
- end
-
- opts.on("-g", "--gem",
- "Passes commands to RubyGems.") do
- require 'shoes/setup'
- require 'rubygems/gem_runner'
- Gem::GemRunner.new.run(ARGV)
- raise SystemExit, ""
- end
-
- opts.on("--manual-html DIRECTORY", "Saves the manual to a directory as HTML.") do |dir|
- manual_as :html, dir
- raise SystemExit, "HTML manual in: #{dir}"
- end
-
- opts.on("--install MODE SRC DEST", "Installs a file.") do |mode|
- src, dest = ARGV
- FileUtils.install src, dest, :mode => mode.to_i(8), :preserve => true
- raise SystemExit, ""
- end
-
- opts.on("--nolayered", "No WS_EX_LAYERED style option.") do
- $NOLAYERED = 1
- Shoes.args!
- end
-
- opts.on_tail("-v", "--version", "Display the version info.") do
- raise SystemExit, File.read("#{DIR}/VERSION.txt").strip
- end
-
- opts.on_tail("-h", "--help", "Show this message") do
- raise SystemExit, opts.to_s
- end
- end
-
- class SettingUp < StandardError; end
-
- @setups = {}
-
- def self.setup &blk
- require 'shoes/setup'
- line = caller[0]
- return if @setups[line]
- script = line[/^(.+?):/, 1]
- set = Shoes::Setup.new(script, &blk)
- @setups[line] = true
- unless set.no_steps?
- raise SettingUp
- end
- end
-
- def self.show_selector
- fname = ask_open_file
- Shoes.visit(fname) if fname
- end
-
- def self.package_app
- fname = ask_open_file
- return false unless fname
- start_shy_builder fname
- end
-
- def self.splash
- font "#{DIR}/fonts/Lacuna.ttf"
- Shoes.app :width => 400, :height => 300, :resizable => false do
- style(Para, :align => "center", :weight => "bold", :font => "Lacuna Regular", :size => 13)
- style(Link, :stroke => yellow, :underline => nil)
- style(LinkHover, :stroke => yellow, :fill => nil)
-
- x1 = 77; y1 = 122
- x2 = 148; y2 = -122
- x3 = 245; y3 = 0
-
- nofill
- strokewidth 40.0
-
- @waves = stack :top => 0, :left => 0
-
- require 'shoes/search'
- require 'shoes/help'
-
- stack :margin => 18 do
- para "Welcome to", :stroke => "#DFA", :margin => 0
- para "SHOES", :size => 48, :stroke => "#DFA", :margin_top => 0
- stack do
- background black(0.2), :curve => 8
- para link("Open an App.") { Shoes.show_selector and close }, :margin => 10, :margin_bottom => 4
- #para link("Package an App.") { Shoes.package_app and close }, :margin => 10, :margin_bottom => 4
- para link("Package an App.") { Shoes.make_pack and close }, :margin => 10, :margin_bottom => 4
- para link("Read the Manual.") { Shoes.show_manual and close }, :margin => 10
- end
- inscription "Alt-Slash opens the console.", :stroke => "#DFA", :align => "center"
- end
-
- animate(10) do |ani|
- a = Math.sin(ani * 0.02) * 20
- @waves.clear do
- background white
- y = -30
- 16.times do |i|
- shape do
- move_to x = (-300 - (i*(a*0.8))), y
- c = (a + 14) * 0.01
- stroke rgb(i * 0.06, c + 0.1, 0.1, 1.0 - (ani * 0.0003))
- 4.times do
- curve_to x1 + x, (y1-(i*a)) + y, x2 + x, (y2+(i*a)) + y, x3 + x, y3 + y
- x += x3
- end
- end
- y += 30
- end
- end
- end
- end
- end
-
- def self.make_pack
- require 'shoes/pack'
- Shoes.app(:width => 500, :height => 480, :resizable => true, &PackMake)
- end
-
- def self.manual_p(str, path)
- str.gsub(/\n+\s*/, " ").
- gsub(/&/, '&amp;').gsub(/>/, '&gt;').gsub(/>/, '&lt;').gsub(/"/, '&quot;').
- gsub(/`(.+?)`/m, '<code>\1</code>').gsub(/\[\[BR\]\]/i, "<br />\n").
- gsub(/\^(.+?)\^/m, '\1').
- gsub(/'''(.+?)'''/m, '<strong>\1</strong>').gsub(/''(.+?)''/m, '<em>\1</em>').
- gsub(/\[\[(http:\/\/\S+?)\]\]/m, '<a href="\1" target="_new">\1</a>').
- gsub(/\[\[(http:\/\/\S+?) (.+?)\]\]/m, '<a href="\1" target="_new">\2</a>').
- gsub(/\[\[(\S+?)\]\]/m) do
- ms, mn = $1.split(".", 2)
- if mn
- '<a href="' + ms + '.html#' + mn + '">' + mn + '</a>'
- else
- '<a href="' + ms + '.html">' + ms + '</a>'
- end
- end.
- gsub(/\[\[(\S+?) (.+?)\]\]/m, '<a href="\1.html">\2</a>').
- gsub(/\!(\{[^}\n]+\})?([^!\n]+\.\w+)\!/) do
- x = "static/#$2"
- FileUtils.cp("#{DIR}/#{x}", "#{path}/#{x}") if File.exists? "#{DIR}/#{x}"
- '<img src="' + x + '" />'
- end
- end
-
- def self.manual_link(sect)
- end
-
- TITLES = {:title => :h1, :subtitle => :h2, :tagline => :h3, :caption => :h4}
-
- def self.manual_as format, *args
- require 'shoes/search'
- require 'shoes/help'
-
- case format
- when :shoes
- Shoes.app(:width => 720, :height => 640, &Shoes::Help)
- else
- extend Shoes::Manual
- man = self
- dir, = args
- FileUtils.mkdir_p File.join(dir, 'static')
- FileUtils.cp "#{DIR}/static/shoes-icon.png", "#{dir}/static"
- %w[manual.css code_highlighter.js code_highlighter_ruby.js].
- each { |x| FileUtils.cp "#{DIR}/static/#{x}", "#{dir}/static" }
- html_bits = proc do
- proc do |sym, text|
- case sym when :intro
- div.intro { p { self << man.manual_p(text, dir) } }
- when :code
- pre { code.rb text.gsub(/^\s*?\n/, '') }
- when :colors
- color_names = (Shoes::COLORS.keys*"\n").split("\n").sort
- color_names.each do |color|
- c = Shoes::COLORS[color.intern]
- f = c.dark? ? "white" : "black"
- div.color(:style => "background: #{c}; color: #{f}") { h3 color; p c }
- end
- when :index
- tree = man.class_tree
- shown = []
- i = 0
- index_p = proc do |k, subs|
- unless shown.include? k
- i += 1
- p "#{k}", :style => "margin-left: #{20*i}px"
- subs.uniq.sort.each do |s|
- index_p[s, tree[s]]
- end if subs
- i -= 1
- shown << k
- end
- end
- tree.sort.each &index_p
- # index_page
- when :list
- ul { text.each { |x| li { self << man.manual_p(x, dir) } } }
- when :samples
- folder = File.join DIR, 'samples'
- h = {}
- Dir.glob(File.join folder, '*').each do |file|
- if File.extname(file) == '.rb'
- key = File.basename(file).split('-')[0]
- h[key] ? h[key].push(file) : h[key] = [file]
- end
- end
- h.each do |k, v|
- p "<h4>#{k}</h4>"
- samples = []
- v.each do |file|
- sample = File.basename(file).split('-')[1..-1].join('-')[0..-4]
- samples << "<a href=\"http://github.com/shoes/shoes/raw/master/manual-snapshots/#{k}-#{sample}.png\">#{sample}</a>"
- end
- p samples.join ' '
- end
- else
- send(TITLES[sym] || :p) { self << man.manual_p(text, dir) }
- end
- end
- end
-
- docs = load_docs(Shoes::Manual::path)
- sections = docs.map { |x,| x }
-
- docn = 1
- docs.each do |title1, opt1|
- subsect = opt1['sections'].map { |x,| x }
- menu = sections.map do |x|
- [x, (subsect if x == title1)]
- end
-
- path1 = File.join(dir, title1.gsub(/\W/, ''))
- make_html("#{path1}.html", title1, menu) do
- h2 "The Shoes Manual"
- h1 title1
- man.wiki_tokens opt1['description'], true, &instance_eval(&html_bits)
- p.next { text "Next: "
- a opt1['sections'].first[1]['title'], :href => "#{opt1['sections'].first[0]}.html" }
- end
-
- optn = 1
- opt1['sections'].each do |title2, opt2|
- path2 = File.join(dir, title2)
- make_html("#{path2}.html", opt2['title'], menu) do
- h2 "The Shoes Manual"
- h1 opt2['title']
- man.wiki_tokens opt2['description'], true, &instance_eval(&html_bits)
- opt2['methods'].each do |title3, desc3|
- sig, val = title3.split(/\s\s+/, 2)
- aname = sig[/^[^(=]+=?/].gsub(/\s/, '').downcase
- a :name => aname
- div.method do
- a sig, :href => "##{aname}"
- text " » #{val}" if val
- end
- div.sample do
- man.wiki_tokens desc3, &instance_eval(&html_bits)
- end
- end
- if opt1['sections'][optn]
- p.next { text "Next: "
- a opt1['sections'][optn][1]['title'], :href => "#{opt1['sections'][optn][0]}.html" }
- elsif docs[docn]
- p.next { text "Next: "
- a docs[docn][0], :href => "#{docs[docn][0].gsub(/\W/, '')}.html" }
- end
- optn += 1
- end
- end
-
- docn += 1
- end
- end
- end
-
- def self.show_manual
- manual_as :shoes
- end
-
- def self.show_log
- require 'shoes/log'
- return if @log_app and Shoes.APPS.include? @log_app
- @log_app =
- Shoes.app do
- extend Shoes::LogWindow
- setup
- end
- end
-
- def self.mount(path, meth, &blk)
- @mounts << [path, meth || blk]
- end
-
- SHOES_URL_RE = %r!^@([^/]+)(.*)$!
-
- def self.run(path)
- uri = URI(path)
- @mounts.each do |mpath, rout|
- m, *args = *path.match(/^#{mpath}$/)
- if m
- unless rout.is_a? Proc
- rout = rout[0].instance_method(rout[1])
- end
- return [rout, args]
- end
- end
- case uri.path when "/"
- [nil]
- when SHOES_URL_RE
- [proc { eval(URI("http://#$1:53045#$2").read) }]
- else
- [NotFound]
- end
- end
-
- def self.args!
- if RUBY_PLATFORM !~ /darwin/ and ARGV.empty?
- Shoes.splash
- end
- OPTS.parse! ARGV
- ARGV[0] or true
- end
-
- def self.uri(str)
- if str =~ SHOES_URL_RE
- URI("http://#$1:53045#$2")
- else
- URI(str) rescue nil
- end
- end
-
- def self.visit(path)
- uri = Shoes.uri(path)
-
- case uri
- when URI::HTTP
- str = uri.read
- if str !~ /Shoes\.app/
- Shoes.app do
- eval(uri.read)
- end
- else
- eval(uri.read)
- end
- else
- path = File.expand_path(path.gsub(/\\/, "/"))
- if path =~ /\.shy$/
- @shy = true
- require 'shoes/shy'
- base = File.basename(path, ".shy")
- tmpdir = "%s/shoes-%s.%d" % [Dir.tmpdir, base, $$]
- shy = Shy.x(path, tmpdir)
- Dir.chdir(tmpdir)
- Shoes.debug "Loaded SHY: #{shy.name} #{shy.version} by #{shy.creator}"
- path = shy.launch
- else
- @shy = false
- Dir.chdir(File.dirname(path))
- path = File.basename(path)
- end
-
- $0.replace path
-
- code = read_file(path)
- eval(code, TOPLEVEL_BINDING, path)
- end
- rescue SettingUp
- rescue Object => e
- error(e)
- show_log
- end
-
- def self.read_file path
- if RUBY_VERSION =~ /^1\.9/ and !@shy
- #File.open(path, 'r:utf-8') { |f| f.read }
- IO.read(path).force_encoding("UTF-8")
- else
- File.read(path)
- end
- end
-
- def self.url(path, meth)
- Shoes.mount(path, [self, meth])
- end
-
- module Basic
- def tween opts, &blk
- opts = opts.dup
-
- if opts[:upward]
- opts[:top] = self.top - opts.delete(:upward)
- elsif opts[:downward]
- opts[:top] = self.top + opts.delete(:downward)
- end
-
- if opts[:sideways]
- opts[:left] = self.left + opts.delete(:sideways)
- end
-
- @TWEEN.remove if @TWEEN
- @TWEEN = parent.animate(opts[:speed] || 20) do
-
- # figure out a coordinate halfway between here and there
- cont = opts.select do |k, v|
- if self.respond_to? k
- n, o = v, self.send(k)
- if n != o
- n = o + ((n - o) / 2)
- n = v if o == n
- self.send("#{k}=", n)
- end
- self.style[k] != v
- end
- end
-
- # if we're there, get rid of the animation
- if cont.empty?
- @TWEEN.remove
- @TWEEN = nil
- blk.call if blk
- end
- end
- end
- end
-
- # complete list of styles
- BASIC_S = [:left, :top, :right, :bottom, :width, :height, :attach, :hidden,
- :displace_left, :displace_top, :margin, :margin_left, :margin_top,
- :margin_right, :margin_bottom]
- TEXT_S = [:strikecolor, :undercolor, :font, :size, :family, :weight,
- :rise, :kerning, :emphasis, :strikethrough, :stretch, :underline,
- :variant]
- MOUSE_S = [:click, :motion, :release, :hover, :leave]
- KEY_S = [:keydown, :keypress, :keyup]
- COLOR_S = [:stroke, :fill]
-
- {Background => [:angle, :radius, :curve, *BASIC_S],
- Border => [:angle, :radius, :curve, :strokewidth, *BASIC_S],
- Canvas => [:scroll, :start, :finish, *(KEY_S|MOUSE_S|BASIC_S)],
- Check => [:click, :checked, *BASIC_S],
- Radio => [:click, :checked, :group, *BASIC_S],
- EditLine => [:change, :secret, :text, *BASIC_S],
- EditBox => [:change, :text, *BASIC_S],
- Effect => [:radius, :distance, :inner, *(COLOR_S|BASIC_S)],
- Image => MOUSE_S|BASIC_S,
- ListBox => [:change, :items, :choose, *BASIC_S],
- # Pattern => [:angle, :radius, *BASIC_S],
- Progress => BASIC_S,
- Shape => COLOR_S|MOUSE_S|BASIC_S,
- TextBlock => [:justify, :align, :leading, *(COLOR_S|MOUSE_S|TEXT_S|BASIC_S)],
- Text => COLOR_S|MOUSE_S|TEXT_S|BASIC_S}.
- each do |klass, styles|
- klass.class_eval do
- include Basic
- styles.each do |m|
- case m when *MOUSE_S
- else
- define_method(m) { style[m] } unless klass.method_defined? m
- define_method("#{m}=") { |v| style(m => v) } unless klass.method_defined? "#{m}="
- end
- end
- end
- end
-
- class Types::Widget
- @types = {}
- def self.inherited subc
- methc = subc.to_s[/(^|::)(\w+)$/, 2].
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
- gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
- @types[methc] = subc
- Shoes.class_eval %{
- def #{methc}(*a, &b)
- a.unshift Widget.instance_variable_get("@types")[#{methc.dump}]
- widget(*a, &b)
- end
- }
- end
- end
-end
-
-def window(*a, &b)
- Shoes.app(*a, &b)
-end
View
55 lib/red_shoes/cache.rb
@@ -1,55 +0,0 @@
-require 'fileutils'
-include FileUtils
-
-# locate ~/.shoes
-require 'tmpdir'
-
-lib_dir = nil
-homes = []
-homes << [ENV['HOME'], File.join( ENV['HOME'], '.shoes' )] if ENV['HOME']
-homes << [ENV['APPDATA'], File.join( ENV['APPDATA'], 'Shoes' )] if ENV['APPDATA']
-homes.each do |home_top, home_dir|
- next unless home_top
- if File.exists? home_top
- lib_dir = home_dir
- break
- end
-end
-LIB_DIR = lib_dir || File.join(Dir::tmpdir, "shoes")
-LIB_DIR.gsub! /\\/, '/'
-SITE_LIB_DIR = File.join(LIB_DIR, '+lib')
-GEM_DIR = File.join(LIB_DIR, '+gem')
-CACHE_DIR = File.join(LIB_DIR, '+cache')
-
-mkdir_p(CACHE_DIR)
-$:.unshift SITE_LIB_DIR
-$:.unshift GEM_DIR
-ENV['GEM_HOME'] = GEM_DIR
-
-require 'rbconfig'
-SHOES_RUBY_ARCH = Config::CONFIG['arch']
-config = {
- 'ruby_install_name' => "shoes --ruby",
- 'RUBY_INSTALL_NAME' => "shoes --ruby",
- 'prefix' => "#{DIR}",
- 'bindir' => "#{DIR}",
- 'rubylibdir' => "#{DIR}/ruby/lib",
- 'datarootdir' => "#{DIR}/share",
- 'dvidir' => "#{DIR}/doc/${PACKAGE}",
- 'psdir' => "#{DIR}/doc/${PACKAGE}",
- 'htmldir' => "#{DIR}/doc/${PACKAGE}",
- 'docdir' => "#{DIR}/doc/${PACKAGE}",
- 'archdir' => "#{DIR}/ruby/lib/#{SHOES_RUBY_ARCH}",
- 'sitedir' => SITE_LIB_DIR,
- 'sitelibdir' => SITE_LIB_DIR,
- 'sitearchdir' => "#{SITE_LIB_DIR}/#{SHOES_RUBY_ARCH}",
- 'LIBRUBYARG_STATIC' => "",
- 'libdir' => "#{DIR}",
- 'LDFLAGS' => "-L. -L#{DIR}"
-}
-Config::CONFIG.merge! config
-Config::MAKEFILE_CONFIG.merge! config
-GEM_CENTRAL_DIR = File.join(DIR, 'ruby/gems/' + Config::CONFIG['ruby_version'])
-Dir[GEM_CENTRAL_DIR + "/gems/*"].each do |gdir|
- $: << "#{gdir}/lib"
-end
View
35 lib/red_shoes/chipmunk.rb
@@ -1,35 +0,0 @@
-require 'chipmunk'
-
-module ChipMunk
- def cp_space
- @space = CP::Space.new
- @space.damping = 0.8
- @space.gravity = vec2 0, 25
- @space
- end
-
- def cp_oval l, t, r, opts = {}
- b = CP::Body.new 1,1
- b.p = vec2 l, t
- @space.add_body b
- @space.add_shape CP::Shape::Circle.new(b, r, vec2(0, 0))
-
- img = image left: l-r-1, top: t-r-1, width: 2*r+2, height: 2*r+2, body: b, inflate: r-2 do
- oval 1, 1, 2*r, opts
- end
- end
-
- def cp_line x0, y0, x1, y1, opts = {}
- opts[:strokewidth] = 5 unless opts[:strokewidth]
- sb = CP::Body.new 1.0/0.0, 1.0/0.0
- seg = CP::Shape::Segment.new sb, vec2(x0, y0), vec2(x1, y1), opts[:strokewidth]
- @space.add_shape seg
- line x0, y0, x1, y1, opts
- end
-end
-
-Shoes::Image.class_eval do
- def cp_move
- move style[:body].p.x.to_i - style[:inflate], style[:body].p.y.to_i - style[:inflate]
- end
-end
View
39 lib/red_shoes/data.rb
@@ -1,39 +0,0 @@
-require 'sqlite3'
-
-data_file = File.join(LIB_DIR, "+data")
-data_init = !File.exists?(data_file)
-
-DATABASE = SQLite3::Database.new data_file
-DATABASE.type_translation = true
-
-class << DATABASE
- DATABASE_VERSION = 1
- def setup
- DATABASE.execute_batch %{
- CREATE TABLE cache (
- url text primary key,
- etag text,
- hash varchar(40),
- saved datetime
- );
- CREATE TABLE upgrades (
- version int primary key
- );
- INSERT INTO upgrades VALUES (?);
- }, DATABASE_VERSION
- end
- def check_cache_for url
- etag, hash, saved =
- DATABASE.get_first_row("SELECT etag, hash, saved FROM cache WHERE url = ?", url)
- {:etag => etag, :hash => hash, :saved => saved.nil? ? 0 : Time.parse(saved.to_s).to_i}
- end
- def notify_cache_of url, etag, hash
- DATABASE.query %{
- REPLACE INTO cache (url, etag, hash, saved)
- VALUES (?, ?, ?, datetime("now", "localtime"));
- }, url, etag, hash
- nil
- end
-end
-
-DATABASE.setup if data_init
View
468 lib/red_shoes/help.rb
@@ -1,468 +0,0 @@
-# -*- encoding: utf-8 -*-
-module Shoes::Manual
- PARA_RE = /\s*?(\{{3}(?:.+?)\}{3})|\n\n/m
- CODE_RE = /\{{3}(?:\s*\#![^\n]+)?(.+?)\}{3}/m
- IMAGE_RE = /\!(\{([^}\n]+)\})?([^!\n]+\.\w+)\!/
- CODE_STYLE = {:size => 9, :margin => 12}
- INTRO_STYLE = {:size => 16, :margin_bottom => 20, :stroke => "#000"}
- SUB_STYLE = {:stroke => "#CCC", :margin_top => 10}
- IMAGE_STYLE = {:margin => 8, :margin_left => 100}
- COLON = ": "
-
- [INTRO_STYLE, SUB_STYLE].each do |h|
- h[:font] = "MS UI Gothic"
- end if Shoes.language == 'ja'
-
- def self.path
- path = "#{DIR}/static/manual-#{Shoes.language}.txt"
- unless File.exists? path
- path = "#{DIR}/static/manual-en.txt"
- end
- path
- end
-
- def dewikify_hi(str, terms, intro = false)
- if terms
- code = []
- str = str.
- gsub(CODE_RE) { |x| code << x; "CODE#[#{code.length-1}]" }.
- gsub(/#{Regexp::quote(terms)}/i, '@\0@').
- gsub(/CODE#\[(\d+)\]/) { code[$1.to_i] }
- end
- dewikify(str, intro)
- end
-
- def dewikify_p(ele, str, *args)
- str = str.gsub(/\n+\s*/, " ").dump.
- gsub(/`(.+?)`/m, '", code("\1"), "').gsub(/\[\[BR\]\]/i, "\n").
- gsub(/\^(.+?)\^/m, '\1').
- gsub(/@(.+?)@/m, '", strong("\1", :fill => yellow), "').
- gsub(/'''(.+?)'''/m, '", strong("\1"), "').gsub(/''(.+?)''/m, '", em("\1"), "').
- gsub(/\[\[(\S+?)\]\]/m, '", link("\1".split(".", 2).last) { open_link("\1") }, "').
- gsub(/\[\[(\S+?) (.+?)\]\]/m, '", link("\2") { open_link("\1") }, "').
- gsub(IMAGE_RE, '", *args); stack(IMAGE_STYLE.merge({\2})) { image("#{DIR}/static/\3") }; #{ele}("')
- #debug str if str =~ /The list of special keys/
- a = str.split(', ", ", ')
- if a.size == 1
- eval("#{ele}(#{str}, *args)")
- else
- flow do
- a[0...-1].each{|s| eval("#{ele}(#{s}, ',', *args)")}
- eval("#{ele}(#{a[-1]}, *args)")
- end
- end
- end
-
- def dewikify_code(str)
- str = str.gsub(/\A\n+/, '').chomp
- stack :margin_bottom => 12 do
- background rgb(210, 210, 210), :curve => 4
- para code(str), CODE_STYLE
- stack :top => 0, :right => 2, :width => 70 do
- stack do
- background "#8A7", :margin => [0, 2, 0, 2], :curve => 4
- para link("Run this", :stroke => "#eee", :underline => "none") { run_code(str) },
- :margin => 4, :align => 'center', :weight => 'bold', :size => 9
- end
- end
- end
- end
-
- def wiki_tokens(str, intro = false)
- paras = str.split(PARA_RE).reject { |x| x.empty? }
- if intro
- yield :intro, paras.shift
- end
- paras.map do |ps|
- if ps =~ CODE_RE
- yield :code, $1
- else
- case ps
- when /\A\{COLORS\}/
- yield :colors, nil
- when /\A\{INDEX\}/
- yield :index, nil
- when /\A\{SAMPLES\}/
- yield :samples, nil
- when /\A \* (.+)/m
- yield :list, $1.split(/^ \* /)
- when /\A==== (.+) ====/
- yield :caption, $1
- when /\A=== (.+) ===/
- yield :tagline, $1
- when /\A== (.+) ==/
- yield :subtitle, $1
- when /\A= (.+) =/
- yield :title, $1
- else
- yield :para, ps
- end
- end
- end
- end
-
- def dewikify(str, intro = false)
- proc do
- wiki_tokens(str, intro) do |sym, text|
- case sym when :intro
- dewikify_p :para, text, INTRO_STYLE
- when :code
- dewikify_code(text)
- when :colors
- color_page
- when :index
- index_page
- when :samples
- sample_page
- when :list
- text.each { |t| stack(:margin_left => 30) {
- fill black; oval -10, 7, 6; dewikify_p :para, t } }
- else
- dewikify_p sym, text
- end
- end
- end
- end
-
- def sample_page
- folder = File.join DIR, 'samples'
- h = {}
- Dir.glob(File.join folder, '*').each do |file|
- if File.extname(file) == '.rb'
- key = File.basename(file).split('-')[0]
- h[key] ? h[key].push(file) : h[key] = [file]
- end
- end
- stack do
- h.each do |k, v|
- subtitle k
- flow do
- v.each do |file|
- para link(File.basename(file).split('-')[1..-1].join('-')[0..-4]){
- Dir.chdir(folder){eval IO.read(file).force_encoding("UTF-8"), TOPLEVEL_BINDING}
- }
- end
- end
- end
- end
- end
-
- def color_page
- color_names = (Shoes::COLORS.keys*"\n").split("\n").sort
- flow do
- color_names.each do |color|
- flow :width => 0.33 do
- c = send(color)
- background c
- para strong(color), "\n", c, :stroke => (c.dark? ? white : black),
- :margin => 4, :align => 'center'
- end
- end
- end
- end
-
- def class_tree
- tree = {}
- Shoes.constants.each do |c|
- k = Shoes.const_get(c)
- next unless k.respond_to? :superclass
-
- c = "Shoes::#{c}"
- if k.superclass == Object
- tree[c] ||= []
- else
- k.ancestors[1..-1].each do |sk|
- break if [Object, Kernel].include? sk
- next unless sk.is_a? Class #don't show mixins
- (tree[sk.name] ||= []) << c
- c = sk.name
- end
- end
- end
- tree
- end
-
- def index_page
- tree = class_tree
- shown = []
- index_p = proc do |k, subs|
- unless shown.include? k
- stack :margin_left => 20 do
- flow do
- para "", :font => case RUBY_PLATFORM
- when /mingw/; "MS UI Gothic"
- when /darwin/; "AppleGothic, Arial"
- else "Arial"
- end
- para k
- end
- subs.uniq.sort.each do |s|
- index_p[s, tree[s]]
- end if subs
- end
- shown << k
- end
- end
- tree.sort.each &index_p
- end
-
- def run_code str
- eval(str, TOPLEVEL_BINDING)
- end
-
- def load_docs path
- return @docs if @docs
- str = Shoes.read_file(path)
- @search = Shoes::Search.new
- @sections, @methods, @mindex = {}, {}, {}
- @docs =
- (str.split(/^= (.+?) =/)[1..-1]/2).map do |k,v|
- sparts = v.split(/^== (.+?) ==/)
-
- sections = (sparts[1..-1]/2).map do |k2,v2|
- meth = v2.split(/^=== (.+?) ===/)
- k2t = k2[/^(?:The )?([\-\w]+)/, 1]
- meth_plain = meth[0].gsub(IMAGE_RE, '')
- @search.add_document :uri => "T #{k2t}", :body => "#{k2}\n#{meth_plain}".downcase
-
- hsh = {'title' => k2, 'section' => k,
- 'description' => meth[0],
- 'methods' => (meth[1..-1]/2).map { |_k,_v|
- @search.add_document :uri => "M #{k}#{COLON}#{k2t}#{COLON}#{_k}", :body => "#{_k}\n#{_v}".downcase
- @mindex["#{k2t}.#{_k[/[\w\.]+/]}"] = [k2t, _k]
- [_k, _v]
- }}
- @methods[k2t] = hsh
- [k2t, hsh]
- end
-
- @search.add_document :uri => "S #{k}", :body => "#{k}\n#{sparts[0]}".downcase
- hsh = {'description' => sparts[0], 'sections' => sections,
- 'class' => "toc" + k.downcase.gsub(/\W+/, '')}
- @sections[k] = hsh
- [k, hsh]
- end
- @search.finish!
- @docs
- end
-
- def show_search
- @toc.each { |k,v| v.hide }
- @title.replace "Search"
- @doc.clear do
- dewikify_p :para, "Try method names (like `button` or `arrow`) or topics (like `slots`)", :align => 'center'
- flow :margin_left => 60 do
- edit_line :width => -60 do |terms|
- @results.clear do
- termd = terms.text.downcase
- #found = termd.empty? ? [] : manual_search(termd)
- found = (termd.empty? or termd[0] == 'z' or termd[0] == 'y') ? [] : manual_search(termd)
- para "#{found.length} matches", :align => "center", :margin_bottom => 0
- found.each do |typ, head|
- flow :margin => 4 do
- case typ
- when "S"
- background "#333", :curve => 4
- caption strong(link(head, :stroke => white) { open_section(head, terms.text) })
- para "Section header", Shoes::Manual::SUB_STYLE
- when "T"
- background "#777", :curve => 4
- caption strong(link(head, :stroke => "#EEE") { open_methods(head, terms.text) })
- hsh = @methods[head]
- para "Sub-section under #{hsh['section']} (#{hsh['methods'].length} methods)", Shoes::Manual::SUB_STYLE
- when "M"
- background "#CCC", :curve => 4
- sect, subhead, head = head.split(Shoes::Manual::COLON, 3)
- para strong(sect, Shoes::Manual::COLON, subhead, Shoes::Manual::COLON, link(head) { open_methods(subhead, terms.text, head) })
- end
- end
- end
- end
- end
- end
- @results = stack
- end
- app.slot.scroll_top = 0
- end
-
- def open_link(head)
- if head == "Search"
- show_search
- elsif @sections.has_key? head
- open_section(head)
- elsif @methods.has_key? head
- open_methods(head)
- elsif @mindex.has_key? head
- head, sub = @mindex[head]
- open_methods(head, nil, sub)
- elsif head =~ /^http:\/\//
- debug head
- visit head
- end
- end
-
- def add_next_link(docn, optn)
- opt1, optn = @docs[docn][1], optn + 1
- if opt1['sections'][optn]
- @doc.para "Next: ",
- link(opt1['sections'][optn][1]['title']) { open_methods(opt1['sections'][optn][0]) },
- :align => "right"
- elsif @docs[docn + 1]
- @doc.para "Next: ",
- link(@docs[docn + 1][0]) { open_section(@docs[docn + 1][0].gsub(/\W/, '')) },
- :align => "right"
- end
- end
-
- def open_section(sect_s, terms = nil)
- sect_h = @sections[sect_s]
- sect_cls = sect_h['class']
- @toc.each { |k,v| v.send(k == sect_cls ? :show : :hide) }
- @title.replace sect_s
- @doc.clear(&dewikify_hi(sect_h['description'], terms, true))
- add_next_link(@docs.index { |x,| x == sect_s }, -1) rescue nil
- app.slot.scroll_top = 0
- end
-
- def open_methods(meth_s, terms = nil, meth_a = nil)
- meth_h = @methods[meth_s]
- @title.replace meth_h['title']
- @doc.clear do
- unless meth_a
- instance_eval &dewikify_hi(meth_h['description'], terms, true)
- end
- meth_h['methods'].each do |mname, expl|
- if meth_a.nil? or meth_a == mname
- sig, val = mname.split("»", 2)
- stack(:margin_top => 8, :margin_bottom => 8) {
- background "#333".."#666", :curve => 3, :angle => 90
- tagline sig, (span("»", val, :stroke => "#BBB") if val), :margin => 4 }
- instance_eval &dewikify_hi(expl, terms)
- end
- end
- end
- optn = nil
- docn = @docs.index { |_,h| optn = h['sections'].index { |x,| x == meth_s } } rescue nil
- add_next_link(docn, optn) if docn
- app.slot.scroll_top = 0
- end
-
- def manual_search(terms)
- terms += " " if terms.length == 1
- @search.find_all(terms).map do |title, count|
- title.split(" ", 2)
- end
- end
-
- def make_html(path, title, menu, &blk)
- require 'hpricot'
- File.open(path, 'w') do |f|
- f << Hpricot do
- xhtml_transitional do
- head do
- meta :"http-equiv" => "Content-Type", "content" => "text/html; charset=utf-8"
- title "The Shoes Manual // #{title}"
- script :type => "text/javascript", :src => "static/code_highlighter.js"
- script :type => "text/javascript", :src => "static/code_highlighter_ruby.js"
- style :type => "text/css" do
- text "@import 'static/manual.css';"
- end
- end
- body do
- div.main! do
- div.manual! &blk
- div.sidebar do
- img :src => "static/shoes-icon.png"
- ul do
- li { a.prime "HELP", :href => "./" }
- menu.each do |m, sm|
- li do
- a m, :href => "#{m[/^\w+/]}.html"
- if sm
- ul.sub do
- sm.each { |smm| li { a smm, :href => "#{smm}.html" } }
- end
- end
- end
- end
-
- end
- end
- end
- end
- end
- end.to_html
- end
- end
-end
-
-def Shoes.make_help_page
- font "#{DIR}/fonts/Coolvetica.ttf" unless Shoes::FONTS.include? "Coolvetica"
- proc do
- extend Shoes::Manual
- docs = load_docs Shoes::Manual.path
-
- style(Shoes::Image, :margin => 8, :margin_left => 100)
- style(Shoes::Code, :stroke => "#C30")
- style(Shoes::LinkHover, :stroke => green, :fill => nil)
- style(Shoes::Para, :size => 12, :stroke => "#332")
- style(Shoes::Tagline, :size => 12, :weight => "bold", :stroke => "#eee", :margin => 6)
- style(Shoes::Caption, :size => 24)
- background "#ddd".."#fff", :angle => 90
-
- [Shoes::LinkHover, Shoes::Para, Shoes::Tagline, Shoes::Caption].each do |type|
- style(type, :font => "MS UI Gothic")
- end if Shoes.language == 'ja'
-
- stack do
- background black
- stack :margin_left => 118 do
- para "The Shoes Manual", :stroke => "#eee", :margin_top => 8, :margin_left => 17,
- :margin_bottom => 0
- @title = title docs[0][0], :stroke => white, :margin => 4, :margin_left => 14,
- :margin_top => 0, :font => "Coolvetica"
- end
- background "rgb(66, 66, 66, 180)".."rgb(0, 0, 0, 0)", :height => 0.7
- background "rgb(66, 66, 66, 100)".."rgb(255, 255, 255, 0)", :height => 20, :bottom => 0
- end
- @doc =
- stack :margin_left => 130, :margin_top => 20, :margin_bottom => 50, :margin_right => 50 + gutter,
- &dewikify(docs[0][-1]['description'], true)
- add_next_link(0, -1)
- stack :top => 80, :left => 0, :attach => Shoes::Window do
- @toc = {}
- stack :margin => 12, :width => 130, :margin_top => 20 do
- docs.each do |sect_s, sect_h|
- sect_cls = sect_h['class']
- para strong(link(sect_s, :stroke => black) { open_section(sect_s) }),
- :size => 11, :margin => 4, :margin_top => 0
- @toc[sect_cls] =
- stack :hidden => @toc.empty? ? false : true do
- links = sect_h['sections'].map do |meth_s, meth_h|
- [link(meth_s) { open_methods(meth_s) }, "\n"]
- end.flatten
- links[-1] = {:size => 9, :margin => 4, :margin_left => 10}
- para *links
- end
- end
- end
- stack :margin => 12, :width => 118, :margin_top => 6 do
- background "#330", :curve => 4
- para "Not finding it? Try ", strong(link("Search", :stroke => white) { show_search }), "!", :stroke => "#ddd", :size => 9, :align => "center", :margin => 6
- end
- stack :margin => 12, :width => 118 do
- inscription "Shoes #{Shoes::RELEASE_NAME}\nRevision: #{Shoes::REVISION}",
- :size => 7, :align => "center", :stroke => "#999"
- end
- end
- image :width => 120, :height => 120, :top => -18, :left => 6 do
- image "#{DIR}/static/shoes-icon.png", :width => 100, :height => 100, :top => 10, :left => 10
- glow 2
- end
- end
-rescue => e
- p e.message
- p e.class
-end
-
-Shoes::Help = Shoes.make_help_page
View
25 lib/red_shoes/image.rb
@@ -1,25 +0,0 @@
-require 'digest/sha1'
-
-class Shoes
- def self.image_temp_path uri, uext
- File.join(Dir::tmpdir, "#{uri.host}-#{Time.now.usec}" + uext)
- end
- def self.image_cache_path hash, ext
- dir = File.join(CACHE_DIR, hash[0,2])
- Dir.mkdir(dir) unless File.exists?(dir)
- File.join(dir, hash[2..-1]) + ext.downcase
- end
- def snapshot(options = {}, &block)
- options[:format] ||= :svg
-
- options[:filename] ||= ( tf_path = ( require 'tempfile'
- tf = Tempfile.new(File.basename(__FILE__)).path ))
-
- _snapshot options do
- block.call
- end
- return File.read(options[:filename])
- ensure
- File.unlink(tf_path) if tf_path
- end
-end
View
128 lib/red_shoes/inspect.rb
@@ -1,128 +0,0 @@
-module Kernel
- def inspect(hits = {})
- return "(#{self.class} ...)" if hits[self]
- hits[self] = true
- if instance_variables.empty?
- "(#{self.class})"
- else
- "(#{self.class} " +
- instance_variables.map do |x|
- v = instance_variable_get(x)
- "#{x}=" + (v.method(:inspect).arity == 0 ? v.inspect : v.inspect(hits))
- end.join(' ') +
- ")"
- end
- end
- #def to_html
- # obj = self
- # Web.Bit {
- # h1 "A #{obj.class}"
- # }
- #end
- def to_s; inspect end
-end
-
-class Array
- def inspect(hits = {})
- return "[...]" if hits[self]
- hits[self] = true
- "[" + map { |x| x.method(:inspect).arity == 0 ? x.inspect : x.inspect(hits) }.join(', ') + "]"
- end
- def to_html
- ary = self
- Web.Bit {
- h5 "A List of Things"
- h1 "An Array"
- unless ary.empty?
- ol {
- ary.map { |x| li { self << HTML(x) } }
- }
- end
- }
- end
- def / len
- a = []
- each_with_index do |x, i|
- a << [] if i % len == 0
- a.last << x
- end
- a
- end
-end
-
-class Hash
- def inspect(hits = {})
- return "{...}" if hits[self]
- hits[self] = true
- mappings = map do |k,v|
- key = k.method(:inspect).arity == 0 ? k.inspect : k.inspect(hits)
- val = v.method(:inspect).arity == 0 ? v.inspect : v.inspect(hits)
- "#{key} => #{val}"
- end
- "{ #{mappings.join(', ')} }"
- end
- def to_html
- h = self
- Web.Bit {
- h5 "Pairs of Things"
- h1 "A Hash"
- unless h.empty?
- ul {
- h.each { |k, v| li { self << "<div class='hashkey'>#{HTML(k)}</div><div class='hashvalue'>#{HTML(v)}</div>" } }
- }
- end
- }
- end
-end
-
-class File
- def inspect(hits = nil)
- "(#{self.class} #{path})"
- end
-end
-
-class Proc
- def inspect(hits = nil)
- v = "a"
- pvars = []
- (arity < 0 ? -(arity+1) : arity).times do |i|
- pvars << v
- v = v.succ
- end
- pvars << "*#{v}" if arity < 0
- "(Proc |#{pvars.join(',')}|)"
- end
-end
-
-class Class
- def make_inspect m = :inspect
- alias_method :the_original_inspect, m
- class_eval %{
- def inspect(hits = nil)
- the_original_inspect
- end
- }
- #def to_html(hits = nil)
- # #{m} + " <div class='classname'>" + self.class.name + "</div>"
- #end
- end
-end
-
-class Module; make_inspect :name end
-class Regexp; make_inspect end
-class String; make_inspect end
-class Symbol; make_inspect end
-class Time; make_inspect end
-class Numeric; make_inspect :to_s end
-class Bignum; make_inspect :to_s end
-class Fixnum; make_inspect :to_s end
-class Float; make_inspect :to_s end
-class TrueClass; make_inspect :to_s end
-class FalseClass; make_inspect :to_s end
-class NilClass; make_inspect end
-
-class Shoes::Types::App
- def inspect(hits = nil)
- "(#{self.class} #{name.dump})"
- end
-end
View
48 lib/red_shoes/log.rb
@@ -1,48 +0,0 @@
-module Shoes::LogWindow
- def setup
- stack do
- flow do
- background black
- stack :width => -100 do
- tagline "Shoes Console", :stroke => white
- end
- button "Clear", :margin => 6, :width => 80, :height => 40 do
- Shoes.log.clear
- end
- end
- @log, @hash = stack, nil
- update
- every(0.2) do
- update
- end
- end
- end
- def update
- if @hash != Shoes.log.hash
- @hash = Shoes.log.hash
- @log.clear do
- i = 0
- Shoes.log.each do |typ, msg, at, mid, rbf, rbl|
- stack do
- background "#f1f5e1" if i % 2 == 0
- inscription strong(typ.to_s.capitalize, :stroke => "#05C"), " in ",
- span(rbf, " line ", rbl, :stroke => "#335"), " | ",
- span(at, :stroke => "#777"),
- :stroke => "#059", :margin => 4, :margin_bottom => 0
- flow do
- stack :margin => 6, :width => 20 do
- image "#{DIR}/static/icon-#{typ}.png"
- end
- stack :margin => 4, :width => -20 do
- s = msg.to_s.force_encoding "UTF-8"
- s << "\n#{msg.backtrace.join("\n")}" if msg.kind_of?(Exception)
- para s, :margin => 4, :margin_top => 0
- end
- end
- end
- i += 1
- end
- end
- end
- end
-end
View
986 lib/red_shoes/minitar.rb
@@ -1,986 +0,0 @@
-#!/usr/bin/env ruby
-#--
-# Archive::Tar::Minitar 0.5.1
-# Copyright © 2004 Mauricio Julio Fernández Pradier and Austin Ziegler
-#
-# This program is based on and incorporates parts of RPA::Package from
-# rpa-base (lib/rpa/package.rb and lib/rpa/util.rb) by Mauricio and has been
-# adapted to be more generic by Austin.
-#
-# It is licensed under the GNU General Public Licence or Ruby's licence.
-#
-# $Id: minitar.rb,v 1.3 2004/09/22 17:47:43 austin Exp $
-#++
-
-module Archive; end
-module Archive::Tar; end
-
- # = Archive::Tar::PosixHeader
- # Implements the POSIX tar header as a Ruby class. The structure of
- # the POSIX tar header is:
- #
- # struct tarfile_entry_posix
- # { // pack/unpack
- # char name[100]; // ASCII (+ Z unless filled) a100/Z100
- # char mode[8]; // 0 padded, octal, null a8 /A8
- # char uid[8]; // ditto a8 /A8
- # char gid[8]; // ditto a8 /A8
- # char size[12]; // 0 padded, octal, null a12 /A12
- # char mtime[12]; // 0 padded, octal, null a12 /A12
- # char checksum[8]; // 0 padded, octal, null, space a8 /A8
- # char typeflag[1]; // see below a /a
- # char linkname[100]; // ASCII + (Z unless filled) a100/Z100
- # char magic[6]; // "ustar\0" a6 /A6
- # char version[2]; // "00" a2 /A2
- # char uname[32]; // ASCIIZ a32 /Z32
- # char gname[32]; // ASCIIZ a32 /Z32
- # char devmajor[8]; // 0 padded, octal, null a8 /A8
- # char devminor[8]; // 0 padded, octal, null a8 /A8
- # char prefix[155]; // ASCII (+ Z unless filled) a155/Z155
- # };
- #
- # The +typeflag+ may be one of the following known values:
- #
- # <tt>"0"</tt>:: Regular file. NULL should be treated as a synonym, for
- # compatibility purposes.
- # <tt>"1"</tt>:: Hard link.
- # <tt>"2"</tt>:: Symbolic link.
- # <tt>"3"</tt>:: Character device node.
- # <tt>"4"</tt>:: Block device node.
- # <tt>"5"</tt>:: Directory.
- # <tt>"6"</tt>:: FIFO node.
- # <tt>"7"</tt>:: Reserved.
- #
- # POSIX indicates that "A POSIX-compliant implementation must treat any
- # unrecognized typeflag value as a regular file."
-class Archive::Tar::PosixHeader
- FIELDS = %w(name mode uid gid size mtime checksum typeflag linkname) +
- %w(magic version uname gname devmajor devminor prefix)
-
- FIELDS.each { |field| attr_reader field.intern }
-
- HEADER_PACK_FORMAT = "a100a8a8a8a12a12a7aaa100a6a2a32a32a8a8a155"
- HEADER_UNPACK_FORMAT = "Z100A8A8A8A12A12A8aZ100A6A2Z32Z32A8A8Z155"
-
- # Creates a new PosixHeader from a data stream.
- def self.new_from_stream(stream)
- data = stream.read(512)
- fields = data.unpack(HEADER_UNPACK_FORMAT)
- name = fields.shift
- mode = fields.shift.oct
- uid = fields.shift.oct
- gid = fields.shift.oct
- size = fields.shift.oct
- mtime = fields.shift.oct
- checksum = fields.shift.oct
- typeflag = fields.shift
- linkname = fields.shift
- magic = fields.shift
- version = fields.shift.oct
- uname = fields.shift
- gname = fields.shift
- devmajor = fields.shift.oct
- devminor = fields.shift.oct
- prefix = fields.shift
-
- empty = (data == "\0" * 512)
-
- new(:name => name, :mode => mode, :uid => uid, :gid => gid,
- :size => size, :mtime => mtime, :checksum => checksum,
- :typeflag => typeflag, :magic => magic, :version => version,
- :uname => uname, :gname => gname, :devmajor => devmajor,
- :devminor => devminor, :prefix => prefix, :empty => empty)
- end
-
- # Creates a new PosixHeader. A PosixHeader cannot be created unless the
- # #name, #size, #prefix, and #mode are provided.
- def initialize(vals)
- unless vals[:name] && vals[:size] && vals[:prefix] && vals[:mode]
- raise ArgumentError
- end
-
- vals[:mtime] ||= 0
- vals[:checksum] ||= ""
- vals[:typeflag] ||= "0"
- vals[:magic] ||= "ustar"
- vals[:version] ||= "00"
-
- FIELDS.each do |field|
- instance_variable_set("@#{field}", vals[field.intern])
- end
- @empty = vals[:empty]
- end
-
- def empty?
- @empty
- end
-
- def to_s
- update_checksum
- header(@checksum)
- end
-
- # Update the checksum field.
- def update_checksum
- hh = header(" " * 8)
- @checksum = oct(calculate_checksum(hh), 6)
- end
-
- private
- def oct(num, len)
- if num.nil?
- "\0" * (len + 1)
- else
- "%0#{len}o" % num
- end
- end
-
- def calculate_checksum(hdr)
- hdr.unpack("C*").inject { |aa, bb| aa + bb }
- end
-
- def header(chksum)
- arr = [name, oct(mode, 7), oct(uid, 7), oct(gid, 7), oct(size, 11),
- oct(mtime, 11), chksum, " ", typeflag, linkname, magic, version,
- uname, gname, oct(devmajor, 7), oct(devminor, 7), prefix]
- str = arr.pack(HEADER_PACK_FORMAT)
- str + "\0" * ((512 - str.size) % 512)
- end
-end
-
-require 'fileutils'
-require 'find'
-
- # = Archive::Tar::Minitar 0.5.1
- # Archive::Tar::Minitar is a pure-Ruby library and command-line
- # utility that provides the ability to deal with POSIX tar(1) archive
- # files. The implementation is based heavily on Mauricio Fernández's
- # implementation in rpa-base, but has been reorganised to promote
- # reuse in other projects.
- #
- # This tar class performs a subset of all tar (POSIX tape archive)
- # operations. We can only deal with typeflags 0, 1, 2, and 5 (see
- # Archive::Tar::PosixHeader). All other typeflags will be treated as
- # normal files.
- #
- # NOTE::: support for typeflags 1 and 2 is not yet implemented in this
- # version.
- #
- # This release is version 0.5.1. The library can only handle files and
- # directories at this point. A future version will be expanded to
- # handle symbolic links and hard links in a portable manner. The
- # command line utility, minitar, can only create archives, extract
- # from archives, and list archive contents.
- #
- # == Synopsis
- # Using this library is easy. The simplest case is:
- #
- # require 'zlib'
- # require 'archive/tar/minitar'
- # include Archive::Tar
- #
- # # Packs everything that matches Find.find('tests')
- # File.open('test.tar', 'wb') { |tar| Minitar.pack('tests', tar) }
- # # Unpacks 'test.tar' to 'x', creating 'x' if necessary.
- # Minitar.unpack('test.tar', 'x')
- #
- # A gzipped tar can be written with:
- #
- # tgz = Zlib::GzipWriter.new(File.open('test.tgz', 'wb'))
- # # Warning: tgz will be closed!
- # Minitar.pack('tests', tgz)
- #
- # tgz = Zlib::GzipReader.new(File.open('test.tgz', 'rb'))
- # # Warning: tgz will be closed!
- # Minitar.unpack(tgz, 'x')
- #
- # As the case above shows, one need not write to a file. However, it
- # will sometimes require that one dive a little deeper into the API,
- # as in the case of StringIO objects. Note that I'm not providing a
- # block with Minitar::Output, as Minitar::Output#close automatically
- # closes both the Output object and the wrapped data stream object.
- #
- # begin
- # sgz = Zlib::GzipWriter.new(StringIO.new(""))
- # tar = Output.new(sgz)
- # Find.find('tests') do |entry|
- # Minitar.pack_file(entry, tar)
- # end
- # ensure
- # # Closes both tar and sgz.
- # tar.close
- # end
- #
- # == Copyright
- # Copyright 2004 Mauricio Julio Fernández Pradier and Austin Ziegler
- #
- # This program is based on and incorporates parts of RPA::Package from
- # rpa-base (lib/rpa/package.rb and lib/rpa/util.rb) by Mauricio and
- # has been adapted to be more generic by Austin.
- #
- # 'minitar' contains an adaptation of Ruby/ProgressBar by Satoru
- # Takabayashi <satoru@namazu.org>, copyright © 2001 - 2004.
- #
- # This program is free software. It may be redistributed and/or
- # modified under the terms of the GPL version 2 (or later) or Ruby's
- # licence.
-module Archive::Tar::Minitar
- VERSION = "0.5.1"
-
- # The exception raised when a wrapped data stream class is expected to
- # respond to #rewind or #pos but does not.
- class NonSeekableStream < StandardError; end
- # The exception raised when a block is required for proper operation of
- # the method.
- class BlockRequired < ArgumentError; end
- # The exception raised when operations are performed on a stream that has
- # previously been closed.
- class ClosedStream < StandardError; end
- # The exception raised when a filename exceeds 256 bytes in length,
- # the maximum supported by the standard Tar format.
- class FileNameTooLong < StandardError; end
- # The exception raised when a data stream ends before the amount of data
- # expected in the archive's PosixHeader.
- class UnexpectedEOF < StandardError; end
-
- # The class that writes a tar format archive to a data stream.
- class Writer
- # A stream wrapper that can only be written to. Any attempt to read
- # from this restricted stream will result in a NameError being thrown.
- class RestrictedStream
- def initialize(anIO)
- @io = anIO
- end
-
- def write(data)
- @io.write(data)
- end
- end
-
- # A RestrictedStream that also has a size limit.
- class BoundedStream < Archive::Tar::Minitar::Writer::RestrictedStream
- # The exception raised when the user attempts to write more data to
- # a BoundedStream than has been allocated.
- class FileOverflow < RuntimeError; end
-
- # The maximum number of bytes that may be written to this data
- # stream.
- attr_reader :limit
- # The current total number of bytes written to this data stream.
- attr_reader :written
-
- def initialize(io, limit)
- @io = io
- @limit = limit
- @written = 0
- end
-
- def write(data)
- raise FileOverflow if (data.size + @written) > @limit
- @io.write(data)
- @written += data.size
- data.size
- end
- end
-
- # With no associated block, +Writer::open+ is a synonym for
- # +Writer::new+. If the optional code block is given, it will be
- # passed the new _writer_ as an argument and the Writer object will
- # automatically be closed when the block terminates. In this instance,
- # +Writer::open+ returns the value of the block.
- def self.open(anIO)
- writer = Writer.new(anIO)
-
- return writer unless block_given?
-
- begin
- res = yield writer
- ensure
- writer.close
- end
-
- res
- end
-
- # Creates and returns a new Writer object.
- def initialize(anIO)
- @io = anIO
- @closed = false
- end
-
- # Adds a file to the archive as +name+. +opts+ must contain the
- # following values:
- #
- # <tt>:mode</tt>:: The Unix file permissions mode value.
- # <tt>:size</tt>:: The size, in bytes.
- #
- # +opts+ may contain the following values:
- #
- # <tt>:uid</tt>: The Unix file owner user ID number.
- # <tt>:gid</tt>: The Unix file owner group ID number.
- # <tt>:mtime</tt>:: The *integer* modification time value.
- #
- # It will not be possible to add more than <tt>opts[:size]</tt> bytes
- # to the file.
- def add_file_simple(name, opts = {}) # :yields BoundedStream:
- raise Archive::Tar::Minitar::BlockRequired unless block_given?
- raise Archive::Tar::ClosedStream if @closed
-
- name, prefix = split_name(name)
-
- header = { :name => name, :mode => opts[:mode], :mtime => opts[:mtime],
- :size => opts[:size], :gid => opts[:gid], :uid => opts[:uid],
- :prefix => prefix }
- header = Archive::Tar::PosixHeader.new(header).to_s
- @io.write(header)
-
- os = BoundedStream.new(@io, opts[:size])
- yield os
- # FIXME: what if an exception is raised in the block?
-
- min_padding = opts[:size] - os.written
- @io.write("\0" * min_padding)
- remainder = (512 - (opts[:size] % 512)) % 512
- @io.write("\0" * remainder)
- end
-
- # Adds a file to the archive as +name+. +opts+ must contain the
- # following value:
- #
- # <tt>:mode</tt>:: The Unix file permissions mode value.
- #
- # +opts+ may contain the following values:
- #
- # <tt>:uid</tt>: The Unix file owner user ID number.
- # <tt>:gid</tt>: The Unix file owner group ID number.
- # <tt>:mtime</tt>:: The *integer* modification time value.
- #
- # The file's size will be determined from the amount of data written
- # to the stream.
- #
- # For #add_file to be used, the Archive::Tar::Minitar::Writer must be
- # wrapping a stream object that is seekable (e.g., it responds to
- # #pos=). Otherwise, #add_file_simple must be used.
- #
- # +opts+ may be modified during the writing to the stream.
- def add_file(name, opts = {}) # :yields RestrictedStream, +opts+:
- raise Archive::Tar::Minitar::BlockRequired unless block_given?
- raise Archive::Tar::Minitar::ClosedStream if @closed
- raise Archive::Tar::Minitar::NonSeekableStream unless @io.respond_to?(:pos=)
-
- name, prefix = split_name(name)
- init_pos = @io.pos
- @io.write("\0" * 512) # placeholder for the header
-
- yield RestrictedStream.new(@io), opts
- # FIXME: what if an exception is raised in the block?
-
- size = @io.pos - (init_pos + 512)
- remainder = (512 - (size % 512)) % 512
- @io.write("\0" * remainder)
-
- final_pos = @io.pos
- @io.pos = init_pos
-
- header = { :name => name, :mode => opts[:mode], :mtime => opts[:mtime],
- :size => size, :gid => opts[:gid], :uid => opts[:uid],
- :prefix => prefix }
- header = Archive::Tar::PosixHeader.new(header).to_s
- @io.write(header)
- @io.pos = final_pos
- end
-
- # Creates a directory in the tar.
- def mkdir(name, opts = {})
- raise ClosedStream if @closed
- name, prefix = split_name(name)
- header = { :name => name, :mode => opts[:mode], :typeflag => "5",
- :size => 0, :gid => opts[:gid], :uid => opts[:uid],
- :mtime => opts[:mtime], :prefix => prefix }
- header = Archive::Tar::PosixHeader.new(header).to_s
- @io.write(header)
- nil
- end
-
- # Passes the #flush method to the wrapped stream, used for buffered
- # streams.
- def flush
- raise ClosedStream if @closed
- @io.flush if @io.respond_to?(:flush)
- end
-
- # Closes the Writer.
- def close
- return if @closed
- @io.write("\0" * 1024)
- @closed = true
- end
-
- private
- def split_name(name)
- raise FileNameTooLong if name.size > 256
- if name.size <= 100
- prefix = ""
- else
- parts = name.split(/\//)
- newname = parts.pop
-
- nxt = ""
-
- loop do
- nxt = parts.pop
- break if newname.size + 1 + nxt.size > 100
- newname = "#{nxt}/#{newname}"
- end
-
- prefix = (parts + [nxt]).join("/")
-
- name = newname
-
- raise FileNameTooLong if name.size > 100 || prefix.size > 155
- end
- return name, prefix
- end
- end
-
- # The class that reads a tar format archive from a data stream. The data
- # stream may be sequential or random access, but certain features only work
- # with random access data streams.
- class Reader
- # This marks the EntryStream closed for reading without closing the
- # actual data stream.
- module InvalidEntryStream
- def read(len = nil); raise ClosedStream; end
- def getc; raise ClosedStream; end
- def rewind; raise ClosedStream; end
- end
-
- # EntryStreams are pseudo-streams on top of the main data stream.
- class EntryStream
- Archive::Tar::PosixHeader::FIELDS.each do |field|
- attr_reader field.intern
- end
-
- def initialize(header, anIO)
- @io = anIO
- @name = header.name
- @mode = header.mode
- @uid = header.uid
- @gid = header.gid
- @size = header.size
- @mtime = header.mtime
- @checksum = header.checksum
- @typeflag = header.typeflag
- @linkname = header.linkname
- @magic = header.magic
- @version = header.version
- @uname = header.uname
- @gname = header.gname
- @devmajor = header.devmajor
- @devminor = header.devminor
- @prefix = header.prefix
- @read = 0
- @orig_pos = @io.pos
- end
-
- # Reads +len+ bytes (or all remaining data) from the entry. Returns
- # +nil+ if there is no more data to read.
- def read(len = nil)
- return nil if @read >= @size
- len ||= @size - @read
- max_read = [len, @size - @read].min
- ret = @io.read(max_read)
- @read += ret.size
- ret
- end
-
- # Reads one byte from the entry. Returns +nil+ if there is no more data
- # to read.
- def getc
- return nil if @read >= @size
- ret = @io.getc
- @read += 1 if ret
- ret
- end
-
- # Returns +true+ if the entry represents a directory.
- def directory?
- @typeflag == "5"
- end
- alias_method :directory, :directory?
-
- # Returns +true+ if the entry represents a plain file.
- def file?
- @typeflag == "0"
- end
- alias_method :file, :file?
-
- # Returns +true+ if the current read pointer is at the end of the
- # EntryStream data.
- def eof?
- @read >= @size
- end
-
- # Returns the current read pointer in the EntryStream.
- def pos
- @read
- end
-
- # Sets the current read pointer to the beginning of the EntryStream.
- def rewind
- raise NonSeekableStream unless @io.respond_to?(:pos=)
- @io.pos = @orig_pos
- @read = 0
- end
-
- def orig_pos
- @orig_pos
- end
-
- def bytes_read
- @read
- end
-
- # Returns the full and proper name of the entry.
- def full_name
- if @prefix != ""
- File.join(@prefix, @name)
- else
- @name
- end
- end
-
- # Closes the entry.
- def close
- invalidate
- end
-
- private
- def invalidate
- extend InvalidEntryStream
- end
- end
-
- # With no associated block, +Reader::open+ is a synonym for
- # +Reader::new+. If the optional code block is given, it will be passed
- # the new _writer_ as an argument and the Reader object will
- # automatically be closed when the block terminates. In this instance,
- # +Reader::open+ returns the value of the block.
- def self.open(anIO)
- reader = Reader.new(anIO)
-
- return reader unless block_given?
-
- begin
- res = yield reader
- ensure
- reader.close
- end
-
- res
- end
-
- # Creates and returns a new Reader object.
- def initialize(anIO)
- @io = anIO
- @init_pos = anIO.pos
- end
-
- # Iterates through each entry in the data stream.
- def each(&block)
- each_entry(&block)
- end
-
- # Resets the read pointer to the beginning of data stream. Do not call
- # this during a #each or #each_entry iteration. This only works with
- # random access data streams that respond to #rewind and #pos.
- def rewind
- if @init_pos == 0
- raise NonSeekableStream unless @io.respond_to?(:rewind)
- @io.rewind
- else
- raise NonSeekableStream unless @io.respond_to?(:pos=)
- @io.pos = @init_pos
- end
- end
-
- # Iterates through each entry in the data stream.
- def each_entry
- loop do
- return if @io.eof?
-
- header = Archive::Tar::PosixHeader.new_from_stream(@io)
- return if header.empty?
-
- entry = EntryStream.new(header, @io)
- size = entry.size
-
- yield entry
-
- skip = (512 - (size % 512)) % 512
-
- if @io.respond_to?(:seek)
- # avoid reading...
- @io.seek(size - entry.bytes_read, IO::SEEK_CUR