Class Limelight::Producer
In: lib/limelight/producer.rb
Parent: Object

A Producer has the hefty responsibility of producing Productions. Given a directory, it will load the neccessary files and create all the neccessary objects to bring a Production to life. A producer will produce only one production.

For directory structures, see Limelight::Main

Methods

Attributes

builtin_styles  [W] 
drb_service  [R] 
production  [R] 
theater  [R] 

Public Class methods

Returns a hash of all the built-in Limglight Styles

[Source]

    # File lib/limelight/producer.rb, line 43
43:       def builtin_styles
44:         unless @builtin_styles
45:           builtin_styles_file = File.join($LIMELIGHT_LIB, "limelight", "builtin", "styles.rb")
46:           @builtin_styles = Limelight.build_styles_from_file(builtin_styles_file)
47:         end
48:         return @builtin_styles
49:       end

A Production name, or root directory, must be provided. If not Theater is provided, one will be created. You may also provide an existing Production for which this Producer will interact.

[Source]

    # File lib/limelight/producer.rb, line 58
58:     def initialize(root_path, theater=nil, production=nil)
59:       if (root_path[-4..-1] == ".lll")
60:         url = IO.read(root_path).strip
61:         root_path = Util::Downloader.download(url)
62:       end
63:       if (root_path[-4..-1] == ".llp")
64:         root_path = unpack_production(root_path)
65:       end
66:       @production = production || Production.new(root_path)
67:       @theater = theater.nil? ? Theater.new(@production) : theater
68:       establish_production
69:     end

Creates a new Producer and has it open a Production by specified name.

[Source]

    # File lib/limelight/producer.rb, line 31
31:       def open(production_name, options={})
32:         producer = new(production_name)
33:         begin
34:           producer.open(options)
35:         rescue Exception => e
36:           puts e
37:           puts e.backtrace
38:         end
39:       end

Public Instance methods

Returns true if the production is compatible with the current version of Limelight or if the user proceeds despite the incompatible warning.

[Source]

     # File lib/limelight/producer.rb, line 97
 97:     def can_proceed_with_compatibility?
 98:       return true if version_compatible?
 99:       return true if Context.instance.studio.utilities_production.should_proceed_with_incompatible_version(@production.name, @production.minimum_limelight_version)
100:       return false
101:     end

Returns the CastingDirector for this Production.

[Source]

    # File lib/limelight/producer.rb, line 81
81:     def casting_director
82:       @casting_director = CastingDirector.new(@production.root) if not @casting_director
83:       return @casting_director
84:     end

Closes the specified production. The producer will trigger the hook, production_closing and production_closed, to keep the production aware of it‘s status. The Studio will also be informed of the closure. If no production remain opened, then the Limelight runtine will exit.

[Source]

     # File lib/limelight/producer.rb, line 179
179:     def close
180:       return if @production.closed?
181:       @production.closed = true
182:       return Thread.new do
183:         begin
184:           Thread.pass
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)
190:         rescue StandardError => e
191:           puts e
192:           puts e.backtrace
193:         end
194:       end
195:     end

Loads the Production without opening it. The Production will be created into memory with all it‘s stages

[Source]

    # File lib/limelight/producer.rb, line 88
88:     def load(options = {})
89:       Gems.install_gems_in_production(@production)
90:       Kernel.load(@production.init_file) if ( !options[:ignore_init] &&  File.exists?(@production.init_file) )
91:       load_stages if File.exists?(@production.stages_file)
92:     end

Loads of the ‘props.rb’ file for a particular Scene and creates all the Prop objects and Scene.

[Source]

     # File lib/limelight/producer.rb, line 149
149:     def load_props(options = {})
150:       scene = Scene.new(options)
151:       if File.exists?(scene.props_file)
152:         content = IO.read(scene.props_file)
153:         options[:build_loader] = @production.root
154:         return Limelight.build_props(scene, options) do
155:           begin
156:             eval content
157:           rescue Exception => e
158:             raise DSL::BuildException.new(scene.props_file, content, e)
159:           end
160:         end
161:       else
162:         return scene
163:       end
164:     end

Loads the ‘stages.rb’ file and configures all the Stages in the Production.

[Source]

     # File lib/limelight/producer.rb, line 134
134:     def load_stages
135:       stages_file = @production.stages_file
136:       content = IO.read(stages_file)
137:       stages = Limelight.build_stages(@theater) do
138:         begin
139:           eval content
140:         rescue Exception => e
141:           raise DSL::BuildException.new(stages_file, content, e)
142:         end
143:       end
144:       return stages
145:     end

Loads the specified ‘styles.rb’ file and created a Hash of Styles.

[Source]

     # File lib/limelight/producer.rb, line 168
168:     def load_styles(context)
169:       extendable_styles = Producer.builtin_styles.merge(@production.root_styles)
170:       return extendable_styles.dup if not File.exists?(context.styles_file)
171:       new_styles = Limelight.build_styles_from_file(context.styles_file, extendable_styles)
172:       return extendable_styles.merge(new_styles)
173:     end

Opens the Production.

[Source]

     # File lib/limelight/producer.rb, line 105
105:     def open(options = {})
106:       @production.production_opening
107:       load
108:       @production.production_loaded
109:       if @theater.has_stages?
110:         @theater.stages.each do |stage|
111:           open_scene(stage.default_scene.to_s, stage) if stage.default_scene
112:         end
113:       elsif @production.default_scene
114:         open_scene(@production.default_scene, @theater.default_stage)
115:       end
116:       @casting_director = nil
117:       @production.production_opened
118:     end

Opens the specified Scene onto the Spcified Stage.

[Source]

     # File lib/limelight/producer.rb, line 122
122:     def open_scene(name, stage, options={})
123:       path = @production.scene_directory(name)
124:       scene_name = File.basename(path)
125:       scene = load_props(options.merge(:production => @production, :casting_director => casting_director, :path => path, :name => scene_name))
126:       styles = load_styles(scene)
127:       scene.styles = styles
128:       stage.open(scene)
129:       return scene
130:     end

Publish the production, using DRb, on the specified port. This is useful for testing or remotely controling your production. Publilshing productions on DRb is typically accomplished by using the —drb_port option of the open command. eg.

  jruby -S limelight open --drb_port=9000 my_production

[Source]

     # File lib/limelight/producer.rb, line 203
203:     def publish_production_on_drb(port)
204:       @drb_service = DRb.start_service("druby://localhost:#{port}", @production)
205:     end

Returns true if the production‘s minimum_limelight_version is compatible with the current version.

[Source]

    # File lib/limelight/producer.rb, line 73
73:     def version_compatible?
74:       current_version = Limelight::Util::Version.new(Limelight::VERSION::STRING)
75:       required_version = Limelight::Util::Version.new(@production.minimum_limelight_version)
76:       return required_version.is_less_than_or_equal(current_version)
77:     end

[Validate]