Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding ability to change destination of rendered files

  • Loading branch information...
commit 22ff326f5d785ba3741c54b4d14ec20c99fdd5d1 1 parent c00c5c8
@winton authored
View
10 README.md
@@ -194,6 +194,12 @@ Only render specific files or directories:
<!-- highlight:-o language:console -->
$ stasis -o index.html.haml,subdirectory
+
+Change the public (destination) directory:
+
+<!-- highlight:-o language:console -->
+
+ $ stasis -p ../public
### Programmatic
@@ -201,6 +207,10 @@ Instanciate a `Stasis` object:
stasis = Stasis.new('/path/to/project/root')
+Optionally specify a destination directory:
+
+ stasis = Stasis.new('/project', '/html')
+
Render all templates:
stasis.render
View
5 bin/stasis
@@ -8,13 +8,18 @@ require 'slop'
opts = Slop.parse :help => true do
on :d, :development, "Development mode\t\t(auto-regenerate)"
on :o, :only, "Only generate specific files\t(comma-separated)", :optional => true, :as => Array
+ on :p, :public, "Public directory path", :optional => true
on :s, :server, "Server mode\t\t\t(default redis host: localhost:6379/0)", :optional => true, :default => "localhost:6379/0"
end
if opts.development?
Stasis::DevMode.new(Dir.pwd, opts)
+elsif opts.only? && opts.public?
+ Stasis.new(Dir.pwd, opts[:public]).render(*opts[:only])
elsif opts.only?
Stasis.new(Dir.pwd).render(*opts[:only])
+elsif opts.public?
+ Stasis.new(Dir.pwd, opts[:public]).render(*opts[:only])
elsif opts.server?
Stasis::Server.new(Dir.pwd, opts)
else
View
2  config/gemsets.yml
@@ -4,6 +4,6 @@ stasis:
redis: ~>2.2.1
rocco: ~>0.8
rspec: ~>1.0
- slop: ~>2.0.0
+ slop: ~>2.1.0
tilt: ~>1.3
yajl-ruby: ~>0.8.2
View
3  lib/stasis.rb
@@ -73,6 +73,9 @@ class Stasis
attr_accessor :root
def initialize(root, destination=root+'/public')
+ root = File.expand_path(root)
+ destination = File.expand_path(destination, root)
+
@destination = destination
@root = root
View
2  lib/stasis/server.rb
@@ -11,7 +11,7 @@ def initialize(root, options={})
puts "\nStarting Stasis server (redis @ #{options[:server]})..."
redis = Redis.connect(:url => "redis://#{options[:server]}")
- stasis = Stasis.new(root)
+ stasis = Stasis.new(*[ root, options[:public] ].compact)
begin
while true
Please sign in to comment.
Something went wrong with that request. Please try again.