vim-jar 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. data/Gemfile.lock +4 -1
  2. data/bin/vim-jar +1 -57
  3. data/bundler/ruby/1.8/bin/rake2thor +19 -0
  4. data/bundler/ruby/1.8/bin/thor +19 -0
  5. data/bundler/ruby/1.8/gems/thor-0.14.6/CHANGELOG.rdoc +103 -0
  6. data/bundler/ruby/1.8/gems/thor-0.14.6/LICENSE +20 -0
  7. data/bundler/ruby/1.8/gems/thor-0.14.6/README.md +307 -0
  8. data/bundler/ruby/1.8/gems/thor-0.14.6/Thorfile +24 -0
  9. data/bundler/ruby/1.8/gems/thor-0.14.6/bin/rake2thor +86 -0
  10. data/bundler/ruby/1.8/gems/thor-0.14.6/bin/thor +6 -0
  11. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/actions/create_file.rb +105 -0
  12. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/actions/create_link.rb +57 -0
  13. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/actions/directory.rb +93 -0
  14. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/actions/empty_directory.rb +134 -0
  15. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/actions/file_manipulation.rb +270 -0
  16. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/actions/inject_into_file.rb +109 -0
  17. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/actions.rb +314 -0
  18. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/base.rb +579 -0
  19. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/core_ext/file_binary_read.rb +9 -0
  20. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  21. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/core_ext/ordered_hash.rb +100 -0
  22. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/error.rb +30 -0
  23. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/group.rb +273 -0
  24. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/invocation.rb +168 -0
  25. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/parser/argument.rb +67 -0
  26. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/parser/arguments.rb +161 -0
  27. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/parser/option.rb +120 -0
  28. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/parser/options.rb +173 -0
  29. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/parser.rb +4 -0
  30. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/rake_compat.rb +66 -0
  31. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/runner.rb +309 -0
  32. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/shell/basic.rb +290 -0
  33. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/shell/color.rb +108 -0
  34. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/shell/html.rb +121 -0
  35. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/shell.rb +88 -0
  36. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/task.rb +114 -0
  37. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/util.rb +229 -0
  38. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor/version.rb +3 -0
  39. data/bundler/ruby/1.8/gems/thor-0.14.6/lib/thor.rb +334 -0
  40. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/actions/create_file_spec.rb +170 -0
  41. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/actions/directory_spec.rb +136 -0
  42. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/actions/empty_directory_spec.rb +98 -0
  43. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/actions/file_manipulation_spec.rb +310 -0
  44. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/actions/inject_into_file_spec.rb +135 -0
  45. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/actions_spec.rb +322 -0
  46. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/base_spec.rb +269 -0
  47. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/core_ext/hash_with_indifferent_access_spec.rb +43 -0
  48. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/core_ext/ordered_hash_spec.rb +115 -0
  49. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/application.rb +2 -0
  50. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/bundle/execute.rb +6 -0
  51. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/bundle/main.thor +1 -0
  52. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/doc/%file_name%.rb.tt +1 -0
  53. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/doc/README +3 -0
  54. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/doc/block_helper.rb +3 -0
  55. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/doc/components/.empty_directory +0 -0
  56. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/doc/config.rb +1 -0
  57. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/group.thor +114 -0
  58. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/invoke.thor +112 -0
  59. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/path with spaces +0 -0
  60. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/script.thor +184 -0
  61. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/fixtures/task.thor +10 -0
  62. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/group_spec.rb +178 -0
  63. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/invocation_spec.rb +100 -0
  64. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/parser/argument_spec.rb +47 -0
  65. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/parser/arguments_spec.rb +64 -0
  66. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/parser/option_spec.rb +202 -0
  67. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/parser/options_spec.rb +319 -0
  68. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/rake_compat_spec.rb +68 -0
  69. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/register_spec.rb +92 -0
  70. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/runner_spec.rb +210 -0
  71. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/shell/basic_spec.rb +223 -0
  72. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/shell/color_spec.rb +41 -0
  73. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/shell/html_spec.rb +27 -0
  74. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/shell_spec.rb +47 -0
  75. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/spec_helper.rb +54 -0
  76. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/task_spec.rb +69 -0
  77. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/thor_spec.rb +334 -0
  78. data/bundler/ruby/1.8/gems/thor-0.14.6/spec/util_spec.rb +163 -0
  79. data/bundler/ruby/1.8/specifications/thor-0.14.6.gemspec +48 -0
  80. data/lib/vim-jar/cli.rb +84 -67
  81. data/lib/vim-jar/config.rb +9 -0
  82. data/lib/vim-jar/installer/git.rb +8 -7
  83. data/lib/vim-jar/plugin.rb +61 -18
  84. data/lib/vim-jar/version.rb +1 -1
  85. data/lib/vim-jar.rb +1 -0
  86. data/spec/vim-jar/config_spec.rb +17 -0
  87. data/spec/vim-jar/git-config +16 -0
  88. data/spec/vim-jar/gitmodules +6 -0
  89. data/spec/vim-jar/plugin_spec.rb +46 -0
  90. data/vim-jar.gemspec +1 -0
  91. metadata +104 -9
data/lib/vim-jar/cli.rb CHANGED
@@ -1,96 +1,113 @@
1
1
  require 'vim-jar'
2
+
2
3
  module Vim
3
4
  module Jar
4
- class Cli
5
- class << self
6
- PATHOGEN_URL = "http://www.vim.org/scripts/download_script.php?src_id=12116"
7
- def init
8
- check!
9
- setup_pathogen unless File.exist?(config.pathogen_path)
10
- done
11
- end
5
+ class Cli < Thor
6
+ map "-T" => :list
7
+ PATHOGEN_URL = "http://www.vim.org/scripts/download_script.php?src_id=12116"
8
+
9
+ desc "init","init environment"
10
+ def init
11
+ check!
12
+ setup_pathogen unless File.exist?(config.pathogen_path)
13
+ done
14
+ end
12
15
 
13
- def install(plugin_name)
14
- check!
15
- plugin = ::Vim::Jar::Plugin.find(plugin_name)
16
- if plugin
17
- plugin.install
18
- else
19
- STDERR.puts "Can not find plugin '#{plugin_name}'"
20
- STDERR.puts "you can run 'vim-jar list' to show all the existing plugins"
21
- exit 1
22
- end
16
+ desc "install NAME", "install plugin"
17
+ def install(plugin_name)
18
+ check!
19
+ plugin = ::Vim::Jar::Plugin.find(plugin_name)
20
+ if plugin
21
+ plugin.install
22
+ else
23
+ STDERR.puts "Can not find plugin '#{plugin_name}'"
24
+ STDERR.puts "you can run 'vim-jar list' to show all the existing plugins"
25
+ exit 1
23
26
  end
27
+ end
24
28
 
25
- def list(options={})
26
- str = ::Vim::Jar::Plugin.plugins.map do |plugin_attr|
27
- "#{plugin_attr['name']}: #{plugin_attr['desc']}"
28
- end.join("\n")
29
- STDOUT.puts str
30
- end
29
+ desc "list", "list all avaliable plugins"
30
+ def list
31
+ str = ::Vim::Jar::Plugin.plugins.map do |plugin_attr|
32
+ "#{plugin_attr['name']}: #{plugin_attr['desc']}"
33
+ end.join("\n")
34
+ STDOUT.puts str
35
+ end
31
36
 
32
- def import(github_url)
33
- begin
34
- ::Vim::Jar::Importer.import(github_url)
35
- STDOUT.puts "'#{github_url}' has import to our local cache"
36
- rescue ImportError => e
37
- STDERR.puts "Can not import '#{github_url}', because #{e.message}"
38
- end
37
+ desc "import", "import plugin info from github.com"
38
+ def import(github_url)
39
+ begin
40
+ ::Vim::Jar::Importer.import(github_url)
41
+ STDOUT.puts "'#{github_url}' has import to our local cache"
42
+ rescue ImportError => e
43
+ STDERR.puts "Can not import '#{github_url}', because #{e.message}"
39
44
  end
45
+ end
40
46
 
41
- def installed
42
- STDOUT.puts ::Vim::Jar::Plugin.installed.join("\n")
43
- end
47
+ desc "installed", "list all installed plugins"
48
+ def installed
49
+ STDOUT.puts ::Vim::Jar::Plugin.installed.join("\n")
50
+ end
44
51
 
45
- private
46
- def config
47
- @config ||= Vim::Jar.config
52
+ desc "uninstall", "uninstall installed plugin"
53
+ def uninstall(name)
54
+ if ::Vim::Jar::Plugin.installed.include?(name)
55
+ ::Vim::Jar::Plugin.uninstall(name)
56
+ STDOUT.puts "plugin #{name} has been already remove from #{config.bundle_home.join(name)}"
57
+ else
58
+ STDERR.puts "You didn't install plugin named #{name}"
48
59
  end
60
+
61
+ end
49
62
 
50
- def check!
51
- begin
52
- config.check
53
- rescue InitError => e
54
- STDERR.puts "Can not init environment because of #{e.message}"
55
- exit 1
56
- end
57
- end
63
+ private
64
+ def config
65
+ @config ||= Vim::Jar.config
66
+ end
58
67
 
59
- def git_init
60
- #TODO will support init git repo
68
+ def check!
69
+ begin
70
+ config.check
71
+ rescue InitError => e
72
+ STDERR.puts "Can not init environment because of #{e.message}"
73
+ exit 1
61
74
  end
75
+ end
62
76
 
63
- def setup_pathogen
64
- config = Vim::Jar.config
65
- FileUtils.mkdir_p(config.autoload_home) if !File.exist?(config.autoload_home)
66
- install_pathogen(config)
67
- end
77
+ def git_init
78
+ #TODO will support init git repo
79
+ end
80
+
81
+ def setup_pathogen
82
+ config = Vim::Jar.config
83
+ FileUtils.mkdir_p(config.autoload_home) if !File.exist?(config.autoload_home)
84
+ install_pathogen(config)
85
+ end
86
+
87
+ def install_pathogen(config)
88
+ system("curl #{PATHOGEN_URL} -o #{config.pathogen_path}")
89
+ STDOUT.puts <<-EOF
68
90
 
69
- def install_pathogen(config)
70
- system("curl #{PATHOGEN_URL} -o #{config.pathogen_path}")
71
- STDOUT.puts <<-EOF
91
+ Pathogen is installed into #{config.pathogen_path}.
72
92
 
73
- Pathogen is installed into #{config.pathogen_path}.
93
+ NOTICE: you need copy line below into #{config.vimrc_path}.
74
94
 
75
- NOTICE: you need copy line below into #{config.vimrc_path}.
76
-
77
95
  call pathogen#runtime_append_all_bundles()
78
96
 
79
- EOF
80
- end
97
+ EOF
98
+ end
81
99
 
82
- def done
83
- #TODO improve finish message
84
- STDOUT.puts <<-EOF
100
+ def done
101
+ #TODO improve finish message
102
+ STDOUT.puts <<-EOF
85
103
 
86
- Congratulation! vim-jar already initialized your environment.
104
+ Congratulation! vim-jar already initialized your environment.
87
105
 
88
- Try:
106
+ Try:
89
107
 
90
108
  vim-jar install [PLUGIN_NAME]
91
109
 
92
- EOF
93
- end
110
+ EOF
94
111
  end
95
112
  end
96
113
  end
@@ -20,6 +20,14 @@ module Vim
20
20
  @under_git ||= File.exist?(vim_home.join(".git"))
21
21
  end
22
22
 
23
+ def gitmodules_file_path
24
+ vim_home.join(".gitmodules")
25
+ end
26
+
27
+ def gitconfig_file_path
28
+ vim_home.join(".git",'config')
29
+ end
30
+
23
31
  def bundle_home
24
32
  Pathname.new(vim_home.join("bundle"))
25
33
  end
@@ -36,6 +44,7 @@ module Vim
36
44
  @yaml_path ||= File.expand_path("./plugins.yml",File.dirname(__FILE__))
37
45
  end
38
46
 
47
+
39
48
  def check
40
49
  %w[vim_home vimrc_path].each do |method_name|
41
50
  path = self.send(method_name)
@@ -1,15 +1,16 @@
1
1
  module Vim
2
- module Jar
3
- module Installer
2
+ module Jar
3
+ module Installer
4
4
  module Git
5
5
  def install_to(source, output_path)
6
- Dir.chdir(config.vim_home)
7
- system("git submodule add #{source} #{Pathname.new(output_path).relative_path_from(config.vim_home)}")
8
- system("git submodule init")
6
+ Dir.chdir(config.vim_home) do
7
+ system("git submodule add #{source} #{Pathname.new(output_path).relative_path_from(config.vim_home)}")
8
+ system("git submodule init")
9
+ end
9
10
  end
10
11
 
11
- def config
12
- ::Vim::Jar::Config.instance
12
+ def config
13
+ ::Vim::Jar::Config.instance
13
14
  end
14
15
  end
15
16
  end
@@ -1,11 +1,11 @@
1
1
  module Vim
2
- module Jar
2
+ module Jar
3
3
  module Plugin
4
4
  autoload :Git, 'vim-jar/plugin/git.rb'
5
5
 
6
- def self.find(plugin_name)
6
+ def self.find(plugin_name)
7
7
  #TODO use sqlite in the future
8
- plugin_attrs = plugins.detect{|p| p["name"].to_s.downcase == plugin_name.to_s.downcase }
8
+ plugin_attrs = plugins.detect { |p| p["name"].to_s.downcase == plugin_name.to_s.downcase }
9
9
  build(plugin_attrs)
10
10
  end
11
11
 
@@ -14,52 +14,95 @@ module Vim
14
14
  if !File.exist? config.yaml_path
15
15
  FileUtils.touch config.yaml_path
16
16
  @plugins = []
17
- else
18
- @plugins = YAML.load_file(config.yaml_path) || []
17
+ else
18
+ @plugins = YAML.load_file(config.yaml_path) || []
19
19
  end
20
20
  @plugins
21
21
  end
22
22
 
23
- def self.exist? name
23
+ def self.exist? name
24
24
  #OPTIMIZE
25
25
  @exist_list ||= {}
26
26
  return @exist_list[name] if @exist_list.has_key? name
27
- result = self.plugins.any? {|p| p["name"].strip.downcase == name.strip.downcase}
27
+ result = self.plugins.any? { |p| p["name"].strip.downcase == name.strip.downcase }
28
28
  @exist_list[name] = result
29
29
  result
30
30
  end
31
31
 
32
- def self.insert(attrs)
32
+ def self.insert(attrs)
33
33
  #OPTIMIZE
34
34
  if self.exist? attrs["name"]
35
35
  return false
36
- else
36
+ else
37
37
  self.plugins << attrs
38
38
  return true
39
39
  end
40
40
  end
41
41
 
42
- def installed
43
- @installed ||= Dir[config.bundle_home.join("*")].map { |bundle_path| File.basename(bundle_path)}
42
+ def self.installed
43
+ @installed ||= Dir[config.bundle_home.join("*")].map { |bundle_path| File.basename(bundle_path) }
44
44
  end
45
45
 
46
- def self.reset
46
+ def self.uninstall(name)
47
+ remove_ref_from_gitmodules(name)
48
+ remove_ref_from_git_config(name)
49
+ remove_from_cache(name)
50
+ end
51
+
52
+ def self.remove_from_cache(name)
53
+ Dir.chdir(config.vim_home) do
54
+ system("git rm --cached bundle/#{name}")
55
+ end
56
+ end
57
+
58
+ def self.remove_ref_from_gitmodules(name)
59
+ f = File.new(config.gitmodules_file_path)
60
+ lines = f.lines.to_a
61
+ lines.delete_if do |x|
62
+ x =~ /bundle\/#{name}/ || x =~ /#{name}\.git$/
63
+ end
64
+ f.close
65
+
66
+ File.open(config.gitmodules_file_path, "w") do |ff|
67
+ lines.each do |l|
68
+ ff.puts l
69
+ end
70
+ end
71
+
72
+ end
73
+
74
+ def self.remove_ref_from_git_config(name)
75
+ f = File.new(config.gitconfig_file_path)
76
+ lines = f.lines.to_a
77
+ lines.delete_if do |x|
78
+ x =~ /bundle\/#{name}/ || x =~ /#{name}\.git$/
79
+ end
80
+ f.close
81
+
82
+ File.open(config.gitconfig_file_path, "w") do |ff|
83
+ lines.each do |l|
84
+ ff.puts l
85
+ end
86
+ end
87
+ end
88
+
89
+ def self.reset
47
90
  self.instance_variable_set("@plugins", nil)
48
91
  self.plugins
49
92
  end
50
93
 
51
- def self.config
94
+ def self.config
52
95
  ::Vim::Jar::Config.instance
53
96
  end
54
97
 
55
98
  def self.build(plugin_attrs)
56
99
  return nil unless plugin_attrs
57
- type = plugin_attrs["type"]
100
+ type = plugin_attrs["type"]
58
101
  case type
59
- when "git"
60
- ::Vim::Jar::Plugin::Git.new(plugin_attrs)
61
- else
62
- nil
102
+ when "git"
103
+ ::Vim::Jar::Plugin::Git.new(plugin_attrs)
104
+ else
105
+ nil
63
106
  end
64
107
  end
65
108
  end
@@ -1,5 +1,5 @@
1
1
  module Vim
2
2
  module Jar
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
data/lib/vim-jar.rb CHANGED
@@ -2,6 +2,7 @@ require 'pathname'
2
2
  require 'fileutils'
3
3
  require 'yaml'
4
4
  require 'curb'
5
+ require 'thor'
5
6
 
6
7
  module Vim
7
8
  module Jar
@@ -49,6 +49,23 @@ describe Vim::Jar::Config do
49
49
  end
50
50
  end
51
51
 
52
+ context ".gitmodules_file_path" do
53
+ it "should be in .vim/.gitmodules" do
54
+ path = Pathname.new(".")
55
+ mock(config).vim_home { path }
56
+ config.gitmodules_file_path.to_s.should == path.join(".gitmodules").to_s
57
+ end
58
+ end
59
+
60
+ context ".gitconfig_file_path" do
61
+ it "should be in .vim/.git/config" do
62
+ path = Pathname.new(".")
63
+ mock(config).vim_home { path }
64
+ config.gitconfig_file_path.to_s.should == path.join(".git/config").to_s
65
+ end
66
+ end
67
+
68
+
52
69
  context ".check" do
53
70
  it "should raise exception if folder check not pass" do
54
71
  mock(File).exist?(anything) { false }
@@ -0,0 +1,16 @@
1
+ [core]
2
+ repositoryformatversion = 0
3
+ filemode = true
4
+ bare = false
5
+ logallrefupdates = true
6
+ ignorecase = true
7
+ [remote "origin"]
8
+ fetch = +refs/heads/*:refs/remotes/origin/*
9
+ url = git@github.com:allenwei/vim-config.git
10
+ [branch "master"]
11
+ remote = origin
12
+ merge = refs/heads/master
13
+ [submodule "bundle/vim-rails"]
14
+ url = git://github.com/tpope/vim-rails.git
15
+ [submodule "bundle/VimClojure"]
16
+ url = git://github.com/vim-scripts/VimClojure.git
@@ -0,0 +1,6 @@
1
+ [submodule "bundle/vim-cucumber"]
2
+ path = bundle/vim-cucumber
3
+ url = git://github.com/tpope/vim-cucumber.git
4
+ [submodule "bundle/vim-afterimage"]
5
+ path = bundle/vim-afterimage
6
+ url = git://github.com/tpope/vim-afterimage.git
@@ -36,4 +36,50 @@ describe Vim::Jar::Plugin do
36
36
  plugin.url.should == "git://github.com/tpope/vim-rails.git"
37
37
  end
38
38
  end
39
+
40
+ context ".remove_ref_from_gitmodules" do
41
+ before(:each) do
42
+ @gitmodules_file_path = File.expand_path("./gitmodules", File.dirname(__FILE__))
43
+ @old_str = File.read @gitmodules_file_path
44
+ stub(Vim::Jar::Plugin.config).gitmodules_file_path { @gitmodules_file_path }
45
+ end
46
+
47
+ after(:each) do
48
+ File.open(@gitmodules_file_path,"w+") do |f|
49
+ f.puts @old_str
50
+ end
51
+ end
52
+
53
+ it "should remove lines include plugin name" do
54
+ Vim::Jar::Plugin.remove_ref_from_gitmodules("vim-cucumber")
55
+ new_str = File.read @gitmodules_file_path
56
+ new_str.split("\n").should have(3).items
57
+ end
58
+ end
59
+
60
+
61
+ context ".remove_ref_from_gitmodules" do
62
+ before(:each) do
63
+ @gitconfig_file_path = File.expand_path("./git-config", File.dirname(__FILE__))
64
+ @old_str = File.read @gitconfig_file_path
65
+ stub(Vim::Jar::Plugin.config).gitconfig_file_path { @gitconfig_file_path }
66
+ end
67
+
68
+ after(:each) do
69
+ File.open(@gitconfig_file_path, "w+") do |f|
70
+ f.puts @old_str
71
+ end
72
+ end
73
+
74
+ it "should remove lines include plugin name" do
75
+ Vim::Jar::Plugin.remove_ref_from_git_config("vim-rails")
76
+ new_str = File.read @gitconfig_file_path
77
+ new_str.should match /\[core\]/
78
+ new_str.should match /\[remote \"origin\"\]/
79
+ new_str.should match /\[branch \"master\"\]/
80
+ new_str.should match /\[submodule \"bundle\/VimClojure\"\]/
81
+ new_str.should_not match /vim-rails/
82
+ end
83
+ end
84
+
39
85
  end
data/vim-jar.gemspec CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
 
20
20
  s.add_runtime_dependency('curb')
21
+ s.add_runtime_dependency('thor')
21
22
  s.add_development_dependency('rspec')
22
23
  s.add_development_dependency('rr')
23
24
  s.add_development_dependency('fuubar')