いくつかの内部プロジェクト用に単純なベースのジェネレーターを構築していますが、正しいディレクトリから実行thor
できないようです。bundle install
新しい [APP_NAME] 関数を実行すると、ディレクトリとファイルがbundle install
作成され、実行されてアプリケーションに必要な gem がインストールされます。
ジェネレータ関数のソース:
def create
puts "Creating application #{name}"
directory 'application', "#{name}"
Dir.chdir("#{Dir.pwd}/#{name}") do
puts `bundle install`
end
end
そして、この create メソッドを呼び出すコマンドを実行した結果のコンソール出力:
$ bundle exec bin/my_gem new test_app
Creating application test_app
create test_app
create test_app/Gemfile
create test_app/Guardfile
create test_app/README.md
create test_app/app/controllers
create test_app/app/helpers
create test_app/app/models
create test_app/app/views
Using thor (0.14.6)
Using my_gem (0.0.1)
Using bundler (1.1.3)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
ご覧のとおり、実行されていますが、ディレクトリ ( 、、、およびその他) ではなくbundle install
、現在のディレクトリ ( thor
、bundler
、my_gem
) で実行されています。test_app
guard
guard-coffeescript
guard-less
ls
またはなどの他のコマンドを実行するとpwd
、期待される結果が得られます。
Gemfile
Guardfile
README.md
app
と
/Users/davidlumley/Development/Gems/my_gem/test_app
違いがあるかどうかはわかりませんが、Ruby の管理には RVM を使用しています。