limelight 0.0.1-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 (165) hide show
  1. data/bin/icons/icon.ico +0 -0
  2. data/bin/icons/icon_48.gif +0 -0
  3. data/bin/icons/limelight.icns +0 -0
  4. data/bin/icons/splash.png +0 -0
  5. data/bin/limelight +6 -0
  6. data/bin/ll +10 -0
  7. data/bin/ll.bat +5 -0
  8. data/lib/init.rb +11 -0
  9. data/lib/limelight/build_exception.rb +45 -0
  10. data/lib/limelight/button_group_cache.rb +11 -0
  11. data/lib/limelight/casting_director.rb +72 -0
  12. data/lib/limelight/commands.rb +66 -0
  13. data/lib/limelight/file_chooser.rb +55 -0
  14. data/lib/limelight/file_filter.rb +26 -0
  15. data/lib/limelight/java_util.rb +29 -0
  16. data/lib/limelight/limelight_exception.rb +9 -0
  17. data/lib/limelight/loaders/file_scene_loader.rb +48 -0
  18. data/lib/limelight/menu_bar.rb +49 -0
  19. data/lib/limelight/paint_action.rb +25 -0
  20. data/lib/limelight/pen.rb +53 -0
  21. data/lib/limelight/players/button.rb +29 -0
  22. data/lib/limelight/players/check_box.rb +38 -0
  23. data/lib/limelight/players/combo_box.rb +44 -0
  24. data/lib/limelight/players/radio_button.rb +47 -0
  25. data/lib/limelight/players/text_area.rb +25 -0
  26. data/lib/limelight/players/text_box.rb +25 -0
  27. data/lib/limelight/players.rb +9 -0
  28. data/lib/limelight/producer.rb +141 -0
  29. data/lib/limelight/production.rb +64 -0
  30. data/lib/limelight/production_builder.rb +49 -0
  31. data/lib/limelight/prop.rb +241 -0
  32. data/lib/limelight/prop_builder.rb +60 -0
  33. data/lib/limelight/scene.rb +75 -0
  34. data/lib/limelight/stage.rb +93 -0
  35. data/lib/limelight/stage_builder.rb +62 -0
  36. data/lib/limelight/styles.rb +37 -0
  37. data/lib/limelight/styles_builder.rb +61 -0
  38. data/lib/limelight/theater.rb +42 -0
  39. data/lib/limelight/util.rb +26 -0
  40. data/lib/limelight/version.rb +20 -0
  41. data/lib/limelight.jar +0 -0
  42. data/productions/examples/8thlight.com/about/about.txt +24 -0
  43. data/productions/examples/8thlight.com/about/props.rb +11 -0
  44. data/productions/examples/8thlight.com/about/styles.rb +2 -0
  45. data/productions/examples/8thlight.com/footer.rb +6 -0
  46. data/productions/examples/8thlight.com/home/props.rb +28 -0
  47. data/productions/examples/8thlight.com/home/styles.rb +2 -0
  48. data/productions/examples/8thlight.com/images/anvil.jpg +0 -0
  49. data/productions/examples/8thlight.com/images/bg.jpg +0 -0
  50. data/productions/examples/8thlight.com/images/botticelli.jpg +0 -0
  51. data/productions/examples/8thlight.com/images/button_bg.jpg +0 -0
  52. data/productions/examples/8thlight.com/images/canvas_bg.jpg +0 -0
  53. data/productions/examples/8thlight.com/images/footer_bg.jpg +0 -0
  54. data/productions/examples/8thlight.com/images/header.jpg +0 -0
  55. data/productions/examples/8thlight.com/images/moses.jpg +0 -0
  56. data/productions/examples/8thlight.com/images/statemachine_thumbnail.png +0 -0
  57. data/productions/examples/8thlight.com/images/thumbnail_book.jpg +0 -0
  58. data/productions/examples/8thlight.com/menu.rb +11 -0
  59. data/productions/examples/8thlight.com/services/props.rb +11 -0
  60. data/productions/examples/8thlight.com/services/services.txt +8 -0
  61. data/productions/examples/8thlight.com/services/styles.rb +2 -0
  62. data/productions/examples/8thlight.com/stages.rb +8 -0
  63. data/productions/examples/8thlight.com/styles.rb +205 -0
  64. data/productions/examples/calculator/players/button.rb +24 -0
  65. data/productions/examples/calculator/players/calculator.rb +15 -0
  66. data/productions/examples/calculator/players/calculator_model.rb +13 -0
  67. data/productions/examples/calculator/props.rb +23 -0
  68. data/productions/examples/calculator/styles.rb +38 -0
  69. data/productions/examples/langstons_ant/html_javascript/ant.css +39 -0
  70. data/productions/examples/langstons_ant/html_javascript/ant.html +22 -0
  71. data/productions/examples/langstons_ant/html_javascript/ant.js +23 -0
  72. data/productions/examples/langstons_ant/players/ant.rb +103 -0
  73. data/productions/examples/langstons_ant/players/log.rb +29 -0
  74. data/productions/examples/langstons_ant/players/start_stop_button.rb +37 -0
  75. data/productions/examples/langstons_ant/players/world.rb +61 -0
  76. data/productions/examples/langstons_ant/props.rb +22 -0
  77. data/productions/examples/langstons_ant/styles.rb +105 -0
  78. data/productions/examples/sandbox/click_me/players/chromaton.rb +47 -0
  79. data/productions/examples/sandbox/click_me/props.rb +8 -0
  80. data/productions/examples/sandbox/click_me/styles.rb +12 -0
  81. data/productions/examples/sandbox/floaters/players/floater.rb +92 -0
  82. data/productions/examples/sandbox/floaters/players/surface.rb +17 -0
  83. data/productions/examples/sandbox/floaters/props.rb +10 -0
  84. data/productions/examples/sandbox/floaters/styles.rb +25 -0
  85. data/productions/examples/sandbox/gradients/players/spinner.rb +23 -0
  86. data/productions/examples/sandbox/gradients/players/teaser.rb +26 -0
  87. data/productions/examples/sandbox/gradients/players/wave.rb +26 -0
  88. data/productions/examples/sandbox/gradients/players/waves.rb +26 -0
  89. data/productions/examples/sandbox/gradients/props.rb +13 -0
  90. data/productions/examples/sandbox/gradients/styles.rb +47 -0
  91. data/productions/examples/sandbox/header.rb +15 -0
  92. data/productions/examples/sandbox/homer/players/homer.rb +20 -0
  93. data/productions/examples/sandbox/homer/props.rb +10 -0
  94. data/productions/examples/sandbox/homer/styles.rb +17 -0
  95. data/productions/examples/sandbox/images/arch.jpg +0 -0
  96. data/productions/examples/sandbox/images/beach.jpg +0 -0
  97. data/productions/examples/sandbox/images/homer.jpg +0 -0
  98. data/productions/examples/sandbox/images/limelight_spotlight.jpg +0 -0
  99. data/productions/examples/sandbox/images/marilyn.jpg +0 -0
  100. data/productions/examples/sandbox/inputs/players/button_input.rb +48 -0
  101. data/productions/examples/sandbox/inputs/players/check_box_input.rb +40 -0
  102. data/productions/examples/sandbox/inputs/players/combo_box_input.rb +41 -0
  103. data/productions/examples/sandbox/inputs/players/radio_button_input.rb +43 -0
  104. data/productions/examples/sandbox/inputs/players/text_area_input.rb +36 -0
  105. data/productions/examples/sandbox/inputs/players/text_box_input.rb +36 -0
  106. data/productions/examples/sandbox/inputs/props.rb +40 -0
  107. data/productions/examples/sandbox/inputs/styles.rb +39 -0
  108. data/productions/examples/sandbox/players/sandbox.rb +11 -0
  109. data/productions/examples/sandbox/rounded_corners/players/box.rb +11 -0
  110. data/productions/examples/sandbox/rounded_corners/props.rb +22 -0
  111. data/productions/examples/sandbox/rounded_corners/styles.rb +18 -0
  112. data/productions/examples/sandbox/scrolling/players/cell.rb +16 -0
  113. data/productions/examples/sandbox/scrolling/props.rb +40 -0
  114. data/productions/examples/sandbox/scrolling/styles.rb +25 -0
  115. data/productions/examples/sandbox/sketching/players/sketchpad.rb +46 -0
  116. data/productions/examples/sandbox/sketching/props.rb +25 -0
  117. data/productions/examples/sandbox/sketching/styles.rb +36 -0
  118. data/productions/examples/sandbox/stages.rb +6 -0
  119. data/productions/examples/sandbox/styles.rb +37 -0
  120. data/productions/examples/sandbox/teaser/players/fader.rb +58 -0
  121. data/productions/examples/sandbox/teaser/props.rb +14 -0
  122. data/productions/examples/sandbox/teaser/styles.rb +22 -0
  123. data/productions/examples/tutorials/tutorial_1/players/sample.rb +11 -0
  124. data/productions/examples/tutorials/tutorial_1/props.rb +9 -0
  125. data/productions/examples/tutorials/tutorial_1/styles.rb +27 -0
  126. data/productions/stage_composer/init.rb +10 -0
  127. data/productions/stage_composer/inspector/players/inspector.rb +80 -0
  128. data/productions/stage_composer/inspector/players/prop_row.rb +12 -0
  129. data/productions/stage_composer/inspector/players/prop_tree.rb +33 -0
  130. data/productions/stage_composer/inspector/players/style_table.rb +12 -0
  131. data/productions/stage_composer/inspector/players/style_value.rb +16 -0
  132. data/productions/stage_composer/inspector/props.rb +19 -0
  133. data/productions/stage_composer/inspector/styles.rb +71 -0
  134. data/productions/stage_composer/lib/init.rb +5 -0
  135. data/productions/stage_composer/lib/limelight/composer/controller.rb +51 -0
  136. data/productions/stage_composer/lib/limelight/composer/lethargy.rb +24 -0
  137. data/productions/stage_composer/production.rb +6 -0
  138. data/productions/stage_composer/stages.rb +15 -0
  139. data/productions/startup/props.rb +5 -0
  140. data/spec/casting_director_spec.rb +94 -0
  141. data/spec/commands_spec.rb +33 -0
  142. data/spec/file_chooser_spec.rb +64 -0
  143. data/spec/file_filter_spec.rb +29 -0
  144. data/spec/java_util_spec.rb +53 -0
  145. data/spec/loaders/file_loader_spec.rb +28 -0
  146. data/spec/paint_action_spec.rb +30 -0
  147. data/spec/pen_spec.rb +62 -0
  148. data/spec/players/button_spec.rb +31 -0
  149. data/spec/players/check_box_spec.rb +40 -0
  150. data/spec/players/combo_box_spec.rb +39 -0
  151. data/spec/players/radio_button_spec.rb +75 -0
  152. data/spec/players/text_area_spec.rb +37 -0
  153. data/spec/players/text_box_spec.rb +37 -0
  154. data/spec/producer_spec.rb +157 -0
  155. data/spec/production_builder_spec.rb +48 -0
  156. data/spec/production_spec.rb +75 -0
  157. data/spec/prop_builder_spec.rb +178 -0
  158. data/spec/prop_spec.rb +216 -0
  159. data/spec/scene_spec.rb +34 -0
  160. data/spec/spec_helper.rb +18 -0
  161. data/spec/stage_builder_spec.rb +90 -0
  162. data/spec/stage_spec.rb +57 -0
  163. data/spec/styles_builder_spec.rb +123 -0
  164. data/spec/theater_spec.rb +66 -0
  165. metadata +275 -0
@@ -0,0 +1,27 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ backdrop {
5
+ background_color "black"
6
+ width "100%"
7
+ height "100%"
8
+ horizontal_alignment "center"
9
+ vertical_alignment "center"
10
+ }
11
+
12
+ sample {
13
+ width 100
14
+ height 100
15
+ margin 5
16
+ horizontal_alignment "center"
17
+ vertical_alignment "center"
18
+ font_size "18"
19
+ font_style "bold"
20
+ text_color "white"
21
+ }
22
+
23
+ selection {
24
+ width 300
25
+ height 300
26
+ background_color "gray"
27
+ }
@@ -0,0 +1,10 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ $: << File.expand_path(File.dirname(__FILE__) + "/lib")
5
+ require 'limelight/composer/controller'
6
+
7
+
8
+ production = Limelight::Production["Stage Composer"]
9
+ controller = Limelight::Composer::Controller.new(production)
10
+ production.controller = controller
@@ -0,0 +1,80 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/../../lib/init")
5
+ require 'limelight/composer/lethargy'
6
+
7
+ module Inspector
8
+
9
+ def self.extended(block)
10
+ puts "Inspector extended"
11
+ block.production.inspector = block
12
+ end
13
+
14
+ def new
15
+ end
16
+
17
+ def open
18
+ # result = scene.stage.choose_file(:title => "Open Limelight Scene", :description => "Limelight Scene", :directory => @directory) { |file| Limelight::Util.is_limelight_scene?(file) }
19
+ # result = "/Users/micahmartin/Projects/limelight/trunk/examples/sandbox/click_me"
20
+ result = "Y:\\Projects\\limelight\\trunk\\examples\\sandbox\\click_me"
21
+ if result
22
+ if Limelight::Util.is_limelight_production?(File.dirname(result))
23
+ load_scene(File.dirname(result), File.basename(result))
24
+ else
25
+ load_scene(result, ".")
26
+ end
27
+
28
+ devitalize(viewer_stage.current_scene)
29
+ prop_tree.build_tree(viewer_stage.current_scene)
30
+ end
31
+ end
32
+
33
+ def inspect_prop(prop)
34
+ style_table.populate(prop.style)
35
+ prop_tree.highlight(prop)
36
+ end
37
+
38
+ def style_table
39
+ return find('style_table')
40
+ end
41
+
42
+ def prop_tree
43
+ return find('prop_tree')
44
+ end
45
+
46
+ private #################################################
47
+
48
+ def load_scene(root, scene_path)
49
+ producer = Limelight::Producer.new(root, theater, scene.production)
50
+ scene_path = scene_path
51
+
52
+ producer.open_scene(scene_path, viewer_stage)
53
+ end
54
+
55
+ def theater
56
+ return scene.production.theater
57
+ end
58
+
59
+ def viewer_stage
60
+ return theater['viewer']
61
+ end
62
+
63
+ def devitalize(prop)
64
+ lethargize(prop)
65
+ prop.include_player(Limelight::Composer::Lethargy)
66
+ prop.children.each { |child| devitalize(child) }
67
+ end
68
+
69
+ def lethargize(prop)
70
+ class << prop
71
+ Limelight::Prop::EVENTS.each do |sym|
72
+ begin
73
+ remove_method sym
74
+ rescue Exception
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ end
@@ -0,0 +1,12 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ module PropRow
5
+
6
+ attr_accessor :prop
7
+
8
+ def mouse_clicked(e)
9
+ production.controller.prop_selected(@prop)
10
+ end
11
+
12
+ end
@@ -0,0 +1,33 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ module PropTree
5
+
6
+ def build_tree(scene)
7
+ self.remove_all
8
+ add_prop_row(scene, 0)
9
+ update
10
+ end
11
+
12
+ def highlight(prop)
13
+ children.each do |child|
14
+ if child.prop == prop
15
+ child.style.background_color = "#B8C6F2"
16
+ child.update
17
+ elsif(child.style.background_color != "white")
18
+ child.style.background_color = "white"
19
+ child.update
20
+ end
21
+ end
22
+ end
23
+
24
+ private #################################################
25
+
26
+ def add_prop_row(prop, indent)
27
+ add Limelight::Prop.new(:name => "prop_row", :left_padding => indent.to_s, :prop => prop, :text => "#{prop.name}:#{prop.id}")
28
+ prop.children.each do |child|
29
+ add_prop_row(child, indent + 10)
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,12 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ module StyleTable
5
+
6
+ def populate(style)
7
+ find_by_name('style_value').each do |style_value|
8
+ style_value.populate(style)
9
+ end
10
+ end
11
+
12
+ end
@@ -0,0 +1,16 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ module StyleValue
5
+
6
+ attr_accessor :descriptor
7
+
8
+ def populate(style)
9
+ self.text = style.get(@descriptor)
10
+ end
11
+
12
+ def focus_lost(e)
13
+ production.controller.value_changed(@descriptor, text)
14
+ end
15
+
16
+ end
@@ -0,0 +1,19 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ __ :name => "inspector"
5
+ tool_bar do
6
+ tool :text => "New", :on_mouse_clicked => "scene.new"
7
+ tool :text => "Open", :on_mouse_clicked => "scene.open"
8
+ end
9
+ prop_tree :id => "prop_tree" do
10
+
11
+ end
12
+ style_table :id => 'style_table' do
13
+ Java::limelight.ui.Style::STYLE_LIST.each do |style|
14
+ style_row do
15
+ style_name :text => style.name
16
+ style_value :players => "text_box", :descriptor => style
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,71 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ inspector {
5
+ width "100%"
6
+ height "100%"
7
+ background_color "#e8e8e8"
8
+ }
9
+
10
+ tool_bar {
11
+ width "100%"
12
+ height :auto
13
+ border_color "#8e8e8e"
14
+ bottom_border_width 1
15
+ }
16
+
17
+ tool {
18
+ width 40
19
+ height 40
20
+ border_color "#8e8e8e"
21
+ right_border_width 1
22
+ text_color :black
23
+ font_face :arial
24
+ font_size 12
25
+ horizontal_alignment :center
26
+ vertical_alignment :center
27
+ hover {
28
+ border_color "#0638CC"
29
+ border_width "2"
30
+ background_color "#B8C6F2"
31
+ text_color "black"
32
+ font_style "bold"
33
+ }
34
+ }
35
+
36
+ prop_tree {
37
+ width "100%"
38
+ height "200"
39
+ background_color :white
40
+ }
41
+
42
+ prop_row {
43
+ width "100%"
44
+ height "15"
45
+ background_color :white
46
+ }
47
+
48
+ style_table {
49
+ width "100%"
50
+ height "68%"
51
+ }
52
+
53
+ style_row {
54
+ width "100%"
55
+ height "28"
56
+ }
57
+
58
+ style_name {
59
+ width "50%"
60
+ height "100%"
61
+ vertical_alignment :center
62
+ horizontal_alignment :right
63
+ horizontal_scrollbar :off
64
+ vertical_scrollbar :off
65
+ }
66
+
67
+ style_value {
68
+ width "50%"
69
+ vertical_alignment :center
70
+ horizontal_alignment :left
71
+ }
@@ -0,0 +1,5 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ $: << File.expand_path(File.dirname(__FILE__))
5
+ require 'limelight/composer/controller'
@@ -0,0 +1,51 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ module Limelight
5
+ module Composer
6
+
7
+ class Controller
8
+
9
+ def initialize(production)
10
+ @production = production
11
+ end
12
+
13
+ def prop_selected(prop)
14
+ puts "Prop clicked: #{prop}"
15
+ highlight(prop)
16
+ @production.inspector.inspect_prop(prop)
17
+ end
18
+
19
+ def value_changed(descriptor, value)
20
+ @highlighted_prop.style.put(descriptor, value)
21
+ @highlighted_prop.update
22
+ end
23
+
24
+ private #############################################
25
+
26
+ def highlight(prop)
27
+ if @highlighted_prop
28
+ @highlighted_prop.after_painting(nil)
29
+ @highlighted_prop.update
30
+ end
31
+ @highlighted_prop = prop
32
+ prop.after_painting { |pen| paint_hightlight(prop, pen) }
33
+ prop.update
34
+ end
35
+
36
+ def paint_hightlight(prop, pen)
37
+ area = prop.area
38
+
39
+ pen.color = "#B8C6F2DD"
40
+ pen.fill_rectangle(0, 0, area.width, area.height)
41
+
42
+ pen.color = "#0638CCDD"
43
+ pen.width = 5
44
+ pen.draw_rectangle(0, 0, area.width - 1, area.height - 1)
45
+ end
46
+
47
+
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,24 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ module Limelight
5
+ module Composer
6
+
7
+ module Lethargy
8
+
9
+ def self.null_event(*args)
10
+ args.each do |sym|
11
+ define_method(sym) { |event| } # do nothing
12
+ end
13
+ end
14
+
15
+ null_event *Limelight::Prop::EVENTS
16
+
17
+ def mouse_clicked(e)
18
+ scene.production.controller.prop_selected(self)
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,6 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ name "Stage Composer"
5
+ attribute :controller
6
+ attribute :inspector
@@ -0,0 +1,15 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ stage "inspector" do
5
+ default_scene "inspector"
6
+ title "Limelight Composer Inspector"
7
+ location [0, 0]
8
+ size [300, 800]
9
+ end
10
+
11
+ stage "viewer" do
12
+ title "Limelight Composer Viewer"
13
+ location [350, 0]
14
+ size [800, 800]
15
+ end
@@ -0,0 +1,5 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ __ :horizontal_alignment => "center", :vertical_alignment => "center", :width => "100%", :height => "100%"
5
+ title :text => "Welcome to Limelight", :font_size => "72"
@@ -0,0 +1,94 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
+ require 'limelight/casting_director'
6
+ require 'limelight/prop_builder'
7
+
8
+ describe Limelight::CastingDirector do
9
+
10
+ before(:each) do
11
+ @scene = Limelight::Scene.new(:casting_director => make_mock("casting_director", :fill_cast => nil), :path => "scene_path")
12
+ @loader = make_mock("loader")
13
+ @casting_director = Limelight::CastingDirector.new(@loader)
14
+ end
15
+
16
+ def make_root(options={})
17
+ @root = Limelight::Prop.new(options)
18
+ @scene << @root
19
+ end
20
+
21
+ it "should include default players" do
22
+ prepare_fake_player("root")
23
+ make_root(:name => "root")
24
+
25
+ @root.should_receive(:include_player).with("root module")
26
+
27
+ @casting_director.fill_cast(@root)
28
+ end
29
+
30
+ def prepare_fake_player(name)
31
+ @loader.should_receive(:exists?).with("scene_path/players/#{name}.rb").and_return(true)
32
+ @loader.should_receive(:path_to).with("scene_path/players/#{name}.rb").and_return("scene_path/players/#{name}.rb")
33
+ Kernel.should_receive(:load).with("scene_path/players/#{name}.rb").and_return(true)
34
+ Object.should_receive(:const_defined?).with(name.camalized).and_return(true)
35
+ Object.should_receive(:const_get).with(name.camalized).and_return("#{name} module")
36
+ end
37
+
38
+ it "should not load any default players if they don't exist" do
39
+ make_root(:name => "root")
40
+ @loader.stub!(:exists?).and_return false
41
+
42
+ @root.should_not_receive(:include_player)
43
+ @child.should_not_receive(:include_player)
44
+ @grandchild.should_not_receive(:include_player)
45
+
46
+ @casting_director.fill_cast(@root)
47
+ end
48
+
49
+ it "should not load any players if they don't define a module with the right name" do
50
+ make_root(:name => "root")
51
+ @loader.stub!(:exists?).and_return(true)
52
+ @loader.stub!(:path_to).and_return("blah")
53
+ Kernel.stub!(:load).and_return(true)
54
+ Object.stub!(:const_defined?).and_return(false)
55
+
56
+ @root.should_not_receive(:include_player)
57
+
58
+ @casting_director.fill_cast(@root)
59
+ end
60
+
61
+ it "should load builtin players" do
62
+ @loader.stub!(:exists?).and_return(false)
63
+ make_root(:name => "root", :players => "button")
64
+
65
+ @casting_director.fill_cast(@root)
66
+
67
+ @root.is_a?(Limelight::Players::Button).should == true
68
+ end
69
+
70
+ it "should load custom players" do
71
+ @loader.stub!(:exists?).and_return(false)
72
+ prepare_fake_player("custom_player")
73
+ make_root(:name => "root", :players => "custom_player")
74
+
75
+ @root.should_receive(:include_player).with("custom_player module")
76
+
77
+ @casting_director.fill_cast(@root)
78
+ end
79
+
80
+ it "should handle multiple players" do
81
+ @loader.stub!(:exists?).and_return(false)
82
+ prepare_fake_player("root")
83
+ prepare_fake_player("custom_player")
84
+
85
+ make_root(:name => "root", :players => "custom_player button")
86
+
87
+ @root.should_receive(:include_player).with("root module")
88
+ @root.should_receive(:include_player).with("custom_player module")
89
+ @root.should_receive(:include_player).with(Limelight::Players::Button)
90
+
91
+ @casting_director.fill_cast(@root)
92
+ end
93
+
94
+ end
@@ -0,0 +1,33 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
+ require 'limelight/commands'
6
+ require 'limelight/producer'
7
+
8
+ describe Limelight::Commands do
9
+
10
+ before(:each) do
11
+ end
12
+
13
+ it "should open a production" do
14
+ args = ["open", "production_name"]
15
+ Limelight::Producer.should_receive(:open).with("production_name")
16
+ Limelight::Commands.run(args)
17
+ end
18
+
19
+ it "should open the default production" do
20
+ args = ["open"]
21
+ Limelight::Producer.should_receive(:open).with(Limelight::DEFAULT_PRODUCTION)
22
+ Limelight::Commands.run(args)
23
+ end
24
+
25
+ it "should pack a production" do
26
+ mock_packer = make_mock("packer")
27
+ Java::limelight::io::Packer.should_receive(:new).and_return(mock_packer)
28
+ mock_packer.should_receive(:pack).with("production_to_pack")
29
+
30
+ Limelight::Commands.run(["pack", "production_to_pack"])
31
+ end
32
+
33
+ end
@@ -0,0 +1,64 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
+ require 'limelight/file_chooser'
6
+
7
+ describe Limelight::FileChooser do
8
+
9
+ before(:each) do
10
+ end
11
+
12
+ it "should create a Java file chooser" do
13
+ chooser = Limelight::FileChooser.new()
14
+ chooser.chooser.class.should == javax.swing.JFileChooser
15
+ end
16
+
17
+ it "should set current directory if provided" do
18
+ chooser = Limelight::FileChooser.new(:directory => "/tmp")
19
+
20
+ chooser.chooser.getCurrentDirectory().getAbsolutePath().should == "/tmp"
21
+ end
22
+
23
+ it "should have a title if provided" do
24
+ chooser = Limelight::FileChooser.new(:title => "Some Title")
25
+
26
+ chooser.chooser.getDialogTitle().should == "Some Title"
27
+ end
28
+
29
+ it "should have a filter if provided" do
30
+ chooser = Limelight::FileChooser.new(:description => "Description") { "filter" }
31
+
32
+ filter = chooser.chooser.getFileFilter()
33
+ filter.description.should == "Description"
34
+ filter.filter.call.should == "filter"
35
+ end
36
+
37
+ it "should return nil if no file was selected" do
38
+ chooser = Limelight::FileChooser.new(:parent => "parent")
39
+ chooser.chooser.should_receive(:showOpenDialog).with("parent").and_return(javax.swing.JFileChooser::CANCEL_OPTION)
40
+
41
+ chooser.choose_file.should == nil
42
+ end
43
+
44
+ it "should return the absolute path if a file was selected" do
45
+ chooser = Limelight::FileChooser.new(:parent => "parent")
46
+ chooser.chooser.should_receive(:showOpenDialog).with("parent").and_return(javax.swing.JFileChooser::APPROVE_OPTION)
47
+ selected_file = make_mock("selected file", :absolute_path => "selected file's absolute path")
48
+ chooser.chooser.should_receive(:getSelectedFile).and_return(selected_file)
49
+
50
+ chooser.choose_file.should == "selected file's absolute path"
51
+ end
52
+
53
+ it "should default to files and directories but allow directory only and file only" do
54
+ chooser = Limelight::FileChooser.new
55
+ chooser.chooser.file_selection_mode.should == javax.swing.JFileChooser::FILES_AND_DIRECTORIES
56
+
57
+ chooser = Limelight::FileChooser.new(:directories_only => true)
58
+ chooser.chooser.file_selection_mode.should == javax.swing.JFileChooser::DIRECTORIES_ONLY
59
+
60
+ chooser = Limelight::FileChooser.new(:files_only => true)
61
+ chooser.chooser.file_selection_mode.should == javax.swing.JFileChooser::FILES_ONLY
62
+ end
63
+
64
+ end
@@ -0,0 +1,29 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
+ require 'limelight/file_filter'
6
+
7
+ describe Limelight::FileFilter do
8
+
9
+ before(:each) do
10
+ end
11
+
12
+ it "should have a description and a block" do
13
+ filter = Limelight::FileFilter.new("Some Description") { "blah" }
14
+
15
+ filter.description.should == "Some Description"
16
+ filter.filter.call.should == "blah"
17
+ end
18
+
19
+ it "should have implement java interface" do
20
+ filter = Limelight::FileFilter.new("Some Description") { |file| file.name == "good" }
21
+
22
+ filter.getDescription().should == "Some Description"
23
+ bad_file = make_mock("file", :name => "bad")
24
+ good_file = make_mock("file", :name => "good")
25
+ filter.accept(bad_file).should == false
26
+ filter.accept(good_file).should == true
27
+ end
28
+
29
+ end
@@ -0,0 +1,53 @@
1
+ #- Copyright 2008 8th Light, Inc.
2
+ #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
+
4
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
5
+ require 'limelight/java_util'
6
+
7
+ describe Class do
8
+
9
+ class TestClass
10
+ attr_accessor :foo, :bar
11
+ getters :foo, :bar
12
+ setters :foo, :bar
13
+ end
14
+
15
+ before(:each) do
16
+ @obj = TestClass.new
17
+ end
18
+
19
+ it "should have java setters" do
20
+ @obj.setFoo("foo value")
21
+ @obj.setBar("bar value")
22
+
23
+ @obj.foo.should == "foo value"
24
+ @obj.bar.should == "bar value"
25
+ end
26
+
27
+ it "should have java getters" do
28
+ @obj.foo = "foo value"
29
+ @obj.bar = "bar value"
30
+
31
+ @obj.getFoo().should == "foo value"
32
+ @obj.getBar().should == "bar value"
33
+ end
34
+
35
+ end
36
+
37
+ describe String do
38
+
39
+ it "should convert into camel case" do
40
+ "class_name".camalized.should == "ClassName"
41
+ "once_upon_a_time".camalized.should == "OnceUponATime"
42
+ "AbC_eFg_hiJ".camalized.should == "AbcEfgHij"
43
+ "with spaces".camalized.should == "WithSpaces"
44
+ end
45
+
46
+ it "should convert into camel case" do
47
+ "class_name".camalized(:lower).should == "className"
48
+ "once_upon_a_time".camalized(:lower).should == "onceUponATime"
49
+ "AbC_eFg_hiJ".camalized(:lower).should == "abcEfgHij"
50
+ "with spaces".camalized(:lower).should == "withSpaces"
51
+ end
52
+
53
+ end