Open richtera opened 10 years ago
I'm in a similar situation. For now I work around it with a Rakefile task:
# Rakefile task to recompile ruhoh when a file changes.
# To use it:
# - add it to a Rakefile in your project's top level directory
# - run ```rake watch``` in a separate tmux session.
#
# It ignores:
# - whatever is in the top-level .gitignore
# - SASS (that compiles in a different task and its output will force a recompile here)
#
# It has caveats:
# - add .watched to .gitignore!
# - This task uses unix shell commands and not pure Ruby (for now)
dir = File.dirname __FILE__
task :watch do
desc "watches directory and compiles project if important files have changed."
while true do
cache = "#{dir}/.watched"
files = %x{ ls -a1 #{dir} | egrep -v -f .gitignore | egrep -v '_scss' | grep -v ^\\\\. | xargs grep -rl . | xargs md5sum }
if not File.exists? cache
File.write( cache, files )
else
require 'tempfile'
tmp = Tempfile.new( '.ruhoh.watched' )
tmp.write( files )
tmp.close
diffs = %x{ diff #{cache} #{tmp.path} }
if diffs.size > 1
puts
puts %x{ruhoh compile -v}
puts
# POST-COMPILE TASKS
# ------------------
# Add any post-compile fixes here (permission updates, extra files under compile/, etc)
# I've commented mine out, but left them in as examples
## Include CSS for comments
#puts %x{mv #{dir}/compiled/assets/stylesheets/comments*.css #{dir}/compiled/comments/comments.css}
#puts
#
## Fix permissions for apache
#puts %x{chown apache:apache #{dir}/compiled/comments/pages}
#puts
#
## Compile README.md to see how it will look when checked in
# puts 'updating README'
#puts %x{/usr/local/rvm/gems/ruby-1.9.3-p392/bin/redcarpet #{dir}/README.md > #{dir}/README.html}
File.write( cache, files )
puts
print "watching #{dir}"
else
print "."
$stdout.flush
end
end
sleep 1
end
end
Ahh, cool solution, thanks Andy
Sent from my iPhone
On Dec 12, 2013, at 4:48 AM, indolent-gnathostome notifications@github.com wrote:
I'm in a similar situation. For now I work around it with a Rakefile task:
add it to a Rakefile in your project's top level directory # - run
rake watch
in a separate tmux session.## It ignores:# -
whatever is in the top-level .gitignore# - SASS (that compiles in a
different task and its output will force a recompile here)## It has
caveats:# - add .watched to .gitignore!# - This task uses unix shell
commands and not pure Ruby dir = File.dirname FILE
task :watch do
desc "watches directory and compiles project if important files have changed."
while true do
cache = "#{dir}/.watched"
files = %x{ ls -a1 #{dir} | egrep -v -f .gitignore | egrep -v
'_scss' | grep -v ^\. | xargs grep -rl . | xargs md5sum } if not File.exists? cache File.write( cache, files ) else require 'tempfile' tmp = Tempfile.new( '.ruhoh.watched' ) tmp.write( files ) tmp.close diffs = %x{ diff #{cache} #{tmp.path} } if diffs.size > 1 puts puts %x{ruhoh compile -v} puts
# POST-COMPILE TASKS
# ------------------
# Add any post-compile fixes here (permission updates, extra
files under compile/, etc)
## Include CSS for comments
#puts %x{mv #{dir}/compiled/assets/stylesheets/comments*.css
#puts
#
## Fix permissions for apache
#puts %x{chown apache:apache #{dir}/compiled/comments/pages}
#puts
#
## Compile README.md to see how it will look when checked in
# puts 'updating README'
#puts %x{/usr/local/rvm/gems/ruby-1.9.3-p392/bin/redcarpet
File.write( cache, files )
puts
print "watching #{dir}"
else
print "."
$stdout.flush
end
end
sleep 1
endend
— Reply to this email directly or view it on GitHubhttps://github.com/ruhoh/ruhoh.rb/issues/252#issuecomment-30402287 .
I would like to use apache to serve up the files during development since I have some php pages to support oauth authentication which so far I have not been able to do with a purely static site. I guess I could do some proxy apache hackery to point to WebBrick, but it would be much better if deployment and development were working more similar anyways.