vimmer 0.1.0 → 0.2.0

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.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@ pkg/*
2
2
  *.gem
3
3
  .bundle
4
4
  tmp/
5
+ log
data/.rspec CHANGED
@@ -1,2 +1 @@
1
1
  --color
2
- --format Fuubar
data/Gemfile.lock CHANGED
@@ -1,25 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vimmer (0.0.1)
4
+ vimmer (0.1.0)
5
5
  thor
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- aruba (0.2.6)
10
+ addressable (2.2.2)
11
+ aruba (0.2.7)
11
12
  background_process
12
- cucumber (~> 0.9.4)
13
- autotest (4.4.2)
13
+ cucumber (~> 0.10.0)
14
+ autotest (4.4.5)
14
15
  autotest-fsevent (0.2.3)
15
16
  sys-uname
16
17
  autotest-growl (0.2.6)
17
18
  background_process (1.2)
18
- builder (2.1.2)
19
- cucumber (0.9.4)
20
- builder (~> 2.1.2)
19
+ bourne (1.0)
20
+ mocha (= 0.9.8)
21
+ builder (3.0.0)
22
+ crack (0.1.8)
23
+ cucumber (0.10.0)
24
+ builder (>= 2.1.2)
21
25
  diff-lcs (~> 1.1.2)
22
- gherkin (~> 2.2.9)
26
+ gherkin (~> 2.3.2)
23
27
  json (~> 1.4.6)
24
28
  term-ansicolor (~> 1.0.5)
25
29
  diff-lcs (1.1.2)
@@ -28,40 +32,45 @@ GEM
28
32
  rspec (~> 2.0)
29
33
  rspec-instafail (~> 0.1.4)
30
34
  ruby-progressbar (~> 0.0.9)
31
- gherkin (2.2.9)
35
+ gherkin (2.3.2)
32
36
  json (~> 1.4.6)
33
37
  term-ansicolor (~> 1.0.5)
34
38
  json (1.4.6)
35
- rr (1.0.2)
36
- rspec (2.0.1)
37
- rspec-core (~> 2.0.1)
38
- rspec-expectations (~> 2.0.1)
39
- rspec-mocks (~> 2.0.1)
40
- rspec-core (2.0.1)
41
- rspec-expectations (2.0.1)
42
- diff-lcs (>= 1.1.2)
39
+ mocha (0.9.8)
40
+ rake
41
+ rake (0.8.7)
42
+ rspec (2.3.0)
43
+ rspec-core (~> 2.3.0)
44
+ rspec-expectations (~> 2.3.0)
45
+ rspec-mocks (~> 2.3.0)
46
+ rspec-core (2.3.1)
47
+ rspec-expectations (2.3.0)
48
+ diff-lcs (~> 1.1.2)
43
49
  rspec-instafail (0.1.4)
44
- rspec-mocks (2.0.1)
45
- rspec-core (~> 2.0.1)
46
- rspec-expectations (~> 2.0.1)
50
+ rspec-mocks (2.3.0)
47
51
  ruby-progressbar (0.0.9)
48
52
  sys-uname (0.8.4)
49
53
  term-ansicolor (1.0.5)
50
- thor (0.14.4)
54
+ thor (0.14.6)
55
+ webmock (1.6.1)
56
+ addressable (>= 2.2.2)
57
+ crack (>= 0.1.7)
51
58
 
52
59
  PLATFORMS
53
60
  ruby
54
61
 
55
62
  DEPENDENCIES
56
- aruba
63
+ aruba (= 0.2.7)
57
64
  autotest
58
65
  autotest-fsevent
59
66
  autotest-growl
67
+ bourne
60
68
  bundler (>= 1.0.0)
61
- cucumber
69
+ cucumber (= 0.10.0)
62
70
  fakefs
63
71
  fuubar
64
- rr
65
- rspec (~> 2.0.0)
72
+ mocha
73
+ rspec (~> 2.3.0)
66
74
  thor
67
75
  vimmer!
76
+ webmock
data/README.mdown CHANGED
@@ -5,7 +5,7 @@ Vimmer makes it easy to install, remove and update Vim plugins from the followin
5
5
  - Github
6
6
  - Vim.org (coming soon)
7
7
 
8
- N.B. Vimmer is a work in process. This is an early alpha release for those who want to give it a try and are willing to submit feedback. I am offering it with NO GUARANTEES. If you're still with me, you can submit your feedback at [https://github.com/densitypop/Vimmer/issues](https://github.com/densitypop/Vimmer/issues). Thank you!
8
+ N.B. Vimmer is a work in progress. This is an early alpha release for those who are willing to try it and submit feedback. I am offering it with NO GUARANTEES. If you're still with me, please submit your feedback at [https://github.com/densitypop/Vimmer/issues](https://github.com/densitypop/Vimmer/issues). Thank you!
9
9
 
10
10
  ## Installation and Usage ##
11
11
 
@@ -21,11 +21,15 @@ Vimmer depends on the Pathogen plugin for managing Vim's runtime path. Using Pat
21
21
 
22
22
  Restart Vim and you're done! For details on installing Pathogen see [Pathogen on Vim.org](http://www.vim.org/scripts/script.php?script_id=2332). Note: I am planning to automatically setup Pathogen during the Vimmer install process.
23
23
 
24
+ ### Documentation ###
25
+
26
+ Vimmer is documented using Cucumber features and hosted on [Relish](http://www.relishapp.com). [View the documentation.](http://relishapp.com/joefiorini/vimmer)
27
+
24
28
  ## Contributing to Vimmer ##
25
29
 
26
30
  1. Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
27
31
  2. Check out the [issue tracker](http://github.com/densitypop/Vimmer/issues) to make sure someone already hasn't requested it and/or contributed it
28
- 3. Fork the project
29
- 4. Write some tests/Cukes; implement until you're happy. This is important to make sure I don't accidentally break your fix in the future
32
+ 3. Fork the project; make sure you're working in your own branch off the develop branch
33
+ 4. Write some tests/Cukes; implement until you're happy and the tests pass. This is important to make sure I don't accidentally break your fix in the future
30
34
  5. Send me a pull request
31
35
 
data/cucumber.yml CHANGED
@@ -1,4 +1,4 @@
1
- default: --format progress features
1
+ default: --format progress features --tags ~@wip
2
2
  html_report: --format progress --format html --out=features_report.html features
3
3
  wip: --tags @wip:1 --wip
4
4
  autotest: --color
@@ -0,0 +1 @@
1
+ {"2975":"fugitive.vim"}
@@ -3,15 +3,14 @@ Feature: Install plugin
3
3
  Background:
4
4
  Given a directory named ".vimmer"
5
5
  And a bundle path set for my system
6
+ And I have no plugins installed
6
7
 
7
8
  Scenario: Install from Github
8
- Given I have no plugins installed
9
9
  When I successfully run "vimmer install 'https://github.com/tpope/vim-awesomemofo.git'"
10
10
  Then a plugin named "vim-awesomemofo" should be installed
11
11
  And the stdout should contain "vim-awesomemofo has been installed"
12
12
 
13
13
  Scenario: Install from Github with bad URL
14
- Given I have no plugins installed
15
14
  When I run "vimmer install 'https://github.com/tpope/not-found.git'"
16
15
  Then I should still not have any plugins installed
17
16
  And it should fail with:
@@ -20,10 +19,32 @@ Feature: Install plugin
20
19
  """
21
20
 
22
21
  Scenario: Install from Github with a non-Github URL
23
- Given I have no plugins installed
24
22
  When I run "vimmer install 'http://example.com/bad'"
25
23
  Then I should still not have any plugins installed
26
24
  And it should fail with:
27
25
  """
28
26
  The URL http://example.com/bad is invalid.
29
27
  """
28
+
29
+ Scenario Outline: Install from Github with a front-end Github URL
30
+ When I successfully run "vimmer install '<URL>'"
31
+ Then a plugin named "vim-awesomemofo" should be installed
32
+ And the stdout should contain "vim-awesomemofo has been installed"
33
+
34
+ Examples:
35
+ | URL |
36
+ | http://github.com/tpope/vim-awesomemofo |
37
+ | https://github.com/tpope/vim-awesomemofo |
38
+
39
+ Scenario: Accept URLs with a "."
40
+ When I run "vimmer install 'http://github.com/tpope/awesomemofo.vim'"
41
+ Then it should pass with:
42
+ """
43
+ awesomemofo.vim has been installed
44
+ """
45
+
46
+ @wip
47
+ Scenario: Install from vim.org
48
+ When I successfully run "vimmer install http://www.vim.org/scripts/script.php?script_id=2975"
49
+ Then a plugin named "fugitive.vim" should be installed
50
+ And the stdout should contain "fugitive.vim has been installed"
@@ -1,6 +1,6 @@
1
1
  Then /^a plugin named "([^"]*)" should be installed$/ do |name|
2
2
  @vimmer.installed_plugins.should include(name)
3
- @vimmer.plugin_store[name].should =~ %r{https://github.com/tpope/vim-awesomemofo.git}
3
+ @vimmer.plugin_store[name].should =~ %r{https://github.com/.*/#{name}\.git}
4
4
  end
5
5
 
6
6
  Then /^I should still not have any plugins installed$/ do
@@ -1,3 +1,7 @@
1
+ Before do
2
+ @aruba_timeout_seconds = 20
3
+ end
4
+
1
5
  After do
2
6
  FileUtils.rm_rf("tmp/aruba/bundle")
3
7
  end
@@ -1,5 +1,7 @@
1
- require 'aruba'
1
+ require 'aruba/cucumber'
2
+ require 'webmock'
3
+ require File.dirname(__FILE__) + '/stubbed_http_requests'
2
4
 
3
- ENV['PATH'] = File.expand_path(File.dirname(__FILE__)) + ":" + ENV['PATH']
5
+ ENV['RUBYOPT'] = "-r#{File.expand_path(File.join(File.dirname(__FILE__), 'stub-commands.rb'))} -rwebmock -r#{File.expand_path(File.join(File.dirname(__FILE__), 'stubbed_http_requests'))} #{ENV['RUBYOPT']}"
4
6
  ENV['VIMMER_HOME'] = File.expand_path(File.join(File.dirname(__FILE__),
5
7
  %w(.. .. tmp aruba .vimmer)))
@@ -0,0 +1,29 @@
1
+ # redefine ` to stub the curl and git commands
2
+ module Kernel
3
+ alias_method :real_backtick, :`
4
+ def `(command)
5
+ case command
6
+ when /^curl (.+)/
7
+ if $1 =~ /\.git\b|not-found/
8
+ '404'
9
+ else
10
+ '200'
11
+ end
12
+
13
+ when /^git (.+)/
14
+ git_arguments = $1
15
+ # git clone <url> (<dir>)
16
+ if git_arguments =~ /^clone \S+ (.+)/
17
+ require 'fileutils'
18
+ FileUtils.mkdir_p $1
19
+ else
20
+ puts 'delegating to git'
21
+ real_backtick "git #{git_arguments}"
22
+ end
23
+
24
+ else
25
+ real_backtick command
26
+ end
27
+ end
28
+ end
29
+
@@ -0,0 +1,6 @@
1
+ include WebMock::API
2
+
3
+ stub_request(:get, "http://www.vim-scripts.org/api/script_ids.json").
4
+ with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
5
+ to_return(:status => 200, :body => File.read(File.dirname(__FILE__) + "/../fixtures/script_ids.json"))
6
+
data/lib/vimmer.rb CHANGED
@@ -15,6 +15,16 @@ module Vimmer
15
15
 
16
16
  end
17
17
 
18
+ class InstallerNotFoundError < StandardError
19
+ attr_accessor :path
20
+
21
+ def initialize(path)
22
+ @path = path
23
+ end
24
+
25
+ end
26
+
27
+
18
28
  def bundle_path
19
29
  settings[:bundle_path]
20
30
  end
data/lib/vimmer/cli.rb CHANGED
@@ -8,8 +8,15 @@ module Vimmer
8
8
  def install(path)
9
9
  setup
10
10
  begin
11
- installer = Vimmer::Installers::Github.new(:path => path)
11
+ installer = Vimmer::Installers.for_url(path)
12
+ # TODO: Make this consistent with VimDotOrg installer
13
+ if installer == Vimmer::Installers::Github
14
+ installer = installer.new(:path => path)
15
+ end
12
16
  installer.install
17
+ rescue Vimmer::InstallerNotFoundError => e
18
+ $stderr.puts "The URL #{e.path} is invalid."
19
+ exit 1
13
20
  rescue Vimmer::InvalidPathError => e
14
21
  $stderr.puts "The URL #{e.path} is invalid."
15
22
  exit 1
@@ -1,7 +1,21 @@
1
1
  module Vimmer
2
2
  module Installers
3
+ extend self
4
+
5
+ autoload :Github, 'vimmer/installers/github'
6
+ autoload :VimDotOrg, 'vimmer/installers/vim_dot_org'
7
+
8
+
9
+ def for_url(url)
10
+ if Github.match?(url)
11
+ Github
12
+ elsif VimDotOrg.match?(url)
13
+ VimDotOrg.for_url(url)
14
+ else
15
+ raise Vimmer::InstallerNotFoundError.new(url)
16
+ end
17
+ end
3
18
 
4
- autoload :Github, 'vimmer/installers/github'
5
19
 
6
20
  end
7
21
  end
@@ -1,5 +1,10 @@
1
1
  module Vimmer
2
2
  module Installers
3
+
4
+ GITHUB_GIT_PATH_TEMPLATE = "https://github.com/%s/%s.git"
5
+ GITHUB_GIT_URL_PATTERN = %r{^https://github.com/[a-zA-Z0-9\-_\+%]+/([a-zA-Z0-9\-_\+\.]+).git$}
6
+ GITHUB_PUBLIC_URL_PATTERN = %r{^https?://github.com/([a-zA-Z0-9\-_\+%]+)/([a-zA-Z0-9\-_\+\.]+[^.git])$}
7
+
3
8
  class Github
4
9
  attr_reader :path, :plugin_name
5
10
 
@@ -24,8 +29,14 @@ module Vimmer
24
29
 
25
30
 
26
31
  def uninstall
27
- FileUtils.rm_rf(File.join(Vimmer.bundle_path, plugin_name))
28
- Vimmer.remove_plugin(plugin_name)
32
+ plugin_path = File.join(Vimmer.bundle_path, plugin_name)
33
+ if File.directory? plugin_path
34
+ FileUtils.rm_rf(plugin_path)
35
+ Vimmer.remove_plugin(plugin_name)
36
+ puts "#{plugin_name} has been uninstalled"
37
+ else
38
+ raise Vimmer::PluginNotFoundError
39
+ end
29
40
  end
30
41
 
31
42
 
@@ -34,6 +45,16 @@ module Vimmer
34
45
  end
35
46
 
36
47
 
48
+ def self.match?(url)
49
+ is_github_url?(url)
50
+ end
51
+
52
+ def self.is_github_url?(url)
53
+ !(GITHUB_PUBLIC_URL_PATTERN.match(url) ||
54
+ GITHUB_GIT_URL_PATTERN.match(url)).nil?
55
+ end
56
+
57
+
37
58
  private
38
59
 
39
60
  def git_clone(path, install_to)
@@ -42,7 +63,11 @@ module Vimmer
42
63
 
43
64
 
44
65
  def initialize_with_path(path)
45
- raise Vimmer::InvalidPathError.new(path) unless path =~ %r{^https://github.com/[a-zA-Z0-9\-_\+%]+/([a-zA-Z0-9\-_\+]+).git$}
66
+
67
+ path = public_path_to_git_path($1, $2) if path =~ GITHUB_PUBLIC_URL_PATTERN
68
+
69
+ raise Vimmer::InvalidPathError.new(path) unless path =~ GITHUB_GIT_URL_PATTERN
70
+
46
71
  @plugin_name = $1
47
72
  @path = path
48
73
  end
@@ -53,10 +78,16 @@ module Vimmer
53
78
  @plugin_name = name
54
79
  end
55
80
 
81
+
56
82
  def remove_extension(path)
57
83
  path.gsub(/\.git$/, '')
58
84
  end
59
85
 
86
+
87
+ def public_path_to_git_path(user, repo)
88
+ GITHUB_GIT_PATH_TEMPLATE % [user, repo]
89
+ end
90
+
60
91
  end
61
92
  end
62
93
  end
@@ -0,0 +1,46 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module Vimmer
5
+ module Installers
6
+
7
+ VIM_DOT_ORG_URL_PATTERN = %r{https?://(?:www\.)?vim\.org/scripts/script.php\?script_id=(\d{1,5})}
8
+
9
+ class VimDotOrg
10
+ attr_reader :path, :plugin_name, :script_id
11
+
12
+
13
+ def self.match?(url)
14
+ !(url =~ VIM_DOT_ORG_URL_PATTERN).nil?
15
+ end
16
+
17
+ def self.for_url(path)
18
+
19
+ m = VIM_DOT_ORG_URL_PATTERN.match(path)
20
+ script_id = m[1]
21
+
22
+ raise Vimmer::PluginNotFoundError unless repository.key?(script_id)
23
+
24
+ script_name = repository[script_id]
25
+ github_path_template = "https://github.com/vim-scripts/%s.git"
26
+
27
+ github_path = github_path_template % [script_name]
28
+
29
+ Github.new(:path => github_path)
30
+ end
31
+
32
+ private
33
+
34
+ def self.repository
35
+ @repository ||= JSON.parse(Net::HTTP.get(repository_uri))
36
+ end
37
+
38
+ def self.repository_uri
39
+ URI.parse("http://vim-scripts.org/api/script_ids.json")
40
+ end
41
+
42
+
43
+ end
44
+
45
+ end
46
+ end
@@ -6,13 +6,13 @@ module Vimmer
6
6
 
7
7
 
8
8
  def initialize
9
- @config = load_config(config_file)
9
+ @config = defaults.merge(load_config(config_file))
10
10
  end
11
11
 
12
12
 
13
13
  def [](key)
14
- value = @config[key.to_s]
15
- if value && (File.directory?(value) || File.file?(value))
14
+ value = File.expand_path(@config[key.to_s])
15
+ if value && File.exists?(value)
16
16
  Pathname.new(value)
17
17
  else
18
18
  value
@@ -85,12 +85,18 @@ module Vimmer
85
85
  end
86
86
 
87
87
  def load_config(config_file)
88
- if File.exist?(config_file)
88
+ config_file = File.expand_path(config_file)
89
+ if config_file && File.exist?(config_file.to_s)
89
90
  YAML.load_file(config_file)
90
91
  else
91
92
  {}
92
93
  end
93
94
  end
94
95
 
96
+
97
+ def defaults
98
+ { "bundle_path" => "~/.vim/bundle" }
99
+ end
100
+
95
101
  end
96
102
  end
@@ -1,3 +1,3 @@
1
1
  module Vimmer
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,20 @@
1
+ #!/bin/bash
2
+
3
+ counter=1
4
+
5
+ rake > /dev/null 2>&1
6
+
7
+ while [[ $? -eq 0 ]]; do
8
+ echo "Count: $counter"
9
+ let counter=$counter+1
10
+ rake > /dev/null 2>&1
11
+ done
12
+
13
+ message="Ran $counter times before failure"
14
+
15
+ if [[ $1 -eq "-s" ]]; then
16
+ say $message
17
+ fi
18
+
19
+ echo $message
20
+ echo "$message\n" >> log/failures.log
@@ -6,16 +6,25 @@ describe "When installing from Github" do
6
6
 
7
7
  FOUND_URL = "https://github.com/tpope/vim-awesomemofo.git"
8
8
  NOT_FOUND_URL = "https://github.com/tpope/not-found.git"
9
+ MALFORMED_URL = "https://foo.com/bar"
10
+
11
+ RSpec::Matchers.define :be_a_valid_github_url do |expected|
12
+ match do
13
+ Github.match?(expected) == true
14
+ end
15
+ end
9
16
 
10
17
  context "with a non-existant URL" do
11
18
 
12
19
  let(:installer) { Github.new(:path => NOT_FOUND_URL) }
13
20
 
14
21
  before do
15
- stub(installer).path_exists? { false }
16
- stub(installer).git_clone
22
+ installer.stubs(:path_exists?).returns(false)
23
+ installer.stubs(:git_clone)
17
24
  end
18
25
 
26
+ it { should be_a_valid_github_url(NOT_FOUND_URL) }
27
+
19
28
  specify "the installer should raise an exception" do
20
29
  lambda { installer.install }.should raise_error(Vimmer::PluginNotFoundError)
21
30
  end
@@ -27,10 +36,12 @@ describe "When installing from Github" do
27
36
  let(:installer) { Github.new(:path => FOUND_URL) }
28
37
 
29
38
  before do
30
- stub(installer).git_clone
31
- stub(installer).path_exists? { true }
39
+ installer.stubs(:git_clone)
40
+ installer.stubs(:path_exists?).returns(true)
32
41
  end
33
42
 
43
+ it { should be_a_valid_github_url(FOUND_URL) }
44
+
34
45
  specify "the installer should not raise an exception" do
35
46
  lambda { installer.install }.should_not raise_error
36
47
  end
@@ -43,10 +54,13 @@ describe "When installing from Github" do
43
54
 
44
55
  context "with a malformed URL" do
45
56
 
46
- subject { Github.new(:path => "https://foo.com/bar") }
57
+ let(:installer) { Github.new(:path => MALFORMED_URL) }
58
+
59
+
60
+ it { should_not be_a_valid_github_url(MALFORMED_URL) }
47
61
 
48
62
  specify "the installer should raise an exception" do
49
- lambda { subject }.should raise_error(Vimmer::InvalidPathError)
63
+ lambda { installer }.should raise_error(Vimmer::InvalidPathError)
50
64
  end
51
65
 
52
66
  end
@@ -60,8 +74,8 @@ describe "When installing from Github" do
60
74
 
61
75
  installer = Github.new(:path => FOUND_URL)
62
76
 
63
- stub(installer).path_exists? { true }
64
- stub(installer).git_clone
77
+ installer.stubs(:path_exists?).returns(true)
78
+ installer.stubs(:git_clone)
65
79
 
66
80
  installer.install
67
81
 
@@ -69,22 +83,14 @@ describe "When installing from Github" do
69
83
 
70
84
  end
71
85
 
72
- def stub_for_install!(installer)
73
-
74
- stub(Vimmer).bundle_path do
75
- Pathname.new("tmp/bundle")
76
- end
86
+ context "with a public facing Github url" do
77
87
 
78
- stub(installer).git_clone do
79
- FileUtils.mkdir_p(Vimmer.bundle_path.join("vim-awesomemofo", "plugins"))
80
- FileUtils.touch(Vimmer.bundle_path.join("vim-awesomemofo", "plugins", "vim-awesomemofo.vim"))
81
- end
88
+ subject { Github.new(:path => "http://github.com/tpope/vim-awesomemofo") }
82
89
 
83
- stub(installer).path_exists? { true }
90
+ its(:path) { should == FOUND_URL }
84
91
 
85
92
  end
86
93
 
87
-
88
94
  it "installs the plugin" do
89
95
 
90
96
  installer = Github.new(:path => FOUND_URL)
@@ -94,15 +100,19 @@ describe "When installing from Github" do
94
100
  installer.install
95
101
 
96
102
  plugin_path = Vimmer.bundle_path.join("vim-awesomemofo")
103
+
104
+
97
105
  File.directory?(plugin_path.to_s).should be_true
98
106
  File.directory?(plugin_path.join("plugins").to_s).should be_true
99
107
  File.file?(plugin_path.join("plugins", "vim-awesomemofo.vim")).should be_true
108
+
100
109
  end
101
110
 
102
111
  it "uninstalls the plugin" do
103
112
 
104
113
  installer = Github.new(:name => "vim-awesomemofo")
105
114
 
115
+
106
116
  stub_for_install! installer
107
117
 
108
118
  installer.install
@@ -115,4 +125,22 @@ describe "When installing from Github" do
115
125
  end
116
126
 
117
127
 
128
+ private
129
+
130
+ def stub_for_install!(installer)
131
+
132
+ Vimmer.stubs(:bundle_path).returns(Pathname.new("tmp/bundle"))
133
+
134
+ class << installer
135
+ def git_clone(arg1, arg2)
136
+ FileUtils.mkdir_p(Vimmer.bundle_path.join("vim-awesomemofo", "plugins"))
137
+ FileUtils.touch(Vimmer.bundle_path.join("vim-awesomemofo", "plugins", "vim-awesomemofo.vim"))
138
+ end
139
+ end
140
+
141
+ installer.stubs(:path_exists?).returns true
142
+
143
+ end
144
+
118
145
  end
146
+
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe "When loading an installer by URL" do
4
+ include Vimmer
5
+
6
+ context "for a Github URL" do
7
+
8
+ subject { Installers.for_url("https://github.com/foo/bar.git") }
9
+
10
+ it { should == Installers::Github }
11
+
12
+ end
13
+
14
+
15
+ context "for a Vim.org URL" do
16
+
17
+ before do
18
+ Installers::VimDotOrg.stubs(:for_url).returns(Installers::VimDotOrg)
19
+ end
20
+
21
+ subject { Installers.for_url("http://vim.org/scripts/script.php?script_id=1234") }
22
+
23
+ it { should == Installers::VimDotOrg }
24
+
25
+ end
26
+
27
+
28
+ context "for an unrecognized URL" do
29
+
30
+ subject { Installers.for_url("http://foo.com/bar") }
31
+
32
+ it { lambda { subject }.should raise_error(Vimmer::InstallerNotFoundError) }
33
+
34
+ end
35
+
36
+
37
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ include Vimmer::Installers
4
+
5
+ describe "When installing from vim.org" do
6
+
7
+ VDO_NOT_FOUND_URL = "http://www.vim.org/scripts/script.php?script_id=0000"
8
+ VDO_MALFORMED_URL = "https://foo.com/bar"
9
+
10
+ RSpec::Matchers.define :be_a_valid_url do |expected|
11
+ match do
12
+ VimDotOrg.match?(expected) == true
13
+ end
14
+ end
15
+
16
+ context "with a non-existent URL" do
17
+
18
+ before do
19
+ VimDotOrg.stubs(:repository).returns({})
20
+ end
21
+
22
+ it { should be_a_valid_url(VDO_NOT_FOUND_URL) }
23
+
24
+ specify "the installer should raise an exception" do
25
+ lambda { VimDotOrg.for_url(VDO_NOT_FOUND_URL) }.should raise_error(Vimmer::PluginNotFoundError)
26
+ end
27
+
28
+ end
29
+
30
+
31
+ context "with a malformed URL" do
32
+
33
+ it { should_not be_a_valid_url(VDO_MALFORMED_URL) }
34
+
35
+ end
36
+
37
+ context "with a good URL" do
38
+
39
+ before do
40
+ VimDotOrg.stubs(:repository).returns({"2975" => "fugitive.vim"})
41
+ end
42
+
43
+ let(:installer) { VimDotOrg.for_url("http://www.vim.org/scripts/script.php?script_id=2975") }
44
+
45
+ context "using the vim-scripts mirror" do
46
+
47
+ it "should return a Github installer" do
48
+ installer.should be_a(Github)
49
+ end
50
+
51
+ it "uses the Github path" do
52
+ installer.path.should == "https://github.com/vim-scripts/fugitive.vim.git"
53
+ end
54
+
55
+ end
56
+
57
+ specify "the installer should not raise an exception" do
58
+
59
+ class << installer
60
+ def git_clone(arg1, arg2)
61
+ end
62
+ end
63
+
64
+ lambda { installer.install }.should_not raise_error
65
+ end
66
+
67
+ specify "the installer calculates the plugin's name" do
68
+ installer.plugin_name.should == "fugitive.vim"
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -23,4 +23,19 @@ describe ".vimmer/" do
23
23
  File.read(settings.config_file).should =~ /bundle_path: ~\/.vim\/bundle/
24
24
  end
25
25
 
26
+
27
+ it "expands the path when calling bundle_path" do
28
+ ENV['VIMMER_HOME'] = vimmer_home.to_s
29
+
30
+ bundle_path = app_root.join("lib", "..", "tmp", "bundle")
31
+ File.open(vimmer_home.join("config").to_s, "w") do |f|
32
+ f << "bundle_path: #{bundle_path}"
33
+ end
34
+
35
+ Vimmer::Settings.new[:bundle_path].should == File.expand_path(bundle_path)
36
+
37
+ ENV['VIMMER_HOME'] = nil
38
+ end
39
+
40
+
26
41
  end
data/spec/spec_helper.rb CHANGED
@@ -6,15 +6,25 @@ $:.unshift File.expand_path('../../lib', __FILE__)
6
6
  require 'vimmer'
7
7
 
8
8
  require 'fakefs/spec_helpers'
9
+ require 'bourne'
9
10
 
10
- RSpec.configure do |config|
11
+ require 'webmock/rspec'
12
+
13
+
14
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
15
 
12
- config.mock_with :rr
16
+ RSpec.configure do |config|
13
17
 
14
18
  config.include FakeFS::SpecHelpers
19
+ config.include WebMock::API
20
+ config.mock_with :mocha
15
21
 
16
22
  def app_root
17
- Pathname.new(File.join(__FILE__, "..", "tmp", ".vimmer"))
23
+ Pathname.new(File.join(File.dirname(__FILE__), ".."))
24
+ end
25
+
26
+ def vimmer_home
27
+ app_root.join("tmp", ".vimmer")
18
28
  end
19
29
 
20
30
 
data/vimmer.gemspec CHANGED
@@ -17,13 +17,15 @@ Gem::Specification.new do |s|
17
17
  s.add_dependency "thor"
18
18
 
19
19
  s.add_development_dependency "bundler", ">=1.0.0"
20
- s.add_development_dependency "rspec", "~> 2.0.0"
21
- s.add_development_dependency "cucumber"
20
+ s.add_development_dependency "rspec", "~> 2.3.0"
21
+ s.add_development_dependency "cucumber", "= 0.10.0"
22
22
  s.add_development_dependency "autotest"
23
23
  s.add_development_dependency "fuubar"
24
24
  s.add_development_dependency "fakefs"
25
- s.add_development_dependency "aruba"
26
- s.add_development_dependency "rr"
25
+ s.add_development_dependency "aruba", "= 0.2.7"
26
+ s.add_development_dependency "mocha"
27
+ s.add_development_dependency "bourne"
28
+ s.add_development_dependency "webmock"
27
29
 
28
30
  s.files = `git ls-files`.split("\n")
29
31
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joe Fiorini
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-22 00:00:00 -05:00
17
+ date: 2010-12-21 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -55,9 +55,9 @@ dependencies:
55
55
  - !ruby/object:Gem::Version
56
56
  segments:
57
57
  - 2
58
+ - 3
58
59
  - 0
59
- - 0
60
- version: 2.0.0
60
+ version: 2.3.0
61
61
  type: :development
62
62
  version_requirements: *id003
63
63
  - !ruby/object:Gem::Dependency
@@ -66,11 +66,13 @@ dependencies:
66
66
  requirement: &id004 !ruby/object:Gem::Requirement
67
67
  none: false
68
68
  requirements:
69
- - - ">="
69
+ - - "="
70
70
  - !ruby/object:Gem::Version
71
71
  segments:
72
72
  - 0
73
- version: "0"
73
+ - 10
74
+ - 0
75
+ version: 0.10.0
74
76
  type: :development
75
77
  version_requirements: *id004
76
78
  - !ruby/object:Gem::Dependency
@@ -118,15 +120,17 @@ dependencies:
118
120
  requirement: &id008 !ruby/object:Gem::Requirement
119
121
  none: false
120
122
  requirements:
121
- - - ">="
123
+ - - "="
122
124
  - !ruby/object:Gem::Version
123
125
  segments:
124
126
  - 0
125
- version: "0"
127
+ - 2
128
+ - 7
129
+ version: 0.2.7
126
130
  type: :development
127
131
  version_requirements: *id008
128
132
  - !ruby/object:Gem::Dependency
129
- name: rr
133
+ name: mocha
130
134
  prerelease: false
131
135
  requirement: &id009 !ruby/object:Gem::Requirement
132
136
  none: false
@@ -138,6 +142,32 @@ dependencies:
138
142
  version: "0"
139
143
  type: :development
140
144
  version_requirements: *id009
145
+ - !ruby/object:Gem::Dependency
146
+ name: bourne
147
+ prerelease: false
148
+ requirement: &id010 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ segments:
154
+ - 0
155
+ version: "0"
156
+ type: :development
157
+ version_requirements: *id010
158
+ - !ruby/object:Gem::Dependency
159
+ name: webmock
160
+ prerelease: false
161
+ requirement: &id011 !ruby/object:Gem::Requirement
162
+ none: false
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ segments:
167
+ - 0
168
+ version: "0"
169
+ type: :development
170
+ version_requirements: *id011
141
171
  description: Install, update and remove Vim plugins without changing directories using this simple command line utility.
142
172
  email:
143
173
  - joe@densitypop.com
@@ -156,27 +186,31 @@ files:
156
186
  - Gemfile.lock
157
187
  - README.mdown
158
188
  - Rakefile
159
- - autotest/discover.rb
160
189
  - bin/vimmer
161
190
  - cucumber.yml
191
+ - features/fixtures/script_ids.json
162
192
  - features/install.feature
163
193
  - features/setup.feature
164
194
  - features/step_definitions/environment_context_steps.rb
165
195
  - features/step_definitions/plugin_assertion_steps.rb
166
196
  - features/step_definitions/plugin_context_steps.rb
167
- - features/support/curl
168
- - features/support/git
169
197
  - features/support/hooks.rb
170
198
  - features/support/setup.rb
199
+ - features/support/stub-commands.rb
200
+ - features/support/stubbed_http_requests.rb
171
201
  - features/support/vimmer_stub.rb
172
202
  - features/uninstall_plugin.feature
173
203
  - lib/vimmer.rb
174
204
  - lib/vimmer/cli.rb
175
205
  - lib/vimmer/installers.rb
176
206
  - lib/vimmer/installers/github.rb
207
+ - lib/vimmer/installers/vim_dot_org.rb
177
208
  - lib/vimmer/settings.rb
178
209
  - lib/vimmer/version.rb
210
+ - script/run_until_failure
179
211
  - spec/install/github_spec.rb
212
+ - spec/install/load_installer_spec.rb
213
+ - spec/install/vim_dot_org_spec.rb
180
214
  - spec/settings_spec.rb
181
215
  - spec/spec_helper.rb
182
216
  - vimmer.gemspec
@@ -213,17 +247,20 @@ signing_key:
213
247
  specification_version: 3
214
248
  summary: Automated Vim plugin management
215
249
  test_files:
250
+ - features/fixtures/script_ids.json
216
251
  - features/install.feature
217
252
  - features/setup.feature
218
253
  - features/step_definitions/environment_context_steps.rb
219
254
  - features/step_definitions/plugin_assertion_steps.rb
220
255
  - features/step_definitions/plugin_context_steps.rb
221
- - features/support/curl
222
- - features/support/git
223
256
  - features/support/hooks.rb
224
257
  - features/support/setup.rb
258
+ - features/support/stub-commands.rb
259
+ - features/support/stubbed_http_requests.rb
225
260
  - features/support/vimmer_stub.rb
226
261
  - features/uninstall_plugin.feature
227
262
  - spec/install/github_spec.rb
263
+ - spec/install/load_installer_spec.rb
264
+ - spec/install/vim_dot_org_spec.rb
228
265
  - spec/settings_spec.rb
229
266
  - spec/spec_helper.rb
data/autotest/discover.rb DELETED
@@ -1 +0,0 @@
1
- Autotest.add_discovery { "rspec2" }
@@ -1,14 +0,0 @@
1
- #!/bin/bash
2
-
3
- args=$#
4
- url=${!args}
5
-
6
- if echo $url | grep ".git$"
7
- then
8
- echo 404
9
- elif echo $url | grep "not-found"
10
- then
11
- echo 404
12
- else
13
- echo 200
14
- fi
data/features/support/git DELETED
@@ -1,10 +0,0 @@
1
- #!/bin/bash
2
- # $1 $2 $3
3
- # clone https://github.com/tpope/vim-awesomemofo.git tmp/aruba/bundle
4
-
5
- if [ $1 == "clone" ]; then
6
- mkdir -p $3
7
- else
8
- echo "delegating to git"
9
- /usr/local/git/bin/git $*
10
- fi