nginxbrew 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGES.txt +13 -0
- data/README.md +25 -5
- data/bin/nginxbrew +7 -1
- data/lib/nginxbrew/config/base.rb +21 -9
- data/lib/nginxbrew/nginxes.rb +87 -0
- data/lib/nginxbrew/tasks.rb +67 -17
- data/lib/nginxbrew/version.rb +1 -1
- data/nginxbrew.gemspec +1 -0
- data/spec/nginxes_spec.rb +95 -0
- data/spec/spec_helper.rb +2 -0
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aabc418d552ab2bf54ddc4abea78611304b1054f
|
4
|
+
data.tar.gz: 3e5c0bc01e29256503496c75ba812c9b4423d930
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88e879d44a09080b6b86bad2239fbddbd404cbfc7889a265db05cbf218c918b0fedf5523b6a2f3db57f83b92f2c0fb1f9122e0e1ce1dd1de13a23ab96ab3aa88
|
7
|
+
data.tar.gz: 74d913c3335dfe272a6aafb513ec998dd3c0234d0e1caf539d4e484259905dbdd211adbf7a651ea35c251f04ecf7e0d7a0d1b11ddd5e7155bb38962d3ec2e084
|
data/.gitignore
CHANGED
data/CHANGES.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Nginxbrew changes
|
2
|
+
|
3
|
+
|
4
|
+
Nginxbrew 0.0.4
|
5
|
+
- New command nginxies, openresties to show up available nginx versions.
|
6
|
+
- Change `configure` option to share pid-file, tmp dir extend over all builds.
|
7
|
+
- Change `make` to add -j2, TODO get num of CPUs dynamically
|
8
|
+
- Bug fixes.
|
9
|
+
|
10
|
+
|
11
|
+
Nginxbrew 0.0.3
|
12
|
+
- Initial commit.
|
13
|
+
|
data/README.md
CHANGED
@@ -62,6 +62,22 @@ If you want to use openresty-1.7.0.1 from other version of nginx, you can do thi
|
|
62
62
|
|
63
63
|
$ nginxbrew use openresty-1.7.0.1
|
64
64
|
|
65
|
+
|
66
|
+
You can see all exsiting versions of nginxes/openresties by the following command.
|
67
|
+
|
68
|
+
$ nginxbrew nginxes
|
69
|
+
$ nginxbrew openresties
|
70
|
+
|
71
|
+
If you specify prefix of version, the version will be filtered.
|
72
|
+
|
73
|
+
$ nginxbrew nginxes 1.7
|
74
|
+
[nginx-]1.7.6
|
75
|
+
[nginx-]1.7.5
|
76
|
+
[nginx-]1.7.4
|
77
|
+
...
|
78
|
+
[nginx-]1.7.0
|
79
|
+
|
80
|
+
|
65
81
|
## Customize configuration
|
66
82
|
|
67
83
|
You can customize Nginxbrew behavior by changing ENV.
|
@@ -95,14 +111,18 @@ then nginxbrew starts to using this configuration.
|
|
95
111
|
## TODO
|
96
112
|
|
97
113
|
- write tests completely
|
98
|
-
-
|
99
|
-
|
114
|
+
- installable the same version of nginx with defferent labels like as follows
|
115
|
+
|
116
|
+
$ nginxbrew install prj1 1.7.6
|
117
|
+
|
118
|
+
$ nginxbrew install prj2 1.7.6
|
119
|
+
|
120
|
+
$ nginxbrew use 1.7.6-prj1
|
100
121
|
|
101
|
-
|
122
|
+
- multiple install
|
102
123
|
|
103
|
-
|
124
|
+
$ nginxbrew install 1.4 openresty-1.7 1.7.5
|
104
125
|
|
105
|
-
$ nginxbrew install 1.7 # head of 1.7 will be installed
|
106
126
|
|
107
127
|
## Contributing
|
108
128
|
|
data/bin/nginxbrew
CHANGED
@@ -10,7 +10,9 @@ Usage: nginxbrew [-v] [-h] command [<args>]
|
|
10
10
|
Available subcommands:
|
11
11
|
install <version> Install nginx with specified version.
|
12
12
|
use <version> Switch nginx into specified version.
|
13
|
-
list Show list of installed nginx versions
|
13
|
+
list Show list of installed nginx versions.
|
14
|
+
nginxes Show list of available nginx versions.
|
15
|
+
openresties Show list of available openresty versions.
|
14
16
|
|
15
17
|
Optional environments:
|
16
18
|
NGINXBREW_HOME Path to nginxbrew (will be) installed, ~/nginxbrew is default.
|
@@ -45,6 +47,10 @@ begin
|
|
45
47
|
Nginxbrew.run(:"#{command}", envs={ "VERSION" => version })
|
46
48
|
when "list"
|
47
49
|
Nginxbrew.run(:list)
|
50
|
+
when "nginxes"
|
51
|
+
Nginxbrew.run(:nginxes, envs={ "HEAD_VERSION" => ARGV.shift })
|
52
|
+
when "openresties"
|
53
|
+
Nginxbrew.run(:openresties, envs={ "HEAD_VERSION" => ARGV.shift })
|
48
54
|
else
|
49
55
|
raise Exception.new("Unknown command '#{command}'")
|
50
56
|
end
|
@@ -14,7 +14,8 @@ module Nginxbrew
|
|
14
14
|
|
15
15
|
attr_accessor :ngx_configure, :ngx_conf_path, :ngx_prefix
|
16
16
|
attr_reader :ngx_user, :ngx_group, :nginx_log_dir,
|
17
|
-
:builtfile, :dist_to, :tarball, :src, :url, :home_dir, :
|
17
|
+
:builtfile, :dist_to, :tarball, :src, :url, :home_dir, :dist_dir,
|
18
|
+
:ngx_sbin_path, :version_name
|
18
19
|
|
19
20
|
def initialize(opts={})
|
20
21
|
@home_dir = opts[:home_dir]
|
@@ -23,9 +24,10 @@ module Nginxbrew
|
|
23
24
|
@is_openresty = opts[:is_openresty]
|
24
25
|
@ngx_user = opts[:ngx_user]
|
25
26
|
@ngx_group = opts[:ngx_group]
|
26
|
-
@
|
27
|
-
@
|
28
|
-
@
|
27
|
+
@version_name = create_version_name(@ngx_version, @is_openresty)
|
28
|
+
@dist_to = File.join(@dist_dir, "ngx-#{@version_name}")
|
29
|
+
@nginx_log_dir = File.join(@home_dir, "logs", @version_name)
|
30
|
+
@src = src_name(@ngx_version, @is_openresty)
|
29
31
|
@tarball = "#{@src}.tar.gz"
|
30
32
|
@url = "#{@is_openresty ? OPENRESTY_URL : NGX_URL}/#{@tarball}"
|
31
33
|
@ngx_sbin_path = File.join(@dist_to, "bin/nginx")
|
@@ -46,15 +48,25 @@ module Nginxbrew
|
|
46
48
|
--conf-path=#{@ngx_conf_path} \
|
47
49
|
--error-log-path=#{@nginx_log_dir}/error.log \
|
48
50
|
--http-log-path=#{@nginx_log_dir}/access.log \
|
49
|
-
--http-client-body-temp-path=#{@
|
50
|
-
--http-proxy-temp-path=#{@
|
51
|
-
--http-fastcgi-temp-path=#{@
|
52
|
-
--http-uwsgi-temp-path=#{@
|
53
|
-
--pid-path=#{@
|
51
|
+
--http-client-body-temp-path=#{@home_dir}/tmp/client_body \
|
52
|
+
--http-proxy-temp-path=#{@home_dir}/tmp/proxy \
|
53
|
+
--http-fastcgi-temp-path=#{@home_dir}/tmp/fastcgi \
|
54
|
+
--http-uwsgi-temp-path=#{@home_dir}/tmp/uwsgi \
|
55
|
+
--pid-path=#{@home_dir}/run/nginx.pid
|
54
56
|
EOF
|
55
57
|
cmd.split(" ").join(" ")
|
56
58
|
end
|
57
59
|
|
60
|
+
private
|
61
|
+
|
62
|
+
def create_version_name(v, is_openresty)
|
63
|
+
is_openresty ? "openresty-#{v}" : v
|
64
|
+
end
|
65
|
+
|
66
|
+
def src_name(v, is_openresty)
|
67
|
+
is_openresty ? "ngx_openresty-#{v}" : "nginx-#{v}"
|
68
|
+
end
|
69
|
+
|
58
70
|
end
|
59
71
|
|
60
72
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "net/http"
|
2
|
+
require "uri"
|
3
|
+
|
4
|
+
|
5
|
+
module Nginxbrew
|
6
|
+
|
7
|
+
class VersionNotFoundError < StandardError
|
8
|
+
|
9
|
+
def initialize(v)
|
10
|
+
super("version '#{v}' is not found in all versions of nginxes/openresties")
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
class Nginxes
|
16
|
+
|
17
|
+
TypeNginx = "nginx"
|
18
|
+
TypeOpenresty = "openresty"
|
19
|
+
|
20
|
+
attr_reader :ngx_type, :versions
|
21
|
+
|
22
|
+
def initialize(ngx_type, versions)
|
23
|
+
unless [TypeNginx, TypeOpenresty].include?(ngx_type)
|
24
|
+
raise Exception.new("Invalid ngx_type #{ngx_type}")
|
25
|
+
end
|
26
|
+
raise Exception.new("No versions of nginx!") if versions.size == 0
|
27
|
+
@ngx_type = ngx_type
|
28
|
+
@versions = versions.uniq.sort.reverse
|
29
|
+
end
|
30
|
+
|
31
|
+
def size
|
32
|
+
@versions.size
|
33
|
+
end
|
34
|
+
|
35
|
+
def filter_versions(head_of)
|
36
|
+
src_numbers = head_of.split(".")
|
37
|
+
src_numbers_size = src_numbers.size
|
38
|
+
r = @versions.select do |v|
|
39
|
+
v.split(".").slice(0, src_numbers_size) == src_numbers
|
40
|
+
end
|
41
|
+
raise VersionNotFoundError.new(head_of) if r.size == 0
|
42
|
+
r
|
43
|
+
end
|
44
|
+
|
45
|
+
def head_of(version)
|
46
|
+
src_numbers = version.split(".")
|
47
|
+
src_numbers_size = src_numbers.size
|
48
|
+
r = @versions.detect do |v|
|
49
|
+
v.split(".").slice(0, src_numbers_size) == src_numbers
|
50
|
+
end
|
51
|
+
raise VersionNotFoundError.new(version) unless r
|
52
|
+
r
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.nginxes
|
56
|
+
versions = html_body_of("http://nginx.org", "/download/").
|
57
|
+
gsub(/href="nginx\-([0-9\.]+?)\.tar\.gz"/).inject([]) do |memo, match|
|
58
|
+
memo << $1
|
59
|
+
memo
|
60
|
+
end
|
61
|
+
Nginxes.new(TypeNginx, versions)
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.openresties
|
65
|
+
versions = html_body_of("http://openresty.org", "/").
|
66
|
+
gsub(/ngx_openresty\-([0-9\.]+?)\.tar\.gz/).inject([]) do |memo, match|
|
67
|
+
memo << $1
|
68
|
+
memo
|
69
|
+
end
|
70
|
+
Nginxes.new(TypeOpenresty, versions)
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def self.html_body_of(host, page)
|
76
|
+
url = URI.parse(host)
|
77
|
+
res = Net::HTTP.start(url.host, url.port) {|http|
|
78
|
+
http.get(page)
|
79
|
+
}
|
80
|
+
raise Exception.new("Failed get list of nginx") if res.code.to_i != 200
|
81
|
+
res.body
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
data/lib/nginxbrew/tasks.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require "logger"
|
3
3
|
require "pathname"
|
4
4
|
require "fileutils"
|
5
|
+
require "nginxbrew/nginxes"
|
5
6
|
|
6
7
|
|
7
8
|
$logger = Logger.new(STDOUT)
|
@@ -16,13 +17,15 @@ end
|
|
16
17
|
def version_from_package(name)
|
17
18
|
prefix = "ngx-"
|
18
19
|
idx = name.index(prefix)
|
19
|
-
|
20
|
+
raise_abort "Invalid name #{name}" if idx < 0
|
20
21
|
name.slice(prefix.size, name.size - 1)
|
21
22
|
end
|
22
23
|
|
23
24
|
|
24
25
|
def installed_packages(root)
|
25
|
-
|
26
|
+
dest = {}
|
27
|
+
return dest unless FileTest.directory?(root)
|
28
|
+
Pathname.new(root).children.select{|e| e.directory? }.inject(dest) do |memo, d|
|
26
29
|
version = version_from_package(File.basename(d))
|
27
30
|
memo[version] = d
|
28
31
|
memo
|
@@ -38,10 +41,15 @@ def sh_exc(cmd, *opts)
|
|
38
41
|
end
|
39
42
|
|
40
43
|
|
44
|
+
def raise_abort(msg)
|
45
|
+
abort "[aborted] #{msg}"
|
46
|
+
end
|
47
|
+
|
48
|
+
|
41
49
|
OPENRESTY = "openresty-"
|
42
50
|
|
43
|
-
HOME_DIR = ENV["NGINXBREW_HOME"] || File.join(ENV["HOME"], "nginxbrew")
|
44
51
|
VERSION = ENV["VERSION"]
|
52
|
+
HOME_DIR = ENV["NGINXBREW_HOME"] || File.join(ENV["HOME"], "nginxbrew")
|
45
53
|
NGINX_USER = ENV["NGINXBREW_USER"] || "nginx"
|
46
54
|
NGINX_GROUP = ENV["NGINXBREW_GROUP"] || "nginx"
|
47
55
|
|
@@ -66,15 +74,27 @@ if VERSION
|
|
66
74
|
require "nginxbrew/config/base"
|
67
75
|
|
68
76
|
is_openresty = VERSION.index(OPENRESTY) == 0
|
69
|
-
|
70
|
-
|
77
|
+
|
78
|
+
# resolve version name
|
79
|
+
$stdout.puts("checking version ...")
|
80
|
+
nginxes = is_openresty ? Nginxbrew::Nginxes.openresties : Nginxbrew::Nginxes.nginxes
|
81
|
+
version = nil
|
82
|
+
raw_version = nil
|
83
|
+
if is_openresty
|
84
|
+
raw_version = nginxes.head_of(VERSION.slice(OPENRESTY.size, VERSION.size - 1))
|
85
|
+
version = "#{OPENRESTY}#{raw_version}"
|
86
|
+
else
|
87
|
+
raw_version = nginxes.head_of(VERSION)
|
88
|
+
version = raw_version
|
89
|
+
end
|
90
|
+
$stdout.puts("resolved version: [#{is_openresty ? 'openresty' : 'nginx'}-]#{raw_version}")
|
91
|
+
|
71
92
|
|
72
93
|
Nginxbrew.config = Nginxbrew::Configuration.new(
|
73
94
|
:home_dir => HOME_DIR,
|
74
95
|
:dist_dir => DIST_DIR,
|
75
|
-
:ngx_version =>
|
96
|
+
:ngx_version => raw_version,
|
76
97
|
:is_openresty => is_openresty,
|
77
|
-
:src => is_openresty ? "ngx_openresty-#{version_}" : "nginx-#{version_}",
|
78
98
|
:ngx_user => NGINX_USER,
|
79
99
|
:ngx_group => NGINX_GROUP
|
80
100
|
)
|
@@ -90,7 +110,7 @@ if VERSION
|
|
90
110
|
TARBALL_DOWNLOADED_TO = File.join(SOURCE_DIR, config.tarball)
|
91
111
|
SOURCE_EXTRACTED_TO = File.join(SOURCE_DIR, config.src)
|
92
112
|
|
93
|
-
desc "get nginx tarball version:#{
|
113
|
+
desc "get nginx tarball version:#{version}"
|
94
114
|
file TARBALL_DOWNLOADED_TO => SOURCE_DIR do
|
95
115
|
Dir.chdir(SOURCE_DIR) do
|
96
116
|
sh_exc("wget", config.url)
|
@@ -108,17 +128,26 @@ if VERSION
|
|
108
128
|
|
109
129
|
desc "do build/install, after that create file:built to keep status of build"
|
110
130
|
file config.builtfile => [SOURCE_EXTRACTED_TO, config.dist_to] do
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
end
|
131
|
+
Dir.chdir(SOURCE_EXTRACTED_TO) do
|
132
|
+
[config.configure_command, "gmake -j2", "gmake install"].each do |cmd|
|
133
|
+
sh_exc(cmd)
|
115
134
|
end
|
116
|
-
|
135
|
+
end
|
136
|
+
sh_exc("touch", config.builtfile)
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
desc "check nginx version duplication before install"
|
141
|
+
task :check_duplicatate do
|
142
|
+
if installed_packages(config.dist_dir).keys.include?(version)
|
143
|
+
raise_abort "#{config.version_name} is already installed"
|
144
|
+
end
|
117
145
|
end
|
118
146
|
|
119
147
|
|
120
148
|
desc "install nginx"
|
121
|
-
task :install => [config.builtfile] do
|
149
|
+
task :install => [:check_duplicatate, config.builtfile] do
|
150
|
+
Rake::Task[:chown].invoke
|
122
151
|
if installed_packages(DIST_DIR).size == 1
|
123
152
|
$logger.debug("this is first install, use this version as default")
|
124
153
|
Rake::Task[:use].invoke
|
@@ -128,9 +157,10 @@ if VERSION
|
|
128
157
|
|
129
158
|
desc "switch nginx version"
|
130
159
|
task :use => [BIN_DIR, :chown] do
|
131
|
-
|
160
|
+
raise_abort "#{config.version_name} is not installed!" unless FileTest.directory?(config.dist_to)
|
132
161
|
FileUtils.ln_s(config.ngx_sbin_path, NGINX_CURRENT_BIN_NAME, :force => true)
|
133
|
-
|
162
|
+
Rake::Task[:chown].invoke
|
163
|
+
$stdout.puts("#{version} default to use")
|
134
164
|
$stdout.puts("bin: #{config.ngx_sbin_path}")
|
135
165
|
end
|
136
166
|
end
|
@@ -142,7 +172,7 @@ task :chown do
|
|
142
172
|
user = ENV["USER"]
|
143
173
|
if sudo_user && sudo_user != user
|
144
174
|
[HOME_DIR, DIST_DIR, BIN_DIR].each do |dir|
|
145
|
-
sh_exc("chown", "-R", sudo_user, dir)
|
175
|
+
sh_exc("chown", "-R", sudo_user, dir) if FileTest.directory?(dir)
|
146
176
|
end
|
147
177
|
end
|
148
178
|
end
|
@@ -163,3 +193,23 @@ task :list => DIST_DIR do
|
|
163
193
|
end
|
164
194
|
end
|
165
195
|
|
196
|
+
|
197
|
+
desc "list nginx versions"
|
198
|
+
task :nginxes do
|
199
|
+
HEAD_VERSION = ENV["HEAD_VERSION"]
|
200
|
+
nginxes = Nginxbrew::Nginxes.nginxes
|
201
|
+
((HEAD_VERSION) ? nginxes.filter_versions(HEAD_VERSION) : nginxes.versions).each do |v|
|
202
|
+
$stdout.puts("[nginx-]#{v}")
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
|
207
|
+
desc "list openresty versions"
|
208
|
+
task :openresties do
|
209
|
+
require "nginxbrew/nginxes"
|
210
|
+
HEAD_VERSION = ENV["HEAD_VERSION"]
|
211
|
+
nginxes = Nginxbrew::Nginxes.openresties
|
212
|
+
((HEAD_VERSION) ? nginxes.filter_versions(HEAD_VERSION) : nginxes.versions).each do |v|
|
213
|
+
$stdout.puts("[ngx_openresty-]#{v}")
|
214
|
+
end
|
215
|
+
end
|
data/lib/nginxbrew/version.rb
CHANGED
data/nginxbrew.gemspec
CHANGED
@@ -0,0 +1,95 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "nginxbrew"
|
3
|
+
require "nginxbrew/nginxes"
|
4
|
+
|
5
|
+
|
6
|
+
describe Nginxbrew::Nginxes, "scraping ngx versions in their page" do
|
7
|
+
|
8
|
+
it "should return list of nginx versions" do
|
9
|
+
ret = Nginxbrew::Nginxes.nginxes
|
10
|
+
expect(ret.size).to be > 0
|
11
|
+
expect(ret.ngx_type).to eq Nginxbrew::Nginxes::TypeNginx
|
12
|
+
end
|
13
|
+
|
14
|
+
it "version text in nginxes is [0-9.]+" do
|
15
|
+
ret = Nginxbrew::Nginxes.nginxes
|
16
|
+
ret.versions.each do |v|
|
17
|
+
expect(v).to match(/[0-9.]+/)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return list of openresty versions" do
|
22
|
+
ret = Nginxbrew::Nginxes.openresties
|
23
|
+
expect(ret.size).to be > 0
|
24
|
+
expect(ret.ngx_type).to eq Nginxbrew::Nginxes::TypeOpenresty
|
25
|
+
end
|
26
|
+
|
27
|
+
it "version text in openresties is [0-9.]+" do
|
28
|
+
ret = Nginxbrew::Nginxes.openresties
|
29
|
+
ret.versions.each do |v|
|
30
|
+
expect(v).to match(/[0-9.]+/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
describe Nginxbrew::Nginxes, "version control" do
|
38
|
+
|
39
|
+
it "should be raised exception when input invalid ngx type" do
|
40
|
+
expect {
|
41
|
+
Nginxbrew::Nginxes.new("INVALID_NGX_TYPE", ["1", "2", "3"])
|
42
|
+
}.to raise_error
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should be raised exception when version list is empty" do
|
46
|
+
expect {
|
47
|
+
Nginxbrew::Nginxes.new(Nginxbrew::Nginxes::TypeNginx, [])
|
48
|
+
}.to raise_error
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should be raised exception when version is not found in head_of" do
|
52
|
+
expect {
|
53
|
+
Nginxbrew::Nginxes.new(Nginxbrew::Nginxes::TypeNginx, ["1", "2", "3"]).head_of("INVALID_VERSION")
|
54
|
+
}.to raise_error
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should be raised exception when version is not found in filter_versions" do
|
58
|
+
expect {
|
59
|
+
Nginxbrew::Nginxes.new(Nginxbrew::Nginxes::TypeNginx, ["1", "2", "3"]).filter_versions("INVALID_VERSION")
|
60
|
+
}.to raise_error
|
61
|
+
end
|
62
|
+
|
63
|
+
it "can know size of versions" do
|
64
|
+
nginxes = Nginxbrew::Nginxes.new(Nginxbrew::Nginxes::TypeNginx, ["0.0.0", "0.0.1"])
|
65
|
+
expect(nginxes.size).to eq 2
|
66
|
+
end
|
67
|
+
|
68
|
+
it "filter_versions should return list of active versions" do
|
69
|
+
nginxes = Nginxbrew::Nginxes.new(
|
70
|
+
Nginxbrew::Nginxes::TypeNginx,
|
71
|
+
%w(0.1 0.2 0.3 1.1 1.2 1.3 2.0.0 2.0.1 2.1.0 2.1.1)
|
72
|
+
)
|
73
|
+
expect(nginxes.filter_versions("1")).to eq ["1.3", "1.2", "1.1"]
|
74
|
+
expect(nginxes.filter_versions("2.1")).to eq ["2.1.1", "2.1.0"]
|
75
|
+
end
|
76
|
+
|
77
|
+
it "versions should be sorted order by version-number desc" do
|
78
|
+
nginxes = Nginxbrew::Nginxes.new(
|
79
|
+
Nginxbrew::Nginxes::TypeNginx,
|
80
|
+
%w(0.0.1 0.0.2 0.1.0 0.1.1 1.0.0 1.0.1 1.1.0 2.0.0)
|
81
|
+
)
|
82
|
+
expect(nginxes.versions).to eq %w(2.0.0 1.1.0 1.0.1 1.0.0 0.1.1 0.1.0 0.0.2 0.0.1)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "head_of should returns head of versions" do
|
86
|
+
nginxes = Nginxbrew::Nginxes.new(
|
87
|
+
Nginxbrew::Nginxes::TypeNginx,
|
88
|
+
%w(0.0.0 0.0.1 0.1.0 0.1.1 1.0.0 2.0.0)
|
89
|
+
)
|
90
|
+
expect(nginxes.head_of("0.0")).to eq "0.0.1"
|
91
|
+
expect(nginxes.head_of("0.1")).to eq "0.1.1"
|
92
|
+
expect(nginxes.head_of("0")).to eq "0.1.1"
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nginxbrew
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takumakanari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Nginxbrew is a tool for install multi-version of nginx/nginxopenresty
|
42
56
|
into your local environment.
|
43
57
|
email:
|
@@ -48,6 +62,7 @@ extensions: []
|
|
48
62
|
extra_rdoc_files: []
|
49
63
|
files:
|
50
64
|
- ".gitignore"
|
65
|
+
- CHANGES.txt
|
51
66
|
- Gemfile
|
52
67
|
- LICENSE.txt
|
53
68
|
- README.md
|
@@ -56,9 +71,12 @@ files:
|
|
56
71
|
- lib/nginxbrew.rb
|
57
72
|
- lib/nginxbrew/config/base.rb
|
58
73
|
- lib/nginxbrew/config/default.rb
|
74
|
+
- lib/nginxbrew/nginxes.rb
|
59
75
|
- lib/nginxbrew/tasks.rb
|
60
76
|
- lib/nginxbrew/version.rb
|
61
77
|
- nginxbrew.gemspec
|
78
|
+
- spec/nginxes_spec.rb
|
79
|
+
- spec/spec_helper.rb
|
62
80
|
homepage: ''
|
63
81
|
licenses:
|
64
82
|
- MIT
|
@@ -83,4 +101,6 @@ rubygems_version: 2.4.2
|
|
83
101
|
signing_key:
|
84
102
|
specification_version: 4
|
85
103
|
summary: Multi installation for nginx.
|
86
|
-
test_files:
|
104
|
+
test_files:
|
105
|
+
- spec/nginxes_spec.rb
|
106
|
+
- spec/spec_helper.rb
|