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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aabc418d552ab2bf54ddc4abea78611304b1054f
4
- data.tar.gz: 3e5c0bc01e29256503496c75ba812c9b4423d930
3
+ metadata.gz: a3799667578a5c727746f7e909d6fed330883248
4
+ data.tar.gz: 7dc63e4e01c90743aee52c1e08b851d098672900
5
5
  SHA512:
6
- metadata.gz: 88e879d44a09080b6b86bad2239fbddbd404cbfc7889a265db05cbf218c918b0fedf5523b6a2f3db57f83b92f2c0fb1f9122e0e1ce1dd1de13a23ab96ab3aa88
7
- data.tar.gz: 74d913c3335dfe272a6aafb513ec998dd3c0234d0e1caf539d4e484259905dbdd211adbf7a651ea35c251f04ecf7e0d7a0d1b11ddd5e7155bb38962d3ec2e084
6
+ metadata.gz: b3bed7f44b4598dd7ede862342dfcb5abd8f701617c6154d7124981f530f273a19ac2efe0cf0a4c34111577831af87a136ab8649077109e48627c45b5f1c4f68
7
+ data.tar.gz: 39872bdf3f1692d21237469540fa2372111edb2aa740cfaae12be887908a9acbab1c1f3d6526b167142245e16d6ba2e9f3e367e7b605cc5a70c79058c5c31141
@@ -1,5 +1,11 @@
1
1
  Nginxbrew changes
2
2
 
3
+ Nginxbrew 0.0.5
4
+ - Changed some directory/path for installation.
5
+ - Quiet shell outs.
6
+ - Hide src directory.
7
+ - Bug fixes.
8
+
3
9
 
4
10
  Nginxbrew 0.0.4
5
11
  - New command nginxies, openresties to show up available nginx versions.
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
 
@@ -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
@@ -1,6 +1,11 @@
1
- require "nginxbrew/version"
2
1
  require "rake"
3
2
 
3
+ require "nginxbrew/version"
4
+ require "nginxbrew/nginxes"
5
+ require "nginxbrew/convention"
6
+ require "nginxbrew/rake_tools"
7
+
8
+
4
9
  module Nginxbrew
5
10
 
6
11
  def run(command, env={})
@@ -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, :version_name
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
- @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)
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 = File.join(@dist_to, "user/share")
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
@@ -1,5 +1,5 @@
1
1
  Nginxbrew.configure do |config|
2
2
  # config.ngx_prefix = File.join(config.home_dir, "share")
3
- # config.ngx_conf_path = File.join(config.home_dir, "share/nginx.conf")
3
+ # config.ngx_conf_path = File.join(config.home_dir, "conf/nginx.conf")
4
4
  end
5
5
 
@@ -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
+
@@ -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.sort.reverse
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
@@ -0,0 +1,12 @@
1
+ def sh_exc(cmd, *opts)
2
+ line = cmd
3
+ line += " " + opts.join(" ")
4
+ $logger.debug("#{line} dir=[#{Dir.pwd}]")
5
+ line += " >/dev/null" unless $debug
6
+ sh line
7
+ end
8
+
9
+
10
+ def raise_abort(msg)
11
+ abort "[aborted] #{msg}"
12
+ end
@@ -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}/src"
19
+ SOURCE_DIR = "#{HOME_DIR}/.src"
63
20
  DIST_DIR = "#{HOME_DIR}/versions"
64
21
  BIN_DIR = "#{HOME_DIR}/bin"
65
- NGINX_CURRENT_BIN_NAME = "#{BIN_DIR}/nginx"
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
- 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
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
- TARBALL_DOWNLOADED_TO = File.join(SOURCE_DIR, config.tarball)
111
- SOURCE_EXTRACTED_TO = File.join(SOURCE_DIR, config.src)
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:#{version}"
114
- file TARBALL_DOWNLOADED_TO => SOURCE_DIR do
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, #{SOURCE_EXTRACTED_TO} will be created"
122
- directory SOURCE_EXTRACTED_TO => TARBALL_DOWNLOADED_TO do
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", TARBALL_DOWNLOADED_TO)
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 => [SOURCE_EXTRACTED_TO, config.dist_to] do
131
- Dir.chdir(SOURCE_EXTRACTED_TO) do
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 installed_packages(config.dist_dir).keys.include?(version)
143
- raise_abort "#{config.version_name} is already installed"
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 installed_packages(DIST_DIR).size == 1
152
- $logger.debug("this is first install, use this version as default")
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
- raise_abort "#{config.version_name} is not installed!" unless FileTest.directory?(config.dist_to)
161
- FileUtils.ln_s(config.ngx_sbin_path, NGINX_CURRENT_BIN_NAME, :force => true)
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("#{version} default to use")
164
- $stdout.puts("bin: #{config.ngx_sbin_path}")
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?(NGINX_CURRENT_BIN_NAME)
185
- target_path = File.readlink(NGINX_CURRENT_BIN_NAME)
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(DIST_DIR).keys.sort.each do |v|
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
@@ -1,3 +1,3 @@
1
1
  module Nginxbrew
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "rspec"
24
+
25
+ spec.required_ruby_version = ">= 2.0.0"
24
26
  end
@@ -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
@@ -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.0.0)
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.0.0 1.1.0 1.0.1 1.0.0 0.1.1 0.1.0 0.0.2 0.0.1)
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
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-25 00:00:00.000000000 Z
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: '0'
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