vimpk 0.1.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.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +33 -0
- data/Rakefile +10 -0
- data/Steepfile +29 -0
- data/exe/vimpk +7 -0
- data/lib/vimpk/cli.rb +9 -0
- data/lib/vimpk/colorizer.rb +37 -0
- data/lib/vimpk/job.rb +34 -0
- data/lib/vimpk/thread_pool.rb +26 -0
- data/lib/vimpk/update.rb +72 -0
- data/lib/vimpk/version.rb +5 -0
- data/lib/vimpk.rb +18 -0
- data/sig/vimpk.rbs +4 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3c7dead9ffe26e414571f4abe1cefd9f4062c7d371fb2a04659c05387af8c5bd
|
4
|
+
data.tar.gz: 249aad7c6ef651efed1ad2a449a79f0cffdd386973750209a2ff312ebba081e0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 806ad154df6624026c2055b08290fc300b544df9c8c68873cfadeb81099ec52a714519ac35e690ce2b686bbe541317b28d4ecfd11aeb47d75ef81af30e836378
|
7
|
+
data.tar.gz: a3d1730a8cb5f1e54f7e26bc991e2263aace1d563610f3259f78acbe96c3c484a3b9d6d86fa2ab5a8ca7fe6c1cbe6f1c3f0758ebd829f4e91f7723409e539167
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Piotr Usewicz
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# VimPK
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/vimpk`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem by executing:
|
8
|
+
|
9
|
+
$ gem install vimpk
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
To use the gem, you can run the following command:
|
14
|
+
|
15
|
+
$ vimpk
|
16
|
+
|
17
|
+
## Development
|
18
|
+
|
19
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
20
|
+
|
21
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pusewicz/vimpk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/pusewicz/vimpk/blob/main/CODE_OF_CONDUCT.md).
|
26
|
+
|
27
|
+
## License
|
28
|
+
|
29
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
30
|
+
|
31
|
+
## Code of Conduct
|
32
|
+
|
33
|
+
Everyone interacting in the Vimpk project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pusewicz/vimpk/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/Steepfile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# D = Steep::Diagnostic
|
2
|
+
#
|
3
|
+
# target :lib do
|
4
|
+
# signature "sig"
|
5
|
+
#
|
6
|
+
# check "lib" # Directory name
|
7
|
+
# check "Gemfile" # File name
|
8
|
+
# check "app/models/**/*.rb" # Glob
|
9
|
+
# # ignore "lib/templates/*.rb"
|
10
|
+
#
|
11
|
+
# # library "pathname" # Standard libraries
|
12
|
+
# # library "strong_json" # Gems
|
13
|
+
#
|
14
|
+
# # configure_code_diagnostics(D::Ruby.default) # `default` diagnostics setting (applies by default)
|
15
|
+
# # configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
|
16
|
+
# # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
|
17
|
+
# # configure_code_diagnostics(D::Ruby.silent) # `silent` diagnostics setting
|
18
|
+
# # configure_code_diagnostics do |hash| # You can setup everything yourself
|
19
|
+
# # hash[D::Ruby::NoMethod] = :information
|
20
|
+
# # end
|
21
|
+
# end
|
22
|
+
|
23
|
+
# target :test do
|
24
|
+
# signature "sig", "sig-private"
|
25
|
+
#
|
26
|
+
# check "test"
|
27
|
+
#
|
28
|
+
# # library "pathname" # Standard libraries
|
29
|
+
# end
|
data/exe/vimpk
ADDED
data/lib/vimpk/cli.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module VimPK
|
2
|
+
module Colorizer
|
3
|
+
private
|
4
|
+
|
5
|
+
def colorize_diff(line)
|
6
|
+
case line
|
7
|
+
when /^diff --git/
|
8
|
+
"\e[1;34m#{line}\e[0m"
|
9
|
+
when /^index/
|
10
|
+
"\e[1;36m#{line}\e[0m"
|
11
|
+
when /^---/
|
12
|
+
"\e[1;31m#{line}\e[0m"
|
13
|
+
when /^\+\+\+/
|
14
|
+
"\e[1;32m#{line}\e[0m"
|
15
|
+
when /^@@/
|
16
|
+
"\e[1;33m#{line}\e[0m"
|
17
|
+
when /^\+/
|
18
|
+
"\e[1;32m#{line}\e[0m"
|
19
|
+
when /^-/
|
20
|
+
"\e[1;31m#{line}\e[0m"
|
21
|
+
else
|
22
|
+
line
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def colorize(text, color: :green)
|
27
|
+
case color
|
28
|
+
when :green
|
29
|
+
"\e[32m#{text}\e[0m"
|
30
|
+
when :red
|
31
|
+
"\e[31m#{text}\e[0m"
|
32
|
+
when :blue
|
33
|
+
"\e[34m#{text}\e[0m"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/vimpk/job.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module VimPK
|
2
|
+
class Job
|
3
|
+
def initialize(dir, updates, output)
|
4
|
+
@dir = dir
|
5
|
+
@basename = File.basename(dir)
|
6
|
+
@updates = updates
|
7
|
+
@output = output
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
branch = git("rev-parse --abbrev-ref HEAD", dir: @dir)
|
12
|
+
git("fetch origin #{branch}", dir: @dir)
|
13
|
+
log = git("log -p --full-diff HEAD..origin/#{branch}", dir: @dir)
|
14
|
+
|
15
|
+
if log.empty?
|
16
|
+
puts("Already up to date.")
|
17
|
+
else
|
18
|
+
git("pull --rebase", dir: @dir)
|
19
|
+
@updates << {basename: @basename, log: log}
|
20
|
+
puts "Updated!"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def puts(message = "\n")
|
25
|
+
@output << {@basename => message}
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def git(command, dir:)
|
31
|
+
IO.popen("git -C #{dir} #{command}", dir: dir, err: [:child, :out]) { |io| io.read.chomp }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module VimPK
|
2
|
+
class ThreadPool
|
3
|
+
def initialize(size = Etc.nprocessors * 2)
|
4
|
+
@size = size
|
5
|
+
@jobs = Queue.new
|
6
|
+
@workers = Array.new(size) do
|
7
|
+
Thread.new(@jobs) do |jobs|
|
8
|
+
while (job = jobs.pop)
|
9
|
+
job.call
|
10
|
+
end
|
11
|
+
|
12
|
+
Thread.exit
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def schedule(job)
|
18
|
+
@jobs << job
|
19
|
+
end
|
20
|
+
|
21
|
+
def shutdown
|
22
|
+
@jobs.close
|
23
|
+
@workers.each(&:join)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/vimpk/update.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
module VimPK
|
2
|
+
class Update
|
3
|
+
include VimPK::Colorizer
|
4
|
+
|
5
|
+
def self.run
|
6
|
+
new.update
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(path = "~/.vim/pack")
|
10
|
+
@before = Time.now
|
11
|
+
@pack_dir = File.expand_path(path)
|
12
|
+
@updates = Queue.new
|
13
|
+
@output = Queue.new
|
14
|
+
@pool = ThreadPool.new
|
15
|
+
@dirs = Dir.glob(File.join(@pack_dir, "*", "{start,opt}", "*", ".git")).sort
|
16
|
+
@basenames = @dirs.map { |dir| File.basename(File.dirname(dir)) }
|
17
|
+
@longest_name = @basenames.map(&:length).max
|
18
|
+
end
|
19
|
+
|
20
|
+
def format_name(name)
|
21
|
+
name.rjust(@longest_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
def update
|
25
|
+
puts "Updating #{@dirs.size} plugins in #{@pack_dir}"
|
26
|
+
|
27
|
+
jobs = @dirs.map do |git_dir|
|
28
|
+
plugin_dir = File.dirname(git_dir)
|
29
|
+
@pool.schedule Job.new(plugin_dir, @updates, @output)
|
30
|
+
end
|
31
|
+
|
32
|
+
@pool.shutdown
|
33
|
+
@output.close
|
34
|
+
|
35
|
+
while (message = @output.pop)
|
36
|
+
case message
|
37
|
+
when String
|
38
|
+
Kernel.puts message
|
39
|
+
when Hash
|
40
|
+
basename = message.keys.first
|
41
|
+
message = message.values.first
|
42
|
+
message = case message
|
43
|
+
when "Updated!" then colorize(message, color: :green)
|
44
|
+
when "Already up to date." then colorize(message, color: :blue)
|
45
|
+
else message
|
46
|
+
end
|
47
|
+
puts "#{format_name(basename)}: #{message}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
puts
|
52
|
+
puts colorize("Done updating #{jobs.size} plugins. Took #{Time.now - @before} seconds.")
|
53
|
+
|
54
|
+
if @updates.size.nonzero?
|
55
|
+
print "Display diffs? (Y/n) "
|
56
|
+
|
57
|
+
answer = $stdin.getch
|
58
|
+
|
59
|
+
if answer.downcase == "y" || answer == "\r"
|
60
|
+
puts
|
61
|
+
puts "Displaying diffs…"
|
62
|
+
|
63
|
+
@updates.size.times do
|
64
|
+
update = @updates.pop
|
65
|
+
next if update[:log].empty?
|
66
|
+
puts update[:log].lines.map { |line| "#{format_name(update[:basename])}: #{colorize_diff line}" }.join
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/vimpk.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "io/console"
|
4
|
+
require "etc"
|
5
|
+
|
6
|
+
require_relative "vimpk/version"
|
7
|
+
|
8
|
+
Thread.abort_on_exception = true
|
9
|
+
|
10
|
+
module VimPK
|
11
|
+
class Error < StandardError; end
|
12
|
+
|
13
|
+
autoload :CLI, "vimpk/cli"
|
14
|
+
autoload :ThreadPool, "vimpk/thread_pool"
|
15
|
+
autoload :Job, "vimpk/job"
|
16
|
+
autoload :Colorizer, "vimpk/colorizer"
|
17
|
+
autoload :Update, "vimpk/update"
|
18
|
+
end
|
data/sig/vimpk.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vimpk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Piotr Usewicz
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-03-15 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- piotr@layer22.com
|
16
|
+
executables:
|
17
|
+
- vimpk
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- LICENSE.txt
|
22
|
+
- README.md
|
23
|
+
- Rakefile
|
24
|
+
- Steepfile
|
25
|
+
- exe/vimpk
|
26
|
+
- lib/vimpk.rb
|
27
|
+
- lib/vimpk/cli.rb
|
28
|
+
- lib/vimpk/colorizer.rb
|
29
|
+
- lib/vimpk/job.rb
|
30
|
+
- lib/vimpk/thread_pool.rb
|
31
|
+
- lib/vimpk/update.rb
|
32
|
+
- lib/vimpk/version.rb
|
33
|
+
- sig/vimpk.rbs
|
34
|
+
homepage: https://github.com/pusewicz/vimpk
|
35
|
+
licenses:
|
36
|
+
- MIT
|
37
|
+
metadata:
|
38
|
+
allowed_push_host: https://rubygems.org
|
39
|
+
homepage_uri: https://github.com/pusewicz/vimpk
|
40
|
+
source_code_uri: https://github.com/pusewicz/vimpk
|
41
|
+
changelog_uri: https://github.com/pusewicz/vimpk/blob/main/CHANGELOG.md
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 3.0.0
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubygems_version: 3.5.6
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: VimPK is a tool for managing Vim plugins via packages.
|
61
|
+
test_files: []
|