2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

グローバルを汚さないHanami環境の立ち上げ

Last updated at Posted at 2018-05-30

グローバルを汚さないHanami環境の立ち上げ

About

rbenv-binstubの使い方とhanamiをプロジェクトごとで分割するための備忘録として:pencil2:

Requirement

  • bundler
  • rbenv-binstubs(おすすめ)

Operation

Init project (file)

shell
mkdir project && cd project
bundle init
Gemfile
source 'https://rubygems.org'

gem 'hanami'

Installation

shell
# install with binstubs
bundle install --path=vendor/bundle --binstubs=/vendor/bin

# or not
bundle install --path=vendor/bundle

Create & Run app

shell
hanami new yourapp
mv yourapp/* ./ && mv yourapp/.* ./
rm -rf yourapp
bundle update
shell
# if set binstubs
hanami s

# or not
bundle exec hanami s

アプリケーション作成について

Create & Run app における以下のコマンド

shell
hanami new yourapp
mv yourapp/* ./ && mv yourapp/.* ./

は、rails new .のような動作をHanamiで同様にhanami new .とするとうまくいかない(参考1, 参考2)ので、ファイル移動にて無理やり同等の動作を実現します(project と yourappで違ってるけど)。

.gitなど.から始まるファイル・ディレクトリをワイルドカード*で指定させるためには

zsh
# zsh
setopt -s dotglob

# bash
shopt -s dotglob

を行うと

shell
mv yourapp/* ./

のように簡素に書くことができます。

参考

bundle exec はもういやだ
How can I get mv (or the * wildcard) to move hidden files?
shopt command in zsh

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?