plastic_rails 0.1.5 → 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: 90f7872cb0a90ce249ef6032210d9ef6e9dd0a4fd4db2b451c4a4c95447d0d68
4
- data.tar.gz: 98304d1e9bddeae78bf548697aac75804f5b6841443e8b7d450b48cfaff2f7b5
3
+ metadata.gz: 3f8a081cd7e8a090c7748843f22728bcd725a994e4c41b88ae5cb57c09a51a4a
4
+ data.tar.gz: b4d444d97a87883ccbe4ecfe4d51f902de0d8f896c1ebb1572b52a6cb5f3eb37
5
5
  SHA512:
6
- metadata.gz: aff574d76f5ba7c0fa36cc8a29f01d6d5b64cd9dc48bbd18060fee392f78f65851ec71044e5ec892804322e75530fa6b7ac34aeb05b9025795f5261f51845b10
7
- data.tar.gz: 04df7a51737a3d1f6b16290b0e01ba223ed8e80868fa3a687c1fb83a4319086c543161cd079ff7a2b45a1410fbd8c0c4be6c438b848e7ffb261b797ab9953c6b
6
+ metadata.gz: 168ee64f3cc86a4d6be86e1f876a20b5522b9e4bfcc5c3c7b73084bec3eaea3f010e12517481628b02f236cddd8fd9d0c8e6c163547589fa828dd89e300f16a8
7
+ data.tar.gz: 3a1df9fc486f4c73d90ac7456595207cabadac703812e6b7cbc268a1f5e83beedf9300e2cb31526ee6ae1e49a715080ab8162a79ec08403955c12209fbeb55aa
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plastic_rails (0.1.4)
4
+ plastic_rails (0.1.5)
5
5
  thor (~> 1.0)
6
6
 
7
7
  GEM
@@ -1,14 +1,18 @@
1
1
  require "thor"
2
2
  require "plastic_rails/version"
3
- require "plastic_rails/fileutils"
4
- THOR_SILENCE_DEPRECATION = true
3
+ THOR_SILENCE_DEPRECATION = true
5
4
 
6
5
  module PlasticRails
7
6
  class Error < StandardError; end
8
7
 
9
8
  class PlaRails < Thor
9
+ include Thor::Actions
10
10
  DEFAULT_TEMPLATE_DIR = File.join(File.dirname(__FILE__) , "tmpl")
11
11
 
12
+ def self.source_root
13
+ Dir.pwd
14
+ end
15
+
12
16
  def self.exit_on_failure?
13
17
  # コマンドが失敗したときに終了ステータス1を返すようにする設定
14
18
  true
@@ -18,52 +22,45 @@ module PlasticRails
18
22
  option :db_path, :default => "./db/mysql/volumes"
19
23
  option :template, :default => DEFAULT_TEMPLATE_DIR
20
24
  def new(appname)
21
- execute("cp -a #{options[:template]} #{appname}")
22
- Dir.chdir(appname)
23
-
24
- # DBのファイルパスを設定する
25
- 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])
26
29
 
27
- # Dockerイメージビルド&rails new (working_dirは `/apps`)
28
- execute("./build.sh #{appname}")
30
+ # Dockerイメージビルド&rails new (working_dirは `/apps`)
31
+ run("./build.sh #{appname}")
29
32
 
30
- # working_dirをrailsアプリのディレクトリに変更する
31
- 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)
32
35
 
33
- # Railsアプリの設定(`bundle install`, `rails db:setup` など)
34
- system("./setup.sh")
36
+ # Railsアプリの設定(`bundle install`, `rails db:setup` など)
37
+ run("./setup.sh")
38
+ end
35
39
  end
36
40
 
37
41
  desc "login", "Log in Rails container related to current directory."
38
42
  def login
39
- execute("docker-compose exec web bash")
43
+ run("docker-compose exec web bash")
40
44
  end
41
45
 
42
46
  desc "up", "Start up Rails container related to current directory."
43
47
  def up
44
- execute("docker-compose up -d")
48
+ run("docker-compose up -d")
45
49
  end
46
50
 
47
51
  desc "stop", "Stop Rails container related to current directory."
48
52
  def stop
49
- execute("docker-compose stop")
53
+ run("docker-compose stop")
50
54
  end
51
55
 
52
56
  desc "down", "Stop and remove Rails container related to current directory."
53
57
  def down
54
- execute("docker-compose down")
58
+ run("docker-compose down")
55
59
  end
56
60
 
57
61
  desc "copy_template [DEST_DIR]", "Copy the default template to any dir. (To use in `new` command with `--template` option.)"
58
62
  def copy_template(dest_dir)
59
- execute("cp -a #{DEFAULT_TEMPLATE_DIR} #{dest_dir}")
60
- end
61
-
62
- private
63
-
64
- def execute(cmd)
65
- puts cmd
66
- system(cmd)
63
+ directory(DEFAULT_TEMPLATE_DIR, dest_dir, :mode => :preserve)
67
64
  end
68
65
  end
69
66
  end
@@ -1,3 +1,3 @@
1
1
  module PlasticRails
2
- VERSION = "0.1.5"
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
 
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.5
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-30 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
@@ -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
@@ -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
-