ruby-nginx 1.0.1 → 1.0.3

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: b53325ca5fc64324eaf5204d8192e9366a9564279e615d2e3797ce700c87556e
4
- data.tar.gz: 6f29b0ed5033f6e738cef7b6b66a514be2d6aa7d1eae9c965f86dc8526e60c4a
3
+ metadata.gz: b9a56d7ceb957f43c95f6e5cebf1d42a7cd46a09f3625b54e54e83f3e76d94a9
4
+ data.tar.gz: 9bbbbf29c2a137f7c68f77e9a266e9d0acbbedef55b47aaadad6436a2476ad50
5
5
  SHA512:
6
- metadata.gz: 4160c514cc0e5562dce1ec6c567dfaa234ecc555fc999eba2aa0739133c9df6a2af2332b688ae415f6593abe21e82c42f5c850fe54a2d00e692db31c78a95a31
7
- data.tar.gz: 04d918dec2962326dbec3e20c02e5c62c4f8e9b5e9268d6416f69a1975895de5ff5c03c092e445b2aba14efdf420211e0d0b66e3e244f854cce9b339263f0304
6
+ metadata.gz: 0de69d714a591acd91cd40a2ef3bc3321a3f187bd5c9305206bf4bae4e608c52740a20088c3035f98cda42d9572bf87fd8acbd14bcc8a1c759716f994ad6914d
7
+ data.tar.gz: f1d52d87b799624478855abdcf5ee23bf09d6545f10d2bcc1cda0de257b824b9ed56e96577fe2a09ec377f276953cc035c0181bd7df139809864ac680583447c
@@ -9,8 +9,30 @@ module Ruby
9
9
  class AddNginxConfig
10
10
  include Ruby::Nginx::Constants
11
11
 
12
- def run(name, config)
13
- Ruby::Nginx::System::SafeFile.write("#{SERVERS_PATH}/#{name}.conf", config)
12
+ def initialize(name, config)
13
+ @name = name
14
+ @config = config
15
+ end
16
+
17
+ def run
18
+ return false unless changed?
19
+
20
+ Ruby::Nginx::System::SafeFile.write(config_path, @config)
21
+ true
22
+ end
23
+
24
+ private
25
+
26
+ def changed?
27
+ !Ruby::Nginx::System::SafeFile.exist?(config_path) || (nginx_config != @config)
28
+ end
29
+
30
+ def config_path
31
+ @config_path ||= "#{SERVERS_PATH}/#{@name}.conf"
32
+ end
33
+
34
+ def nginx_config
35
+ @nginx_config ||= Ruby::Nginx::System::SafeFile.read(config_path)
14
36
  end
15
37
  end
16
38
  end
@@ -9,8 +9,25 @@ module Ruby
9
9
  class RemoveNginxConfig
10
10
  include Ruby::Nginx::Constants
11
11
 
12
- def run(name)
13
- Ruby::Nginx::System::SafeFile.rm("#{SERVERS_PATH}/#{name}.conf")
12
+ def initialize(name)
13
+ @name = name
14
+ end
15
+
16
+ def run
17
+ return false unless exists?
18
+
19
+ Ruby::Nginx::System::SafeFile.rm(config_path)
20
+ true
21
+ end
22
+
23
+ private
24
+
25
+ def exists?
26
+ Ruby::Nginx::System::SafeFile.exist?(config_path)
27
+ end
28
+
29
+ def config_path
30
+ @config_path ||= "#{SERVERS_PATH}/#{@name}.conf"
14
31
  end
15
32
  end
16
33
  end
@@ -32,11 +32,11 @@ module Ruby
32
32
  end
33
33
 
34
34
  def add_server_config(name, config)
35
- Commands::AddNginxConfig.new.run(name, config)
35
+ Commands::AddNginxConfig.new(name, config).run
36
36
  end
37
37
 
38
38
  def remove_server_config(name)
39
- Commands::RemoveNginxConfig.new.run(name)
39
+ Commands::RemoveNginxConfig.new(name).run
40
40
  end
41
41
 
42
42
  def validate_config!
@@ -10,11 +10,15 @@ module Ruby
10
10
  def mkdir(dir_path)
11
11
  safe_path = File.expand_path(dir_path)
12
12
 
13
- FileUtils.mkdir_p(dir_path)
13
+ FileUtils.mkdir_p(safe_path)
14
14
 
15
15
  safe_path
16
16
  end
17
17
 
18
+ def exist?(file_path)
19
+ File.exist?(File.expand_path(file_path))
20
+ end
21
+
18
22
  def touch(file_path)
19
23
  safe_path = File.expand_path(file_path)
20
24
 
@@ -25,9 +29,7 @@ module Ruby
25
29
  end
26
30
 
27
31
  def read(file_path)
28
- safe_path = File.expand_path(file_path)
29
-
30
- File.read(safe_path)
32
+ File.read(File.expand_path(file_path))
31
33
  end
32
34
 
33
35
  def write(file_path, content)
@@ -39,9 +41,7 @@ module Ruby
39
41
  end
40
42
 
41
43
  def rm(file_path)
42
- safe_path = File.expand_path(file_path)
43
-
44
- FileUtils.rm_f(safe_path)
44
+ FileUtils.rm_f(File.expand_path(file_path))
45
45
  end
46
46
  end
47
47
  end
@@ -56,6 +56,7 @@ server {
56
56
 
57
57
  # Do not use the default proxy_temp_path, this is to avoid directory permissions issues.
58
58
  proxy_temp_path <%= options[:temp_path] %> 1 2;
59
+ client_body_temp_path <%= options[:temp_path] %> 1 2;
59
60
 
60
61
  # reverse proxy
61
62
  location @<%= name %> {
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Ruby
4
4
  module Nginx
5
- VERSION = "1.0.1"
5
+ VERSION = "1.0.3"
6
6
 
7
7
  Version = Gem::Version
8
8
  end
data/lib/ruby/nginx.rb CHANGED
@@ -14,9 +14,11 @@ module Ruby
14
14
  setup!
15
15
  conf = config(options, &block)
16
16
 
17
- System::Nginx.add_server_config(conf.name, conf.generate!)
18
- System::Nginx.validate_config!
19
- System::Nginx.restart!
17
+ if System::Nginx.add_server_config(conf.name, conf.generate!)
18
+ System::Nginx.validate_config!
19
+ System::Nginx.restart!
20
+ end
21
+
20
22
  System::Hosts.add(conf.domain, conf.host)
21
23
 
22
24
  conf
@@ -30,8 +32,7 @@ module Ruby
30
32
  def self.remove!(options = {}, &block)
31
33
  conf = config(options, &block)
32
34
 
33
- System::Nginx.remove_server_config(conf.name)
34
- System::Nginx.restart!
35
+ System::Nginx.restart! if System::Nginx.remove_server_config(conf.name)
35
36
  System::Hosts.remove(conf.domain)
36
37
 
37
38
  conf
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-nginx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bert McCutchen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-27 00:00:00.000000000 Z
11
+ date: 2025-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erb