green_shoes 1.0.337 → 1.1.348

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/VERSION +1 -1
  2. data/bin/gshoes +57 -0
  3. data/bin/gshoes.bat +2 -0
  4. data/bin/gshoes.ico +0 -0
  5. data/lib/green_shoes.rb +2 -0
  6. data/lib/shoes/app.rb +1 -1
  7. data/lib/shoes/help.rb +1 -1
  8. data/lib/shoes/helper_methods.rb +2 -2
  9. data/lib/shoes/minitar.rb +986 -0
  10. data/lib/shoes/shy.rb +130 -0
  11. data/samples/sample1.rb +2 -2
  12. data/samples/sample10.rb +1 -1
  13. data/samples/sample11.rb +1 -1
  14. data/samples/sample12.rb +1 -1
  15. data/samples/sample13.rb +1 -1
  16. data/samples/sample14-1.rb +1 -1
  17. data/samples/sample14.rb +1 -1
  18. data/samples/sample15.rb +2 -2
  19. data/samples/sample16.rb +1 -1
  20. data/samples/sample17.rb +1 -1
  21. data/samples/sample18.rb +2 -2
  22. data/samples/sample19.rb +1 -1
  23. data/samples/sample2.rb +6 -5
  24. data/samples/sample20.rb +5 -5
  25. data/samples/sample21.rb +2 -2
  26. data/samples/sample22.rb +1 -1
  27. data/samples/sample23.rb +2 -2
  28. data/samples/sample24.rb +2 -2
  29. data/samples/sample25.rb +2 -2
  30. data/samples/sample26.rb +1 -1
  31. data/samples/sample27.rb +1 -1
  32. data/samples/sample28.rb +1 -1
  33. data/samples/sample29.rb +1 -1
  34. data/samples/sample3.rb +1 -1
  35. data/samples/sample30.rb +2 -2
  36. data/samples/sample31.rb +1 -1
  37. data/samples/sample32.rb +1 -1
  38. data/samples/sample33.rb +1 -1
  39. data/samples/sample34.rb +1 -1
  40. data/samples/sample35.rb +3 -3
  41. data/samples/sample36.rb +2 -2
  42. data/samples/sample37.rb +1 -1
  43. data/samples/sample38.rb +1 -1
  44. data/samples/sample39.rb +2 -2
  45. data/samples/sample4.rb +1 -1
  46. data/samples/sample40.rb +1 -1
  47. data/samples/sample41.rb +1 -1
  48. data/samples/sample42.rb +1 -1
  49. data/samples/sample43.rb +1 -1
  50. data/samples/sample44.rb +1 -1
  51. data/samples/sample45.rb +1 -1
  52. data/samples/sample46.rb +1 -1
  53. data/samples/sample47.rb +2 -2
  54. data/samples/sample48.rb +1 -1
  55. data/samples/sample49.rb +1 -1
  56. data/samples/sample5.rb +2 -2
  57. data/samples/sample50.rb +1 -1
  58. data/samples/sample51.rb +2 -2
  59. data/samples/sample52.rb +1 -1
  60. data/samples/sample53.rb +1 -1
  61. data/samples/sample54.rb +2 -2
  62. data/samples/sample55.rb +1 -1
  63. data/samples/sample56.rb +1 -1
  64. data/samples/sample57.rb +1 -1
  65. data/samples/sample58.rb +2 -2
  66. data/samples/sample6.rb +1 -1
  67. data/samples/sample7.rb +1 -1
  68. data/samples/sample8.rb +2 -2
  69. data/samples/sample9.rb +2 -2
  70. data/samples/sample99.rb +1 -1
  71. data/static/manual-en.txt +27 -2
  72. data/static/manual-ja.txt +26 -2
  73. metadata +11 -6
  74. data/samples/potato_chopping/1258_s060.gif +0 -0
data/lib/shoes/shy.rb ADDED
@@ -0,0 +1,130 @@
1
+ #
2
+ # lib/shoes/shy.rb
3
+ # Shy, the Shoes YAML archive format
4
+ #
5
+ require 'digest/md5'
6
+ require 'zlib'
7
+ require 'find'
8
+ require 'tmpdir'
9
+ require 'yaml'
10
+
11
+ class Shy
12
+ VERSION = 0x0001
13
+ MAGIC = "_shy".freeze
14
+ LAYOUT = "A4vV".freeze #Force to Little Endian for all platforms
15
+
16
+ yaml_as 'tag:hackety.org,2007:shy'
17
+ attr_accessor :name, :creator, :version, :launch
18
+
19
+ def self.launchable(d)
20
+ if File.directory? d
21
+ Dir["#{d}/**/*.rb"].map do |path|
22
+ path.gsub(%r!#{Regexp::quote(d)}/!, '')
23
+ end
24
+ else
25
+ [File.basename(d)]
26
+ end
27
+ end
28
+
29
+ def self.__hdr__(f)
30
+ hdr = f.read(10).unpack(LAYOUT)
31
+ raise IOError, "Invalid header" if hdr[0] != MAGIC and hdr[1] > VERSION
32
+ YAML.load(f.read(hdr[2]))
33
+ end
34
+
35
+
36
+ def self.du(root)
37
+ size = 0
38
+ Find.find(root) do |path|
39
+ if FileTest.directory?(path)
40
+ if File.basename(path)[0] == ?.
41
+ Find.prune
42
+ else
43
+ next
44
+ end
45
+ else
46
+ size += FileTest.size(path)
47
+ end
48
+ end
49
+ size
50
+ end
51
+
52
+ def self.meta(path, d = ".")
53
+ File.open(path, 'rb') do |f|
54
+ shy = __hdr__(f)
55
+ end
56
+ end
57
+
58
+ def self.x(path, d = ".")
59
+ File.open(path, 'rb') do |f|
60
+ shy = __hdr__(f)
61
+ inp = Zlib::GzipReader.new(f)
62
+ Archive::Tar::Minitar.unpack(inp, d)
63
+ shy
64
+ end
65
+ end
66
+
67
+ def self.c(path, shy, d, &blk)
68
+ path = File.expand_path(path)
69
+ meta = shy.to_yaml
70
+ File.open(path, "wb") do |f|
71
+ f << [MAGIC, VERSION, meta.length].pack(LAYOUT)
72
+ f << meta
73
+ self.czf(f, d, &blk)
74
+ end
75
+ end
76
+
77
+ def self.progress(total, &blk)
78
+ if blk
79
+ last, left = 0.0, total
80
+ proc do |action, name, stats|
81
+ if action == :file_progress
82
+ left -= stats[:currinc]
83
+ prg = 1.0 - (left.to_f / total.to_f)
84
+ blk[name, (last = prg), left] if prg - last > 0.02
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+ def self.czf(f, d, &blk)
91
+ total = du(d)
92
+ out = Zlib::GzipWriter.new(f)
93
+ files = ["."]
94
+ unless File.directory? d
95
+ files = [File.basename(d)]
96
+ d = File.dirname(d)
97
+ end
98
+ Dir.chdir(d) do
99
+ Archive::Tar::Minitar.pack(files, out, &blk)
100
+ end
101
+ end
102
+
103
+ def self.xzf(f, d, &blk)
104
+ gz = Zlib::GzipReader.new(f)
105
+ Archive::Tar::Minitar.unpack(gz, d, &blk)
106
+ end
107
+
108
+ def self.md5sum(path)
109
+ digest = Digest::MD5.new
110
+ File.open(path, "rb") do |f|
111
+ digest.update f.read(8192) until f.eof
112
+ end
113
+ digest.hexdigest
114
+ end
115
+
116
+ def self.hrun(f)
117
+ b, i = 0, 1
118
+ last = 65535
119
+ while i < last
120
+ case f.readline
121
+ when /OLDSKIP=(\d+)/
122
+ last = $1.to_i
123
+ when /FULLSIZE=(\d+)/
124
+ b = $1.to_i
125
+ end
126
+ i += 1
127
+ end
128
+ b
129
+ end
130
+ end
data/samples/sample1.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  xspeed, yspeed = 10, 6
4
4
  xdir, ydir = 1, 1
@@ -10,7 +10,7 @@ Shoes.app width: 300, height: 300 do
10
10
  button('stop'){a.stop}
11
11
  button('move'){p.move 200, 30}
12
12
  button('remove'){p.clear}
13
- img = image '../static/gshoes-icon.png'
13
+ img = image File.join(DIR, '../static/gshoes-icon.png')
14
14
  img.click{alert "You're soooo quick!"}
15
15
 
16
16
  x, y = 150, 150
data/samples/sample10.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app width: 300, height: 300 do
4
4
  flow do
data/samples/sample11.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # Same snippet as http://shoes.heroku.com/manual/Events.html#motion{|left,top|...}
2
2
 
3
- require '../lib/green_shoes'
3
+ require 'green_shoes'
4
4
 
5
5
  Shoes.app width: 200, height: 200 do
6
6
  background black
data/samples/sample12.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app width: 300, height: 300 do
4
4
  background cadetblue
data/samples/sample13.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  # The same as sample60.rb on Shoes Tutorial Note
4
4
  Shoes.app :width => 300, :height => 300 do
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app width: 520, height: 520 do
4
4
  def mk_ovals degree, color, size, mx, my, n, n1, n2, n3
data/samples/sample14.rb CHANGED
@@ -10,7 +10,7 @@
10
10
  # directions. As the circles move they change size and color.
11
11
  #
12
12
 
13
- require '../lib/green_shoes'
13
+ require 'green_shoes'
14
14
 
15
15
  degree = 0
16
16
  color = 0
data/samples/sample15.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  TEXT =<<EOS
4
4
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, \
@@ -17,4 +17,4 @@ Shoes.app do
17
17
  para lines[0], NL
18
18
  para lines[1], NL, justify: true
19
19
  para lines[2], NL, leading: -5
20
- end
20
+ end
data/samples/sample16.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # Same snippet as http://shoes-tutorial-note.heroku.com/html/00402_No.1_para.html
2
2
 
3
- require '../lib/green_shoes'
3
+ require 'green_shoes'
4
4
 
5
5
  Shoes.app :width => 240, :height => 95 do
6
6
  para 'Testing, test, test. ',
data/samples/sample17.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # Add new method bg and fg to sample17
2
2
 
3
- require '../lib/green_shoes'
3
+ require 'green_shoes'
4
4
 
5
5
  Shoes.app :width => 240, :height => 95 do
6
6
  para 'Testing, test, test. ',
data/samples/sample18.rb CHANGED
@@ -1,10 +1,10 @@
1
- require "../lib/green_shoes"
1
+ require "green_shoes"
2
2
 
3
3
  Shoes.app width: 700, height: 600 do
4
4
  title "Shoes is a ", link("tiny"){alert "Cool!"}, " graphics toolkit. "
5
5
 
6
6
  flow width: 0.4 do
7
- img = image '../static/gshoes-icon.png'
7
+ img = image File.join(DIR, '../static/gshoes-icon.png')
8
8
  img.click{alert "You're soooo quick!"}
9
9
  end
10
10
 
data/samples/sample19.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # almost the same code as sample58 on (Red) Shoes Tutorial Note:
2
2
  # http://shoes-tutorial-note.heroku.com/html/00704_Assignment_4_Pong_in_Shoes.html
3
- require '../lib/green_shoes'
3
+ require 'green_shoes'
4
4
 
5
5
  Shoes.app :width => 400, :height => 400, :resizable => false do
6
6
  vx, vy = 3, 4
data/samples/sample2.rb CHANGED
@@ -1,13 +1,14 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app title: 'Green Shoes New Logo Icon!', width: 300, height: 420 do
4
4
  stack do
5
- image '../static/gshoes-icon.png'
5
+ path = File.join(DIR, '../static/gshoes-icon.png')
6
+ image path
6
7
  flow do
7
- image '../static/gshoes-icon.png'
8
- image '../static/gshoes-icon.png'
8
+ image path
9
+ image path
9
10
  end
10
- image '../static/gshoes-icon.png'
11
+ image path
11
12
  para ' ' * 30, 'Created by Zak'
12
13
  end
13
14
  end
data/samples/sample20.rb CHANGED
@@ -1,24 +1,24 @@
1
1
  # This is a tiny flip book (aka Para-Para Manga in Japanese)
2
2
  # original is http://www.paraman.net/play/preview/1258
3
3
  #
4
- require '../lib/green_shoes'
4
+ require 'green_shoes'
5
5
 
6
6
  Shoes.app title: 'potacho', width: 175, height: 160 do
7
7
  background tan
8
8
 
9
9
  @imgs = []
10
- 1.upto 60 do |i|
11
- @imgs << image("./potato_chopping/1258_s#{"%03d" % i}.gif").hide.move(10, 10)
10
+ 1.upto 59 do |i|
11
+ @imgs << image(File.join(DIR, "../samples/potato_chopping/1258_s#{"%03d" % i}.gif")).hide.move(10, 10)
12
12
  end
13
13
 
14
14
  @imgs.first.show
15
15
 
16
16
  def potacho
17
- @imgs[59].hide
17
+ @imgs[58].hide
18
18
  a = animate 12 do |i|
19
19
  @imgs[i].show
20
20
  @imgs[i-1].hide if i > 0
21
- a.stop if i > 58
21
+ a.stop if i > 57
22
22
  end
23
23
  end
24
24
 
data/samples/sample21.rb CHANGED
@@ -1,7 +1,7 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app width: 300, height: 100 do
4
4
  background forestgreen, curve: 30
5
5
  border gold, strokewidth: 5, curve: 30
6
6
  subtitle fg(strong('Shoes Shoes Shoes'), white), align: 'center'
7
- end
7
+ end
data/samples/sample22.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app do
4
4
  background chocolate..black, angle: 130
data/samples/sample23.rb CHANGED
@@ -1,7 +1,7 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app width: 300, height: 300 do
4
- fname = '../static/gshoes-icon.png'
4
+ fname = File.join(DIR, '../static/gshoes-icon.png')
5
5
  background yellow..orange, angle: 90
6
6
  border fname, strokewidth: 20, curve: 100
7
7
  fill fname
data/samples/sample24.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app width: 400, height: 400 do
4
4
  cap [:rect, :curve, :project][rand 3]
@@ -8,7 +8,7 @@ Shoes.app width: 400, height: 400 do
8
8
  rect 200, 200, 100, 100
9
9
  rect 0, 200, 100, 100
10
10
  rect 200, 0, 100, 100
11
- stroke '../static/gshoes-icon.png'
11
+ stroke File.join(DIR, '../static/gshoes-icon.png')
12
12
  strokewidth 10
13
13
  line 355, 180, 5, 111, strokewidth: 20
14
14
  stroke red
data/samples/sample25.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app width: 305, height: 460 do
4
4
  background lightskyblue
@@ -11,7 +11,7 @@ Shoes.app width: 305, height: 460 do
11
11
  end
12
12
  end
13
13
 
14
- image '../static/gshoes-icon.png', margin: 20, margin_left: 80
14
+ image File.join(DIR, '../static/gshoes-icon.png'), margin: 20, margin_left: 80
15
15
  tagline fg(em(strong('A sample for margin style.')), maroon),
16
16
  margin: [30, 0, 0, 30]
17
17
 
data/samples/sample26.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app width: 450, height: 150 do
4
4
  background black
data/samples/sample27.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app do
4
4
  button 'go' do
data/samples/sample28.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # The Game Snake. Refer to Gallery No.7: http://shoes-tutorial-note.heroku.com/html/01120_Fancy_Gallery_6-10.html
2
- require '../lib/green_shoes'
2
+ require 'green_shoes'
3
3
 
4
4
  Shoes.app :title => 'Snake Game v0.1' do
5
5
  background black
data/samples/sample29.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app do
4
4
  lb = list_box items: COLORS.keys.map(&:to_s), choose: 'red' do |s|
data/samples/sample3.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app width: 300, height: 400 do
4
4
  fill rgb(0, 0.6, 0.9, 0.1)
data/samples/sample30.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  # Almost same code as sample22.rb : http://shoes-tutorial-note.heroku.com/html/00508_The_Widget_class.html
2
2
 
3
- require '../lib/green_shoes'
3
+ require 'green_shoes'
4
4
 
5
5
  class Answer < Shoes::Widget
6
6
  attr_reader :mark
7
7
  def initialize word
8
8
  flow do
9
9
  para word, width: 70
10
- @mark = image('./loogink.png', width: 20, height: 20).hide
10
+ @mark = image(File.join(DIR, '../samples/loogink.png'), width: 20, height: 20).hide
11
11
  end
12
12
  end
13
13
  end
data/samples/sample31.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app do
4
4
  strokewidth 3
data/samples/sample32.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app title: 'A Tiny Chipmunk Physics Demo' do
4
4
  extend ChipMunk
data/samples/sample33.rb CHANGED
@@ -1,4 +1,4 @@
1
- require '../lib/green_shoes'
1
+ require 'green_shoes'
2
2
 
3
3
  Shoes.app width: 500, height: 100, title: 'Bloopsaphone Play Lists'do
4
4
  background mediumspringgreen..hotpink, angle: 90
data/samples/sample34.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # Refer to NKS (Nobody Knows Shoes) page 21.
2
2
 
3
- require '../lib/green_shoes'
3
+ require 'green_shoes'
4
4
 
5
5
  Shoes.app width: 280, height: 440 do
6
6
  flow width: 1.0, margin: 10 do