vimget 0.1.1 → 0.1.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.
data/README CHANGED
@@ -1,6 +1,21 @@
1
1
  = VimGet
2
2
  == A vim script management tool
3
3
 
4
+ === Basic Usage
4
5
 
6
+ After you first time installing the vimget, there is not any script information
7
+ in your local cache. So you need install a new script by its id.
8
+
9
+ For example, if you need install taglist (for the first time), you need enter:
10
+
11
+ <i>$ vim-get install --id 273</i>
12
+
13
+ To remove one script:
14
+
15
+ <i>$ vim-get uninstall taglist.vim</i>
16
+
17
+ Sync local script version database with vim site:
18
+
19
+ <i>$ vim-get sync</i>
5
20
 
6
21
  Author:: Eddy Xu (mailto:eddyxu@gmail.com)
data/bin/vim-get CHANGED
File without changes
data/doc/vim-get.1 ADDED
@@ -0,0 +1,16 @@
1
+ .TH vim-get 1 "20 April 2008"
2
+ .SH NAME
3
+ vim\-get \- Vim Script Manager
4
+ .SH SYNOPSIS
5
+ .B vim\-get [options]
6
+ .I command
7
+ .B [args]
8
+ .SH DESCRITPION
9
+ vim-get is a vim script manager. It can automatically track the newest version of vim plugin scripts,
10
+ install and upgrade them.
11
+
12
+ For more informations, use "vim-get help".
13
+ .SH ALSO
14
+ vim(1)
15
+ .SH AUTHOR
16
+ Eddy Xu <eddyxu@gmail.com>
@@ -7,7 +7,7 @@
7
7
  # License:: Distributed under BSD License
8
8
  # Copyright:: Copyright 2008 (c) Quarkare.com (http://www.quarkware.com)
9
9
  #
10
- # $Id: command.rb 8 2008-04-12 12:47:35Z eddyxu $
10
+ # $Id: command.rb 10 2008-04-20 18:04:04Z eddyxu $
11
11
  #
12
12
 
13
13
  require 'optparse'
@@ -90,14 +90,20 @@ module VimGet
90
90
  @rest.shift
91
91
  end
92
92
 
93
+ # return a array of arguments anc clean the @rest
94
+ def fetch_arguments
95
+ ret = @rest.dup
96
+ @rest.clear
97
+ ret
98
+ end
99
+
93
100
  private
94
101
 
95
102
  def handle_options(args)
96
103
  @rest = parser.parse(*args)
97
104
  @options[:args] = args
98
-
99
105
  # remove the operation name
100
- @rest.shift if @rest.first == @program_name
106
+ @rest.shift if @rest.first == @command
101
107
  end
102
108
 
103
109
  # singleton entry for OptionParser
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # File: clean_command.rb
3
+ # =Clean Command
4
+ # This clean command will delete all distributed files
4
5
  #
5
- # Brief: clean command
6
+ # Author:: Eddy Xu (mailto:eddyxu@gmail.com)
7
+ # License:: Distributed under BSD License
8
+ # Copyright:: 2008 (c) Quarkware.com (http://www.quarkware.com)
6
9
  #
7
- # Author: Eddy Xu <eddyxu@gmail.com>
8
- #
9
- # Copyright: 2008 (c) Quarkware.com
10
- #
11
- # $Id: clean_command.rb 5 2008-04-11 18:33:39Z eddyxu $
10
+ # $Id: clean_command.rb 11 2008-05-17 17:47:35Z eddyxu $
12
11
  #
13
12
 
14
13
  require "vimget/command"
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # File: install_command.rb
3
+ # =Install Command
4
+ # Command to install a script or scripts
4
5
  #
5
- # Brief: install command
6
+ # Author:: Eddy Xu (mailto:eddyxu@gmail.com)
7
+ # License:: Distributed under BSD License
8
+ # Copyright:: 2008 (c) Quarkware.com (http://www.quarkware.com)
6
9
  #
7
- # Author: Eddy Xu <eddyxu@gmail.com>
8
- #
9
- # Copyright: 2008 (c) Quarkware.com
10
- #
11
- # $Id: install_command.rb 5 2008-04-11 18:33:39Z eddyxu $
10
+ # $Id: install_command.rb 11 2008-05-17 17:47:35Z eddyxu $
12
11
  #
13
12
 
14
13
  require "vimget/command"
@@ -45,16 +44,13 @@ module VimGet
45
44
  VimGet.db.add(script)
46
45
  end
47
46
  else
48
- @rest.shift if @rest.first == "install"
49
- if @rest.empty?
50
- raise CommandLineError, "Missing arguments"
47
+ script_name = fetch_one_argu
48
+ if script_name.nil?
49
+ raise CommandLineError, "You must indicate one script to install."
51
50
  end
51
+ script = VimGet.db.find(script_name)
52
52
 
53
- name = @rest.first
54
-
55
- script = VimGet.db.find(name)
56
-
57
- raise UnknownScriptError, "Unknow script!" if script.nil?
53
+ raise UnknownScriptError, "Unknow script! (Perhaps you need install it by indicate its id)" if script.nil?
58
54
  end
59
55
 
60
56
  installer = Installer.new(@options)
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # File: installed_command.rb
3
+ # =Installed Command
4
+ # List out all installed commands
4
5
  #
5
- # Brief: installed command
6
+ # Author:: Eddy Xu (mailto:eddyxu@gmail.com)
7
+ # License:: Distributed under BSD License
8
+ # Copyright:: 2008 (c) Quarkware.com (http://www.quarkware.com)
6
9
  #
7
- # Author: Eddy Xu <eddyxu@gmail.com>
8
- #
9
- # Copyright: 2008 (c) Quarkware.com
10
- #
11
- # $Id: installed_command.rb 6 2008-04-11 19:01:26Z eddyxu $
10
+ # $Id: installed_command.rb 11 2008-05-17 17:47:35Z eddyxu $
12
11
  #
13
12
 
14
13
  require "vimget/commands/list_command"
@@ -2,10 +2,11 @@
2
2
  #
3
3
  # list command
4
4
  #
5
- # $Id: list_command.rb 7 2008-04-11 22:48:50Z eddyxu $
5
+ # $Id: list_command.rb 10 2008-04-20 18:04:04Z eddyxu $
6
6
 
7
7
  require "vimget/command"
8
- require "vimget/db.rb"
8
+ require "vimget/db"
9
+ require 'vimget/output'
9
10
 
10
11
  module VimGet
11
12
  module Commands
@@ -19,43 +20,25 @@ module VimGet
19
20
  add_customer_options
20
21
  end
21
22
 
22
- def usage
23
- "#{program_name} [STRING]"
24
- end
25
-
26
23
  def execute
27
24
  raise CommandLineError, "Ambiguous command!" if @options[:outdated] && @options[:installed]
28
25
 
29
26
  if @options[:outdated]
30
- puts "List outdated scripts"
31
27
  scripts = VimGet.db.outdated_scripts
32
28
  elsif @options[:installed]
33
- puts "List installed scripts"
34
29
  scripts = VimGet.db.installed_scripts
35
30
  else
36
- puts "List scripts"
37
31
  scripts = VimGet.db.search
38
32
  end
39
33
 
40
- scripts.each do |s|
41
- if @options[:format] == "plain"
42
- puts "[#{s.name}]"
43
- puts "id: #{s.sid}"
44
- puts "author: #{s.author}"
45
- puts "installed: #{s.installed}"
46
- puts "version: #{s.version}"
47
- puts
48
- #elsif @options[:format] == "xml"
49
- # puts "<script name=\"#{s.name}\" id=\"#{s.sid}\">"
50
- # puts "</script>"
51
- end
52
- end
34
+ outputer = Output.new(@options[:format])
35
+ outputer.short(scripts)
53
36
  end
54
37
 
55
38
  private
56
39
 
57
40
  def add_customer_options
58
- #add_option(:list, '--xml', 'Display in XML Format') { |v,opts| opts[:format] = "xml" }
41
+ add_option(:list, '--xml', 'Display in XML Format') { |v,opts| opts[:format] = "xml" }
59
42
  add_option(:list, '-o', '--outdated', 'List all outdated scripts') {|v,opts| opts[:outdated] = v}
60
43
  add_option(:list, '-i', '--installed', 'List all installed scripts') {|v,opts| opts[:installed] = v}
61
44
  end
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # File: outdated_command.rb
3
+ # =Outdated Command
4
+ # list out all outdated scripts
4
5
  #
5
- # Brief: outdated command
6
+ # Author:: Eddy Xu (mailto:eddyxu@gmail.com)
7
+ # License:: Distributed under BSD License
8
+ # Copyright:: 2008 (c) Quarkware.com (http://www.quarkware.com)
6
9
  #
7
- # Author: Eddy Xu <eddyxu@gmail.com>
8
- #
9
- # Copyright: 2008 (c) Quarkware.com
10
- #
11
- # $Id: outdated_command.rb 6 2008-04-11 19:01:26Z eddyxu $
10
+ # $Id: outdated_command.rb 11 2008-05-17 17:47:35Z eddyxu $
12
11
  #
13
12
 
14
13
  require "vimget/commands/list_command"
@@ -17,6 +16,7 @@ module VimGet
17
16
 
18
17
  module Commands
19
18
 
19
+ # List all outdated command
20
20
  class OutdatedCommand < ListCommand
21
21
  def initialize
22
22
  super("outdated", "Display all outdated scripts")
@@ -8,7 +8,7 @@
8
8
  #
9
9
  # Copyright 2008 (c) Quarkware.com
10
10
  #
11
- # $Id: uninstall_command.rb 5 2008-04-11 18:33:39Z eddyxu $
11
+ # $Id: uninstall_command.rb 10 2008-04-20 18:04:04Z eddyxu $
12
12
 
13
13
  require "vimget/command"
14
14
  require "vimget/db"
@@ -23,11 +23,6 @@ module VimGet
23
23
  def initialize
24
24
  super("uninstall", "Uninstall a script")
25
25
 
26
- add_option("-i",
27
- "--id ID",
28
- Integer,
29
- "Indicated the id of script to uninstall") { |v,opts| opts[:uninstall_id] = v }
30
-
31
26
  add_option('--purge',
32
27
  'Remove all associated files, including vim-get manifest') { |v,opts| opts[:purge] = v }
33
28
 
@@ -35,23 +30,25 @@ module VimGet
35
30
  'Do not motify any files') { |v,opts| opts[:dry_run] = v }
36
31
  end
37
32
 
33
+ def usage
34
+ "#{@program_name} SCRIPT [SCRIPT ...] "
35
+ end
36
+
37
+ def arguments
38
+ "SCRIPT\t\tname of script to uninstall"
39
+ end
40
+
38
41
  def execute
39
- if @options[:uninstall_id]
40
- script = VimGet.db.find_with_id(@options[:uninstall_id])
41
- else
42
- @rest.shift if @rest.first == "uninstall"
43
- raise CommandLineError, "Missing arguments" if @rest.empty?
44
-
45
- name = @rest.first
46
- script = VimGet.db.find(name)
47
- end
48
-
49
- if script.nil?
50
- raise UnknownScriptError, "This script is not installed yet."
51
- end
42
+ args = fetch_arguments
43
+ raise CommandLineError, "You must indicate one script at least to uninstall." if args.empty?
52
44
 
53
45
  installer = Installer.new(@options)
54
- installer.uninstall(script)
46
+ args.each do |name|
47
+ script = VimGet.db.find(name)
48
+ raise UnknownScriptError, "This script is not installed yet." if script.nil?
49
+
50
+ installer.uninstall(script)
51
+ end
55
52
  end
56
53
  end
57
54
  end
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # File: upgrade_command.rb
3
+ # =Upgrade Command
4
+ # Perform upgrading operation
4
5
  #
5
- # Brief: perform upgrading operation
6
+ # Author:: Eddy Xu (mailto:eddyxu@gmail.com)
7
+ # License:: Distributed under BSD License
8
+ # Copyright:: 2008 (c) Quarkware.com (http://www.quarkware.com)
6
9
  #
7
- # Author: Eddy Xu <eddyxu@gmail.com>
8
- #
9
- # Copyright: 2008 (c) Quarkware.com
10
- #
11
- # $Id: upgrade_command.rb 7 2008-04-11 22:48:50Z eddyxu $
10
+ # $Id: upgrade_command.rb 11 2008-05-17 17:47:35Z eddyxu $
12
11
  #
13
12
 
14
13
  require "vimget/command"
@@ -23,7 +22,17 @@ module VimGet
23
22
  super('upgrade', 'upgrade outdated script(s)')
24
23
  end
25
24
 
25
+ def usage
26
+ "#{@program_name} [SCRIPT SCRIPT...]"
27
+ end
28
+
29
+ def arguments
30
+ "SCRIPT the name of script to upgrade"
31
+ end
32
+
33
+ # do the upgrading action
26
34
  def execute
35
+ args = fetch_arguments
27
36
  outdated_scripts = VimGet.db.outdated_scripts
28
37
 
29
38
  if outdated_scripts.empty?
data/lib/vimget/db.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # manage local script index database
4
4
  #
5
- # $Id: db.rb 7 2008-04-11 22:48:50Z eddyxu $
5
+ # $Id: db.rb 10 2008-04-20 18:04:04Z eddyxu $
6
6
 
7
7
  require "vimget/configure"
8
8
  require "vimget/script"
@@ -93,7 +93,9 @@ manifest {
93
93
  end
94
94
 
95
95
  def find(name)
96
- search(name).first
96
+ path = abs_file(name)
97
+ return parse_script(path) if File.exist? path
98
+ return nil
97
99
  end
98
100
 
99
101
  def outdated_scripts
@@ -141,6 +143,10 @@ manifest {
141
143
  def db_file(script)
142
144
  File.expand_path(File.join(@db_path, script.name + @@EXT))
143
145
  end
146
+
147
+ def abs_file(name)
148
+ File.expand_path(File.join(@db_path, name + @@EXT))
149
+ end
144
150
  end
145
151
 
146
152
  end
@@ -1,14 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
- # File installer.rb
3
+ # Act the install operations
4
4
  #
5
- # Brief act the install operations
5
+ # Author:: Eddy Xu <eddyxu@gmail.com>
6
+ # Copyright:: 2008 (c) Quarkware.com
7
+ # License:: Distributed under BSD License
6
8
  #
7
- # Author Eddy Xu <eddyxu@gmail.com>
8
- #
9
- # Copyright 2008 (c) Quarkware.com
10
- #
11
- # $Id: installer.rb 6 2008-04-11 19:01:26Z eddyxu $
9
+ # $Id: installer.rb 13 2008-08-14 08:31:49Z eddyxu $
12
10
 
13
11
  require 'fileutils'
14
12
  require 'open-uri'
@@ -26,6 +24,7 @@ module VimGet
26
24
  FileUtils.mkdir_p(@dist_path) if not File.exist? @dist_path
27
25
  end
28
26
 
27
+ # Install a script
29
28
  def install(script)
30
29
  filepath = fetch(script)
31
30
  script.manifest = extract(filepath)
@@ -34,6 +33,7 @@ module VimGet
34
33
  VimGet.db.update(script) unless @options[:dry_run]
35
34
  end
36
35
 
36
+ # Uninstall one script
37
37
  def uninstall(script)
38
38
  puts "#{script.name} is not installed yet.";return if !script.installed?
39
39
 
@@ -145,11 +145,16 @@ module VimGet
145
145
  def remove_manifest(script)
146
146
  script.manifest.each do |f|
147
147
  abs_path = absolute_vim_path(f)
148
- print " Deleting #{abs_path}..." if @options[:verbose]
148
+ print " Deleting #{abs_path}..." if @options[:verbose] or @options[:debug]
149
149
  if not File.exist?(abs_path)
150
150
  puts "Missing!" if @options[:verbose]
151
151
  next
152
152
  end
153
+
154
+ if File.directory?(abs_path)
155
+ next
156
+ end
157
+
153
158
  File.delete(abs_path) unless @options[:dry_run]
154
159
  puts "Ok" if @options[:verbose]
155
160
  end
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Generate output in customize format
4
+ #
5
+ # Author:: Eddy Xu (mailto:eddyxu@gmail.com)
6
+ # License:: Distributed under BSD License
7
+ # Copyright:: 2008 (c) Quarkware.com
8
+ #
9
+ # $Id: output.rb 10 2008-04-20 18:04:04Z eddyxu $
10
+
11
+ module VimGet
12
+
13
+ # Output information in special format
14
+ # Supported format: plain, xml, (rss)
15
+ class Output
16
+ attr_reader :format
17
+ def initialize(format = "plain")
18
+ @format = format
19
+ end
20
+
21
+ def short(script_array)
22
+ if @format == "plain"
23
+ script_array.each do |s|
24
+ if s.installed?
25
+ ver = "#{s.version} (#{s.installed})"
26
+ else
27
+ ver = "#{s.version}"
28
+ end
29
+ printf("%-30s %-10s\n", s.name, ver)
30
+ end
31
+ elsif @format == "xml"
32
+ # simply implement
33
+ puts "<scripts>"
34
+ script_array.each do |s|
35
+ puts " <script name='#{s.name}' version='#{s.version}' installed='#{s.installed}'/>"
36
+ end
37
+ puts "</scripts>"
38
+
39
+ else
40
+
41
+ end
42
+ end
43
+
44
+ def long(script_array)
45
+ if @format == "plain"
46
+ script_array.each do |s|
47
+ puts "[#{s.name}]"
48
+ puts ""
49
+ end
50
+ end
51
+ end
52
+
53
+ def detail(script)
54
+
55
+ end
56
+ end
57
+ end
data/lib/vimget.rb CHANGED
@@ -6,13 +6,13 @@
6
6
  # License:: Distributed under BSD License
7
7
  # Copyright:: Copyright (c) 2008 Quarkware.com
8
8
  #
9
- # $Id: vimget.rb 8 2008-04-12 12:47:35Z eddyxu $
9
+ # $Id: vimget.rb 13 2008-08-14 08:31:49Z eddyxu $
10
10
 
11
11
  require 'fileutils'
12
12
  require "vimget/command_manager"
13
13
  require "vimget/configure"
14
14
 
15
- VIMGET_VERSION = "0.1.1"
15
+ VIMGET_VERSION = "0.1.3"
16
16
 
17
17
  module VimGet
18
18
 
data/test/tc_command.rb CHANGED
@@ -2,21 +2,44 @@
2
2
  #
3
3
  # test case for command.rb
4
4
  #
5
- # author: Eddy Xu <eddyxu@gmail.com>
5
+ # Author: Eddy Xu <eddyxu@gmail.com>
6
+ # Copyright: 2008 (c) Quarkware.com
6
7
  #
7
- # $Id: tc_command.rb 8 2008-04-12 12:47:35Z eddyxu $
8
+ # $Id: tc_command.rb 9 2008-04-15 21:29:01Z eddyxu $
8
9
 
9
10
  require 'test/unit'
10
11
  require 'vimget/command'
11
12
 
13
+ class TestCommand < VimGet::BaseCommand
14
+ def initialize
15
+ super('test', 'a simulator command for test purpose')
16
+ end
17
+
18
+ def execute
19
+ end
20
+ end
21
+
12
22
  class CommandTest < Test::Unit::TestCase
23
+
13
24
  def setup
25
+ @cmd = TestCommand.new
14
26
  end
15
27
 
16
28
  def teardown
17
29
 
30
+ end
31
+
32
+ def test_common
33
+ base_command = VimGet::BaseCommand.new('base')
34
+ # call underfined execute in base class
35
+ assert_raise(RuntimeError) {
36
+ base_command.execute
37
+ }
38
+
39
+
18
40
  end
19
41
 
20
42
  def test_parse_option
43
+
21
44
  end
22
- end
45
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vimget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eddy Xu
@@ -9,7 +9,7 @@ autorequire: vimget
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-12 00:00:00 +08:00
12
+ date: 2008-08-14 00:00:00 +08:00
13
13
  default_executable:
14
14
  - vim-get
15
15
  dependencies:
@@ -53,12 +53,14 @@ files:
53
53
  - lib/vimget/db.rb
54
54
  - lib/vimget/exceptions.rb
55
55
  - lib/vimget/installer.rb
56
+ - lib/vimget/output.rb
56
57
  - lib/vimget/script.rb
57
58
  - lib/vimget/webparser.rb
58
59
  - lib/vimget.rb
60
+ - doc/vim-get.1
59
61
  - README
60
62
  has_rdoc: true
61
- homepage: http://www.xulei.org/projects/vimget
63
+ homepage: https://rubyforge.org/projects/vimget/
62
64
  post_install_message:
63
65
  rdoc_options: []
64
66
 
@@ -78,8 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
80
  version:
79
81
  requirements: []
80
82
 
81
- rubyforge_project:
82
- rubygems_version: 1.1.1
83
+ rubyforge_project: vimget
84
+ rubygems_version: 1.0.1
83
85
  signing_key:
84
86
  specification_version: 2
85
87
  summary: An vim script tool