Thin_Upstreams 0.2.0 → 0.3.0
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.
- data/README.md +13 -7
- data/Thin_Upstreams.gemspec +1 -1
- data/lib/Thin_Upstreams.rb +7 -17
- data/lib/Thin_Upstreams/version.rb +1 -3
- data/spec/tests/create.rb +9 -0
- metadata +1 -1
data/README.md
CHANGED
@@ -64,27 +64,33 @@ Note: Output File
|
|
64
64
|
Usage: In Ruby
|
65
65
|
------
|
66
66
|
|
67
|
-
Accepts optional file glob:
|
68
|
-
|
69
67
|
require "Thin_Upstreams"
|
70
68
|
|
71
69
|
Dir.chdir("/my_apps") {
|
70
|
+
|
72
71
|
Thin_Upstreams()
|
72
|
+
# or...
|
73
73
|
Thin_Upstreams "*/configs/my.thin.yml"
|
74
|
+
|
75
|
+
# File /my_apps/upstreams.conf is
|
76
|
+
# created/overwritten.
|
74
77
|
}
|
75
78
|
|
76
|
-
|
79
|
+
The file glob follows the same format use by [Dir.glob](http://ruby-doc.org/core-1.9.3/Dir.html#method-c-glob).
|
80
|
+
|
81
|
+
**Remember**: Use `Thin_Upstreams()`, not `Thin_Upstreams`, when using no arguments.
|
77
82
|
|
78
83
|
Usage: Bash/Shell
|
79
84
|
------
|
80
85
|
|
81
|
-
File glob argument is optional:
|
82
|
-
|
83
86
|
cd /my_apps
|
84
87
|
Thin_Upstreams
|
85
|
-
Thin_Upstreams "*/configs/
|
88
|
+
Thin_Upstreams "*/configs/thin.yml"
|
89
|
+
|
90
|
+
**Remember**: Use single quotation marks when using a Ruby-style glob in your shell to
|
91
|
+
prevent your shell from expanding the glob:
|
86
92
|
|
87
|
-
|
93
|
+
Thin_Upstreams '*/{configs,.}/thin.yml'
|
88
94
|
|
89
95
|
Run Tests
|
90
96
|
---------
|
data/Thin_Upstreams.gemspec
CHANGED
@@ -5,7 +5,7 @@ require "Thin_Upstreams/version"
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "Thin_Upstreams"
|
8
|
-
s.version =
|
8
|
+
s.version = Thin_Upstreams_Version
|
9
9
|
s.authors = ["da99"]
|
10
10
|
s.email = ["i-hate-spam-45671204@mailinator.com"]
|
11
11
|
s.homepage = "https://github.com/da99/Thin_Upstreams"
|
data/lib/Thin_Upstreams.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'Thin_Upstreams/version'
|
2
2
|
require "yaml"
|
3
3
|
|
4
|
-
def Thin_Upstreams glob = "./*/config/thin.yml"
|
4
|
+
def Thin_Upstreams glob = "./*/{config,.}/thin.yml"
|
5
5
|
|
6
6
|
str = %~\n~
|
7
7
|
arr = Dir.glob(glob).sort.each { |file|
|
@@ -12,7 +12,7 @@ def Thin_Upstreams glob = "./*/config/thin.yml"
|
|
12
12
|
path.sub(pwd, '').split("/").first
|
13
13
|
end
|
14
14
|
|
15
|
-
ports =
|
15
|
+
ports = Thin_Port_To_Array(o["port"], o["servers"])
|
16
16
|
str << %~
|
17
17
|
upstream #{app_name} {
|
18
18
|
#{ ports.map { |i| "server 127.0.0.1:#{i}" }.join(";
|
@@ -24,18 +24,8 @@ def Thin_Upstreams glob = "./*/config/thin.yml"
|
|
24
24
|
File.write "upstreams.conf", str
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
port = Integer(raw_port)
|
33
|
-
q = Integer(raw_num || 1)
|
34
|
-
(0...q).to_a.map { |i| port + i }
|
35
|
-
end
|
36
|
-
|
37
|
-
end # === module Class_Methods
|
38
|
-
|
39
|
-
extend Class_Methods
|
40
|
-
|
41
|
-
end # === class Thin_Upstreams
|
27
|
+
def Thin_Port_To_Array raw_port, raw_num
|
28
|
+
port = Integer(raw_port)
|
29
|
+
q = Integer(raw_num || 1)
|
30
|
+
(0...q).to_a.map { |i| port + i }
|
31
|
+
end
|
data/spec/tests/create.rb
CHANGED
@@ -76,5 +76,14 @@ describe "Thin_Upstreams" do
|
|
76
76
|
}
|
77
77
|
end
|
78
78
|
|
79
|
+
it "uses a default glob of: */{config,.}/thin.yml" do
|
80
|
+
chdir {
|
81
|
+
Thin_Upstreams()
|
82
|
+
%w{ 3010 6010 7020 }.each { |port|
|
83
|
+
File.read('upstreams.conf')[":7020"].should == ":7020"
|
84
|
+
}
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
79
88
|
end # === Thin_Upstreams
|
80
89
|
|