paul_rake 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ require 'paul_rake'
2
+ require 'rails'
3
+
4
+ module MyGem
5
+ class Railtie < Rails::Railtie
6
+ rake_tasks do
7
+ load 'lib/tasks/nginx.rake'
8
+ # This may point to incorrect path. Code below is suggested.
9
+ # Dir[File.join(File.dirname(__FILE__),'tasks/*.rake')].each { |f| load f }
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module PaulRake
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -0,0 +1,48 @@
1
+ namespace :nginx do
2
+
3
+ def ask message
4
+ print message
5
+ STDIN.gets.chomp
6
+ end
7
+
8
+ desc 'Creates nginx conf files for single domain'
9
+ task :conf,[:domain] do |cmd,args|
10
+ domain = args[:domain]
11
+ puts domain
12
+ puts domain.strip
13
+ content = ERB.new(File.read(Rails.root.join('lib','domain_server_name.conf.erb'))).result(binding)
14
+ File.open(Rails.root.join('config','nginx',domain), 'w') {|f| f.write(content) }
15
+ end
16
+
17
+
18
+ desc 'Creates nginx conf files for all domains'
19
+ task :create do
20
+ domains = []
21
+ File.open(Rails.root.join('lib','domains_for_sale')).each_line do |line|
22
+ p line
23
+ domains << line.strip
24
+ end
25
+ domains.each do |domain|
26
+ Rake::Task['nginx:conf'].reenable
27
+ Rake::Task['nginx:conf'].invoke(domain)
28
+ end
29
+ end
30
+
31
+ desc 'copy all nginx files to nginx direcotry'
32
+ task :copy do
33
+ command = "cp #{Rails.root.join('config','nginx')}/* /etc/nginx/domains_for_sale/"
34
+ system(command)
35
+ end
36
+
37
+ desc 'Choose port for this app'
38
+ task :port do
39
+ puts "The following ports are already used on this server:"
40
+ system ('cat ../*/port') # refactor to ruby code
41
+ port = ask("\nWhich starting port you want to use for this app? ")
42
+ File.open('port', 'w') {|f| f.write(port) }
43
+ end
44
+
45
+
46
+
47
+ end
48
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paul_rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -24,7 +24,9 @@ files:
24
24
  - README.md
25
25
  - Rakefile
26
26
  - lib/paul_rake.rb
27
+ - lib/paul_rake/railtie.rb
27
28
  - lib/paul_rake/version.rb
29
+ - lib/tasks/nginx.rake
28
30
  - paul_rake.gemspec
29
31
  homepage: ''
30
32
  licenses: []