epall-limelight 0.5.2-java → 0.5.3-java

Sign up to get free protection for your applications and to get access to all the features.
data/lib/limelight.jar CHANGED
Binary file
@@ -21,7 +21,7 @@ module Limelight
21
21
 
22
22
  def load_command(name)
23
23
  begin
24
- name = name.gsub('-', '')
24
+ name = name.gsub('-', '')
25
25
  require "limelight/commands/#{name}_command"
26
26
  rescue LoadError => e
27
27
  end
@@ -12,7 +12,7 @@ module Limelight
12
12
  # Open a limelight production.
13
13
  # options:
14
14
  # -h, --help Prints this usage summary.
15
- # -d, --drb_port=<port> Publish the Studio using DRb on the specified port.
15
+ # -d, --drb_port=<port> Publish productions using DRb starting with specified port.
16
16
  #
17
17
  class OpenCommand < Command
18
18
 
@@ -42,7 +42,7 @@ module Limelight
42
42
  end
43
43
 
44
44
  def build_options(spec) #:nodoc:
45
- spec.on("-d <port>", "--drb_port=<port>", "Publish the Studio using DRb on the specified port.") { |value| @drb_port = value }
45
+ spec.on("-d <port>", "--drb_port=<port>", "Publish productions using DRb starting with specified port.") { |value| @drb_port = value }
46
46
  end
47
47
 
48
48
  def parse_remainder(args)
@@ -50,7 +50,7 @@ module Limelight
50
50
  end
51
51
 
52
52
  def process
53
- Context.instance.studio.publish_on_drb(@drb_port.to_i) if @drb_port
53
+ Context.instance.studio.publish_productions_on_drb(@drb_port.to_i) if @drb_port
54
54
  Context.instance.studio.open(@production_path)
55
55
  end
56
56
 
@@ -2,7 +2,7 @@
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
4
  $LIMELIGHT_LIB = File.expand_path(File.join(File.dirname(__FILE__), '..'))
5
- $: << $LIMELIGHT_LIB unless $:.include?($LIMELIGHT_LIB)
5
+ $:.unshift $LIMELIGHT_LIB unless $:.include?($LIMELIGHT_LIB)
6
6
  $LIMELIGHT_HOME = File.expand_path(File.join($LIMELIGHT_LIB, ".."))
7
7
 
8
8
  if Java::java.lang.System.getProperty("limelight.home").nil?
@@ -13,11 +13,13 @@ require 'limelight/production'
13
13
  require 'limelight/gems'
14
14
  require 'limelight/util/downloader'
15
15
  require 'limelight/version'
16
+ require 'drb'
16
17
 
17
18
  module Limelight
18
19
 
19
20
  # A Producer has the hefty responsibility of producing Productions. Given a directory, it will load the neccessary
20
- # files and create all the neccessary objects to bring a Production to life.
21
+ # files and create all the neccessary objects to bring a Production to life. A producer will produce only
22
+ # one production.
21
23
  #
22
24
  # For directory structures, see Limelight::Main
23
25
  #
@@ -47,7 +49,7 @@ module Limelight
47
49
  end
48
50
  end
49
51
 
50
- attr_reader :theater, :production
52
+ attr_reader :theater, :production, :drb_service
51
53
  attr_writer :builtin_styles
52
54
 
53
55
  # A Production name, or root directory, must be provided. If not Theater is provided, one will be created.
@@ -174,16 +176,17 @@ module Limelight
174
176
  # to keep the production aware of it's status. The Studio will also be informed of the closure. If no
175
177
  # production remain opened, then the Limelight runtine will exit.
176
178
  #
177
- def close(production)
178
- return if production.closed?
179
- production.closed = true
179
+ def close
180
+ return if @production.closed?
181
+ @production.closed = true
180
182
  return Thread.new do
181
183
  begin
182
184
  Thread.pass
183
- production.production_closing
184
- production.theater.close
185
- production.production_closed
186
- Context.instance.studio.production_closed(production)
185
+ @production.production_closing
186
+ @production.theater.close
187
+ @production.production_closed
188
+ @drb_service.stop_service if @drb_service
189
+ Context.instance.studio.production_closed(@production)
187
190
  rescue StandardError => e
188
191
  puts e
189
192
  puts e.backtrace
@@ -191,6 +194,16 @@ module Limelight
191
194
  end
192
195
  end
193
196
 
197
+ # Publish the production, using DRb, on the specified port. This is useful for testing or remotely controling
198
+ # your production. Publilshing productions on DRb is typically accomplished by using the --drb_port option
199
+ # of the open command. eg.
200
+ #
201
+ # jruby -S limelight open --drb_port=9000 my_production
202
+ #
203
+ def publish_production_on_drb(port)
204
+ @drb_service = DRb.start_service("druby://localhost:#{port}", @production)
205
+ end
206
+
194
207
  def establish_production #:nodoc:
195
208
  @production.producer = self
196
209
  @production.theater = @theater
@@ -150,7 +150,14 @@ module Limelight
150
150
  # The production will actually delegate to it's producer and the producer will close the production down.
151
151
  #
152
152
  def close
153
- @producer.close(self)
153
+ @producer.close
154
+ end
155
+
156
+ # Publish this production using DRb on the specified port. The production will delegate to its producer to
157
+ # actually do the publishing.
158
+ #
159
+ def publish_on_drb(port)
160
+ @producer.publish_production_on_drb(port)
154
161
  end
155
162
 
156
163
  # Called when the last stage in this production's theater is closed. If the allow_close? returns true
@@ -9,12 +9,59 @@ require 'limelight/string'
9
9
  require 'limelight/specs/test_scene_opener'
10
10
 
11
11
  module Limelight
12
+
13
+ # Limelight comes with builtin assistance for testing your productions with rspec.
14
+ # See Limelight::Specs::SpecHelper
15
+ #
12
16
  module Specs
13
17
 
14
18
  class << self
15
19
  attr_accessor :producer
16
20
  end
17
-
21
+
22
+ # Limelight comes with builtin assistance for testing your productions with rspec. To get started, add the following
23
+ # to your describe block...
24
+ #
25
+ # uses_limelight :scene => "my_scene"
26
+ #
27
+ # This will add before(:each) blocks that will setup your production and load your scene before each test.
28
+ # It also provides some accessors to common objects like the scene and production. Afterwards, you can
29
+ # write tests that look like this.
30
+ #
31
+ # it "should do something with the scene" do
32
+ # scene.name.should == "my_scene"
33
+ # scene.find("title").text.should == "This is the Title"
34
+ # production.theater["default_stage"].current_scene.should be(scene)
35
+ # end
36
+ #
37
+ # There are several other options you can supply with 'uses_limelight':
38
+ #
39
+ # :hidden - (true or false) Defaults to true, but if you turn it off, the scene will pop open on your screen. This
40
+ # can be really nifty at times and really annoying at other time.
41
+ #
42
+ # :stage - The name of the stage you want the scene to be loaded on. The theater's default stage will be used by
43
+ # default.
44
+ #
45
+ # :scene_name - To be used instead of the :scene option. This will create an empty scene in your production with
46
+ # the specified name.
47
+ #
48
+ # :scene_path - To be used in conjunction with :scene_name. This will cause the empty scene to be loaded with
49
+ # the specified path. Styles and Players associated with the path will be applied to the created scene.
50
+ #
51
+ # The 'uses_limelight' methods also accepts block using the Limelight::DSL::PropBuilder DSL. This is convenient for building a
52
+ # simple prop structure sufficient to test the desired behavior. Here's an example:
53
+ #
54
+ # describe "my scene" do
55
+ # uses_limelight :scene_name => "some_name", :scene_path => "my_scene_path" do
56
+ # clicky :id => "clicky", :text => "click me", :on_mouse_clicked => "self.text = 'Hey! You clicked me!'"
57
+ # end
58
+ #
59
+ # it "should change text on clicky when clicked" do
60
+ # scene.find("clicky").mouse_clicked(nil)
61
+ # clicky.text.should == "Hey! You clicked me!"
62
+ # end
63
+ # end
64
+ #
18
65
  module SpecHelper
19
66
  def scene
20
67
  if !@scene
@@ -26,10 +73,12 @@ module Limelight
26
73
  end
27
74
  end
28
75
 
29
- module Spec
76
+ module Spec #:nodoc:
30
77
  module Example
31
78
  class ExampleGroup
32
79
 
80
+ # Deprecated
81
+ #
33
82
  def self.uses_scene(scene_name, options = {})
34
83
  uses_limelight({:scene => scene_name}.merge(options))
35
84
  end
@@ -5,7 +5,7 @@ module Limelight
5
5
  module Specs
6
6
  module SpecHelper
7
7
 
8
- class TestSceneOpener
8
+ class TestSceneOpener #:nodoc:
9
9
  def initialize(producer, ll_spec_options, prop_block)
10
10
  @producer = producer
11
11
  @prop_block = prop_block
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
3
  describe "!-SCENE_TITLE-!" do
4
4
 
5
- uses_scene "!-SCENE_NAME-!", :hidden => true
5
+ uses_limelight :scene => "!-SCENE_NAME-!", :hidden => true
6
6
 
7
7
  it "should have default text" do
8
8
  scene.children.size.should == 1
@@ -2,6 +2,7 @@
2
2
  #- Limelight and all included source files are distributed under terms of the GNU LGPL.
3
3
 
4
4
  require 'limelight/limelight_exception'
5
+ require 'thread'
5
6
 
6
7
  module Limelight
7
8
 
@@ -18,12 +19,13 @@ module Limelight
18
19
  def initialize(production)
19
20
  @production = production
20
21
  @stages = {}
22
+ @mutex = Mutex.new
21
23
  end
22
24
 
23
25
  # Returns an Array of Stages that belong to this Theater.
24
26
  #
25
27
  def stages
26
- return @stages.values
28
+ return @mutex.synchronize { @stages.values }
27
29
  end
28
30
 
29
31
  # Returns true if the theater has at least one stage
@@ -35,7 +37,7 @@ module Limelight
35
37
  # Returns the Stage with the spcified name, nil if none exist with the specified name.
36
38
  #
37
39
  def [](stage_name)
38
- return @stages[stage_name]
40
+ return @mutex.synchronize { @stages[stage_name] }
39
41
  end
40
42
 
41
43
  # Adds a Stage to the Theater. Raises an exception is the name of the Stage is duplicated.
@@ -43,7 +45,7 @@ module Limelight
43
45
  def add_stage(name, options = {})
44
46
  raise LimelightException.new("Duplicate stage name: '#{name}'") if @stages[name]
45
47
  stage = build_stage(name, options)
46
- @stages[name] = stage
48
+ @mutex.synchronize { @stages[name] = stage }
47
49
  return stage
48
50
  end
49
51
 
@@ -65,9 +67,9 @@ module Limelight
65
67
  # Removes the stage from this theater.
66
68
  #
67
69
  def stage_closed(stage)
68
- @stages.delete(stage.name)
70
+ @mutex.synchronize { @stages.delete(stage.name) }
69
71
  @active_stage = nil if @active_stage == stage
70
- @production.theater_empty! if @stages.empty? || !any_visible_stages?
72
+ @production.theater_empty! if !any_stages? || !any_visible_stages?
71
73
  end
72
74
 
73
75
  # If no Stages are added, the Theater will provide a default Stage named "Limelight".
@@ -80,8 +82,9 @@ module Limelight
80
82
  # Close this theater. All stages in this theater will be closed and the active_stage will be nil'ed.
81
83
  #
82
84
  def close
83
- @stages.values.each { |stage| stage.close }
84
- @stages.clear
85
+ stages_to_close = @mutex.synchronize { @stages.values.dup }
86
+ stages_to_close.each { |stage| stage.close }
87
+ @mutex.synchronize { @stages.clear }
85
88
  @active_stage = nil
86
89
  end
87
90
 
@@ -93,8 +96,12 @@ module Limelight
93
96
 
94
97
  private ###############################################
95
98
 
99
+ def any_stages?
100
+ return @mutex.synchronize { @stages.empty? }
101
+ end
102
+
96
103
  def any_visible_stages?
97
- return @stages.values.any? { |s| s.visible? }
104
+ return @mutex.synchronize { @stages.values.any? { |s| s.visible? } }
98
105
  end
99
106
 
100
107
  end
@@ -6,7 +6,7 @@ module Limelight
6
6
  unless defined? MAJOR
7
7
  MAJOR = 0
8
8
  MINOR = 5
9
- TINY = 2
9
+ TINY = 3
10
10
 
11
11
  STRING = [MAJOR, MINOR, TINY].join('.')
12
12
  TAG = "REL_" + [MAJOR, MINOR, TINY].join('_')
@@ -44,7 +44,7 @@ describe Limelight::Commands::OpenCommand do
44
44
 
45
45
  it "should start the studio on drb" do
46
46
  Limelight::Main.should_receive(:initialize_context)
47
- @studio.should_receive(:publish_on_drb).with(1234)
47
+ @studio.should_receive(:publish_productions_on_drb).with(1234)
48
48
  @studio.should_receive(:open).with("some_prod")
49
49
 
50
50
  @command.run ["-d", "1234", "some_prod"]
@@ -215,15 +215,32 @@ describe Limelight::Producer do
215
215
 
216
216
  it "should close a production" do
217
217
  theater = mock("theater")
218
- production = mock("production", :theater => theater, :closed? => false)
218
+ production = @producer.production
219
+ production.theater = theater
219
220
  production.should_receive(:closed=).with(true)
220
221
  production.should_receive(:production_closing)
221
222
  theater.should_receive(:close)
222
223
  production.should_receive(:production_closed)
223
224
  Limelight::Context.instance.studio.should_receive(:production_closed).with(production)
224
225
 
225
- close_thread = @producer.close(production)
226
+ close_thread = @producer.close
226
227
  close_thread.join()
227
228
  end
229
+
230
+ it "should publish a production on drb" do
231
+ service = mock("service")
232
+ DRb.should_receive(:start_service).with("druby://localhost:9000", @producer.production).and_return(service)
233
+
234
+ @producer.publish_production_on_drb(9000)
235
+ end
236
+
237
+ it "should stop the drb service when closing the production" do
238
+ service = mock("service")
239
+ DRb.stub!(:start_service).with("druby://localhost:9000", @producer.production).and_return(service)
240
+ @producer.publish_production_on_drb(9000)
241
+
242
+ service.should_receive(:stop_service)
243
+ @producer.close.join
244
+ end
228
245
 
229
246
  end
@@ -58,11 +58,16 @@ describe Limelight::Production, "Instance methods" do
58
58
  end
59
59
 
60
60
  it "should tell producer to do the closing" do
61
- @producer.should_receive(:close).with(@production)
61
+ @producer.should_receive(:close)
62
62
 
63
63
  @production.close
64
64
  end
65
65
 
66
+ it "should publish on drb" do
67
+ @producer.should_receive(:publish_production_on_drb).with(9000)
68
+ @production.publish_on_drb(9000)
69
+ end
70
+
66
71
  it "should handle empty theater" do
67
72
  @production.should_receive(:allow_close?).at_least(1).and_return(true)
68
73
  @production.should_receive(:close)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epall-limelight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: java
6
6
  authors:
7
7
  - Eric Allen
@@ -9,7 +9,7 @@ autorequire: init
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-29 00:00:00 -04:00
12
+ date: 2009-11-02 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -141,7 +141,6 @@ files:
141
141
  - spec/limelight/scene_spec.rb
142
142
  - spec/limelight/stage_spec.rb
143
143
  - spec/limelight/string_spec.rb
144
- - spec/limelight/styles_spec.rb
145
144
  - spec/limelight/templates/production_templater_spec.rb
146
145
  - spec/limelight/templates/scene_templater_spec.rb
147
146
  - spec/limelight/templates/templater_logger_spec.rb
@@ -329,6 +328,6 @@ rubyforge_project: limelight
329
328
  rubygems_version: 1.3.5
330
329
  signing_key:
331
330
  specification_version: 3
332
- summary: Limelight-0.5.2 - Limelight http://limelight.8thlight.com
331
+ summary: Limelight-0.5.3 - Limelight http://limelight.8thlight.com
333
332
  test_files: []
334
333
 
@@ -1,53 +0,0 @@
1
- #- Copyright � 2008-2009 8th Light, Inc. All Rights Reserved.
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/styles'
6
-
7
- describe Limelight::Styles do
8
-
9
- def const_format(name)
10
- return name.gsub(" ", "")
11
- end
12
-
13
- def method_format(name)
14
- return name.downcase.gsub(" ", "_")
15
- end
16
-
17
- it "should have all the styles" do
18
- Limelight::Styles::Style::STYLE_LIST.each do |descriptor|
19
- const_name = const_format(descriptor.name)
20
- Limelight::Styles.const_get(const_name)
21
- end
22
- end
23
-
24
- # it "should generate code" do
25
- # Limelight::Styles::Style::STYLE_LIST.each do |descriptor|
26
- # const_name = const_format(descriptor.name)
27
- # method_name = method_format(descriptor.name)
28
- # spaces = 40 - const_name.length
29
- # puts "# Specifies the #{descriptor.name} of a prop."
30
- # puts "#"
31
- # puts "# style.#{method_name} = <value>"
32
- # puts "#"
33
- # puts "#{const_name} #{'' * spaces} = Limelight::Styles::Style::STYLE_LIST.get(#{descriptor.index})"
34
- # puts ""
35
- # end
36
- # end
37
-
38
- # it "should generate code" do
39
- # Limelight::Styles::Style::STYLE_LIST.each do |descriptor|
40
- # const_name = const_format(descriptor.name)
41
- # method_name = method_format(descriptor.name)
42
- # spaces = 40 - const_name.length
43
- # puts "<tr>"
44
- # puts "\t<td>'''#{method_name}'''</td>"
45
- # puts "\t<td></td>"
46
- # puts "\t<td>#{descriptor.defaultValue}</td>"
47
- # puts "\t<td></td>"
48
- # puts "</tr>"
49
- # end
50
- # end
51
-
52
-
53
- end