Class: PlasticRails::PlaRails
- Inherits:
-
Thor
- Object
- Thor
- PlasticRails::PlaRails
- Includes:
- Thor::Actions
- Defined in:
- lib/plastic_rails.rb
Constant Summary collapse
- DEFAULT_TEMPLATE_DIR =
File.join(File.dirname(__FILE__) , "tmpl")
Class Method Summary collapse
Instance Method Summary collapse
- #copy_template(dest_dir) ⇒ Object
- #down ⇒ Object
- #login ⇒ Object
- #new(appname) ⇒ Object
- #stop ⇒ Object
- #up ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
16 17 18 19 |
# File 'lib/plastic_rails.rb', line 16 def self.exit_on_failure? # コマンドが失敗したときに終了ステータス1を返すようにする設定 true end |
.source_root ⇒ Object
12 13 14 |
# File 'lib/plastic_rails.rb', line 12 def self.source_root Dir.pwd end |
Instance Method Details
#copy_template(dest_dir) ⇒ Object
62 63 64 |
# File 'lib/plastic_rails.rb', line 62 def copy_template(dest_dir) directory(DEFAULT_TEMPLATE_DIR, dest_dir, :mode => :preserve) end |
#down ⇒ Object
57 58 59 |
# File 'lib/plastic_rails.rb', line 57 def down run("docker-compose down") end |
#login ⇒ Object
42 43 44 |
# File 'lib/plastic_rails.rb', line 42 def login run("docker-compose exec web bash") end |
#new(appname) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/plastic_rails.rb', line 24 def new(appname) directory([:template], appname, :mode => :preserve) inside(appname) do # DBのファイルパスを設定する gsub_file("docker-compose.yml", /%DB_PATH%/, [:db_path]) # Dockerイメージビルド&rails new (working_dirは `/apps`) run("./build.sh #{appname}") # working_dirをrailsアプリのディレクトリに変更する gsub_file("docker-compose.yml", /(working_dir: \/apps\/)/, '\1' + appname) # Railsアプリの設定(`bundle install`, `rails db:setup` など) run("./setup.sh") end end |
#stop ⇒ Object
52 53 54 |
# File 'lib/plastic_rails.rb', line 52 def stop run("docker-compose stop") end |
#up ⇒ Object
47 48 49 |
# File 'lib/plastic_rails.rb', line 47 def up run("docker-compose up -d") end |