#7 ✓invalid
Jay Phillips

Component generator requires Adhearsion gem to be installed

Reported by Jay Phillips | November 8th, 2007 @ 08:03 PM

The "script/generate" file that Rubigen generates does not recognize the component generator unless "rake install_gem" is performed to install the Adhearsion gem globally.

We had a similar issue with the app generator which Dr Nic fixed with revision 573.

Here is Dr Nic's diff in that commit:

Index: lib/adhearsion/cli.rb
--- lib/adhearsion/cli.rb	(revision 572)
+++ lib/adhearsion/cli.rb	(revision 573)
@@ -45,7 +45,10 @@
             require 'rubygems'
             require 'rubigen'
             require 'rubigen/scripts/generate'
-            RubiGen::Base.use_application_sources! :ahn
+            source = RubiGen::PathSource.new(:application, 
+              File.join(File.dirname(__FILE__), "../../app_generators"))
+            RubiGen::Base.reset_sources
+            RubiGen::Base.append_sources source
             RubiGen::Scripts::Generate.new.run([path], :generator => 'ahn')

Comments and changes to this ticket

  • Jay Phillips

    Jay Phillips November 8th, 2007 @ 09:29 PM

    • State changed from “new” to “open”

    I found that the generate and destroy scripts are created automatically by Rubigen with the following line in ahn_generator.rb:

    m.dependency "install_rubigen_scripts", [destination_root, 'ahn', 'adhearsion', 'test_spec'], :shebang => options[:shebang], :collision => :force

    It seems that Rubigen must generate scripts that work outside of an installed gem.

    Dr Nic! :)

  • Jay Phillips

    Jay Phillips November 8th, 2007 @ 09:33 PM

    • Assigned user changed from “Jay Phillips” to “Dr Nic”
  • Dr Nic

    Dr Nic November 9th, 2007 @ 04:38 AM

    Isn't rubigen a dependent gem of adhearsion already? Is there a problem with just adding ['rubigen', '>=1.1.1'] to the hoe dependency list?

  • Dr Nic

    Dr Nic November 9th, 2007 @ 04:39 AM

    Or am I missing the problem...

  • Jay Phillips

    Jay Phillips November 9th, 2007 @ 10:15 AM

    Yeah, it's not a gem dependency problem.

    Remember the issue I was experiencing with the app generator? When the Adhearsion gem was installed, everything was peachy, but when I tried to run the generator directly without the gem installed, it'd say "Could not find generator".

    When the Adhearsion gem isn't installed, I'm experiencing this same issue.

    ~/Desktop $ gem list adhearsion
    *** LOCAL GEMS ***
    ~/Desktop $ (Adhearsion not installed as a gem)
    ~/Desktop $ ahn create foobar
          create  components/simon_game/lib
          create  components/simon_game/test
          create  config
          create  helpers
          create  .ahnrc
          create  components/simon_game/configuration.rb
          create  components/simon_game/lib/simon_game.rb
          create  components/simon_game/test/test_helper.rb
          create  components/simon_game/test/test_simon_game.rb
          create  config/startup.rb
          create  dialplan.rb
          create  README
          create  Rakefile
      dependency  install_rubigen_scripts
          create    script
          create    script/generate
          create    script/destroy
    ~/Desktop $ cd foobar/
    ~/Desktop/foobar $ ./script/generate 
    Usage: ./script/generate generator [options] [args]
    General Options:
        -h, --help                       Show this help message and quit.
        -p, --pretend                    Run but do not make any changes.
        -f, --force                      Overwrite files that already exist.
        -s, --skip                       Skip files that already exist.
        -q, --quiet                      Suppress normal output.
        -t, --backtrace                  Debugging: show backtrace on errors.
        -c, --svn                        Modify files with subversion. (Note: svn must be in path)
    Installed Generators
      Rubygems: test_unit
      Builtin: test_unit
    More are available at http://rubigen.rubyforge.org/
    Run generate with no arguments for usage information
         ./script/generate test_unit
    ~/Desktop/foobar $ ./script/generate component phone_hero
    Couldn't find 'component' generator
    ~/Desktop/foobar $

    In this terminal output, notice how

    • Adhearsion isn't installed as a gem
    • Adhearsion project creation works as it should
    • The script/generate and script/destroy files are there
    • Running script/generate alone shows that only a test_unit generator could be found
    • Generating a component failed with the message "Couldn't find 'component' generator"
  • Dr Nic

    Dr Nic November 9th, 2007 @ 03:39 PM

    Ahh, this is more difficult - the script/generate script doesn't know where you have your ahn edge src stored.

    In Rails, you'd put edge rails in vendor/rails and rails_generator would look there for generators.

    We can do the same for ahn if you want to support vendor/ahn within each ahn app.

  • Jay Phillips

    Jay Phillips November 9th, 2007 @ 03:48 PM

    If anything, a component should be able to expose new generators. For now, let's not worry about application-specific generators and assume that component generation is something every Adhearsion app should allow. This is actually why that "script" folder irks me so much.

    Dr Nic, I think this is good evidence that sticking the generator into the "ahn" command makes sense. If that's the case, we can always use __FILE__ and get the exact directory from which the Adhearsion process was loaded.

    I propose this syntax:

    ahn create:component phone_hero [/path/to/app]

    When no path is given, it'll default to the current directory.

    Do you think this'll help?

  • Jay Phillips

    Jay Phillips March 24th, 2009 @ 06:30 PM

    • Tag set to generators
    • State changed from “open” to “invalid”

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Shared Ticket Bins

People watching this ticket