vvm-rb 1.0.3 → 1.0.4

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: 3b5f4f657faa8d83bc1809b0694c174dbebb8cf5
4
- data.tar.gz: d6b500f4c0d840f22b4d150932f0787b077cb347
3
+ metadata.gz: 32c51f21af48612f2f8c9555e5e9c9622c9470f0
4
+ data.tar.gz: 8ef8927b47f61441d738b544856a7961f7553738
5
5
  SHA512:
6
- metadata.gz: d4e66aecc2c932705db678fc21bd23b8863d858041b09c0eb3d46dc67d7d892e98574bd4f4b15126241754abc8ff9d9396327d0c29ee4822235bec5e1760cd94
7
- data.tar.gz: ec9702e41aed414e9cfd2168b1659ba15e8abfc3fea5956cd0647aab29eb7665eb7eb88c154a5c7057a3b595da513e8b3b9fba48ce4e135173e4128ce555f605
6
+ metadata.gz: b0a57c971bd69c88fcca3fdfc8df79b57d097e518ddf7dd2d3dd19ced076347e4771edb5c33630228e255b6321d16038791319a9e536ee33fee9a4418c96005a
7
+ data.tar.gz: 07dbc860185e3158c12b0d294eee2968e33de91bfa5411c98ebf92f207a32ad59bc6dbd2df2ff2fce1391fd95bb66881e7d4215c4c231cdcccb47a28b4660524
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.0.4
data/lib/vvm/validator.rb CHANGED
@@ -5,10 +5,10 @@ module Vvm
5
5
  module_function
6
6
 
7
7
  def validate_before_invoke(command)
8
- new_version? if command == 'install'
9
- installed_version? if %w(reinstall rebuild use uninstall).include?(command)
10
8
  version? if %w(install rebuild use uninstall).include?(command)
11
9
  hg? if %w(install reinstall rebuild list).include?(command)
10
+ new_version? if command == 'install'
11
+ installed_version? if %w(reinstall rebuild use uninstall).include?(command)
12
12
  end
13
13
 
14
14
  def hg?
@@ -17,7 +17,7 @@ module Vvm
17
17
  end
18
18
 
19
19
  def version?
20
- abort 'undefined vim version. please run [ vvm list ].' if version.nil?
20
+ abort 'undefined vim version. please run [ vvm list ].' if find_version.nil?
21
21
  true
22
22
  end
23
23
 
@@ -33,11 +33,14 @@ module Vvm
33
33
 
34
34
  private
35
35
 
36
- def version
36
+ def find_version
37
37
  version_regex = /\Av7-.+\z|\A(\d\.\d(a|b){0,1}(\.\d+){0,1})\z/
38
38
  regex = /(\Astart\z|\Atip\z|\Asystem\z|\Alatest\z|#{version_regex})/
39
- ver = $*.find { |v| v =~ regex }
40
- Version.format(ver)
39
+ $*.find { |v| v =~ regex }
40
+ end
41
+
42
+ def version
43
+ Version.format(find_version)
41
44
  end
42
45
 
43
46
  def version_include?(ver)
data/lib/vvm/version.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Vvm
2
2
  class Version
3
3
  def self.list
4
+ Installer.fetch unless File.exist?(vimorg_dir)
4
5
  Dir.chdir(vimorg_dir) do
5
6
  list = `hg tags`.split.reverse
6
7
  return list.values_at(* list.each_index.select(&:odd?))
@@ -108,7 +108,7 @@ describe 'Validator' do
108
108
  before(:all) { $* << %w(vvm install) }
109
109
 
110
110
  context 'available tag' do
111
- before { $*[2] = NEW_VERSION }
111
+ before(:all) { $*[2] = NEW_VERSION }
112
112
 
113
113
  it 'success to run the method' do
114
114
  expect(version?).to be_truthy
@@ -116,7 +116,7 @@ describe 'Validator' do
116
116
  end
117
117
 
118
118
  context 'latest' do
119
- before { $*[2] = 'latest' }
119
+ before(:all) { $*[2] = 'latest' }
120
120
 
121
121
  it 'success to run the method' do
122
122
  expect(version?).to be_truthy
@@ -124,7 +124,7 @@ describe 'Validator' do
124
124
  end
125
125
 
126
126
  context 'tag is not available' do
127
- before { $*[2] = '--use' }
127
+ before(:all) { $*[2] = '--use' }
128
128
 
129
129
  it 'cannot run the method' do
130
130
  expect(proc { version? }).to raise_error
@@ -133,29 +133,73 @@ describe 'Validator' do
133
133
  end
134
134
 
135
135
  describe 'new_version?' do
136
- context 'new version' do
137
- it 'success to run the method' do
138
- expect(new_version?(NEW_VERSION)).to be_truthy
136
+ context 'with arg' do
137
+ context 'new version' do
138
+ it 'success to run the method' do
139
+ expect(new_version?(NEW_VERSION)).to be_truthy
140
+ end
141
+ end
142
+
143
+ context 'version is installed' do
144
+ it 'cannot run the method' do
145
+ expect(proc { new_version?(VERSION1) }).to raise_error
146
+ end
139
147
  end
140
148
  end
141
149
 
142
- context 'version is installed' do
143
- it 'cannot run the method' do
144
- expect(proc { new_version?(VERSION1) }).to raise_error
150
+ context 'without arg' do
151
+ before(:all) { $* << %w(vvm install) }
152
+
153
+ context 'new version' do
154
+ before(:all) { $*[2] = NEW_VERSION }
155
+
156
+ it 'success to run the method' do
157
+ expect(new_version?).to be_truthy
158
+ end
159
+ end
160
+
161
+ context 'version is installed' do
162
+ before(:all) { $*[2] = VERSION1 }
163
+
164
+ it 'cannot run the method' do
165
+ expect(proc { new_version? }).to raise_error
166
+ end
145
167
  end
146
168
  end
147
169
  end
148
170
 
149
171
  describe 'installed_version?' do
150
- context 'version is installed' do
151
- it 'success to run the method' do
152
- expect(installed_version?(VERSION1)).to be_truthy
172
+ context 'with arg' do
173
+ context 'version is installed' do
174
+ it 'success to run the method' do
175
+ expect(installed_version?(VERSION1)).to be_truthy
176
+ end
177
+ end
178
+
179
+ context 'version is not installed' do
180
+ it 'cannot run the method' do
181
+ expect(proc { installed_version?(NEW_VERSION) }).to raise_error
182
+ end
153
183
  end
154
184
  end
155
185
 
156
- context 'version is not installed' do
157
- it 'cannot run the method' do
158
- expect(proc { installed_version?(NEW_VERSION) }).to raise_error
186
+ context 'without arg' do
187
+ before(:all) { $* << %w(vvm install) }
188
+
189
+ context 'version is installed' do
190
+ before(:all) { $*[2] = VERSION1 }
191
+
192
+ it 'success to run the method' do
193
+ expect(installed_version?).to be_truthy
194
+ end
195
+ end
196
+
197
+ context 'version is not installed' do
198
+ before(:all) { $*[2] = NEW_VERSION }
199
+
200
+ it 'cannot run the method' do
201
+ expect(proc { installed_version? }).to raise_error
202
+ end
159
203
  end
160
204
  end
161
205
  end
data/spec/version_spec.rb CHANGED
@@ -5,6 +5,7 @@ require 'tmpdir'
5
5
  describe 'Version' do
6
6
  describe 'list' do
7
7
  it 'echo available vim versions' do
8
+ FileUtils.rm_rf(vimorg_dir) if File.exist?(vimorg_dir)
8
9
  expect(Vvm::Version.list.join("\n")).to match(/\Astart\n(v7-.+\n)+tip\z/)
9
10
  end
10
11
  end
data/vvm-rb.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: vvm-rb 1.0.3 ruby lib
5
+ # stub: vvm-rb 1.0.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "vvm-rb"
9
- s.version = "1.0.3"
9
+ s.version = "1.0.4"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vvm-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuu Shigetani