Class: Arcabouco::Server
- Inherits:
-
Object
- Object
- Arcabouco::Server
- Defined in:
- lib/arcabouco/server.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#rack ⇒ Object
Returns the value of attribute rack.
-
#root ⇒ Object
Returns the value of attribute root.
-
#web ⇒ Object
Returns the value of attribute web.
Instance Method Summary collapse
- #build ⇒ Object
- #compile_view(path, output) ⇒ Object
- #get_env ⇒ Object
- #get_rack ⇒ Object
-
#initialize ⇒ Server
constructor
A new instance of Server.
- #prepare_env_for_build ⇒ Object
- #run ⇒ Object
- #setup_env ⇒ Object
- #setup_rack ⇒ Object
Constructor Details
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
70 71 72 |
# File 'lib/arcabouco/server.rb', line 70 def env @env end |
#rack ⇒ Object
Returns the value of attribute rack.
69 70 71 |
# File 'lib/arcabouco/server.rb', line 69 def rack @rack end |
#root ⇒ Object
Returns the value of attribute root.
68 69 70 |
# File 'lib/arcabouco/server.rb', line 68 def root @root end |
#web ⇒ Object
Returns the value of attribute web.
71 72 73 |
# File 'lib/arcabouco/server.rb', line 71 def web @web end |
Instance Method Details
#build ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/arcabouco/server.rb', line 126 def build FileUtils.mkpath Arcabouco.root + "/public" FileUtils.mkpath Arcabouco.root + "/public/app.assets" prepare_env_for_build manifest = Sprockets::Manifest.new(env, Arcabouco.root + "/public/app.assets/manifest.json") manifest.compile Arcabouco.asset_list compile_view "/", "index.html" compile_view "/save_app.html", "save_app.html" compile_view "/manifest.appcache", "manifest.appcache" end |
#compile_view(path, output) ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/arcabouco/server.rb', line 112 def compile_view(path,output) browser = Rack::Test::Session.new(Rack::MockSession.new(rack)) response = browser.get path, {} File.open(Arcabouco.root + "/public/" + output, 'w+') do |f| f.puts response.body end end |
#get_env ⇒ Object
89 90 91 |
# File 'lib/arcabouco/server.rb', line 89 def get_env self.env end |
#get_rack ⇒ Object
93 94 95 |
# File 'lib/arcabouco/server.rb', line 93 def get_rack self.rack end |
#prepare_env_for_build ⇒ Object
120 121 122 123 |
# File 'lib/arcabouco/server.rb', line 120 def prepare_env_for_build self.env.js_compressor = :uglify self.env.css_compressor = :sass end |
#run ⇒ Object
140 141 142 143 |
# File 'lib/arcabouco/server.rb', line 140 def run thin = Rack::Handler.get('thin') thin.run self.rack end |
#setup_env ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/arcabouco/server.rb', line 79 def setup_env self.env = Sprockets::Environment.new self.env.append_path 'app/media' self.env.append_path 'app/js' self.env.append_path 'app/css' self.env.append_path HandlebarsAssets.path self.env.append_path File.join(Arcabouco.gem_root,'assets','css') self.env.append_path File.join(Arcabouco.gem_root,'assets','js') end |
#setup_rack ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/arcabouco/server.rb', line 97 def setup_rack self.web = Arcabouco::WebServer.new web = self.web # app_css.write_to( Arcabouco.root + "/public/app-#{app_css.digest}.min.css" ) $environment = self.get_env() self.rack = Rack::Builder.new do map '/app.assets' do run $environment end run web end self.rack end |