Login  Register

guard - generating to a different directory

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

guard - generating to a different directory

snicoll
First of all I am very new to Ruby so sorry if it is a dumb question.

I am trying to port the Guardfile of the spring framework developer documentation so that it generates its index.html at the same location as the gradle build.

I changed it slightly to generate (and watch) to another directory, something like

 Asciidoctor.render_file(m[0], :to_dir => File.expand_path("../../build/reference/htmlsingle", __FILE__), ...

Nothing happens. However, if I run the same command from a simple ruby file, it works. I could not find a way to debug this and running guard with -d does not help much.

Any clue?

Thanks!
Stéphane
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: guard - generating to a different directory

LightGuardjp
Welcome!

Looking at the email and the small bit of code you've posted I don't see anything wrong with that. The expand_path is a bit odd though. If you already know where it needs to go, just put it there instead of using the expand path. It's possible that expand_path is getting confused because the second argument is a file instead of a directory. 

Also, what do you have in the watch arg? Maybe posting you're whole Guardfile will help. 

Sent from Mailbox for iPhone


On Wed, Jan 8, 2014 at 2:52 AM, snicoll [via Asciidoctor :: Discussion] <[hidden email]> wrote:

First of all I am very new to Ruby so sorry if it is a dumb question.

I am trying to port the Guardfile of the spring framework developer documentation so that it generates its index.html at the same location as the gradle build.

I changed it slightly to generate (and watch) to another directory, something like

 Asciidoctor.render_file(m[0], :to_dir => File.expand_path("../../build/reference/htmlsingle", __FILE__), ...

Nothing happens. However, if I run the same command from a simple ruby file, it works. I could not find a way to debug this and running guard with -d does not help much.

Any clue?

Thanks!
Stéphane


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/guard-generating-to-a-different-directory-tp1265.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: guard - generating to a different directory

snicoll
Thanks!

I have added the link in my original post. Here it is:
https://github.com/spring-projects/spring-framework/blob/master/src/asciidoc/Guardfile

Don't look too deep at my change: as I said, it's my first step with Ruby. You can also reproduce that yourself pretty easily as the code is on github.

Cheers,
S.
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: guard - generating to a different directory

LightGuardjp
I'll have to take a closer look and clone the repo later today as it all looks correct.


On Wed, Jan 8, 2014 at 8:44 AM, snicoll [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thanks!

I have added the link in my original post. Here it is:
https://github.com/spring-projects/spring-framework/blob/master/src/asciidoc/Guardfile

Don't look too deep at my change: as I said, it's my first step with Ruby. You can also reproduce that yourself pretty easily as the code is on github.

Cheers,
S.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/guard-generating-to-a-different-directory-tp1265p1267.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: guard - generating to a different directory

snicoll
LightGuardjp wrote
I'll have to take a closer look and clone the repo later today as it all
looks correct.
Hi Jason, any clue?

Thanks!
S.
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: guard - generating to a different directory

LightGuardjp
Sorry, didn't get to it yet. 

Sent from Mailbox for iPhone


On Fri, Jan 10, 2014 at 4:10 AM, snicoll [via Asciidoctor :: Discussion] <[hidden email]> wrote:

LightGuardjp wrote
I'll have to take a closer look and clone the repo later today as it all
looks correct.
Hi Jason, any clue?

Thanks!
S.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/guard-generating-to-a-different-directory-tp1265p1269.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML

Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: guard - generating to a different directory

LightGuardjp
In reply to this post by snicoll
Just tried it, it works for me.


On Fri, Jan 10, 2014 at 8:45 AM, Jason Porter <[hidden email]> wrote:
Sorry, didn't get to it yet. 

Sent from Mailbox for iPhone


On Fri, Jan 10, 2014 at 4:10 AM, snicoll [via Asciidoctor :: Discussion] <[hidden email]> wrote:

LightGuardjp wrote
I'll have to take a closer look and clone the repo later today as it all
looks correct.
Hi Jason, any clue?

Thanks!
S.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/guard-generating-to-a-different-directory-tp1265p1269.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML




--
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: guard - generating to a different directory

snicoll
Jason,

Have you changed locally the script to write the file in a different location as I mentioned in my original post?

Specifically changing :to_dir to the following :to_dir => File.expand_path("../../build/reference/htmlsingle", __FILE__)

If you've done that, can you let me know a bit more about your environment so that I better understand what's wrong with mine?

Thanks,
S.
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: guard - generating to a different directory

LightGuardjp
Right... forgot that bit :)

guard                                                                                                                   
15:26:59 - INFO - Guard is using NotifySend to send notifications.
15:26:59 - INFO - Guard is using TerminalTitle to send notifications.
15:26:59 - INFO - LiveReload is waiting for a browser to connect.
15:26:59 - INFO - Guard is now watching at '/tmp/spring-framework/src/asciidoc'
15:27:27 - ERROR - Problem with watch action!
> [#] target directory does not exist: /tmp/spring-framework/src/build/reference/htmlsingle
15:27:27 - ERROR - /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/asciidoctor-0.1.4/lib/asciidoctor.rb:909:in `render'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/asciidoctor-0.1.4/lib/asciidoctor.rb:993:in `render_file'
> [#] /tmp/spring-framework/src/asciidoc/Guardfile:10:in `block (2 levels) in _instance_eval_guardfile'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/watcher.rb:124:in `call'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/watcher.rb:124:in `call_action'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/watcher.rb:55:in `block (2 levels) in match_files'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/watcher.rb:52:in `each'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/watcher.rb:52:in `block in match_files'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/watcher.rb:51:in `each'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/watcher.rb:51:in `inject'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/watcher.rb:51:in `match_files'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/runner.rb:41:in `block in run_on_changes'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/runner.rb:140:in `block (3 levels) in _scoped_plugins'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/runner.rb:138:in `each'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/runner.rb:138:in `block (2 levels) in _scoped_plugins'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/runner.rb:137:in `catch'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/runner.rb:137:in `block in _scoped_plugins'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/runner.rb:135:in `each'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/runner.rb:135:in `_scoped_plugins'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/runner.rb:40:in `run_on_changes'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/setuper.rb:189:in `block (2 levels) in _setup_listener'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/commander.rb:108:in `block in within_preserved_state'
> [#] <internal:prelude>:10:in `synchronize'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/commander.rb:105:in `within_preserved_state'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/guard-2.2.3/lib/guard/setuper.rb:188:in `block in _setup_listener'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/listen-2.2.0/lib/listen/listener.rb:136:in `call'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/listen-2.2.0/lib/listen/listener.rb:136:in `block in _wait_for_changes'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/listen-2.2.0/lib/listen/listener.rb:131:in `loop'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/listen-2.2.0/lib/listen/listener.rb:131:in `_wait_for_changes'
> [#] /home/jporter/.rvm/gems/ruby-1.9.3-p429@markup/gems/listen-2.2.0/lib/listen/listener.rb:40:in `block in start'
[1] guard(main)>

!!! (kills guard / pry)
mkdir -p /tmp/spring-framework/src/build/reference/htmlsingle
Restart guard (didn't seem to pick up the change)

It all works, you're just not receiving any feedback about it rendering (or reloading to the browser). I added a little bit to verify it actually is doing the re-render:

diff --git a/src/asciidoc/Guardfile b/src/asciidoc/Guardfile
index 449ee11..68e38f5 100644
--- a/src/asciidoc/Guardfile
+++ b/src/asciidoc/Guardfile
@@ -7,10 +7,7 @@ FileUtils.cp_r('images','build')
 
 guard 'shell' do
   watch(/^.*\.adoc$/) {|m|
-    Asciidoctor.render_file(m[0], :to_dir => "build", :safe => Asciidoctor::SafeMode::UNSAFE, :attributes=> {'idprefix' => '', 'idseparator' => '-', 'copycss' => '', 'icons' => 'font', 'source-highlighter' => 'prettify', 'sectanchors' => '', 'doctype' => 'book','toc2' => '', 'spring-version' => '4.0.0.BUILD-SNAPSHOT', 'revnumber' => '4.0.0.BUILD-SNAPSHOT' })
+    Asciidoctor.render_file(m[0], :to_dir => File.expand_path("../../build/reference/htmlsingle", __FILE__), :safe => Asciidoctor::SafeMode::UNSAFE, :attributes=> {'idprefix' => '', 'idseparator' => '-', 'copycss' => '', 'icons' => 'font', 'source-highlighter' => 'prettify', 'sectanchors' => '', 'doctype' => 'book','toc2' => '', 'spring-version' => '4.0.0.BUILD-SNAPSHOT', 'revnumber' => '4.0.0.BUILD-SNAPSHOT' })
+    puts "Finished rendering file #{m[0]} to #{File.expand_path("../../build/reference/htmlsingle", __FILE__)}"
   }
 end
-
-guard 'livereload' do
-  watch(%r{build/.+\.(css|js|html)$})
-end

Now you could try to match the livereload folder. Another option is to put the Guardfile at the root level and then just have it watch the correct directory and then you don't need to worry about relative to which file / directory.


On Fri, Jan 10, 2014 at 3:21 PM, snicoll [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Jason,

Have you changed locally the script to write the file in a different location as I mentioned in my original post?

Specifically changing :to_dir to the following :to_dir => File.expand_path("../../build/reference/htmlsingle", __FILE__)

If you've done that, can you let me know a bit more about your environment so that I better understand what's wrong with mine?

Thanks,
S.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/guard-generating-to-a-different-directory-tp1265p1272.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--