vvm-rb 0.0.8 → 0.0.9

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: 3458bae9a708052db6dd0fecdabe4515108007b1
4
- data.tar.gz: c3fb8c3b8349db056c3213fbca62ca44a2aa32f1
3
+ metadata.gz: 8c067745c355d0c1ea19f68c96093a87e50b5bb2
4
+ data.tar.gz: 1ba262a04a40b2bbd04b1f52353fddeeb811f199
5
5
  SHA512:
6
- metadata.gz: 23d547e7634a4fb2c50aa570d5da3b67402bdeb707ed3782012d3098d525c833981884d4758364ebadfb124d12e54f5dbc0daaa64071f28e6fe1db14c195d057
7
- data.tar.gz: 486e1d4d831b95b83b3780c64b1681d83f8f29c8d2b83b7cac8212a950d0cbd332f84c36d929fd05c977a76e37cfd402850393614eb51da2c6fdaf339a2b8f72
6
+ metadata.gz: f95705dc184f0a6c8f46542ef587ea54b0fbdfbc6e427afbc477662bb86e6918e76ab2b8ebf1d27bc2cac7fa867e8b126e7a9e524054e3dfeea8f4852d039c14
7
+ data.tar.gz: e390d1374df2c609ffb72c7e98ff9daf12b9a6e533f7d7a7414ee4759623da91103a954e855ada84fcd6bd85d25b3d42a8305185ddc5966cddb1ed7ccf53c42f
data/.rubocop.yml CHANGED
@@ -1,3 +1,5 @@
1
+ LineLength:
2
+ Max: 80
1
3
  MethodLength:
2
4
  Max: 30
3
5
  HashSyntax:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
@@ -1,5 +1,4 @@
1
1
  module Accesser
2
-
3
2
  module_function
4
3
 
5
4
  def get_dot_dir
data/lib/vvm-rb/cli.rb CHANGED
@@ -39,12 +39,12 @@ test -f ~/.vvm-rb/etc/login && source ~/.vvm-rb/etc/login
39
39
  desc 'list', 'Look available vim versions'
40
40
  def list
41
41
  Installer.fetch
42
- puts Version.list
42
+ puts Version.list.join("\n")
43
43
  end
44
44
 
45
45
  desc 'versions', 'Look installed vim versions.'
46
46
  def versions
47
- puts Version.versions
47
+ puts Version.versions.join("\n")
48
48
  end
49
49
 
50
50
  desc 'uninstall [TAG]', 'Uninstall a specific version of Vim.'
@@ -54,11 +54,19 @@ test -f ~/.vvm-rb/etc/login && source ~/.vvm-rb/etc/login
54
54
 
55
55
  before_method(:install, :reinstall, :rebuild, :list) { check_hg }
56
56
  before_method(:install, :reinstall, :rebuild, :use, :uninstall) { check_tag }
57
+ before_method(:install) { new_version?(Version.versions) }
58
+ before_method(:reinstall, :rebuild, :use, :uninstall) do
59
+ version_exist?(Version.versions)
60
+ end
57
61
 
58
62
  private
59
63
 
60
64
  def installer(version, conf)
61
65
  Installer.fetch
66
+ if version == 'latest'
67
+ version = Version.list.select { |v| v =~ /^v7-.+$/ }.last
68
+ new_version?(Version.versions, version)
69
+ end
62
70
  i = Installer.new(version, conf)
63
71
  i.checkout
64
72
  i.configure
@@ -1,7 +1,6 @@
1
1
  require 'fileutils'
2
2
 
3
3
  class Installer
4
-
5
4
  def initialize(version, conf = [])
6
5
  @version = version
7
6
  @conf = conf.empty? && ENV['VVMOPT'] ? ENV['VVMOPT'].split(' ') : conf
@@ -1,5 +1,4 @@
1
1
  module Validator
2
-
3
2
  module_function
4
3
 
5
4
  def check_hg
@@ -9,10 +8,30 @@ module Validator
9
8
  return true
10
9
  end
11
10
 
12
- def check_tag
13
- unless $*[1] =~ /(^start$|^tip$|^v7-.+$|^system$)/
11
+ def check_tag(tag = $*[1])
12
+ unless tag =~ /(^start$|^tip$|^v7-.+$|^system$|^latest$)/
14
13
  abort 'undefined vim version. please run [ vvm-rb list ].'
15
14
  end
16
15
  return true
17
16
  end
17
+
18
+ def new_version?(versions, version = $*[1])
19
+ if version_include?(versions, version)
20
+ abort "#{version} is already installed."
21
+ end
22
+ return true
23
+ end
24
+
25
+ def version_exist?(versions, version = $*[1])
26
+ unless version_include?(versions, version)
27
+ abort "#{version} is not installed."
28
+ end
29
+ return true
30
+ end
31
+
32
+ private
33
+
34
+ def version_include?(versions, version)
35
+ return versions.include?(version)
36
+ end
18
37
  end
@@ -2,7 +2,7 @@ class Version
2
2
  def self.list
3
3
  Dir.chdir(get_vimorg_dir) do
4
4
  list = `hg tags`.split.reverse
5
- return list.values_at(* list.each_index.select { |i| i.odd? }).join("\n")
5
+ return list.values_at(* list.each_index.select { |i| i.odd? })
6
6
  end
7
7
  end
8
8
 
@@ -11,6 +11,6 @@ class Version
11
11
  Dir.glob(File.join(get_vims_dir, 'v*')).sort.each do |d|
12
12
  output << File.basename(d)
13
13
  end
14
- return output.join("\n")
14
+ return output
15
15
  end
16
16
  end
@@ -8,7 +8,7 @@ describe 'Installer' do
8
8
  FileUtils.rm_rf(get_repos_dir)
9
9
  FileUtils.rm_rf(get_etc_dir)
10
10
  ENV['VVMOPT'] = '--enable-rubyinterp'
11
- @version = 'v7-4'
11
+ @version = 'v7-4-103'
12
12
  @installer = Installer.new(@version)
13
13
  end
14
14
 
@@ -68,7 +68,7 @@ describe 'Installer' do
68
68
 
69
69
  describe 'rebuild' do
70
70
  before :all do
71
- @version = 'v7-4'
71
+ @version = 'v7-4-103'
72
72
  @installer = Installer.new(@version)
73
73
  end
74
74
 
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,7 @@ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
6
  ]
7
7
  SimpleCov.start do
8
8
  add_filter '/spec/'
9
+ add_filter '/vendor/'
9
10
  end
10
11
 
11
12
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -18,6 +19,8 @@ include VvmRb
18
19
 
19
20
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
20
21
 
22
+ # [todo] - test is too slow
23
+
21
24
  RSpec.configure do |config|
22
25
  config.before :suite do
23
26
  cache_dir = get_cache_dir
@@ -25,7 +28,7 @@ RSpec.configure do |config|
25
28
  ENV['VVMROOT'] = cache_dir
26
29
  FileUtils.mkdir_p(cache_dir)
27
30
  Installer.fetch
28
- %w{ v7-3-969 v7-4 }.each do |v|
31
+ %w{ v7-4-083 v7-4-103 }.each do |v|
29
32
  i = Installer.new(v)
30
33
  i.checkout
31
34
  i.configure
@@ -48,5 +51,5 @@ RSpec.configure do |config|
48
51
  end
49
52
 
50
53
  def get_cache_dir
51
- File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '.vvm_cache'))
54
+ File.expand_path(File.join(File.dirname(__FILE__), '..', '.vvm_cache'))
52
55
  end
@@ -14,7 +14,7 @@ describe 'Switcher' do
14
14
 
15
15
  context 'different version' do
16
16
  before :all do
17
- version = 'v7-4'
17
+ version = 'v7-4-103'
18
18
  Switcher.new(version).use
19
19
  @vims_dir = get_vims_dir(version)
20
20
  @current = get_current_dir
@@ -4,7 +4,7 @@ describe 'Uninstaller' do
4
4
  describe 'uninstall' do
5
5
  context 'vim version is currently used' do
6
6
  before :all do
7
- version = 'v7-4'
7
+ version = 'v7-4-103'
8
8
  Switcher.new(version).use
9
9
  @uninstaller = Uninstaller.new(version)
10
10
  end
@@ -16,7 +16,7 @@ describe 'Uninstaller' do
16
16
 
17
17
  context 'can uninstall version' do
18
18
  before :all do
19
- @version = 'v7-3-969'
19
+ @version = 'v7-4-083'
20
20
  Uninstaller.new(@version).uninstall
21
21
  end
22
22
 
@@ -48,4 +48,46 @@ describe 'Validator' do
48
48
  end
49
49
  end
50
50
  end
51
+
52
+ describe 'new_version?' do
53
+ def dummy_method ; end
54
+ before_method(:dummy_method) { new_version?(Version.versions) }
55
+
56
+ context 'new version' do
57
+ before { $*[1] = 'v7-4-050' }
58
+
59
+ it 'success to run the method' do
60
+ expect(dummy_method).to be_nil
61
+ end
62
+ end
63
+
64
+ context 'version is installed' do
65
+ before { $*[1] = 'v7-4-103' }
66
+
67
+ it 'cannot run the method' do
68
+ expect(proc { dummy_method }).to raise_error
69
+ end
70
+ end
71
+ end
72
+
73
+ describe 'version_exist?' do
74
+ def dummy_method ; end
75
+ before_method(:dummy_method) { version_exist?(Version.versions) }
76
+
77
+ context 'version is installed' do
78
+ before { $*[1] = 'v7-4-103' }
79
+
80
+ it 'success to run the method' do
81
+ expect(dummy_method).to be_nil
82
+ end
83
+ end
84
+
85
+ context 'version is not installed' do
86
+ before { $*[1] = 'v7-4-050' }
87
+
88
+ it 'cannot run the method' do
89
+ expect(proc { dummy_method }).to raise_error
90
+ end
91
+ end
92
+ end
51
93
  end
data/spec/version_spec.rb CHANGED
@@ -3,13 +3,13 @@ require 'spec_helper'
3
3
  describe 'Version' do
4
4
  describe 'list' do
5
5
  it 'echo available vim versions' do
6
- expect(Version.list).to match(/start\n(v7-.+\n)+tip$/)
6
+ expect(Version.list.join("\n")).to match(/start\n(v7-.+\n)+tip$/)
7
7
  end
8
8
  end
9
9
 
10
10
  describe 'versions' do
11
11
  it 'echo installed vim versions' do
12
- expect(Version.versions).to eq("v7-3-969\nv7-4")
12
+ expect(Version.versions.join("\n")).to eq("v7-4-083\nv7-4-103")
13
13
  end
14
14
  end
15
15
  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.8 ruby lib
5
+ # stub: vvm-rb 0.0.9 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "vvm-rb"
9
- s.version = "0.0.8"
9
+ s.version = "0.0.9"
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-11-20"
13
+ s.date = "2013-11-27"
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.8
4
+ version: 0.0.9
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-11-20 00:00:00.000000000 Z
11
+ date: 2013-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake