plastic_rails 0.1.3 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35fa2c046e18c260dfae8b7491fabe5054b76d8e5ca7462b74bd65b69c0baadf
4
- data.tar.gz: 44adf2a356d4909266f589b9269c6dfc501cf7586a5799fed2c13d75df64f7be
3
+ metadata.gz: a4ce67e7a8357e3eee0dee4e2d159bb33db0699b3fcb42e8726922bd56cf0f88
4
+ data.tar.gz: 1eeffac3e2ee44baf34c3b1c9f9e84885397108fd9c327a7e074b0c3cb2b94be
5
5
  SHA512:
6
- metadata.gz: 5c62dcb721cde0c0a25ea51a49b2e3507a79aab62383088bc88243f8f489fda950f13552598ca2813057a48125e7bf184e85c2d01ecb775c625a2a33fc593b27
7
- data.tar.gz: 7c16415929e2890c37c2a4d64a6b788a507522c8431662121ce81ec04afe2ac9bb1cf1604ca737a6c740a06983f8a6d9031b3a3b9e047980f0dadf3972045cb3
6
+ metadata.gz: c1d339303f98ca667ec28ceab50ea5043d6d8be0eed097e954eab1fbcff56df8d40fbbd5b13b99a01da0b42afcb1c8b26bb4fd4282cce6be740cff1a51ad4745
7
+ data.tar.gz: bf7cdd44635a1984e3d4332e214e669470b8a0e855611e802a4a16fc26726f7e8e0eea23ca8cfdf0d139da4131fff55df6a3f6346c831b91d707cb2982f2100e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plastic_rails (0.1.2)
4
+ plastic_rails (0.1.6)
5
5
  thor (~> 1.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -9,7 +9,6 @@ docker上にRuby on Railsの環境を一発で作るスクリプト
9
9
 
10
10
  ## Requirements
11
11
  - Docker
12
- - Docker Compose
13
12
  - ruby
14
13
 
15
14
  ## install
@@ -29,12 +28,14 @@ gem install plastic_rails
29
28
  - `rails s -b 0.0.0.0`
30
29
 
31
30
  ## 環境の操作
32
- 環境を作成した後は以下のコマンドで環境を操作する。
33
-
34
- - コンテナ停止(<APP_NAME>ディレクトリで)
35
- - `docker-compose stop`
36
- - コンテナ削除(<APP_NAME>ディレクトリで)
37
- - `docker-compose down`
31
+ 環境を作成した後は以下のコマンドで環境を操作する。(<APP_NAME>ディレクトリで実行する)
32
+
33
+ - コンテナ停止
34
+ - `plastic_rails stop`
35
+ - コンテナ削除
36
+ - `plastic_rails down`
37
+ - コンテナ起動
38
+ - `plastic_rails up`
38
39
  - 削除したコンテナを再セットアップ
39
40
  - `./setup.sh`
40
41
 
@@ -1,3 +1,3 @@
1
1
  module PlasticRails
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/plastic_rails.rb CHANGED
@@ -1,48 +1,66 @@
1
1
  require "thor"
2
2
  require "plastic_rails/version"
3
- require "plastic_rails/fileutils"
3
+ THOR_SILENCE_DEPRECATION = true
4
4
 
5
5
  module PlasticRails
6
6
  class Error < StandardError; end
7
7
 
8
8
  class PlaRails < Thor
9
+ include Thor::Actions
9
10
  DEFAULT_TEMPLATE_DIR = File.join(File.dirname(__FILE__) , "tmpl")
10
- desc "new APPNAME", "Create a Rails application skelton with Docker container."
11
+
12
+ def self.source_root
13
+ Dir.pwd
14
+ end
15
+
16
+ def self.exit_on_failure?
17
+ # コマンドが失敗したときに終了ステータス1を返すようにする設定
18
+ true
19
+ end
20
+
21
+ desc "new [APPNAME]", "Create a Rails application skelton with Docker container."
11
22
  option :db_path, :default => "./db/mysql/volumes"
12
23
  option :template, :default => DEFAULT_TEMPLATE_DIR
13
24
  def new(appname)
14
- execute("cp -a #{options[:template]} #{appname}")
15
- Dir.chdir(appname)
25
+ directory(options[:template], appname, :mode => :preserve)
26
+ inside(appname) do
27
+ # DBのファイルパスを設定する
28
+ gsub_file("docker-compose.yml", /%DB_PATH%/, options[:db_path])
16
29
 
17
- # DBのファイルパスを設定する
18
- FileUtils.sed("docker-compose.yml",/%DB_PATH%/,options[:db_path])
30
+ # Dockerイメージビルド&rails new (working_dirは `/apps`)
31
+ run("./build.sh #{appname}")
19
32
 
20
- # Dockerイメージビルド&rails new (working_dirは `/apps`)
21
- execute("./build.sh #{appname}")
33
+ # working_dirをrailsアプリのディレクトリに変更する
34
+ gsub_file("docker-compose.yml", /(working_dir: \/apps\/)/, '\1' + appname)
22
35
 
23
- # working_dirをrailsアプリのディレクトリに変更する
24
- FileUtils.sed("docker-compose.yml",/(working_dir: \/apps\/)/,'\1' + appname)
25
-
26
- # Railsアプリの設定(`bundle install`, `rails db:setup` など)
27
- system("./setup.sh")
36
+ # Railsアプリの設定(`bundle install`, `rails db:setup` など)
37
+ run("./setup.sh")
38
+ end
28
39
  end
29
40
 
30
41
  desc "login", "Log in Rails container related to current directory."
31
42
  def login
32
- execute("docker-compose exec web bash")
43
+ run("docker-compose exec web bash")
33
44
  end
34
45
 
46
+ desc "up", "Start up Rails container related to current directory."
47
+ def up
48
+ run("docker-compose up -d")
49
+ end
35
50
 
36
- desc "copy_template", "Copy the default template to any dir. (To use in `new` command with `--template` option.)"
37
- def copy_template(dest_dir)
38
- execute("cp -a #{DEFAULT_TEMPLATE_DIR} #{dest_dir}")
51
+ desc "stop", "Stop Rails container related to current directory."
52
+ def stop
53
+ run("docker-compose stop")
39
54
  end
40
55
 
41
- private
56
+ desc "down", "Stop and remove Rails container related to current directory."
57
+ def down
58
+ run("docker-compose down")
59
+ end
42
60
 
43
- def execute(cmd)
44
- puts cmd
45
- system(cmd)
61
+ desc "copy_template [DEST_DIR]", "Copy the default template to any dir. (To use in `new` command with `--template` option.)"
62
+ def copy_template(dest_dir)
63
+ directory(DEFAULT_TEMPLATE_DIR, dest_dir, :mode => :preserve)
46
64
  end
47
65
  end
48
66
  end
data/lib/tmpl/build.sh CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
  set -eu
3
3
  APPNAME=$1
4
- BUILD_CMD="docker-compose build --no-cache --build-arg APPNAME=$APPNAME"
4
+ BUILD_CMD="docker-compose build --no-cache"
5
5
  RUN_ON_WEB_CMD="docker-compose run --rm web"
6
6
  OSTYPE=$(uname)
7
7
 
@@ -3,7 +3,6 @@ services:
3
3
  db:
4
4
  image: mysql:5.7
5
5
  environment:
6
- MYSQL_USER: root
7
6
  MYSQL_ROOT_PASSWORD: password
8
7
  ports:
9
8
  - '3316:3306'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plastic_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koki Hashimoto
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-24 00:00:00.000000000 Z
11
+ date: 2021-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,7 +71,6 @@ files:
71
71
  - bin/setup
72
72
  - exe/plastic_rails
73
73
  - lib/plastic_rails.rb
74
- - lib/plastic_rails/fileutils.rb
75
74
  - lib/plastic_rails/version.rb
76
75
  - lib/tmpl/Dockerfile
77
76
  - lib/tmpl/apps/.keep
@@ -87,7 +86,7 @@ homepage: http://github.com/koki-h/plastic_rails
87
86
  licenses:
88
87
  - MIT
89
88
  metadata: {}
90
- post_install_message:
89
+ post_install_message:
91
90
  rdoc_options: []
92
91
  require_paths:
93
92
  - lib
@@ -102,8 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
101
  - !ruby/object:Gem::Version
103
102
  version: '0'
104
103
  requirements: []
105
- rubygems_version: 3.1.4
106
- signing_key:
104
+ rubygems_version: 3.0.3
105
+ signing_key:
107
106
  specification_version: 4
108
107
  summary: docker上にRuby on Railsの環境を一発で作るスクリプト
109
108
  test_files: []
@@ -1,12 +0,0 @@
1
- module FileUtils
2
- def self.sed(file, pattern, replacement)
3
- File.open(file, "r") do |f_in|
4
- buf = f_in.read
5
- buf.gsub!(pattern, replacement)
6
- File.open(file, "w") do |f_out|
7
- f_out.write(buf)
8
- end
9
- end
10
- end
11
- end
12
-