Commit 144a249
Changed files (5)
lib/boot/container_configuration.rb
@@ -1,4 +1,6 @@
class ContainerConfiguration
+ extend Command
+
def self.run(container)
container.register(:event_aggregator) { EventAggregator.new }.as_singleton
container.register(:shell) { ApplicationShell.new }.as_singleton
lib/boot/events_registration.rb
@@ -1,4 +1,6 @@
class EventsRegistration
+ extend Command
+
def self.run(container)
register_items_with(container.resolve(:event_aggregator))
end
lib/utility/command.rb
@@ -0,0 +1,5 @@
+module Command
+ def then(other_command)
+ CompositeCommand.new(self, other_command)
+ end
+end
lib/utility/composite_command.rb
@@ -0,0 +1,11 @@
+class CompositeCommand
+ def initialize(first, last)
+ @first = first
+ @last = last
+ end
+
+ def run(*args)
+ @first.run(*args)
+ @last.run(*args)
+ end
+end
lib/application.rb
@@ -1,6 +1,7 @@
require 'rubygems'
require 'bundler'
Bundler.require(:default)
+require_relative 'utility/command.rb'
Dir["lib/**/*.rb"].each do |file|
$:.unshift(File.dirname(file)) unless $:.include?(File.dirname(file))
@@ -11,8 +12,8 @@ class Application
def run(arguments)
Gtk.init
container = Spank::Container.new
- ContainerConfiguration.run(container)
- EventsRegistration.run(container)
+ ContainerConfiguration.then(EventsRegistration).run(container)
+
container.resolve(:shell_presenter).present
Gtk.main
end