Class: Snap::Server
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Snap::Server
- Defined in:
- lib/snap/server.rb
Class Method Summary collapse
-
.run!(options = {}) ⇒ Object
require ‘logger’ use Rack::CommonLogger, Logger.new(STDOUT) Add Rack::Cache.
Instance Method Summary collapse
- #at_root? ⇒ Boolean
-
#get_current_dir ⇒ Object
TODO: Cattr?.
- #get_root_dir ⇒ Object
- #get_snap_files ⇒ Object
- #set_current_dir(newdir) ⇒ Object
Class Method Details
.run!(options = {}) ⇒ Object
require ‘logger’ use Rack::CommonLogger, Logger.new(STDOUT) Add Rack::Cache
14 15 16 17 |
# File 'lib/snap/server.rb', line 14 def self.run!(={}) @@root_dir = [:root] super.run! if super.respond_to?("run!") end |
Instance Method Details
#at_root? ⇒ Boolean
77 78 79 |
# File 'lib/snap/server.rb', line 77 def at_root? File.(get_current_dir) == File.(get_root_dir) end |
#get_current_dir ⇒ Object
TODO: Cattr?
24 25 26 |
# File 'lib/snap/server.rb', line 24 def get_current_dir @dir end |
#get_root_dir ⇒ Object
19 20 21 |
# File 'lib/snap/server.rb', line 19 def get_root_dir @@root_dir ||= Dir.pwd end |
#get_snap_files ⇒ Object
71 72 73 74 75 |
# File 'lib/snap/server.rb', line 71 def get_snap_files files = Dir.glob("#{get_current_dir}/**").map{|f| SnapFile.new(f)} files.insert(0,SnapFile.new(File.join(get_current_dir, '..'))) unless at_root? files end |
#set_current_dir(newdir) ⇒ Object
28 29 30 |
# File 'lib/snap/server.rb', line 28 def set_current_dir(newdir) @dir = newdir end |