limelight 0.2.1-java → 0.3.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. data/bin/ll.bat +1 -1
  2. data/lib/i4jruntime.jar +0 -0
  3. data/lib/junit-4.4.jar +0 -0
  4. data/lib/limelight.jar +0 -0
  5. data/lib/limelight/animation.rb +3 -3
  6. data/lib/limelight/builtin/players.rb +2 -1
  7. data/lib/limelight/builtin/players/combo_box.rb +8 -2
  8. data/lib/limelight/builtin/players/image.rb +47 -0
  9. data/lib/limelight/builtin/styles.rb +1 -1
  10. data/lib/limelight/casting_director.rb +70 -39
  11. data/lib/limelight/commands/command.rb +150 -0
  12. data/lib/limelight/commands/create_command.rb +79 -0
  13. data/lib/limelight/commands/freeze_command.rb +113 -0
  14. data/lib/limelight/commands/open_command.rb +49 -0
  15. data/lib/limelight/commands/pack_command.rb +45 -0
  16. data/lib/limelight/dsl/build_exception.rb +51 -0
  17. data/lib/limelight/dsl/menu_bar.rb +71 -0
  18. data/lib/limelight/dsl/production_builder.rb +71 -0
  19. data/lib/limelight/dsl/prop_builder.rb +155 -0
  20. data/lib/limelight/dsl/stage_builder.rb +105 -0
  21. data/lib/limelight/dsl/styles_builder.rb +134 -0
  22. data/lib/limelight/file_loader.rb +46 -0
  23. data/lib/limelight/gems.rb +45 -0
  24. data/lib/limelight/java_couplings.rb +7 -2
  25. data/lib/limelight/java_util.rb +2 -15
  26. data/lib/limelight/main.rb +7 -5
  27. data/lib/limelight/producer.rb +87 -66
  28. data/lib/limelight/production.rb +42 -4
  29. data/lib/limelight/prop.rb +84 -70
  30. data/lib/limelight/scene.rb +75 -20
  31. data/lib/limelight/specs/spec_helper.rb +58 -0
  32. data/lib/limelight/stage.rb +11 -6
  33. data/lib/limelight/string.rb +35 -0
  34. data/lib/limelight/studio.rb +29 -0
  35. data/lib/limelight/templates/production_templater.rb +42 -0
  36. data/lib/limelight/templates/scene_templater.rb +41 -0
  37. data/lib/limelight/templates/sources/freezing/limelight_init.rb.template +5 -0
  38. data/lib/limelight/templates/sources/production/init.rb.template +15 -0
  39. data/lib/limelight/templates/sources/production/production.rb.template +9 -0
  40. data/lib/limelight/templates/sources/production/stages.rb.template +17 -0
  41. data/lib/limelight/templates/sources/production/styles.rb.template +12 -0
  42. data/lib/limelight/templates/sources/scene/props.rb.template +6 -0
  43. data/lib/limelight/templates/sources/scene/styles.rb.template +18 -0
  44. data/lib/limelight/templates/templater.rb +128 -0
  45. data/lib/limelight/templates/templater_logger.rb +36 -0
  46. data/lib/limelight/theater.rb +21 -7
  47. data/lib/limelight/util.rb +22 -6
  48. data/lib/limelight/version.rb +2 -2
  49. data/productions/examples/8thlight.com/styles.rb +1 -1
  50. data/productions/examples/langstons_ant/html_javascript/ant.html +1 -1
  51. data/productions/examples/langstons_ant/init.rb +1 -0
  52. data/productions/examples/langstons_ant/players/log.rb +2 -2
  53. data/productions/examples/langstons_ant/players/world.rb +0 -26
  54. data/productions/examples/sandbox.llp +0 -0
  55. data/productions/examples/sandbox/click_me/players/chromaton.rb +10 -4
  56. data/productions/examples/sandbox/floaters/players/floater.rb +4 -2
  57. data/productions/examples/sandbox/gradients/players/spinner.rb +5 -1
  58. data/productions/examples/sandbox/gradients/players/teaser.rb +2 -2
  59. data/productions/examples/sandbox/gradients/players/wave.rb +2 -2
  60. data/productions/examples/sandbox/gradients/players/waves.rb +2 -2
  61. data/productions/examples/sandbox/header.rb +1 -0
  62. data/productions/examples/sandbox/images/logo.png +0 -0
  63. data/productions/examples/sandbox/images_scene/props.rb +25 -0
  64. data/productions/examples/sandbox/images_scene/styles.rb +30 -0
  65. data/productions/examples/sandbox/inputs/styles.rb +1 -1
  66. data/productions/examples/sandbox/scrolling/props.rb +12 -12
  67. data/productions/examples/sandbox/teaser/players/fader.rb +2 -8
  68. data/productions/stage_composer/inspector/styles.rb +2 -2
  69. data/productions/startup/styles.rb +2 -2
  70. data/spec/builtin/players/button_spec.rb +0 -1
  71. data/spec/builtin/players/image_spec.rb +41 -0
  72. data/spec/casting_director_spec.rb +114 -44
  73. data/spec/commands/command_spec.rb +18 -0
  74. data/spec/commands/create_command_spec.rb +74 -0
  75. data/spec/commands/freeze_command_spec.rb +59 -0
  76. data/spec/commands/open_command_spec.rb +30 -0
  77. data/spec/commands/pack_command_spec.rb +23 -0
  78. data/spec/dsl/production_builder_spec.rb +46 -0
  79. data/spec/{prop_builder_spec.rb → dsl/prop_builder_spec.rb} +80 -24
  80. data/spec/{stage_builder_spec.rb → dsl/stage_builder_spec.rb} +4 -4
  81. data/spec/{styles_builder_spec.rb → dsl/styles_builder_spec.rb} +6 -6
  82. data/spec/{loaders/file_loader_spec.rb → file_loader_spec.rb} +4 -4
  83. data/spec/gems_spec.rb +83 -0
  84. data/spec/java_util_spec.rb +1 -17
  85. data/spec/main_spec.rb +17 -0
  86. data/spec/producer_spec.rb +89 -79
  87. data/spec/production_spec.rb +28 -3
  88. data/spec/prop_spec.rb +82 -16
  89. data/spec/scene_spec.rb +73 -3
  90. data/spec/spec_helper.rb +37 -1
  91. data/spec/stage_spec.rb +10 -1
  92. data/spec/string_spec.rb +35 -0
  93. data/spec/studio_spec.rb +14 -0
  94. data/spec/styles_spec.rb +14 -0
  95. data/spec/templates/production_templater_spec.rb +44 -0
  96. data/spec/templates/scene_templater_spec.rb +25 -0
  97. data/spec/templates/templater_logger_spec.rb +38 -0
  98. data/spec/templates/templater_spec.rb +104 -0
  99. data/spec/theater_spec.rb +12 -21
  100. metadata +75 -23
  101. data/bin/icons/splash.png +0 -0
  102. data/lib/limelight/build_exception.rb +0 -48
  103. data/lib/limelight/commands.rb +0 -52
  104. data/lib/limelight/loaders/file_scene_loader.rb +0 -49
  105. data/lib/limelight/menu_bar.rb +0 -68
  106. data/lib/limelight/production_builder.rb +0 -66
  107. data/lib/limelight/prop_builder.rb +0 -119
  108. data/lib/limelight/stage_builder.rb +0 -103
  109. data/lib/limelight/styles_builder.rb +0 -131
  110. data/spec/commands_spec.rb +0 -34
  111. data/spec/production_builder_spec.rb +0 -48
data/spec/theater_spec.rb CHANGED
@@ -9,14 +9,15 @@ describe Limelight::Theater do
9
9
 
10
10
  before(:each) do
11
11
  @theater = Limelight::Theater.new
12
- @__stage__ = Limelight::Stage.new(@theater, "default")
12
+ @stage = @theater.add_stage("default")
13
13
  end
14
14
 
15
15
  it "should allow adding of stages" do
16
- @theater.add_stage(@__stage__)
17
-
18
16
  @theater.stages.length.should == 1
19
- @theater.stages[0].should == @__stage__
17
+ @theater.stages[0].should == @stage
18
+
19
+ @stage.theater.should == @theater
20
+ @stage.name.should == "default"
20
21
  end
21
22
 
22
23
  it "should not return the actual_list of stages" do
@@ -24,36 +25,26 @@ describe Limelight::Theater do
24
25
  end
25
26
 
26
27
  it "should know it's active stage" do
27
- stage2 = Limelight::Stage.new(@theater, "two")
28
-
29
- @theater.add_stage(@__stage__)
30
- @theater.add_stage(stage2)
28
+ stage2 = @theater.add_stage("two")
31
29
 
32
30
  @theater.active_stage.should == nil
33
31
  @theater.stage_activated(stage2)
34
32
  @theater.active_stage.should == stage2
35
- @theater.stage_activated(@__stage__)
36
- @theater.active_stage.should == @__stage__
33
+ @theater.stage_activated(@stage)
34
+ @theater.active_stage.should == @stage
37
35
  end
38
36
 
39
37
  it "should allow recalling stage by name" do
40
- stage2 = Limelight::Stage.new(@theater, "two")
41
- stage3 = Limelight::Stage.new(@theater, "three")
42
- @theater.add_stage(@__stage__)
43
- @theater.add_stage(stage2)
44
- @theater.add_stage(stage3)
38
+ stage2 = @theater.add_stage("two")
39
+ stage3 = @theater.add_stage("three")
45
40
 
46
- @theater["default"].should == @__stage__
41
+ @theater["default"].should == @stage
47
42
  @theater["two"].should == stage2
48
43
  @theater["three"].should == stage3
49
44
  end
50
45
 
51
46
  it "should not allow duplicate theater names" do
52
- stage = Limelight::Stage.new(@theater, "default")
53
- duplicate = Limelight::Stage.new(@theater, "default")
54
-
55
- @theater.add_stage(stage)
56
- lambda { @theater.add_stage(stage) }.should raise_error(Limelight::LimelightException, "Duplicate stage name: 'default'")
47
+ lambda { @theater.add_stage("default") }.should raise_error(Limelight::LimelightException, "Duplicate stage name: 'default'")
57
48
  end
58
49
 
59
50
  it "should have a default stage" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: limelight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: java
6
6
  authors:
7
7
  - Micah Martin, 8th Light
@@ -9,7 +9,7 @@ autorequire: init
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-17 00:00:00 -05:00
12
+ date: 2008-11-05 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -22,15 +22,20 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
+ - lib/i4jruntime.jar
25
26
  - lib/init.rb
27
+ - lib/junit-4.4.jar
28
+ - lib/limelight
26
29
  - lib/limelight/animation.rb
27
- - lib/limelight/build_exception.rb
30
+ - lib/limelight/builtin
31
+ - lib/limelight/builtin/players
28
32
  - lib/limelight/builtin/players/button.rb
29
33
  - lib/limelight/builtin/players/check_box.rb
30
34
  - lib/limelight/builtin/players/combo_box.rb
31
35
  - lib/limelight/builtin/players/combo_box_popup_list.rb
32
36
  - lib/limelight/builtin/players/combo_box_popup_list_item.rb
33
37
  - lib/limelight/builtin/players/curtains.rb
38
+ - lib/limelight/builtin/players/image.rb
34
39
  - lib/limelight/builtin/players/radio_button.rb
35
40
  - lib/limelight/builtin/players/text_area.rb
36
41
  - lib/limelight/builtin/players/text_box.rb
@@ -38,27 +43,55 @@ files:
38
43
  - lib/limelight/builtin/styles.rb
39
44
  - lib/limelight/button_group_cache.rb
40
45
  - lib/limelight/casting_director.rb
41
- - lib/limelight/commands.rb
46
+ - lib/limelight/commands
47
+ - lib/limelight/commands/command.rb
48
+ - lib/limelight/commands/create_command.rb
49
+ - lib/limelight/commands/freeze_command.rb
50
+ - lib/limelight/commands/open_command.rb
51
+ - lib/limelight/commands/pack_command.rb
52
+ - lib/limelight/dsl
53
+ - lib/limelight/dsl/build_exception.rb
54
+ - lib/limelight/dsl/menu_bar.rb
55
+ - lib/limelight/dsl/production_builder.rb
56
+ - lib/limelight/dsl/prop_builder.rb
57
+ - lib/limelight/dsl/stage_builder.rb
58
+ - lib/limelight/dsl/styles_builder.rb
42
59
  - lib/limelight/file_chooser.rb
43
60
  - lib/limelight/file_filter.rb
61
+ - lib/limelight/file_loader.rb
62
+ - lib/limelight/gems.rb
44
63
  - lib/limelight/java_couplings.rb
45
64
  - lib/limelight/java_util.rb
46
65
  - lib/limelight/limelight_exception.rb
47
- - lib/limelight/loaders/file_scene_loader.rb
48
66
  - lib/limelight/main.rb
49
- - lib/limelight/menu_bar.rb
50
67
  - lib/limelight/paint_action.rb
51
68
  - lib/limelight/pen.rb
52
69
  - lib/limelight/producer.rb
53
70
  - lib/limelight/production.rb
54
- - lib/limelight/production_builder.rb
55
71
  - lib/limelight/prop.rb
56
- - lib/limelight/prop_builder.rb
57
72
  - lib/limelight/scene.rb
73
+ - lib/limelight/specs
74
+ - lib/limelight/specs/spec_helper.rb
58
75
  - lib/limelight/stage.rb
59
- - lib/limelight/stage_builder.rb
76
+ - lib/limelight/string.rb
77
+ - lib/limelight/studio.rb
60
78
  - lib/limelight/styles.rb
61
- - lib/limelight/styles_builder.rb
79
+ - lib/limelight/templates
80
+ - lib/limelight/templates/production_templater.rb
81
+ - lib/limelight/templates/scene_templater.rb
82
+ - lib/limelight/templates/sources
83
+ - lib/limelight/templates/sources/freezing
84
+ - lib/limelight/templates/sources/freezing/limelight_init.rb.template
85
+ - lib/limelight/templates/sources/production
86
+ - lib/limelight/templates/sources/production/init.rb.template
87
+ - lib/limelight/templates/sources/production/production.rb.template
88
+ - lib/limelight/templates/sources/production/stages.rb.template
89
+ - lib/limelight/templates/sources/production/styles.rb.template
90
+ - lib/limelight/templates/sources/scene
91
+ - lib/limelight/templates/sources/scene/props.rb.template
92
+ - lib/limelight/templates/sources/scene/styles.rb.template
93
+ - lib/limelight/templates/templater.rb
94
+ - lib/limelight/templates/templater_logger.rb
62
95
  - lib/limelight/theater.rb
63
96
  - lib/limelight/util.rb
64
97
  - lib/limelight/version.rb
@@ -66,28 +99,41 @@ files:
66
99
  - spec/builtin/players/button_spec.rb
67
100
  - spec/builtin/players/check_box_spec.rb
68
101
  - spec/builtin/players/combo_box_spec.rb
102
+ - spec/builtin/players/image_spec.rb
69
103
  - spec/builtin/players/radio_button_spec.rb
70
104
  - spec/builtin/players/text_area_spec.rb
71
105
  - spec/builtin/players/text_box_spec.rb
72
106
  - spec/casting_director_spec.rb
73
- - spec/commands_spec.rb
107
+ - spec/commands/command_spec.rb
108
+ - spec/commands/create_command_spec.rb
109
+ - spec/commands/freeze_command_spec.rb
110
+ - spec/commands/open_command_spec.rb
111
+ - spec/commands/pack_command_spec.rb
112
+ - spec/dsl/production_builder_spec.rb
113
+ - spec/dsl/prop_builder_spec.rb
114
+ - spec/dsl/stage_builder_spec.rb
115
+ - spec/dsl/styles_builder_spec.rb
74
116
  - spec/file_chooser_spec.rb
75
117
  - spec/file_filter_spec.rb
118
+ - spec/file_loader_spec.rb
119
+ - spec/gems_spec.rb
76
120
  - spec/java_util_spec.rb
77
- - spec/loaders/file_loader_spec.rb
121
+ - spec/main_spec.rb
78
122
  - spec/paint_action_spec.rb
79
123
  - spec/pen_spec.rb
80
124
  - spec/producer_spec.rb
81
- - spec/production_builder_spec.rb
82
125
  - spec/production_spec.rb
83
- - spec/prop_builder_spec.rb
84
126
  - spec/prop_spec.rb
85
127
  - spec/scene_spec.rb
86
128
  - spec/spec_helper.rb
87
- - spec/stage_builder_spec.rb
88
129
  - spec/stage_spec.rb
89
- - spec/styles_builder_spec.rb
130
+ - spec/string_spec.rb
131
+ - spec/studio_spec.rb
90
132
  - spec/styles_spec.rb
133
+ - spec/templates/production_templater_spec.rb
134
+ - spec/templates/scene_templater_spec.rb
135
+ - spec/templates/templater_logger_spec.rb
136
+ - spec/templates/templater_spec.rb
91
137
  - spec/theater_spec.rb
92
138
  - productions/examples
93
139
  - productions/examples/8thlight.com
@@ -129,6 +175,7 @@ files:
129
175
  - productions/examples/langstons_ant/html_javascript/ant.css
130
176
  - productions/examples/langstons_ant/html_javascript/ant.html
131
177
  - productions/examples/langstons_ant/html_javascript/ant.js
178
+ - productions/examples/langstons_ant/init.rb
132
179
  - productions/examples/langstons_ant/players
133
180
  - productions/examples/langstons_ant/players/ant.rb
134
181
  - productions/examples/langstons_ant/players/log.rb
@@ -167,7 +214,12 @@ files:
167
214
  - productions/examples/sandbox/images/beach.jpg
168
215
  - productions/examples/sandbox/images/homer.jpg
169
216
  - productions/examples/sandbox/images/limelight_spotlight.jpg
217
+ - productions/examples/sandbox/images/logo.png
170
218
  - productions/examples/sandbox/images/marilyn.jpg
219
+ - productions/examples/sandbox/images_scene
220
+ - productions/examples/sandbox/images_scene/players
221
+ - productions/examples/sandbox/images_scene/props.rb
222
+ - productions/examples/sandbox/images_scene/styles.rb
171
223
  - productions/examples/sandbox/inputs
172
224
  - productions/examples/sandbox/inputs/players
173
225
  - productions/examples/sandbox/inputs/players/button_input.rb
@@ -214,6 +266,7 @@ files:
214
266
  - productions/examples/sandbox/teaser/players/fader.rb
215
267
  - productions/examples/sandbox/teaser/props.rb
216
268
  - productions/examples/sandbox/teaser/styles.rb
269
+ - productions/examples/sandbox.llp
217
270
  - productions/examples/tutorials
218
271
  - productions/examples/tutorials/tutorial_1
219
272
  - productions/examples/tutorials/tutorial_1/players
@@ -253,7 +306,6 @@ files:
253
306
  - bin/icons/icon.ico
254
307
  - bin/icons/icon_48.gif
255
308
  - bin/icons/limelight.icns
256
- - bin/icons/splash.png
257
309
  - bin/limelight
258
310
  - bin/ll
259
311
  - bin/ll.bat
@@ -282,23 +334,23 @@ rubyforge_project: limelight
282
334
  rubygems_version: 1.2.0
283
335
  signing_key:
284
336
  specification_version: 2
285
- summary: Limelight-0.2.1 - Limelight http://limelight.8thlight.com
337
+ summary: Limelight-0.3.0 - Limelight http://limelight.8thlight.com
286
338
  test_files:
287
339
  - spec/casting_director_spec.rb
288
- - spec/commands_spec.rb
289
340
  - spec/file_chooser_spec.rb
290
341
  - spec/file_filter_spec.rb
342
+ - spec/file_loader_spec.rb
343
+ - spec/gems_spec.rb
291
344
  - spec/java_util_spec.rb
345
+ - spec/main_spec.rb
292
346
  - spec/paint_action_spec.rb
293
347
  - spec/pen_spec.rb
294
348
  - spec/producer_spec.rb
295
- - spec/production_builder_spec.rb
296
349
  - spec/production_spec.rb
297
- - spec/prop_builder_spec.rb
298
350
  - spec/prop_spec.rb
299
351
  - spec/scene_spec.rb
300
- - spec/stage_builder_spec.rb
301
352
  - spec/stage_spec.rb
302
- - spec/styles_builder_spec.rb
353
+ - spec/string_spec.rb
354
+ - spec/studio_spec.rb
303
355
  - spec/styles_spec.rb
304
356
  - spec/theater_spec.rb
data/bin/icons/splash.png DELETED
Binary file
@@ -1,48 +0,0 @@
1
- #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
- #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
-
4
- module Limelight
5
-
6
- # An Exception used by many of the DSL Builders. Allows nice errors messages, with line numbers, to be printed.
7
- #
8
- class BuildException < Exception
9
-
10
- attr_reader :filename, :line_number
11
-
12
- def initialize(filename, file_contents, e)
13
- @filename = filename
14
- @file_contents = file_contents
15
- @original_exception = e
16
- @line_number = find_line_number
17
- super(build_error_message)
18
- set_backtrace(e.backtrace)
19
- end
20
-
21
- def find_line_number
22
- lines = [@original_exception.message].concat @original_exception.backtrace
23
- line_number = nil
24
- lines.each do |line|
25
- match = line.match(/\(eval\):(\d+):/)
26
- if(match)
27
- line_number = match[1].to_i
28
- break
29
- end
30
- end
31
- return line_number
32
- end
33
-
34
- def build_error_message
35
- lines = @file_contents.split("\n")
36
- start_line = @line_number - 4 < 0 ? 0 : @line_number - 4
37
- end_line = @line_number + 2 >= lines.size ? lines.size - 1: @line_number + 2
38
- message = "#{@filename}:#{@line_number}: #{@original_exception.message}"
39
- message << "\n\t----- #{@filename} lines #{start_line + 1} - #{end_line + 1} -----"
40
- (start_line..end_line).each do |i|
41
- message << "\n\t#{i == @line_number - 1 ? "*": " "} #{i+1}: #{lines[i]}"
42
- end
43
- message << "\n"
44
- return message
45
- end
46
- end
47
-
48
- end
@@ -1,52 +0,0 @@
1
- #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
- #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
-
4
- module Limelight
5
-
6
- DEFAULT_PRODUCTION = File.expand_path(File.dirname(__FILE__) + "/../../productions/startup")
7
-
8
- # Commands used in the Main method.
9
- #
10
- module Commands
11
-
12
- # Opens a Production
13
- #
14
- # jruby -S limelight open <production_name>
15
- #
16
- class OpenProduction
17
- def self.description
18
- return "Open a limelight production or scene."
19
- end
20
-
21
- def run(args)
22
- Main.initialize_context
23
- require 'limelight/producer'
24
- production = args.length > 0 ? args[0] : DEFAULT_PRODUCTION
25
- Limelight::Producer.open(production)
26
- end
27
- end
28
-
29
- # Compresses the specified Production into a single .llp file.
30
- #
31
- # jruby -S limelight pack <production_name>
32
- #
33
- class PackProduction
34
- def self.description
35
- return "Pack the designated limelight production into a .llp file."
36
- end
37
-
38
- def run(args)
39
- packer = Limelight::Util::Packer.new
40
- packer.pack(args.shift)
41
- end
42
- end
43
-
44
- COMMANDS = {
45
- "open" => OpenProduction,
46
- "pack" => PackProduction
47
- }
48
-
49
- end
50
-
51
-
52
- end
@@ -1,49 +0,0 @@
1
- #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
- #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
-
4
- module Limelight
5
- module Loaders
6
-
7
- class FileSceneLoader #:nodoc:
8
-
9
- include SceneLoader
10
-
11
- attr_reader :root
12
-
13
- def self.for_root(root)
14
- loader = new
15
- loader.reset_on_root(root)
16
- return loader
17
- end
18
-
19
- def reset_on_root(root)
20
- @root = File.expand_path(root)
21
- end
22
-
23
- def path_to(path)
24
- #TODO What about windoze?
25
- if(path[0] == "/"[0])
26
- return path
27
- else
28
- return File.expand_path(File.join(@root, path))
29
- end
30
- end
31
-
32
- def exists?(path)
33
- return File.exists?(path_to(path))
34
- end
35
-
36
- alias :pathTo :path_to
37
-
38
- def load(path)
39
- file_to_load = path_to(path)
40
- raise LimelightException.new("File not found: #{file_to_load}") if not File.exists?(file_to_load)
41
- return IO.read(file_to_load)
42
- end
43
-
44
- alias :read :load
45
-
46
- end
47
-
48
- end
49
- end
@@ -1,68 +0,0 @@
1
- #- Copyright 2008 8th Light, Inc. All Rights Reserved.
2
- #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
-
4
- module Limelight
5
-
6
- class AnonymousActionListener #:nodoc:
7
- include java.awt.event.ActionListener
8
-
9
- def initialize(context, symbol)
10
- @context = context
11
- @symbol = symbol
12
- end
13
-
14
- def actionPerformed(e)
15
- method = @context.method(@symbol)
16
- method.call
17
- end
18
- end
19
-
20
- # A class used to build menu bars using a DSL.
21
- #
22
- # MenuBar.build(self) do
23
- # menu("File") do
24
- # item("Open", :open_chosen_scene)
25
- # item("Refresh", :reload)
26
- # end
27
- # end
28
- #
29
- # This example created one menu named 'File' with two menu items: 'Open' and 'Refresh'. The seconds parameter of the
30
- # menu items is the symbol of a method on the context that will be invoked when the menu item is selected.
31
- #
32
- class MenuBar
33
-
34
- def self.build(context, &prop)
35
- builder = self.new(context)
36
- builder.instance_eval(&prop)
37
- return builder.menu_bar
38
- end
39
-
40
- attr_reader :menu_bar
41
-
42
- # This builder must be provided with a context. All menu item actions will be invoked on the context.
43
- #
44
- def initialize(context)
45
- @context = context
46
- @menu_bar = javax.swing.JMenuBar.new
47
- end
48
-
49
- # Creates a new menu with the provided name
50
- #
51
- def menu(name)
52
- @menu = javax.swing.JMenu.new(name)
53
- @menu_bar.add(@menu)
54
- yield
55
- end
56
-
57
- # Created a new menu item with the provided name. The symbols paramter is the name of a method on the context
58
- # that will be invoked when the item is selected.
59
- #
60
- def item(name, symbol)
61
- menu_item = javax.swing.JMenuItem.new(name)
62
- @menu.add(menu_item)
63
- menu_item.addActionListener(AnonymousActionListener.new(@context, symbol))
64
- end
65
-
66
- end
67
-
68
- end