Class: Adva::Static::Server::Watch
- Inherits:
-
Object
- Object
- Adva::Static::Server::Watch
- Includes:
- Request
- Defined in:
- lib/adva/static/server/watch.rb,
lib/adva/static/server/watch/handler.rb
Defined Under Namespace
Classes: Handler
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#watch ⇒ Object
readonly
Returns the value of attribute watch.
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize(app, options = {}, &block) ⇒ Watch
constructor
A new instance of Watch.
- #update(path, event_type = nil) ⇒ Object
Constructor Details
#initialize(app, options = {}, &block) ⇒ Watch
Returns a new instance of Watch.
15 16 17 18 19 20 |
# File 'lib/adva/static/server/watch.rb', line 15 def initialize(app, = {}, &block) @app = app @dir = Pathname.new([:dir] || File.('import')) dir.mkpath run! end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
11 12 13 |
# File 'lib/adva/static/server/watch.rb', line 11 def app @app end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
11 12 13 |
# File 'lib/adva/static/server/watch.rb', line 11 def dir @dir end |
#watch ⇒ Object (readonly)
Returns the value of attribute watch.
11 12 13 |
# File 'lib/adva/static/server/watch.rb', line 11 def watch @watch end |
Instance Method Details
#get(path) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/adva/static/server/watch.rb', line 33 def get(path) import = Adva::Static::Import.new(:source => dir) request = import.request_for(path) self.request('GET', request.public_path, STORE_HEADER => true) rescue Exception => e Adva.out.puts e. e.backtrace.each { |line| Adva.out.puts line } end |
#update(path, event_type = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/adva/static/server/watch.rb', line 22 def update(path, event_type = nil) Adva.out.puts "\n#{event_type}: #{path}" import = Import.new(:source => dir) request = import.request_for(path) status, headers, response = self.request('POST', request.path, request.params) response = get(path) if !request.destroy? && status == 302 rescue Exception => e Adva.out.puts e. e.backtrace.each { |line| Adva.out.puts line } end |