vimpk 0.2.0 → 0.4.0

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
  SHA256:
3
- metadata.gz: a4859149e17e0bc00e3a7230deeeecc6304eab4ed9acd2671509ea3d4ac016ae
4
- data.tar.gz: ed44805797dbaa69cdf31c2767fdf928691169c9606df2ab610b412ea84adc20
3
+ metadata.gz: 8d6e8ca14353f2e289dcf72b6049f1f694b7277ca702c48e95526a3bbc736a7a
4
+ data.tar.gz: efddf087e1596aa801a174dd30242bcf72913aeac50ba443976f7f0c5b64111a
5
5
  SHA512:
6
- metadata.gz: a7de3bfbf7b2fd882f2f9b8c0fc10b4cd8ad11bfff0b480a8b5fefc14bee11c10c393a521075bfe61de130ad3eb221fe573d2d11e1880121ce995b8374ed49c0
7
- data.tar.gz: 3824e72fcc014941d33d1b139143185e752166a794809c7917c5824138db94c55b2caec2c896f88150c76c63d44f4d69c10ea66dbcd5c79fd151b3df5efeffe3
6
+ metadata.gz: 78c8fbb9298b12bce49f149507c7b89b7f2437b2942f53320f42e0c79fc63843ef83e565f0cbfc716657669f19c04b2150715aa8e8a60ed959cbca410065f7df
7
+ data.tar.gz: 575726746604f123e148bee44fc9c001222df4d7dfa9bf7cb092021a08e34aadd522c23d2b949ba383c9d86dbd5cfd2c4e1891ee775ac27d0e3b6797d23d4cc5
data/.overcommit.yml CHANGED
@@ -18,8 +18,6 @@ CommitMsg:
18
18
  sample_message: "feat: Add new feature"
19
19
  TrailingPeriod:
20
20
  enabled: true
21
- SpellCheck:
22
- enabled: true
23
21
 
24
22
  PostCheckout:
25
23
  ALL:
data/lib/vimpk/cli.rb CHANGED
@@ -13,17 +13,24 @@ module VimPK
13
13
  @command = determine_command
14
14
  rescue OptionParser::MissingArgument, OptionParser::InvalidOption => e
15
15
  warn e.message
16
- abort "Use --help for usage information"
16
+ abort help_message
17
17
  end
18
18
 
19
19
  def call
20
20
  if @command
21
21
  send(@command, *@argv)
22
+ exit 0
22
23
  else
23
24
  puts @parser.parser
24
25
  end
25
26
  end
26
27
 
28
+ private
29
+
30
+ def help_message
31
+ "Use --help for usage information"
32
+ end
33
+
27
34
  def determine_command
28
35
  return nil if @argv.empty?
29
36
 
@@ -31,6 +38,8 @@ module VimPK
31
38
  case name
32
39
  when "i", "install"
33
40
  :install_command
41
+ when "l", "list"
42
+ :list_command
34
43
  when "mv", "move"
35
44
  :move_command
36
45
  when "u", "update"
@@ -38,48 +47,54 @@ module VimPK
38
47
  when "rm", "remove"
39
48
  :remove_command
40
49
  else
41
- warn colorize("Unknown command: #{name}", color: :red)
42
- abort "Use --help for usage information"
50
+ warn colorize("Unknown command: #{name}", color: :yellow)
51
+ abort help_message
43
52
  end
44
53
  end
45
54
 
55
+ def list_command
56
+ command = List.new(@options)
57
+ list = command.call
58
+ puts list.sort_by(&:downcase)
59
+ end
60
+
46
61
  def install_command(package = nil)
47
62
  time = Time.now
48
- install = Install.new(package, @options[:path], @options[:pack], @options[:type])
49
- puts "Installing #{package} to #{install.dest}…"
50
- install.call
51
- puts colorize("Installed #{package} to #{install.dest}. Took #{Time.now - time} seconds.", color: :green)
63
+ command = Install.new(package, @options)
64
+ puts "Installing #{package} to #{command.dest}…"
65
+ command.call
66
+ puts colorize("Installed #{package} to #{command.dest}. Took #{Time.now - time} seconds.", color: :green)
52
67
  rescue Git::GitError => e
53
- warn colorize("Error: #{e.message}", color: :red)
68
+ warn colorize("Error: #{e.message}", color: :yellow)
54
69
  abort e.output.lines.map { |line| " #{line}" }.join
55
70
  rescue Install::PackageExistsError => e
56
- warn colorize("Error: #{e.message}", color: :red)
71
+ abort colorize("Error: #{e.message}", color: :red)
57
72
  rescue ArgumentError => e
58
- warn colorize("Error: #{e.message}", color: :red)
73
+ abort colorize("Error: #{e.message}", color: :red)
59
74
  end
60
75
 
61
76
  def move_command(name = nil)
62
- move = Move.new(name, @options[:path], @options[:pack], @options[:type])
63
- move.call
64
- puts colorize("Moved #{name} to #{move.dest}.", color: :green)
77
+ command = Move.new(name, @options)
78
+ command.call
79
+ puts colorize("Moved #{name} to #{command.dest}.", color: :green)
65
80
  rescue Move::PackageNotFoundError, Move::MultiplePackagesFoundError, ArgumentError => e
66
81
  abort colorize(e.message, color: :red)
67
82
  end
68
83
 
69
84
  def update_command
70
- update = Update.new(@options[:path])
71
- puts "Updating #{update.plugins.size} packages in #{@options[:path]}…"
85
+ command = Update.new(@options)
86
+ puts "Updating #{command.plugins.size} packages in #{@options[:path]}…"
72
87
  start_time = Time.now
73
- update.call
88
+ command.call
74
89
 
75
90
  statuses = {}
76
91
 
77
- while (log = update.logs.pop)
92
+ while (log = command.logs.pop)
78
93
  basename = log[:basename]
79
94
  statuses[basename] = log[:log]
80
95
  end
81
96
 
82
- basenames = update.plugins.map { |dir| File.basename(dir) }.sort_by(&:downcase)
97
+ basenames = command.plugins.map { |dir| File.basename(dir) }.sort_by(&:downcase)
83
98
 
84
99
  max_name_length = statuses.keys.map(&:length).max
85
100
 
@@ -91,11 +106,11 @@ module VimPK
91
106
  end
92
107
  end
93
108
 
94
- if statuses.size < update.jobs.size
95
- puts "The remaining #{update.jobs.size - statuses.size} plugins are up to date."
109
+ if statuses.size < command.jobs.size
110
+ puts "The remaining #{command.jobs.size - statuses.size} plugins are up to date."
96
111
  end
97
112
 
98
- puts colorize("Finished updating #{update.jobs.size} plugins. Took #{Time.now - start_time} seconds.")
113
+ puts colorize("Finished updating #{command.jobs.size} plugins. Took #{Time.now - start_time} seconds.")
99
114
 
100
115
  if statuses.size.nonzero?
101
116
  print "Display diffs? (Y/n) "
@@ -114,7 +129,7 @@ module VimPK
114
129
  end
115
130
 
116
131
  def remove_command(name = nil)
117
- Remove.new(name, @options[:path]).call
132
+ Remove.new(name, @options).call
118
133
 
119
134
  puts colorize("Package #{name} removed.", color: :green)
120
135
  rescue ArgumentError, VimPK::Remove::PackageNotFoundError => e
data/lib/vimpk/install.rb CHANGED
@@ -6,11 +6,11 @@ module VimPK
6
6
 
7
7
  attr_reader :dest
8
8
 
9
- def initialize(package, path, pack, type)
9
+ def initialize(package, options)
10
10
  @package = package || raise(ArgumentError, "Package name is required")
11
- @path = path
12
- @pack = pack
13
- @type = type
11
+ @path = options.path
12
+ @pack = options.pack || options.default_pack
13
+ @type = options.type || options.default_type
14
14
  @dest = File.join(@path, @pack, @type, File.basename(@package))
15
15
  @source = "https://github.com/#{package}.git"
16
16
  @git = Git
data/lib/vimpk/list.rb ADDED
@@ -0,0 +1,24 @@
1
+ require "fileutils"
2
+
3
+ module VimPK
4
+ class List
5
+ PackageNotFoundError = Class.new(StandardError)
6
+
7
+ attr_reader :dest
8
+
9
+ def initialize(options)
10
+ @path = options.path
11
+ @pack = options.pack || "*"
12
+ @type = options.type || "{start,opt}"
13
+ end
14
+
15
+ def call
16
+ pattern = File.join(@path, @pack, @type, "*")
17
+ glob = Dir.glob(pattern)
18
+
19
+ raise PackageNotFoundError, "No packages were found in #{pattern}." if glob.empty?
20
+
21
+ glob
22
+ end
23
+ end
24
+ end
data/lib/vimpk/move.rb CHANGED
@@ -7,12 +7,12 @@ module VimPK
7
7
 
8
8
  attr_reader :dest
9
9
 
10
- def initialize(name, path, pack = nil, type = nil)
10
+ def initialize(name, options)
11
11
  @name = name || raise(ArgumentError, "Package name is required")
12
12
  raise ArgumentError, "New pack or type is required" unless pack || type
13
- @path = path
14
- @pack = pack
15
- @type = type
13
+ @path = options.path
14
+ @pack = options.pack
15
+ @type = options.type
16
16
  end
17
17
 
18
18
  def call
data/lib/vimpk/options.rb CHANGED
@@ -10,11 +10,11 @@ module VimPK
10
10
  DEFAULT_TYPE = "start"
11
11
  DEFAULT_PACK = "plugins"
12
12
 
13
- DefaultOptions = Struct.new(:path, :pack, :type)
13
+ DefaultOptions = Struct.new(:path, :pack, :type, :default_pack, :default_type)
14
14
 
15
15
  def initialize(argv)
16
16
  @argv = argv
17
- @options = DefaultOptions.new(DEFAULT_PATH, DEFAULT_PACK, DEFAULT_TYPE)
17
+ @options = DefaultOptions.new(DEFAULT_PATH, nil, nil, DEFAULT_PACK, DEFAULT_TYPE)
18
18
 
19
19
  @parser = OptionParser.new do |parser|
20
20
  parser.banner = "Usage: #{parser.program_name} [options] [command [options]"
@@ -54,7 +54,8 @@ module VimPK
54
54
  parser.separator ""
55
55
  parser.separator "Commands:"
56
56
  parser.separator " i|install REPO/NAME [--opt|--start] [--pack=PATH] [--path=PATH] Install a package"
57
- parser.separator " mv|move Move a package"
57
+ parser.separator " l|list [--opt|--start] [--pack=PATH] [--path=PATH] List packages"
58
+ parser.separator " mv|move NAME [--opt|--start] [--pack=PATH] Move a package"
58
59
  parser.separator " u|update Update all packages"
59
60
  parser.separator " rm|remove NAME Remove all occurrences of a package"
60
61
  end
data/lib/vimpk/remove.rb CHANGED
@@ -4,9 +4,9 @@ module VimPK
4
4
  class Remove
5
5
  PackageNotFoundError = Class.new(StandardError)
6
6
 
7
- def initialize(name, path)
7
+ def initialize(name, options)
8
8
  @name = name || raise(ArgumentError, "Package name is required")
9
- @path = path
9
+ @path = options.path
10
10
  end
11
11
 
12
12
  def call
data/lib/vimpk/update.rb CHANGED
@@ -4,8 +4,8 @@ module VimPK
4
4
 
5
5
  attr_reader :jobs, :logs, :plugins
6
6
 
7
- def initialize(path)
8
- @pack_dir = File.expand_path(path)
7
+ def initialize(options)
8
+ @pack_dir = File.expand_path(options.path)
9
9
  @logs = Queue.new
10
10
  @pool = ThreadPool.new
11
11
  @plugins = Dir.glob(File.join(@pack_dir, "*", "{start,opt}", "*", ".git")).sort.map(&File.method(:dirname))
data/lib/vimpk/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VimPK
4
- VERSION = "0.2.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/vimpk.rb CHANGED
@@ -15,6 +15,7 @@ module VimPK
15
15
  autoload :Git, "vimpk/git"
16
16
  autoload :Install, "vimpk/install"
17
17
  autoload :Job, "vimpk/job"
18
+ autoload :List, "vimpk/list"
18
19
  autoload :Move, "vimpk/move"
19
20
  autoload :Options, "vimpk/options"
20
21
  autoload :Remove, "vimpk/remove"
data/vimpk.gemspec ADDED
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/vimpk/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "vimpk"
7
+ spec.version = VimPK::VERSION
8
+ spec.authors = ["Piotr Usewicz"]
9
+ spec.email = ["piotr@layer22.com"]
10
+
11
+ spec.summary = "VimPK is a tool for managing Vim plugins via packages."
12
+ spec.homepage = "https://github.com/pusewicz/vimpk"
13
+ spec.license = "MIT"
14
+
15
+ if RUBY_VERSION >= "2.7"
16
+ spec.required_ruby_version = ">= 2.6.0"
17
+ end
18
+
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = spec.homepage
23
+ spec.metadata["changelog_uri"] = File.join(spec.homepage, "blob/main/CHANGELOG.md")
24
+ spec.metadata["github_repo"] = "https://github.com/pusewicz/vimpk.git"
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ spec.files = Dir.chdir(__dir__) do
29
+ `git ls-files -z`.split("\x0").reject do |f|
30
+ (File.expand_path(f) == __FILE__) ||
31
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile .standard.yml CHANGELOG.md CODE_OF_CONDUCT.md README.md Rakefile])
32
+ end
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ # Uncomment to register a new dependency of your gem
39
+ # spec.add_dependency "example-gem", "~> 1.0"
40
+
41
+ # For more information and examples about making a new gem, check out our
42
+ # guide at: https://bundler.io/guides/creating_gem.html
43
+ end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vimpk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Usewicz
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-16 00:00:00.000000000 Z
11
+ date: 2024-03-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
13
+ description:
14
14
  email:
15
15
  - piotr@layer22.com
16
16
  executables:
@@ -27,12 +27,14 @@ files:
27
27
  - lib/vimpk/git.rb
28
28
  - lib/vimpk/install.rb
29
29
  - lib/vimpk/job.rb
30
+ - lib/vimpk/list.rb
30
31
  - lib/vimpk/move.rb
31
32
  - lib/vimpk/options.rb
32
33
  - lib/vimpk/remove.rb
33
34
  - lib/vimpk/thread_pool.rb
34
35
  - lib/vimpk/update.rb
35
36
  - lib/vimpk/version.rb
37
+ - vimpk.gemspec
36
38
  homepage: https://github.com/pusewicz/vimpk
37
39
  licenses:
38
40
  - MIT
@@ -42,7 +44,7 @@ metadata:
42
44
  source_code_uri: https://github.com/pusewicz/vimpk
43
45
  changelog_uri: https://github.com/pusewicz/vimpk/blob/main/CHANGELOG.md
44
46
  github_repo: https://github.com/pusewicz/vimpk.git
45
- post_install_message:
47
+ post_install_message:
46
48
  rdoc_options: []
47
49
  require_paths:
48
50
  - lib
@@ -57,8 +59,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
59
  - !ruby/object:Gem::Version
58
60
  version: '0'
59
61
  requirements: []
60
- rubygems_version: 3.5.6
61
- signing_key:
62
+ rubygems_version: 3.5.3
63
+ signing_key:
62
64
  specification_version: 4
63
65
  summary: VimPK is a tool for managing Vim plugins via packages.
64
66
  test_files: []