nginxbrew 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.txt +6 -0
- data/README.md +8 -6
- data/bin/nginxbrew +10 -0
- data/lib/nginxbrew.rb +6 -1
- data/lib/nginxbrew/config/base.rb +6 -10
- data/lib/nginxbrew/config/default.rb +1 -1
- data/lib/nginxbrew/convention.rb +43 -0
- data/lib/nginxbrew/nginxes.rb +49 -1
- data/lib/nginxbrew/rake_tools.rb +12 -0
- data/lib/nginxbrew/tasks.rb +37 -82
- data/lib/nginxbrew/version.rb +1 -1
- data/nginxbrew.gemspec +2 -0
- data/spec/convention_spec.rb +57 -0
- data/spec/nginxes_spec.rb +11 -2
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3799667578a5c727746f7e909d6fed330883248
|
4
|
+
data.tar.gz: 7dc63e4e01c90743aee52c1e08b851d098672900
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3bed7f44b4598dd7ede862342dfcb5abd8f701617c6154d7124981f530f273a19ac2efe0cf0a4c34111577831af87a136ab8649077109e48627c45b5f1c4f68
|
7
|
+
data.tar.gz: 39872bdf3f1692d21237469540fa2372111edb2aa740cfaae12be887908a9acbab1c1f3d6526b167142245e16d6ba2e9f3e367e7b605cc5a70c79058c5c31141
|
data/CHANGES.txt
CHANGED
data/README.md
CHANGED
@@ -31,13 +31,15 @@ If you need to install openresty,
|
|
31
31
|
$ nginxbrew install openresty-1.7.0.1
|
32
32
|
|
33
33
|
|
34
|
-
After the command execution, ~/nginxbrew will be created into your machine and nginx is installed as follows
|
34
|
+
After the command execution, ~/nginxbrew (or path which set NGINXBREW_HOME in env) will be created into your machine and nginx is installed as follows
|
35
|
+
|
36
|
+
~/nginxbrew/bin/nginx -- current sbin
|
37
|
+
~/nginxbrew/run/ -- directory for pid file, be shared
|
38
|
+
~/nginxbrew/logs/<version>/ -- log files
|
39
|
+
~/nginxbrew/versions/ngx-<version>/ -- $prefix directory of each version
|
40
|
+
~/nginxbrew/versions/ngx-<version>/conf/ -- nginx.conf and other configuration files
|
41
|
+
~/nginxbrew/versions/ngx-<version>/bin/nginx -- nginx bin for each version
|
35
42
|
|
36
|
-
~/nginxbrew/bin/nginx -- current sbin
|
37
|
-
~/nginxbrew/logs/<version> -- logfiles
|
38
|
-
~/nginxbrew/versions/ngx-<version>/nginx.conf -- root config file
|
39
|
-
~/nginxbrew/versions/ngx-<version> -- configs, sbin|pid of each version
|
40
|
-
~/nginxbrew/versions/ngx-<version>/user/share -- $prefix directory of each version
|
41
43
|
|
42
44
|
Then you can start up nginx by command which same as original nginx as follows
|
43
45
|
|
data/bin/nginxbrew
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "nginxbrew"
|
3
|
+
require "logger"
|
4
|
+
|
3
5
|
|
4
6
|
usage =<<-EOF
|
5
7
|
Usage: nginxbrew [-v] [-h] command [<args>]
|
@@ -38,6 +40,12 @@ end
|
|
38
40
|
ENV["HOME"] ||= File.dirname(__FILE__) # recover $HOME if empty
|
39
41
|
|
40
42
|
|
43
|
+
$debug = ENV["NGINXBREW_DEBUG"].to_i == 1
|
44
|
+
|
45
|
+
$logger = Logger.new(STDOUT)
|
46
|
+
$logger.level = $debug ? Logger::DEBUG : Logger::ERROR
|
47
|
+
|
48
|
+
|
41
49
|
begin
|
42
50
|
command = ARGV.shift
|
43
51
|
case command
|
@@ -55,8 +63,10 @@ begin
|
|
55
63
|
raise Exception.new("Unknown command '#{command}'")
|
56
64
|
end
|
57
65
|
rescue SystemExit => e # from rake.abort
|
66
|
+
$stderr.puts e.backtrace if $debug
|
58
67
|
exit 255
|
59
68
|
rescue Exception => e
|
69
|
+
$stderr.puts e.backtrace if $debug
|
60
70
|
$stderr.puts "ERROR: #{e.message}"
|
61
71
|
exit 255
|
62
72
|
end
|
data/lib/nginxbrew.rb
CHANGED
@@ -15,7 +15,7 @@ module Nginxbrew
|
|
15
15
|
attr_accessor :ngx_configure, :ngx_conf_path, :ngx_prefix
|
16
16
|
attr_reader :ngx_user, :ngx_group, :nginx_log_dir,
|
17
17
|
:builtfile, :dist_to, :tarball, :src, :url, :home_dir, :dist_dir,
|
18
|
-
:ngx_sbin_path, :
|
18
|
+
:ngx_sbin_path, :package_name
|
19
19
|
|
20
20
|
def initialize(opts={})
|
21
21
|
@home_dir = opts[:home_dir]
|
@@ -24,17 +24,17 @@ module Nginxbrew
|
|
24
24
|
@is_openresty = opts[:is_openresty]
|
25
25
|
@ngx_user = opts[:ngx_user]
|
26
26
|
@ngx_group = opts[:ngx_group]
|
27
|
-
@
|
28
|
-
@dist_to = File.join(@dist_dir,
|
29
|
-
@nginx_log_dir = File.join(@home_dir, "logs", @
|
27
|
+
@package_name = opts[:package_name]
|
28
|
+
@dist_to = File.join(@dist_dir, @package_name)
|
29
|
+
@nginx_log_dir = File.join(@home_dir, "logs", @package_name)
|
30
30
|
@src = src_name(@ngx_version, @is_openresty)
|
31
31
|
@tarball = "#{@src}.tar.gz"
|
32
32
|
@url = "#{@is_openresty ? OPENRESTY_URL : NGX_URL}/#{@tarball}"
|
33
33
|
@ngx_sbin_path = File.join(@dist_to, "bin/nginx")
|
34
34
|
@builtfile = File.join(@dist_to, "built")
|
35
35
|
@ngx_configure = nil
|
36
|
-
@ngx_conf_path = File.join(@dist_to, "nginx.conf")
|
37
|
-
@ngx_prefix =
|
36
|
+
@ngx_conf_path = File.join(@dist_to, "conf/nginx.conf")
|
37
|
+
@ngx_prefix = @dist_to
|
38
38
|
end
|
39
39
|
|
40
40
|
def configure_command
|
@@ -59,10 +59,6 @@ module Nginxbrew
|
|
59
59
|
|
60
60
|
private
|
61
61
|
|
62
|
-
def create_version_name(v, is_openresty)
|
63
|
-
is_openresty ? "openresty-#{v}" : v
|
64
|
-
end
|
65
|
-
|
66
62
|
def src_name(v, is_openresty)
|
67
63
|
is_openresty ? "ngx_openresty-#{v}" : "nginx-#{v}"
|
68
64
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "pathname"
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
|
5
|
+
module Nginxbrew
|
6
|
+
|
7
|
+
class NamingConvention
|
8
|
+
|
9
|
+
NGX = "ngx-"
|
10
|
+
|
11
|
+
OPENRESTY = "openresty-" # <NGX>-<OPENRESTY>-x.x.x
|
12
|
+
|
13
|
+
def self.resolve(version)
|
14
|
+
is_openresty = openresty?(version)
|
15
|
+
raw_version = is_openresty ? openresty_to_raw_version(version) : version
|
16
|
+
[raw_version, is_openresty]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.openresty?(v)
|
20
|
+
v.index(OPENRESTY) == 0
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.openresty_to_raw_version(v)
|
24
|
+
v.slice(OPENRESTY.size, v.size - 1)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.package_name_from(raw_version, is_openresty)
|
28
|
+
"#{NGX}#{is_openresty ? OPENRESTY : ''}#{raw_version}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.version_from_package(name)
|
32
|
+
idx = name.index(NGX)
|
33
|
+
if idx > -1
|
34
|
+
ret = name.slice(NGX.size, name.size - 1).strip
|
35
|
+
return ret if ret.size > 0
|
36
|
+
end
|
37
|
+
raise Exception.new("Invalid version name '#{name}'")
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
data/lib/nginxbrew/nginxes.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "net/http"
|
2
2
|
require "uri"
|
3
3
|
|
4
|
+
include Nginxbrew
|
5
|
+
|
4
6
|
|
5
7
|
module Nginxbrew
|
6
8
|
|
@@ -12,6 +14,48 @@ module Nginxbrew
|
|
12
14
|
|
13
15
|
end
|
14
16
|
|
17
|
+
class LocalEnv
|
18
|
+
|
19
|
+
def initialize(dist_dir)
|
20
|
+
@dist_dir = dist_dir
|
21
|
+
end
|
22
|
+
|
23
|
+
def exists?(raw_version, is_openresty)
|
24
|
+
ret = installed_packages.detect do |v, data|
|
25
|
+
v == raw_version && data[:openresty] == is_openresty
|
26
|
+
end
|
27
|
+
!ret.nil?
|
28
|
+
end
|
29
|
+
|
30
|
+
def installed_packages
|
31
|
+
dest = {}
|
32
|
+
return dest unless FileTest.directory?(@dist_dir)
|
33
|
+
child_dirs.inject(dest) do |memo, d|
|
34
|
+
version = NamingConvention.version_from_package(File.basename(d))
|
35
|
+
is_openresty = NamingConvention.openresty?(version)
|
36
|
+
raw_version = is_openresty ?
|
37
|
+
NamingConvention.openresty_to_raw_version(version) : version
|
38
|
+
memo[version] = {
|
39
|
+
:openresty => is_openresty,
|
40
|
+
:raw_version => raw_version,
|
41
|
+
:version => version
|
42
|
+
}
|
43
|
+
memo
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def has_one_build?
|
48
|
+
installed_packages.size == 1
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def child_dirs
|
54
|
+
Pathname.new(@dist_dir).children.select{|e| e.directory? }
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
15
59
|
class Nginxes
|
16
60
|
|
17
61
|
TypeNginx = "nginx"
|
@@ -25,7 +69,11 @@ module Nginxbrew
|
|
25
69
|
end
|
26
70
|
raise Exception.new("No versions of nginx!") if versions.size == 0
|
27
71
|
@ngx_type = ngx_type
|
28
|
-
@versions = versions.uniq.
|
72
|
+
@versions = versions.uniq.map do |v|
|
73
|
+
Gem::Version.new(v) # 1.15.x <> 1.8.x should be 1.15.x > 1.8.x
|
74
|
+
end.sort.reverse.map do |v|
|
75
|
+
v.to_s
|
76
|
+
end
|
29
77
|
end
|
30
78
|
|
31
79
|
def size
|
data/lib/nginxbrew/tasks.rb
CHANGED
@@ -1,54 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require "logger"
|
3
2
|
require "pathname"
|
4
3
|
require "fileutils"
|
5
|
-
require "nginxbrew/nginxes"
|
6
4
|
|
7
|
-
|
8
|
-
$logger = Logger.new(STDOUT)
|
9
|
-
$logger.level = (ENV["NGINXBREW_DEBUG"].to_i == 1) ? Logger::DEBUG : Logger::ERROR
|
10
|
-
|
11
|
-
|
12
|
-
def package_name_from(version)
|
13
|
-
"ngx-#{version}"
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
def version_from_package(name)
|
18
|
-
prefix = "ngx-"
|
19
|
-
idx = name.index(prefix)
|
20
|
-
raise_abort "Invalid name #{name}" if idx < 0
|
21
|
-
name.slice(prefix.size, name.size - 1)
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
def installed_packages(root)
|
26
|
-
dest = {}
|
27
|
-
return dest unless FileTest.directory?(root)
|
28
|
-
Pathname.new(root).children.select{|e| e.directory? }.inject(dest) do |memo, d|
|
29
|
-
version = version_from_package(File.basename(d))
|
30
|
-
memo[version] = d
|
31
|
-
memo
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
def sh_exc(cmd, *opts)
|
37
|
-
line = cmd
|
38
|
-
line += " " + opts.join(" ")
|
39
|
-
$logger.debug("exec: #{line}")
|
40
|
-
sh line
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
def raise_abort(msg)
|
45
|
-
abort "[aborted] #{msg}"
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
OPENRESTY = "openresty-"
|
5
|
+
verbose(false) # stop verbosing by rake
|
50
6
|
|
51
7
|
VERSION = ENV["VERSION"]
|
8
|
+
|
52
9
|
HOME_DIR = ENV["NGINXBREW_HOME"] || File.join(ENV["HOME"], "nginxbrew")
|
53
10
|
NGINX_USER = ENV["NGINXBREW_USER"] || "nginx"
|
54
11
|
NGINX_GROUP = ENV["NGINXBREW_GROUP"] || "nginx"
|
@@ -59,41 +16,35 @@ if CONFIG_FILE && !FileTest.file?(CONFIG_FILE)
|
|
59
16
|
end
|
60
17
|
|
61
18
|
|
62
|
-
SOURCE_DIR = "#{HOME_DIR}
|
19
|
+
SOURCE_DIR = "#{HOME_DIR}/.src"
|
63
20
|
DIST_DIR = "#{HOME_DIR}/versions"
|
64
21
|
BIN_DIR = "#{HOME_DIR}/bin"
|
65
|
-
|
22
|
+
NGINX_BIN = "#{BIN_DIR}/nginx"
|
66
23
|
|
67
24
|
|
68
25
|
[HOME_DIR, SOURCE_DIR, BIN_DIR, DIST_DIR].each do |dir|
|
69
26
|
directory dir
|
70
27
|
end
|
71
28
|
|
29
|
+
local_env = Nginxbrew::LocalEnv.new(DIST_DIR)
|
30
|
+
|
72
31
|
|
73
32
|
if VERSION
|
74
33
|
require "nginxbrew/config/base"
|
75
34
|
|
76
|
-
is_openresty = VERSION.index(OPENRESTY) == 0
|
77
|
-
|
78
|
-
# resolve version name
|
79
35
|
$stdout.puts("checking version ...")
|
36
|
+
raw_version, is_openresty = NamingConvention.resolve(VERSION)
|
80
37
|
nginxes = is_openresty ? Nginxbrew::Nginxes.openresties : Nginxbrew::Nginxes.nginxes
|
81
|
-
|
82
|
-
|
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
|
38
|
+
raw_version = nginxes.head_of(raw_version)
|
39
|
+
package_name = NamingConvention.package_name_from(raw_version, is_openresty)
|
90
40
|
$stdout.puts("resolved version: [#{is_openresty ? 'openresty' : 'nginx'}-]#{raw_version}")
|
91
|
-
|
41
|
+
$stdout.puts("nginx package: #{package_name}")
|
92
42
|
|
93
43
|
Nginxbrew.config = Nginxbrew::Configuration.new(
|
94
44
|
:home_dir => HOME_DIR,
|
95
45
|
:dist_dir => DIST_DIR,
|
96
46
|
:ngx_version => raw_version,
|
47
|
+
:package_name => package_name,
|
97
48
|
:is_openresty => is_openresty,
|
98
49
|
:ngx_user => NGINX_USER,
|
99
50
|
:ngx_group => NGINX_GROUP
|
@@ -107,28 +58,30 @@ if VERSION
|
|
107
58
|
|
108
59
|
directory config.dist_to
|
109
60
|
|
110
|
-
|
111
|
-
|
61
|
+
tarball_download_to = File.join(SOURCE_DIR, config.tarball)
|
62
|
+
source_extract_to = File.join(SOURCE_DIR, config.src)
|
112
63
|
|
113
|
-
desc "get nginx tarball version:#{
|
114
|
-
file
|
64
|
+
desc "get nginx tarball version:#{config.package_name}"
|
65
|
+
file tarball_download_to => SOURCE_DIR do
|
66
|
+
$stdout.puts("download #{config.package_name} from #{config.url}")
|
115
67
|
Dir.chdir(SOURCE_DIR) do
|
116
|
-
sh_exc("wget", config.url)
|
68
|
+
sh_exc("wget", config.url, "-q")
|
117
69
|
end
|
118
70
|
end
|
119
71
|
|
120
72
|
|
121
|
-
desc "extract tarball, #{
|
122
|
-
directory
|
73
|
+
desc "extract tarball, #{source_extract_to} will be created"
|
74
|
+
directory source_extract_to => tarball_download_to do
|
123
75
|
Dir.chdir(SOURCE_DIR) do
|
124
|
-
sh_exc("tar", "zxf",
|
76
|
+
sh_exc("tar", "zxf", tarball_download_to)
|
125
77
|
end
|
126
78
|
end
|
127
79
|
|
128
80
|
|
129
81
|
desc "do build/install, after that create file:built to keep status of build"
|
130
|
-
file config.builtfile => [
|
131
|
-
|
82
|
+
file config.builtfile => [source_extract_to, config.dist_to] do
|
83
|
+
$stdout.puts("building #{config.package_name} ...")
|
84
|
+
Dir.chdir(source_extract_to) do
|
132
85
|
[config.configure_command, "gmake -j2", "gmake install"].each do |cmd|
|
133
86
|
sh_exc(cmd)
|
134
87
|
end
|
@@ -139,8 +92,8 @@ if VERSION
|
|
139
92
|
|
140
93
|
desc "check nginx version duplication before install"
|
141
94
|
task :check_duplicatate do
|
142
|
-
if
|
143
|
-
|
95
|
+
if local_env.exists?(raw_version, is_openresty)
|
96
|
+
warn "#{config.package_name} is already installed"
|
144
97
|
end
|
145
98
|
end
|
146
99
|
|
@@ -148,8 +101,8 @@ if VERSION
|
|
148
101
|
desc "install nginx"
|
149
102
|
task :install => [:check_duplicatate, config.builtfile] do
|
150
103
|
Rake::Task[:chown].invoke
|
151
|
-
if
|
152
|
-
$
|
104
|
+
if local_env.has_one_build?
|
105
|
+
$stdout.puts("this is first install, use this version as default")
|
153
106
|
Rake::Task[:use].invoke
|
154
107
|
end
|
155
108
|
end
|
@@ -157,11 +110,13 @@ if VERSION
|
|
157
110
|
|
158
111
|
desc "switch nginx version"
|
159
112
|
task :use => [BIN_DIR, :chown] do
|
160
|
-
|
161
|
-
|
113
|
+
unless FileTest.directory?(config.dist_to)
|
114
|
+
raise_abort "#{config.package_name} is not installed!"
|
115
|
+
end
|
116
|
+
FileUtils.ln_s(config.ngx_sbin_path, NGINX_BIN, :force => true)
|
162
117
|
Rake::Task[:chown].invoke
|
163
|
-
$stdout.puts("#{
|
164
|
-
$stdout.puts("bin
|
118
|
+
$stdout.puts("#{config.package_name} default to use")
|
119
|
+
$stdout.puts("bin linked to #{config.ngx_sbin_path}")
|
165
120
|
end
|
166
121
|
end
|
167
122
|
|
@@ -181,13 +136,13 @@ end
|
|
181
136
|
desc "list installed nginx"
|
182
137
|
task :list => DIST_DIR do
|
183
138
|
used_version = nil
|
184
|
-
if FileTest.file?(
|
185
|
-
target_path = File.readlink(
|
139
|
+
if FileTest.file?(NGINX_BIN)
|
140
|
+
target_path = File.readlink(NGINX_BIN)
|
186
141
|
path_list = target_path.split("/")
|
187
142
|
2.times {|i| path_list.pop } # remove bin/nginx
|
188
|
-
used_version = version_from_package(path_list.pop)
|
143
|
+
used_version = NamingConvention.version_from_package(path_list.pop)
|
189
144
|
end
|
190
|
-
installed_packages
|
145
|
+
local_env.installed_packages.keys.sort.each do |v|
|
191
146
|
prefix = (v == used_version) ? "*" : " "
|
192
147
|
$stdout.puts("#{prefix} #{v}")
|
193
148
|
end
|
data/lib/nginxbrew/version.rb
CHANGED
data/nginxbrew.gemspec
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "nginxbrew"
|
3
|
+
require "nginxbrew/convention"
|
4
|
+
|
5
|
+
include Nginxbrew
|
6
|
+
|
7
|
+
|
8
|
+
describe Nginxbrew::NamingConvention, "controls versions/builds in local env" do
|
9
|
+
|
10
|
+
it "make package name from version for nginx" do
|
11
|
+
ret = NamingConvention.package_name_from("1.1.1", false)
|
12
|
+
expect(ret).to eq "ngx-1.1.1"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "make package name from version for openresty" do
|
16
|
+
ret = NamingConvention.package_name_from("1.1.1", true)
|
17
|
+
expect(ret).to eq "ngx-openresty-1.1.1"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "can get correct version from package name" do
|
21
|
+
ret = NamingConvention.version_from_package("ngx-1.1.1")
|
22
|
+
expect(ret).to eq "1.1.1"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "raise error if package name is invalid (prefix is wrong)" do
|
26
|
+
expect {
|
27
|
+
NamingConvention.version_from_package("INVALID-1.1.1")
|
28
|
+
}.to raise_error
|
29
|
+
end
|
30
|
+
|
31
|
+
it "raise error if package name is invalid (only prefix)" do
|
32
|
+
expect {
|
33
|
+
NamingConvention.version_from_package("ngx-")
|
34
|
+
}.to raise_error
|
35
|
+
end
|
36
|
+
|
37
|
+
it "true/false from openresty?" do
|
38
|
+
expect(NamingConvention.openresty?("openresty-1.1.1")).to be_truthy
|
39
|
+
expect(NamingConvention.openresty?("NOTOPENRESTY-1.1.1")).to be_falsey
|
40
|
+
end
|
41
|
+
|
42
|
+
it "can get raw version from openresty" do
|
43
|
+
ret = NamingConvention.openresty_to_raw_version("openresty-1.1.1")
|
44
|
+
expect(ret).to eq "1.1.1"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "resolve ngx versions" do
|
48
|
+
ret = NamingConvention.resolve("1.1.1")
|
49
|
+
expect(ret).to match_array ["1.1.1", false]
|
50
|
+
end
|
51
|
+
|
52
|
+
it "resolve openresty versions" do
|
53
|
+
ret = NamingConvention.resolve("openresty-1.1.1")
|
54
|
+
expect(ret).to match_array ["1.1.1", true]
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/spec/nginxes_spec.rb
CHANGED
@@ -77,9 +77,9 @@ describe Nginxbrew::Nginxes, "version control" do
|
|
77
77
|
it "versions should be sorted order by version-number desc" do
|
78
78
|
nginxes = Nginxbrew::Nginxes.new(
|
79
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.
|
80
|
+
%w(0.0.1 0.0.2 0.1.0 0.1.1 1.0.0 1.0.1 1.1.0 2.15.1 2.8.15)
|
81
81
|
)
|
82
|
-
expect(nginxes.versions).to eq %w(2.
|
82
|
+
expect(nginxes.versions).to eq %w(2.15.1 2.8.15 1.1.0 1.0.1 1.0.0 0.1.1 0.1.0 0.0.2 0.0.1)
|
83
83
|
end
|
84
84
|
|
85
85
|
it "head_of should returns head of versions" do
|
@@ -92,4 +92,13 @@ describe Nginxbrew::Nginxes, "version control" do
|
|
92
92
|
expect(nginxes.head_of("0")).to eq "0.1.1"
|
93
93
|
end
|
94
94
|
|
95
|
+
it "head_of is first element of versions which sorted by version number" do
|
96
|
+
nginxes = Nginxbrew::Nginxes.new(
|
97
|
+
Nginxbrew::Nginxes::TypeNginx,
|
98
|
+
%w(1.5.8.1 1.5.12.1 1.5.11.1)
|
99
|
+
)
|
100
|
+
expect(nginxes.head_of("1.5")).to eq "1.5.12.1"
|
101
|
+
expect(nginxes.head_of("1")).to eq "1.5.12.1"
|
102
|
+
end
|
103
|
+
|
95
104
|
end
|
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.5
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,10 +71,13 @@ files:
|
|
71
71
|
- lib/nginxbrew.rb
|
72
72
|
- lib/nginxbrew/config/base.rb
|
73
73
|
- lib/nginxbrew/config/default.rb
|
74
|
+
- lib/nginxbrew/convention.rb
|
74
75
|
- lib/nginxbrew/nginxes.rb
|
76
|
+
- lib/nginxbrew/rake_tools.rb
|
75
77
|
- lib/nginxbrew/tasks.rb
|
76
78
|
- lib/nginxbrew/version.rb
|
77
79
|
- nginxbrew.gemspec
|
80
|
+
- spec/convention_spec.rb
|
78
81
|
- spec/nginxes_spec.rb
|
79
82
|
- spec/spec_helper.rb
|
80
83
|
homepage: ''
|
@@ -89,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
92
|
requirements:
|
90
93
|
- - ">="
|
91
94
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
95
|
+
version: 2.0.0
|
93
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
97
|
requirements:
|
95
98
|
- - ">="
|
@@ -102,5 +105,6 @@ signing_key:
|
|
102
105
|
specification_version: 4
|
103
106
|
summary: Multi installation for nginx.
|
104
107
|
test_files:
|
108
|
+
- spec/convention_spec.rb
|
105
109
|
- spec/nginxes_spec.rb
|
106
110
|
- spec/spec_helper.rb
|