Module: Zgomot
- Defined in:
- lib/zgomot/boot.rb,
lib/zgomot/main.rb,
lib/zgomot/config.rb
Defined Under Namespace
Modules: Comp, Delegator, Midi, UI Classes: Boot, Drivers, Error
Constant Summary collapse
- VERSION =
"0.0.0"
- DISPATCHER_POLL =
1.133
- DEFAULT_CONFIG =
{ :beats_per_minute => 120, :time_signature => '4/4', :resolution => '1/32' }
Class Attribute Summary collapse
-
.app_path ⇒ Object
Returns the value of attribute app_path.
-
.config ⇒ Object
Returns the value of attribute config.
-
.config_file ⇒ Object
Returns the value of attribute config_file.
-
.live ⇒ Object
Returns the value of attribute live.
-
.log_file ⇒ Object
Returns the value of attribute log_file.
Class Method Summary collapse
- .add_path(dir) ⇒ Object
- .last_error ⇒ Object
- .logger ⇒ Object
- .logger=(logger) ⇒ Object
- .set_last_error(error) ⇒ Object
- .watch(dir = nil) ⇒ Object
Class Attribute Details
.app_path ⇒ Object
Returns the value of attribute app_path.
20 21 22 |
# File 'lib/zgomot/config.rb', line 20 def app_path @app_path end |
.config ⇒ Object
Returns the value of attribute config.
20 21 22 |
# File 'lib/zgomot/config.rb', line 20 def config @config end |
.config_file ⇒ Object
Returns the value of attribute config_file.
20 21 22 |
# File 'lib/zgomot/config.rb', line 20 def config_file @config_file end |
.live ⇒ Object
Returns the value of attribute live.
20 21 22 |
# File 'lib/zgomot/config.rb', line 20 def live @live end |
.log_file ⇒ Object
Returns the value of attribute log_file.
20 21 22 |
# File 'lib/zgomot/config.rb', line 20 def log_file @log_file end |
Class Method Details
.add_path(dir) ⇒ Object
23 24 25 |
# File 'lib/zgomot/config.rb', line 23 def add_path(dir) File.join(Zgomot.app_path, dir) end |
.last_error ⇒ Object
29 30 31 |
# File 'lib/zgomot/main.rb', line 29 def self.last_error @last_error end |
.logger ⇒ Object
21 |
# File 'lib/zgomot/config.rb', line 21 def logger; @logger ||= Logger.new(STDOUT); end |
.logger=(logger) ⇒ Object
22 |
# File 'lib/zgomot/config.rb', line 22 def logger=(logger); @logger = logger; end |
.set_last_error(error) ⇒ Object
33 34 35 |
# File 'lib/zgomot/main.rb', line 33 def self.set_last_error(error) @last_error = error end |
.watch(dir = nil) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/zgomot/main.rb', line 37 def self.watch(dir=nil) dir ||= '.' raise(Zgomot::Error, "Directory '#{dir}' does not exist") unless Dir.exists?(dir) Zgomot.logger.info "WATCHING '#{dir}' FOR UPDATES" Thread.new do FSSM.monitor(dir) do update do |dir, file| unless /.*\.rb$/.match(file).nil? Zgomot.set_last_error(nil) path = File.join(dir, file) Zgomot.logger.info "LOADED UPDATED FILE: #{path}" = Zgomot::Midi::Stream.streams.values.select{|s| s.status_eql?(:playing)} .each{|s| Zgomot::Midi::Stream.pause(s.name)} sleep(Zgomot::Midi::Clock.measure_sec) begin load path rescue Exception => e Zgomot.set_last_error(e.) end .each{|s| Zgomot::Midi::Stream.play(s.name)} end end create do |dir, file| unless /.*\.rb$/.match(file).nil? Zgomot.set_last_error(nil) path = File.join(dir, file) Zgomot.logger.info "LOADED CREATED FILE: #{path}" begin load path rescue Exception => e Zgomot.set_last_error(e.) end end end end end dir end |