plastic_rails 0.1.1 → 0.1.6

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: fdb7c135f44fc073f189797c4e28186ac696dd3253a655a39b20aa655cac2b33
4
- data.tar.gz: 80496abf6809a62be2d3dada9802f33070f8a8e04071134024d9495e5e3b1699
3
+ metadata.gz: 3f8a081cd7e8a090c7748843f22728bcd725a994e4c41b88ae5cb57c09a51a4a
4
+ data.tar.gz: b4d444d97a87883ccbe4ecfe4d51f902de0d8f896c1ebb1572b52a6cb5f3eb37
5
5
  SHA512:
6
- metadata.gz: 8572821cf9ad1da0dd53719a53c959a8d48604a399148a7f6246e6eaea4e00bc4f20cec7ec2dc839a16de4ce8c56566fc75c1b086a3cf9635815142ed2f320fc
7
- data.tar.gz: feab6b5c1495b63ef607162368cd108d3283e98d255f945900a4ffaeb321a073e3998fc22e2bb5ba455ce4e65adeb654c0590b80e7de45c6f90d3fa4cf5cbbba
6
+ metadata.gz: 168ee64f3cc86a4d6be86e1f876a20b5522b9e4bfcc5c3c7b73084bec3eaea3f010e12517481628b02f236cddd8fd9d0c8e6c163547589fa828dd89e300f16a8
7
+ data.tar.gz: 3a1df9fc486f4c73d90ac7456595207cabadac703812e6b7cbc268a1f5e83beedf9300e2cb31526ee6ae1e49a715080ab8162a79ec08403955c12209fbeb55aa
data/.gitignore CHANGED
@@ -7,5 +7,4 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  .DS_Store
10
- Gemfile.lock
11
10
  .ruby-version
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ plastic_rails (0.1.5)
5
+ thor (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ rake (13.0.1)
11
+ thor (1.0.1)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 2.1)
18
+ plastic_rails!
19
+ rake (~> 13.0)
20
+
21
+ BUNDLED WITH
22
+ 2.1.4
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Plastic Rails
2
+ [![Gem Version](https://badge.fury.io/rb/plastic_rails.svg)](https://badge.fury.io/rb/plastic_rails)
3
+
4
+
2
5
  docker上にRuby on Railsの環境を一発で作るスクリプト
3
6
 
4
7
  プラレールのように自分用のレールを引こう
5
8
 
9
+
6
10
  ## Requirements
7
11
  - Docker
8
12
  - Docker Compose
@@ -20,20 +24,33 @@ gem install plastic_rails
20
24
  - rails new済のDockerコンテナを作成する
21
25
  - `plastic_rails new <APP_NAME>`
22
26
  - コンテナのシェルにログインする
23
- - `cd <APP_NAME>; docker-compose exec web bash; `
27
+ - `cd <APP_NAME>; plastic_rails login; `
24
28
  - コンテナ上でRails serverを起動する
25
29
  - `rails s -b 0.0.0.0`
26
30
 
27
31
  ## 環境の操作
28
- 環境を作成した後は以下のコマンドで環境を操作する。
29
-
30
- - コンテナ停止(<APP_NAME>ディレクトリで)
31
- - `docker-compose stop`
32
- - コンテナ削除(<APP_NAME>ディレクトリで)
33
- - `docker-compose down`
32
+ 環境を作成した後は以下のコマンドで環境を操作する。(<APP_NAME>ディレクトリで実行する)
33
+
34
+ - コンテナ停止
35
+ - `plastic_rails stop`
36
+ - コンテナ削除
37
+ - `plastic_rails down`
38
+ - コンテナ起動
39
+ - `plastic_rails up`
34
40
  - 削除したコンテナを再セットアップ
35
41
  - `./setup.sh`
36
42
 
43
+ ## カスタマイズ
44
+ DockerfileやRailsのテンプレートを修正することによって、作成する環境をカスタマイズできる。DBをデフォルトのMySQLから別のものに変更することなどが可能。
45
+
46
+ - デフォルトのテンプレートをコピー
47
+ - `plastic_rails copy_template <NEW_TEMPLATE>`
48
+ - <NEW_TEMPLATE> に デフォルトのテンプレート(DockerfileやRailsのアプリケーションテンプレート)が入ったディレクトリがコピーされる。
49
+ - テンプレートを修正する
50
+ - 修正したテンプレートを使用して環境を作成する
51
+ - `plastic_rails new <APP_NAME> --template=<NEW_TEMPLATE>`
52
+
53
+
37
54
  ## Plastic Rails自体の開発・デバッグ
38
55
  ### デバッグ環境(Vagrant)作成
39
56
  - あらかじめ、VirtualboxとVagrantをインストールしておく。
@@ -1,42 +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
- TMPL_DIR=File.dirname(__FILE__)
10
- p TMPL_DIR
11
- desc "new APPNAME", "create a Rails application skelton with Docker container."
9
+ include Thor::Actions
10
+ DEFAULT_TEMPLATE_DIR = File.join(File.dirname(__FILE__) , "tmpl")
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."
12
22
  option :db_path, :default => "./db/mysql/volumes"
23
+ option :template, :default => DEFAULT_TEMPLATE_DIR
13
24
  def new(appname)
14
- execute("cp -a #{TMPL_DIR}/tmpl #{appname}")
15
- Dir.chdir(appname)
16
-
17
- # DBのファイルパスを設定する
18
- FileUtils.sed("docker-compose.yml",/%DB_PATH%/,options[:db_path])
25
+ directory(options[:template], appname, :mode => :preserve)
26
+ inside(appname) do
27
+ # DBのファイルパスを設定する
28
+ gsub_file("docker-compose.yml", /%DB_PATH%/, options[:db_path])
19
29
 
20
- # Dockerイメージビルド&rails new (working_dirは `/apps`)
21
- execute("./build.sh #{appname}")
30
+ # Dockerイメージビルド&rails new (working_dirは `/apps`)
31
+ run("./build.sh #{appname}")
22
32
 
23
- # working_dirをrailsアプリのディレクトリに変更する
24
- FileUtils.sed("docker-compose.yml",/(working_dir: \/apps\/)/,'\1' + appname)
33
+ # working_dirをrailsアプリのディレクトリに変更する
34
+ gsub_file("docker-compose.yml", /(working_dir: \/apps\/)/, '\1' + appname)
25
35
 
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
- desc "login", "log in Rails container related to current directory."
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
 
35
- private
46
+ desc "up", "Start up Rails container related to current directory."
47
+ def up
48
+ run("docker-compose up -d")
49
+ end
50
+
51
+ desc "stop", "Stop Rails container related to current directory."
52
+ def stop
53
+ run("docker-compose stop")
54
+ end
55
+
56
+ desc "down", "Stop and remove Rails container related to current directory."
57
+ def down
58
+ run("docker-compose down")
59
+ end
36
60
 
37
- def execute(cmd)
38
- puts cmd
39
- 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)
40
64
  end
41
65
  end
42
66
  end
@@ -1,3 +1,3 @@
1
1
  module PlasticRails
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -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
 
File without changes
@@ -10,23 +10,10 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["gohannnotomo@gmail.com"]
11
11
 
12
12
  spec.summary = %q{docker上にRuby on Railsの環境を一発で作るスクリプト}
13
- spec.description = %q{プラレールのように自分用のレールを引こう}
13
+ spec.description = %q{docker上にRuby on Railsの環境を一発で作るスクリプト。プラレールのように自分用のレールを引こう。}
14
14
  spec.homepage = "http://github.com/koki-h/plastic_rails"
15
15
  spec.license = "MIT"
16
16
 
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- # if spec.respond_to?(:metadata)
20
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
- #
22
- # spec.metadata["homepage_uri"] = spec.homepage
23
- # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
24
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
25
- # else
26
- # raise "RubyGems 2.0 or newer is required to protect against " \
27
- # "public gem pushes."
28
- # end
29
-
30
17
  # Specify which files should be added to the gem when it is released.
31
18
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
19
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
@@ -36,7 +23,7 @@ Gem::Specification.new do |spec|
36
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
24
  spec.require_paths = ["lib"]
38
25
 
39
- spec.add_development_dependency "bundler"
40
- spec.add_development_dependency "rake"
41
- spec.add_runtime_dependency "thor"
26
+ spec.add_development_dependency "bundler", "~> 2.1"
27
+ spec.add_development_dependency "rake", "~> 13.0"
28
+ spec.add_runtime_dependency "thor", "~> 1.0"
42
29
  end
metadata CHANGED
@@ -1,58 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plastic_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koki Hashimoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-18 00:00:00.000000000 Z
11
+ date: 2020-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '2.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
55
- description: プラレールのように自分用のレールを引こう
54
+ version: '1.0'
55
+ description: docker上にRuby on Railsの環境を一発で作るスクリプト。プラレールのように自分用のレールを引こう。
56
56
  email:
57
57
  - gohannnotomo@gmail.com
58
58
  executables:
@@ -63,6 +63,7 @@ files:
63
63
  - ".gitignore"
64
64
  - CODE_OF_CONDUCT.md
65
65
  - Gemfile
66
+ - Gemfile.lock
66
67
  - LICENSE.txt
67
68
  - README.md
68
69
  - Rakefile
@@ -70,7 +71,6 @@ files:
70
71
  - bin/setup
71
72
  - exe/plastic_rails
72
73
  - lib/plastic_rails.rb
73
- - lib/plastic_rails/fileutils.rb
74
74
  - lib/plastic_rails/version.rb
75
75
  - lib/tmpl/Dockerfile
76
76
  - lib/tmpl/apps/.keep
@@ -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
-