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")
- DOCKER_COMPOSE_CMD =
'docker compose'
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
17 18 19 20 |
# File 'lib/plastic_rails.rb', line 17 def self.exit_on_failure? # コマンドが失敗したときに終了ステータス1を返すようにする設定 true end |
.source_root ⇒ Object
13 14 15 |
# File 'lib/plastic_rails.rb', line 13 def self.source_root Dir.pwd end |
Instance Method Details
#copy_template(dest_dir) ⇒ Object
63 64 65 |
# File 'lib/plastic_rails.rb', line 63 def copy_template(dest_dir) directory(DEFAULT_TEMPLATE_DIR, dest_dir, :mode => :preserve) end |
#down ⇒ Object
58 59 60 |
# File 'lib/plastic_rails.rb', line 58 def down run("#{DOCKER_COMPOSE_CMD} down") end |
#login ⇒ Object
43 44 45 |
# File 'lib/plastic_rails.rb', line 43 def login run("#{DOCKER_COMPOSE_CMD} exec web bash") end |
#new(appname) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/plastic_rails.rb', line 25 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
53 54 55 |
# File 'lib/plastic_rails.rb', line 53 def stop run("#{DOCKER_COMPOSE_CMD} stop") end |
#up ⇒ Object
48 49 50 |
# File 'lib/plastic_rails.rb', line 48 def up run("#{DOCKER_COMPOSE_CMD} up -d") end |