Class: Tipsy::Runner
- Inherits:
-
Object
- Object
- Tipsy::Runner
- Defined in:
- lib/tipsy/runner.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
-
#compile ⇒ Object
Responsible for compiling the final site for deployment.
-
#create ⇒ Object
Generates a new site in the specified path.
-
#deploy ⇒ Object
Responsible for deploying a compiled site to a production server.
-
#initialize(ar, stdin) ⇒ Runner
constructor
A new instance of Runner.
-
#serve ⇒ Object
Create an instance of Rack::Builder to serve the “static” site.
Constructor Details
#initialize(ar, stdin) ⇒ Runner
Returns a new instance of Runner.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/tipsy/runner.rb', line 8 def initialize(ar, stdin) @args = [ar].flatten cmd = args.first || "serve" cmd = "serve" if ['', 'run', 's', 'serve'].include?(cmd) cmd = "create" if cmd == 'new' args.shift Tipsy::Site.configure! @site = Tipsy::Site.new send(:"#{cmd}") end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
6 7 8 |
# File 'lib/tipsy/runner.rb', line 6 def args @args end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
6 7 8 |
# File 'lib/tipsy/runner.rb', line 6 def site @site end |
Instance Method Details
#compile ⇒ Object
Responsible for compiling the final site for deployment. This process will take the following steps:
-
Copy files recursively from /public
-
Compile javascripts, sprites, and css files into their respective directories within the compile folder
-
Render all templates and place in their proper directories within the compile folder.
101 102 103 |
# File 'lib/tipsy/runner.rb', line 101 def compile Tipsy::Runners::Compiler.new(@args, @site) end |
#create ⇒ Object
Generates a new site in the specified path.
87 88 89 |
# File 'lib/tipsy/runner.rb', line 87 def create Tipsy::Runners::Generator.new(args, @site) end |
#deploy ⇒ Object
Responsible for deploying a compiled site to a production server.
110 111 112 |
# File 'lib/tipsy/runner.rb', line 110 def deploy Tipsy::Runners::Deployer.new end |
#serve ⇒ Object
Create an instance of Rack::Builder to serve the “static” site.
24 25 26 27 28 29 30 31 32 33 34 35 36 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 75 76 77 78 79 80 81 |
# File 'lib/tipsy/runner.rb', line 24 def serve require 'tipsy/server' require 'tipsy/view' require 'rack' conf = Tipsy::Site.config = "Rack::Legacy could not be loaded. Add it to your gemfile or set 'enable_php' to false in config.rb" = "Rack::Rewrite could not be loaded. Add it to your gemfile or remove 'rewrite_rules' from config.rb" if conf.enable_php begin require 'rack-legacy' require 'tipsy/handler/php' rescue LoadError puts end end app = Rack::Builder.new { use Rack::Reloader use Rack::ShowStatus unless conf.rewrite_rules.empty? begin require 'rack-rewrite' puts "Enabling Rack Rewrite" use Rack::Rewrite do conf.rewrite_rules.each do |pair| rewrite pair.first, pair.last end end rescue LoadError puts end end if conf.enable_php begin puts "PHP Enabled" use Rack::Legacy::Php, conf.public_path rescue end end use Rack::ShowExceptions use Tipsy::Handler::StaticHandler, :root => conf.public_path, :urls => %w[/] run Rack::Cascade.new([ Rack::URLMap.new(Tipsy::Handler::AssetHandler.map!), Tipsy::Server.new ]) }.to_app conf = Tipsy::Site.config = { :Host => conf.address, :Port => conf.port } Tipsy::Server.run!(app, ) end |