vvm-rb 0.0.13 → 0.0.14

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: 7ca509efad41c570ea6149eb75ad18a1a232cfb7
4
- data.tar.gz: 5b1cf1aec013315ac192db95300872edd01a3456
3
+ metadata.gz: 3b0c5ce1f3171c0f708d880c112ee34c77d504a7
4
+ data.tar.gz: 4f4cd9ff34744a99727838d46682c98b7a4561ed
5
5
  SHA512:
6
- metadata.gz: df10d6dd84f272c1684b1d2f9d56a2cd7f8cccca16b5de0216d23747e4a01980c8a96a1ee3c01615df3853cbdffe81bc395b9c73b4745e4da513123adc41b07d
7
- data.tar.gz: 8ae64bf45876b565f67c1d31dabffd53d898e84ada747a374a8498f126686f49944964fca43719abd1f0dfe978e538d29c6b90e8c174a8f0613b78719f6f3bc4
6
+ metadata.gz: be346af4b466e0a5cd50deb9d4464a2c8bd9456c9beb63f847a19b7f4c66fcf1c589490a798602edbc53aa65d45650a5fed6f7e941e072aad06b19682498a27b
7
+ data.tar.gz: e9b8e6a2ed72f820de74d39f419231460c51c64f349b8743dce35aded380a329756e1ef3a3d878451caedf175dcca2e9a2dc919567730efd190c1c7d51893910
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.13
1
+ 0.0.14
data/lib/vvm-rb/cli.rb CHANGED
@@ -7,9 +7,10 @@ class Cli < Thor
7
7
  desc 'install [VERSION] [CONFIGURE_OPTS]', 'Install a specific version of Vim'
8
8
  method_option :use, type: :boolean, aliases: '-u', banner: 'Use installed vim'
9
9
  def install(version, *conf)
10
- version = format_version(version)
10
+ version = Version.format(version)
11
+ new_version?(version)
11
12
 
12
- Installer.fetch
13
+ Installer.pull
13
14
  i = Installer.new(version, conf)
14
15
  i.checkout
15
16
  i.configure
@@ -42,7 +43,7 @@ class Cli < Thor
42
43
 
43
44
  desc 'list', 'Look available vim versions'
44
45
  def list
45
- Installer.fetch
46
+ Installer.pull
46
47
  puts Version.list.join("\n")
47
48
  end
48
49
 
@@ -56,21 +57,16 @@ class Cli < Thor
56
57
  Uninstaller.new(version).uninstall
57
58
  end
58
59
 
59
- before_method(:install, :reinstall, :rebuild, :list) { check_hg }
60
- before_method(:install, :reinstall, :rebuild, :use, :uninstall) { check_tag }
61
60
  before_method(:install) { new_version? }
62
61
  before_method(:reinstall, :rebuild, :use, :uninstall) { version_exist? }
62
+ before_method(:install, :reinstall, :rebuild, :use, :uninstall) { check_tag }
63
+ before_method(:install, :reinstall, :rebuild, :list) { check_hg }
64
+ before_method(*instance_methods(false)) do
65
+ Installer.fetch unless File.exists?(get_vimorg_dir)
66
+ end
63
67
 
64
68
  private
65
69
 
66
- def format_version(version)
67
- if version == 'latest'
68
- version = Version.list.select { |v| v =~ /^v7-.+$/ }.last
69
- new_version?(version)
70
- end
71
- return version
72
- end
73
-
74
70
  def message
75
71
  print "\e[32m"
76
72
  puts <<-EOS
@@ -10,7 +10,10 @@ class Installer
10
10
  FileUtils.mkdir_p(get_repos_dir)
11
11
  repos_dir = get_vimorg_dir
12
12
  system("hg clone #{VIM_URI} #{repos_dir}") unless File.exists?(repos_dir)
13
- Dir.chdir(repos_dir) { system('hg pull') }
13
+ end
14
+
15
+ def self.pull
16
+ Dir.chdir(get_vimorg_dir) { system('hg pull') }
14
17
  end
15
18
 
16
19
  def checkout
@@ -28,11 +28,9 @@ module Validator
28
28
  private
29
29
 
30
30
  def get_version
31
- version = $*.find { |v| v =~ /(^start$|^tip$|^v7-.+$|^system$|^latest$)/ }
32
- if version == 'latest'
33
- version = Version.list.select { |v| v =~ /^v7-.+$/ }.last
34
- end
35
- return version
31
+ regex = /(^start$|^tip$|^v7-.+$|^(\d\.\d\.\d+)$|^system$|^latest$)/
32
+ version = $*.find { |v| v =~ regex }
33
+ return Version.format(version)
36
34
  end
37
35
 
38
36
  def version_include?(version)
@@ -1,8 +1,6 @@
1
1
  class Version
2
2
  def self.list
3
- vimorg_dir = get_vimorg_dir
4
- return [] unless File.exists?(vimorg_dir)
5
- Dir.chdir(vimorg_dir) do
3
+ Dir.chdir(get_vimorg_dir) do
6
4
  list = `hg tags`.split.reverse
7
5
  return list.values_at(* list.each_index.select { |i| i.odd? })
8
6
  end
@@ -17,4 +15,22 @@ class Version
17
15
  end
18
16
  return output
19
17
  end
18
+
19
+ def self.latest
20
+ return list.select { |v| v =~ /^v7-.+$/ }.last
21
+ end
22
+
23
+ def self.convert(version)
24
+ return "v#{version.gsub(/\./, '-')}"
25
+ end
26
+
27
+ def self.format(version)
28
+ case version
29
+ when /^latest$/
30
+ version = latest
31
+ when /^(\d\.\d\.\d+)$/
32
+ version = convert(version)
33
+ end
34
+ return version
35
+ end
20
36
  end
@@ -22,6 +22,16 @@ describe 'Installer' do
22
22
  end
23
23
  end
24
24
 
25
+ context 'pull' do
26
+ before :all do
27
+ Installer.pull
28
+ end
29
+
30
+ it 'exists vimorg dir' do
31
+ expect($?.success?).to be_true
32
+ end
33
+ end
34
+
25
35
  context 'checkout' do
26
36
  before :all do
27
37
  @installer.checkout
@@ -33,7 +33,7 @@ describe 'Validator' do
33
33
  before_method(:dummy_method) { check_tag }
34
34
 
35
35
  before :all do
36
- $* << ['vvm-rb', 'install']
36
+ $* << %w(vvm-rb install)
37
37
  end
38
38
 
39
39
  context 'available tag' do
data/spec/version_spec.rb CHANGED
@@ -1,20 +1,11 @@
1
1
  require 'spec_helper'
2
2
  require 'fileutils'
3
+ require 'tmpdir'
3
4
 
4
5
  describe 'Version' do
5
6
  describe 'list' do
6
- context 'vimorg dirctory exists' do
7
- it 'echo available vim versions' do
8
- expect(Version.list.join("\n")).to match(/start\n(v7-.+\n)+tip$/)
9
- end
10
- end
11
- context 'vimorg dirctory is not found' do
12
- before do
13
- FileUtils.rm_rf(get_vimorg_dir)
14
- end
15
- it 'echo nothing' do
16
- expect(Version.list).to eq []
17
- end
7
+ it 'echo available vim versions' do
8
+ expect(Version.list.join("\n")).to match(/start\n(v7-.+\n)+tip$/)
18
9
  end
19
10
  end
20
11
 
@@ -26,11 +17,52 @@ describe 'Version' do
26
17
  end
27
18
  context 'vims dirctory is not found' do
28
19
  before do
29
- FileUtils.rm_rf(get_vims_dir)
20
+ @tmp_vvmroot = ENV['VVMROOT']
21
+ @tmp2 = Dir.mktmpdir
22
+ ENV['VVMROOT'] = @tmp2
30
23
  end
24
+
25
+ after do
26
+ ENV['VVMROOT'] = @tmp_vvmroot
27
+ FileUtils.rm_rf(@tmp2)
28
+ end
29
+
31
30
  it 'echo nothing' do
32
31
  expect(Version.versions).to eq []
33
32
  end
34
33
  end
35
34
  end
35
+
36
+ describe 'latest' do
37
+ it 'return latest vim version' do
38
+ expect(Version.latest).to match(/^v7-.+$/)
39
+ end
40
+ end
41
+
42
+ describe 'convert' do
43
+ it 'version to tag' do
44
+ expect(Version.convert('7.4.112')).to eq 'v7-4-112'
45
+ end
46
+ end
47
+
48
+ describe 'format' do
49
+
50
+ context 'tag' do
51
+ it 'return formated vim version' do
52
+ expect(Version.format('v7-4-112')).to eq 'v7-4-112'
53
+ end
54
+ end
55
+
56
+ context 'dicimal version' do
57
+ it 'return formated vim version' do
58
+ expect(Version.format('7.4.112')).to eq 'v7-4-112'
59
+ end
60
+ end
61
+
62
+ context 'latest' do
63
+ it 'return latest vim version' do
64
+ expect(Version.format('latest')).to match(/^v7-.+$/)
65
+ end
66
+ end
67
+ end
36
68
  end
data/vvm-rb.gemspec CHANGED
@@ -2,15 +2,15 @@
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 0.0.13 ruby lib
5
+ # stub: vvm-rb 0.0.14 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "vvm-rb"
9
- s.version = "0.0.13"
9
+ s.version = "0.0.14"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Yuu Shigetani"]
13
- s.date = "2013-12-10"
13
+ s.date = "2013-12-11"
14
14
  s.description = "vim version manager."
15
15
  s.email = "s2g4t1n2@gmail.com"
16
16
  s.executables = ["vvm-rb"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vvm-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuu Shigetani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-10 00:00:00.000000000 Z
11
+ date: 2013-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake