daddy 0.3.19 → 0.3.20

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
  SHA1:
3
- metadata.gz: 01a33400464b3cc61d95cfb69f808bbe0c51aa90
4
- data.tar.gz: 41e97b62515c994968f3f3025dfe4509e7450c46
3
+ metadata.gz: e5e8dd983e1179051e585b3ac7ed0ea38d70fff4
4
+ data.tar.gz: 5649a648bee817b0efaa3e95a31c04871e8f47c5
5
5
  SHA512:
6
- metadata.gz: e4216e1e0413dd7f4a790bd9a2993292360787c6c0d9f9d3b970e4bd4951190828677451cca1afe4400591a943d614451a00443ea370796c5ff596ff7eee531f
7
- data.tar.gz: 91b58e058666402e7c56be725d03a07f7e96c204e60988e40be392ff843fc8f7751468b4f54049468b9814588373a7626c6c355650db3a2c2fe935c7c318206e
6
+ metadata.gz: de63a0e8518b99343af0a7e98615e815c5af4d5e42df8b4c04da1e71da2510434507e6903fb44a8b74ab9c45bd06702054844786caead7c20c770f2e0a3250d8
7
+ data.tar.gz: 78881695c5e0838d904084364567dc684890130677d46e605a7daf5a8d02a8e093091868c9dae03efbb5dcf5725b86eb193558832f08bf185b6501db3236fb3a
data/lib/daddy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Daddy
2
- VERSION = '0.3.19'.freeze
2
+ VERSION = '0.3.20'.freeze
3
3
  end
data/lib/tasks/nginx.rake CHANGED
@@ -6,8 +6,8 @@ namespace :dad do
6
6
  desc 'Nginxをインストールします。'
7
7
  task :install => :environment do
8
8
  repo = File.join(File.dirname(__FILE__), 'nginx', 'nginx.repo')
9
- fail unless system("sudo cp -f #{repo} /etc/yum.repos.d/")
10
- fail unless system("sudo yum install nginx")
9
+ run "sudo cp -f #{repo} /etc/yum.repos.d/",
10
+ "sudo yum install nginx"
11
11
 
12
12
  default_config_files = [
13
13
  '/etc/nginx/conf.d/default.conf',
@@ -31,9 +31,13 @@ namespace :dad do
31
31
 
32
32
  desc 'Nginxにアプリケーションの設定ファイルをインストールします。'
33
33
  task :config => :environment do
34
- fail unless system("RAILS_ROOT=#{rails_root} RAILS_ENV=#{Rails.env} APP_NAME=#{app_name} erb -T - #{File.dirname(__FILE__)}/nginx.app.conf.erb > tmp/nginx.#{app_name}.conf")
35
- system("sudo mkdir -p /etc/nginx/conf.d/servers")
36
- system("sudo cp -f tmp/nginx.#{app_name}.conf /etc/nginx/conf.d/servers/#{app_name}.conf")
34
+ conf = File.join('tmp', 'nginx', "#{app_name}.conf")
35
+ render File.join(File.dirname(__FILE__), 'nginx', 'app.conf.erb'), :to => conf
36
+
37
+ unless dry_run?
38
+ run "sudo mkdir -p /etc/nginx/conf.d/servers",
39
+ "sudo cp -f #{conf} /etc/nginx/conf.d/servers/"
40
+ end
37
41
  end
38
42
 
39
43
  end
@@ -1,22 +1,22 @@
1
- upstream <%= ENV['APP_NAME'] %> {
2
- server unix:/tmp/<%= ENV['APP_NAME'] %>_<%= ENV['RAILS_ENV'][0..2] %>.sock;
1
+ upstream <%= app_name %> {
2
+ server unix:/tmp/<%= app_name %>.sock;
3
3
  }
4
4
 
5
5
  server {
6
6
  listen 80;
7
7
  server_name localhost;
8
8
 
9
- root <%= ENV['RAILS_ROOT'] %>/public;
9
+ root <%= rails_root %>/public;
10
10
  try_files $uri/index.html $uri @app;
11
11
 
12
12
  location @app {
13
- proxy_pass http://<%= ENV['APP_NAME'] %>;
13
+ proxy_pass http://<%= app_name %>;
14
14
  proxy_set_header Host $http_host;
15
15
  proxy_set_header X-Real-IP $remote_addr;
16
16
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
17
17
  }
18
18
 
19
- <% if ENV['RAILS_ENV'] == 'production' %>
19
+ <% if rails_env == 'production' %>
20
20
  location ~ ^/(assets)/ {
21
21
  gzip_vary on;
22
22
  gzip_static on;
@@ -18,13 +18,27 @@ def self.template_dir
18
18
  File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'templates')
19
19
  end
20
20
 
21
+ def self.dry_run?
22
+ %w{ DRY_RUN DR }.each do |key|
23
+ return true if %w{ true t yes y 1 }.include?(ENV[key].to_s.downcase)
24
+ end
25
+
26
+ false
27
+ end
28
+
21
29
  def self.task_file(*path)
22
30
  File.join(File.dirname(__FILE__), *path)
23
31
  end
24
32
 
25
33
  def self.render(template, options = {})
26
- FileUtils.mkdir_p(File.dirname(options[:to]))
27
- File.write(options[:to], ERB.new(File.read(template), 0, '-').result)
34
+ text = ERB.new(File.read(template), 0, '-').result
35
+
36
+ if options[:to]
37
+ FileUtils.mkdir_p(File.dirname(options[:to]))
38
+ File.write(options[:to], text)
39
+ end
40
+
41
+ text
28
42
  end
29
43
 
30
44
  def self.ask(prompt, options = {})
@@ -61,4 +75,4 @@ def self.run(*commands)
61
75
  puts c
62
76
  fail unless system(c)
63
77
  end
64
- end
78
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.19
4
+ version: 0.3.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-07 00:00:00.000000000 Z
11
+ date: 2015-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -346,8 +346,8 @@ files:
346
346
  - lib/tasks/kibana/configure.sh
347
347
  - lib/tasks/kibana/install.sh
348
348
  - lib/tasks/kibana/nginx.conf.erb
349
- - lib/tasks/nginx.app.conf.erb
350
349
  - lib/tasks/nginx.rake
350
+ - lib/tasks/nginx/app.conf.erb
351
351
  - lib/tasks/nginx/nginx.conf.erb
352
352
  - lib/tasks/nginx/nginx.repo
353
353
  - lib/tasks/phantomjs.rake