vimpk 0.1.2 → 0.3.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: 1fb0dfb2236f49356b5b50889c8f063c70952ba85fce011400943acc449ca8c5
4
- data.tar.gz: 513194b7c2e2bc8b3a3c48393addf328f10834f53568721673484fcd9569343c
3
+ metadata.gz: 3352cab20c957f4b4fc580b6d9f2f0c91d0021cac3713ab6294111192ce5167d
4
+ data.tar.gz: 1044a2130c51433400d29c970be3e841d86469ab7dd5ddfeab615b3115a88626
5
5
  SHA512:
6
- metadata.gz: a2c7c9684d5d750c00f31f314d0fe80f3f1cfa6bfa9bcfb135ea39880bd1b2b9ffba8d790550ca563ba74290992f47c77e9b23c20838e82bab21c712a416e95e
7
- data.tar.gz: c56b63a7ad96710c7b6fc76a71ba69db43b99d4cba37b12c8a5f60c98dbe9e227556b1a97e6cefa194b29ce8482ea69ec815b3c29a67bcedcbf83b4c688b304a
6
+ metadata.gz: 31a0432618e7f85059b10d25b7aa2034ed18bf64b077b04665e08ae8f216402a8195a343ea53767911232af0908d7e2043e8ea3e8d234a81dbda53badac9f53f
7
+ data.tar.gz: 6ed9798aedf9bfd255abffe3d93acb6d9aa5e3378c2462a4be569b55b10bc40b840cf8d3242a04fcd2f61098dc99cdfcf5d6b6fd68c245163170c6dea6071453
data/.overcommit.yml ADDED
@@ -0,0 +1,33 @@
1
+ ---
2
+ gemfile: Gemfile
3
+
4
+ PreCommit:
5
+ TrailingWhitespace:
6
+ enabled: true
7
+ YamlSyntax:
8
+ enabled: true
9
+
10
+ CommitMsg:
11
+ CapitalizedSubject:
12
+ enabled: false
13
+ EmptyMessage:
14
+ enabled: true
15
+ MessageFormat:
16
+ enabled: true
17
+ pattern: "^(feat|fix|docs|style|refactor|perf|test|chore|revert)?: [A-Z].*"
18
+ sample_message: "feat: Add new feature"
19
+ TrailingPeriod:
20
+ enabled: true
21
+
22
+ PostCheckout:
23
+ ALL:
24
+ quiet: true
25
+ BundleInstall:
26
+ enabled: true
27
+ quiet: true
28
+
29
+ PrePush:
30
+ ALL:
31
+ quiet: true
32
+ Minitest:
33
+ enabled: true
data/lib/vimpk/cli.rb CHANGED
@@ -12,8 +12,8 @@ module VimPK
12
12
  @options = @parser.parse
13
13
  @command = determine_command
14
14
  rescue OptionParser::MissingArgument, OptionParser::InvalidOption => e
15
- puts e.message
16
- abort("Use --help for usage information")
15
+ warn e.message
16
+ abort help_message
17
17
  end
18
18
 
19
19
  def call
@@ -24,6 +24,12 @@ module VimPK
24
24
  end
25
25
  end
26
26
 
27
+ private
28
+
29
+ def help_message
30
+ "Use --help for usage information"
31
+ end
32
+
27
33
  def determine_command
28
34
  return nil if @argv.empty?
29
35
 
@@ -31,12 +37,15 @@ module VimPK
31
37
  case name
32
38
  when "i", "install"
33
39
  :install_command
40
+ when "mv", "move"
41
+ :move_command
34
42
  when "u", "update"
35
43
  :update_command
36
44
  when "rm", "remove"
37
45
  :remove_command
38
46
  else
39
- raise ArgumentError, "Unknown command: #{name}"
47
+ warn colorize("Unknown command: #{name}", color: :yellow)
48
+ abort help_message
40
49
  end
41
50
  end
42
51
 
@@ -47,12 +56,20 @@ module VimPK
47
56
  install.call
48
57
  puts colorize("Installed #{package} to #{install.dest}. Took #{Time.now - time} seconds.", color: :green)
49
58
  rescue Git::GitError => e
50
- puts colorize("Error: #{e.message}", color: :red)
59
+ warn colorize("Error: #{e.message}", color: :yellow)
51
60
  abort e.output.lines.map { |line| " #{line}" }.join
52
61
  rescue Install::PackageExistsError => e
53
- puts colorize("Error: #{e.message}", color: :red)
62
+ abort colorize("Error: #{e.message}", color: :red)
54
63
  rescue ArgumentError => e
55
- puts colorize("Error: #{e.message}", color: :red)
64
+ abort colorize("Error: #{e.message}", color: :red)
65
+ end
66
+
67
+ def move_command(name = nil)
68
+ move = Move.new(name, @options[:path], @options[:pack], @options[:type])
69
+ move.call
70
+ puts colorize("Moved #{name} to #{move.dest}.", color: :green)
71
+ rescue Move::PackageNotFoundError, Move::MultiplePackagesFoundError, ArgumentError => e
72
+ abort colorize(e.message, color: :red)
56
73
  end
57
74
 
58
75
  def update_command
@@ -106,7 +123,7 @@ module VimPK
106
123
  Remove.new(name, @options[:path]).call
107
124
 
108
125
  puts colorize("Package #{name} removed.", color: :green)
109
- rescue ArgumentError, VimPK::Remove::PackageNotFound => e
126
+ rescue ArgumentError, VimPK::Remove::PackageNotFoundError => e
110
127
  abort colorize(e.message, color: :red)
111
128
  end
112
129
  end
@@ -3,6 +3,7 @@ module VimPK
3
3
  private
4
4
 
5
5
  def colorize_diff(line)
6
+ return line if ENV["NO_COLOR"]
6
7
  case line
7
8
  when /^diff --git/
8
9
  "\e[1;34m#{line}\e[0m"
@@ -24,6 +25,7 @@ module VimPK
24
25
  end
25
26
 
26
27
  def colorize(text, color: :green)
28
+ return text if ENV["NO_COLOR"]
27
29
  case color
28
30
  when :green
29
31
  "\e[32m#{text}\e[0m"
data/lib/vimpk/move.rb ADDED
@@ -0,0 +1,41 @@
1
+ require "fileutils"
2
+
3
+ module VimPK
4
+ class Move
5
+ PackageNotFoundError = Class.new(StandardError)
6
+ MultiplePackagesFoundError = Class.new(StandardError)
7
+
8
+ attr_reader :dest
9
+
10
+ def initialize(name, path, pack = nil, type = nil)
11
+ @name = name || raise(ArgumentError, "Package name is required")
12
+ raise ArgumentError, "New pack or type is required" unless pack || type
13
+ @path = path
14
+ @pack = pack
15
+ @type = type
16
+ end
17
+
18
+ def call
19
+ glob = Dir.glob(File.join(@path, "*", "{start,opt}", @name))
20
+
21
+ if glob.empty?
22
+ raise PackageNotFoundError, "Package #{@name} not found in #{@path}."
23
+ elsif glob.size > 1
24
+ raise MultiplePackagesFoundError, "Multiple packages #{@name} found in #{glob.join(" and ")}."
25
+ else
26
+ source = glob.first
27
+ current_type = File.basename(File.dirname(source))
28
+ current_pack = File.basename(File.dirname(File.dirname(source)))
29
+ @dest = File.join(@path, @pack || current_pack, @type || current_type, @name)
30
+
31
+ if File.exist?(dest)
32
+ raise ArgumentError, "Package #{@name} already exists in #{dest}."
33
+ else
34
+ FileUtils.mkdir_p(File.dirname(dest))
35
+ end
36
+
37
+ FileUtils.mv(source, dest)
38
+ end
39
+ end
40
+ end
41
+ end
data/lib/vimpk/options.rb CHANGED
@@ -54,6 +54,7 @@ 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
58
  parser.separator " u|update Update all packages"
58
59
  parser.separator " rm|remove NAME Remove all occurrences of a package"
59
60
  end
data/lib/vimpk/remove.rb CHANGED
@@ -2,7 +2,7 @@ require "fileutils"
2
2
 
3
3
  module VimPK
4
4
  class Remove
5
- PackageNotFound = Class.new(StandardError)
5
+ PackageNotFoundError = Class.new(StandardError)
6
6
 
7
7
  def initialize(name, path)
8
8
  @name = name || raise(ArgumentError, "Package name is required")
@@ -13,7 +13,7 @@ module VimPK
13
13
  glob = Dir.glob(File.join(@path, "*", "{start,opt}", @name))
14
14
 
15
15
  if glob.empty?
16
- raise PackageNotFound, "Package #{@name} not found in #{@path}."
16
+ raise PackageNotFoundError, "Package #{@name} not found in #{@path}."
17
17
  else
18
18
  glob.each do |dir|
19
19
  FileUtils.rm_rf(dir)
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.1.2"
4
+ VERSION = "0.3.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 :Move, "vimpk/move"
18
19
  autoload :Options, "vimpk/options"
19
20
  autoload :Remove, "vimpk/remove"
20
21
  autoload :ThreadPool, "vimpk/thread_pool"
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.1.2
4
+ version: 0.3.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-15 00:00:00.000000000 Z
11
+ date: 2024-03-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
13
+ description:
14
14
  email:
15
15
  - piotr@layer22.com
16
16
  executables:
@@ -18,6 +18,7 @@ executables:
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - ".overcommit.yml"
21
22
  - LICENSE.txt
22
23
  - exe/vimpk
23
24
  - lib/vimpk.rb
@@ -26,11 +27,13 @@ files:
26
27
  - lib/vimpk/git.rb
27
28
  - lib/vimpk/install.rb
28
29
  - lib/vimpk/job.rb
30
+ - lib/vimpk/move.rb
29
31
  - lib/vimpk/options.rb
30
32
  - lib/vimpk/remove.rb
31
33
  - lib/vimpk/thread_pool.rb
32
34
  - lib/vimpk/update.rb
33
35
  - lib/vimpk/version.rb
36
+ - vimpk.gemspec
34
37
  homepage: https://github.com/pusewicz/vimpk
35
38
  licenses:
36
39
  - MIT
@@ -40,7 +43,7 @@ metadata:
40
43
  source_code_uri: https://github.com/pusewicz/vimpk
41
44
  changelog_uri: https://github.com/pusewicz/vimpk/blob/main/CHANGELOG.md
42
45
  github_repo: https://github.com/pusewicz/vimpk.git
43
- post_install_message:
46
+ post_install_message:
44
47
  rdoc_options: []
45
48
  require_paths:
46
49
  - lib
@@ -55,8 +58,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
58
  - !ruby/object:Gem::Version
56
59
  version: '0'
57
60
  requirements: []
58
- rubygems_version: 3.5.6
59
- signing_key:
61
+ rubygems_version: 3.5.3
62
+ signing_key:
60
63
  specification_version: 4
61
64
  summary: VimPK is a tool for managing Vim plugins via packages.
62
65
  test_files: []