guard list / guard -T Errors #160

Closed
earlonrails opened this Issue Oct 12, 2011 · 3 comments

Projects

None yet

3 participants

@earlonrails

Hello again all!

I was using 0.7.0 before my recent pull was accepted. Now I am trying to use 0.8.4 and I get this when I do guard list or guard -T.
I saw that this was an error before. I wonder if I am maybe just implementing incorrectly.

Here are the errors I see.

[ree-1.8.7-2011.03][KraussMac:~/Documents/git_tygerweb/tygerweb]$ guard list

Turn off AMQP/RabbitMQ support...
Authenticating mongo...
/Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:417:in load_missing_constant': Guard is not missing constant DslDescriber! (ArgumentError) from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:inconst_missing'
from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:98:in send' from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:98:inconst_missing'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/guard-0.8.4/lib/guard/cli.rb:86:in list' from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/task.rb:22:insend'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/task.rb:22:in run' from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/invocation.rb:118:ininvoke_task'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor.rb:263:in dispatch' from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/base.rb:389:instart'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/guard-0.8.4/bin/guard:6
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/bin/guard:19:in load' from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/bin/guard:19 [ree-1.8.7-2011.03][KraussMac:~/Documents/git_tygerweb/tygerweb]$ guard -T Turn off AMQP/RabbitMQ support... Authenticating mongo... /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:417:inload_missing_constant': Guard is not missing constant DslDescriber! (ArgumentError)
from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in const_missing' from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:98:insend'
from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:98:in const_missing' from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/guard-0.8.4/lib/guard/cli.rb:154:inshow'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/task.rb:22:in send' from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/task.rb:22:inrun'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/invocation.rb:118:in invoke_task' from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor.rb:263:indispatch'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/base.rb:389:in start' from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/guard-0.8.4/bin/guard:6 from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/bin/guard:19:inload'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/bin/guard:19

Guardfile

$rails_rake_task = true
require 'config/boot'
options = { :environment => (ENV['RAILS_ENV'] || "development").dup }
ENV["RAILS_ENV"] = options[:environment]
RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV)
require 'config/environment'
require 'util/guards/ftp_guard'

group 'ftp' do
guard 'ftpguard' do
watch(%r{^tmp/facbingham/.+.txt}){|m| [521, m, "CAI"]}
watch(%r{^tmp/facgoodingjms/.+.txt}){|m| [1175, m, "CAI"]}
watch(%r{^tmp/caiftp/washington.txt}){|m| [31, m, "CAI"]}
watch(%r{^tmp/owyheeft/.+.txt}){|m| [74, m, "CAI"]}
watch(%r{^tmp/caiftp/FortHall.txt}){|m| [885, m, "CAI"]}
watch(%r{^tmp/facbingham/.+.txt}){|m| [1345, m, "CAI"]}
watch(%r{^tmp/facwhitley/inbox/.+.csv}){|m| [1545, m]}
watch(%r{^tmp/facordes/inbox/.+.xml}){|m| [1295, m]}
end
end

util/guards/ftp_guard.rb

require 'guard'
require 'guard/guard'
require 'mongoid'
require 'sync/import/integration/jms_integration'

module Guard
class FtpGuard < Guard
def start
puts "Starting FtpGuarding"
end

def stop
  puts "Stopping FtpGuarding"  
end

def reload
  stop
  start
end

def run_all
  true
end

def choose_fac(path_hash)
  fac_id = path_hash[:facility_id]
  path = path_hash[:file_name]
  vendor = path_hash[:vendor]
  case vendor
    when "CAI"
      require 'sync/import/jms_vendors/vendor_cai'
      fork_ftp{
        jms_i = JmsIntegration.create(:facility_id => fac_id, :file_name =>path, :file_type =>"txt", :i_type=> "ftp", 
                                      :mapping=>VendorCai::TXT_MAP, 
                                      :jms_procs => VendorCai::PARSE_BLOCK) 
        jms_i.save
        jms_i.synchronize
      }
    when "1545"
      fork_ftp{
        jms_i = JmsIntegration.create(:facility_id => fac_id, :file_name =>path, :file_type =>"csv", :i_type=> "ftp")
        #jms_i.synchronize
      }
    when "1295"
      fork_ftp{
        jms_i = JmsIntegration.create(:facility_id => fac_id, :file_name =>path, :file_type =>"xml", :i_type=> "ftp")
        #jms_i.synchronize
      }
    else
      puts "Hey I am else"
  end
end

def run_on_change(paths)
  new_paths = []
  new_paths << {:facility_id => paths[0], :file_name => paths[1], :vendor=> paths[2]}
  new_paths.size == 1 ? choose_fac(new_paths[0]) : new_paths.each do |np| choose_fac(np) end
end

def fork_ftp(&fblock)
  fork do
    yield fblock
  end
end

end
end

Very funny error description.. Guard is not missing constant DslDescriber! Haha if it is not missing then what is the problem lol!
It doesn't effect running my guards as before but I just cannot list my available guards which is somewhat annoying.

Kevin

@thibaudgg
Member

have you tried to launch guard with bundle exec? bundle exec guard list

@netzpirat

I have refactored the cli class and extracted the show and list methods to the DslDescriber class and added the missing specs: cdf0906 I have no problem with both options and they work as expected. Due this refactoring I made the guardfile_structure method private on the DslDescriber, but I don't see how this could lead to your error message.

Can you please test if adding :: to Guard::DslDescriber.list(options) and Guard::DslDescriber.show(options) in cli.rb resolves the problem?

 def list
     ::Guard::DslDescriber.list(options)
 end

 def show
   ::Guard::DslDescriber.show(options)
 end
@earlonrails

I did try bundle exec guard list

[ree-1.8.7-2011.03][KraussMac:~/Documents/git_tygerweb/tygerweb]$ bundle exec guard list

Turn off AMQP/RabbitMQ support...
Authenticating mongo...
/Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:417:in load_missing_constant': Guard is not missing constant DslDescriber! (ArgumentError) from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:inconst_missing'
from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:98:in send' from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:98:inconst_missing'
from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/guard-0.8.4/lib/guard/cli.rb:86:in list' from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/thor-0.14.6/lib/thor/task.rb:22:insend'
from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/thor-0.14.6/lib/thor/task.rb:22:in run' from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/thor-0.14.6/lib/thor/invocation.rb:118:ininvoke_task'
from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/thor-0.14.6/lib/thor.rb:263:in dispatch' from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/thor-0.14.6/lib/thor/base.rb:389:instart'
from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/guard-0.8.4/bin/guard:6
from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/bin/guard:19:in `load'
from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/bin/guard:19

I then tried netzpirat's idea, but using gem open and it does get me farther along in the file.

[ree-1.8.7-2011.03][KraussMac:~/Documents/git_tygerweb/tygerweb]$ guard -T

Turn off AMQP/RabbitMQ support...
Authenticating mongo...
/Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:417:in load_missing_constant': Guard is not missing constant UI! (ArgumentError) from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:inconst_missing'
from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:98:in send' from /Users/telmate/Documents/git_tygerweb/tygerweb/help/ruby/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:98:inconst_missing'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/guard-0.8.4/lib/guard/cli.rb:157:in show' from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/guard-0.8.4/lib/guard/cli.rb:154:ineach'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/guard-0.8.4/lib/guard/cli.rb:154:in show' from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/task.rb:22:insend'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/task.rb:22:in run' from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/invocation.rb:118:ininvoke_task'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor.rb:263:in dispatch' from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/thor-0.14.6/lib/thor/base.rb:389:instart'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/gems/guard-0.8.4/bin/guard:6
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/bin/guard:19:in `load'
from /Users/telmate/.rvm/gems/ree-1.8.7-2011.03/bin/guard:19

Now we get this error. Guard is not missing constant UI!
Again with the not missing hehe...

So finally I changed def show some more adding '::' to all the Guard constant references.
def show
::Guard::DslDescriber.evaluate_guardfile(options)

  ::Guard::DslDescriber.guardfile_structure.each do |group|
    unless group[:guards].empty?
      if group[:group]
        ::Guard::UI.info "Group #{ group[:group] }:"
      else
        ::Guard::UI.info '(global):'
      end

      group[:guards].each do |guard|
        line = "  #{ guard[:name] }"

        unless guard[:options].empty?
          line += ": #{ guard[:options].collect { |k, v| "#{ k } => #{ v.inspect }" }.join(', ') }"
        end

        ::Guard::UI.info line
      end
    end
  end

  ::Guard::UI.info ''
end

And then no errors with listing...
If you guys want I can commit and put in a pull request, but w/e is easiest :D

Kevin

@netzpirat netzpirat closed this in 10f1542 Oct 12, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment