latest_version 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: dda6fe0f325a80126ace0f9e2b262e125caac6757562cc70a466b019aec8e587
4
- data.tar.gz: f56342dfa1ea4ae6cfae2f70ee8602e4779858aae69da26656a74964425a8737
2
+ SHA1:
3
+ metadata.gz: 68f299f299d037cbd1b7b2a657198ae1e66cfbf8
4
+ data.tar.gz: 30a0b933c6959e26b91576667624ce60e4b7fb62
5
5
  SHA512:
6
- metadata.gz: bc5ad872e920e2397f326c61c116fd67bbf46023d349f93ab5bc6e54c979455a1ee4e33026ef9da166d06f9a05cf15b3042ac695673683307ff84adc283ad7a2
7
- data.tar.gz: a62c72144017fcaa275d2242945b3add658c38989dc48df7731588741a5050efbd7cab3b40118d977e650197c8bcf39433c2b1e1d02012c43c27312695c66f0c
6
+ metadata.gz: f640866198c3d1211e7aea905cec773152fa18fd1bc4030b2431dacec571f0af0c085ff477b17d540fbd39e3b37baed9f8b09651992cc7a9c3017f5eba20baa7
7
+ data.tar.gz: cd397dcca305c40704bdde30d4d2ae0c04f7fad470c48c6b8f4a5609eaef1df83208e939fa1374af42f6738198e94544e6870cbea09c01a393ddac117bac289e
data/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.2] - 2020-02-18
11
+
12
+ ### Added
13
+
14
+ - Shell completion for bash and fish.
15
+
10
16
  ## [0.1.1] - 2020-02-15
11
17
 
12
18
  ### Added
@@ -20,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
20
26
 
21
27
  - Support for ruby, rails and python.
22
28
 
23
- [unreleased]: https://github.com/zubin/latest_version/compare/v0.1.1...HEAD
29
+ [unreleased]: https://github.com/zubin/latest_version/compare/v0.1.2...HEAD
30
+ [0.1.2]: https://github.com/zubin/latest_version/compare/v0.1.1...v0.1.2
24
31
  [0.1.1]: https://github.com/zubin/latest_version/compare/v0.1.0...v0.1.1
25
32
  [0.1.0]: https://github.com/zubin/latest_version/releases/tag/v0.1.0
data/README.md CHANGED
@@ -15,12 +15,14 @@ $ gem install latest_version
15
15
  ```sh
16
16
  $ latest_version --help
17
17
  Commands:
18
- latest_version elixir # Returns latest version of elixir
19
- latest_version help [COMMAND] # Describe available commands or one specific command
20
- latest_version python # Returns latest version of python
21
- latest_version rails # Returns latest version of rails
22
- latest_version ruby # Returns latest version of ruby
23
- latest_version rust # Returns latest version of rust
18
+ latest_version completion SHELL # Installs shell completion
19
+ latest_version completions # Lists supported completions
20
+ latest_version elixir # Returns latest version of elixir
21
+ latest_version help [COMMAND] # Describe available commands or one specific command
22
+ latest_version python # Returns latest version of python
23
+ latest_version rails # Returns latest version of rails
24
+ latest_version ruby # Returns latest version of ruby
25
+ latest_version rust # Returns latest version of rust
24
26
  ```
25
27
 
26
28
  ## Contributing
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ _latest_version() {
6
+ COMPREPLY=()
7
+ local word="${COMP_WORDS[COMP_CWORD]}"
8
+ case "$COMP_CWORD" in
9
+ 1 )
10
+ local words="$(latest_version --help |awk '/^ [a-z]/ {print $2}')"
11
+ local completions="$(compgen -W "$words" -- "$word")"
12
+ COMPREPLY=( $completions )
13
+ ;;
14
+ 2 )
15
+ case "${COMP_WORDS[1]}" in
16
+ completion )
17
+ local words="$(latest_version completions)"
18
+ local completions="$(compgen -W "$words" -- "$word")"
19
+ COMPREPLY=( $completions )
20
+ ;;
21
+ esac
22
+ ;;
23
+ esac
24
+ }
25
+
26
+ alias lv=latest_version
27
+ complete -F _latest_version latest_version lv
@@ -0,0 +1,15 @@
1
+ complete -c latest_version -x -a '(__fish_latest_version_completion)'
2
+
3
+ function __fish_latest_version_completion
4
+ set cmd (commandline -opc)
5
+ switch (count $cmd)
6
+ case 1
7
+ latest_version --help |awk '/^ [a-z]/ {print $2}'
8
+ case 2
9
+ if [ $cmd[2] = 'completion' ]
10
+ latest_version completions
11
+ end
12
+ end
13
+ end
14
+
15
+ abbr --add lv latest_version
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Zubin Henner"]
9
9
  spec.email = ['zubin@users.noreply.github.com']
10
10
 
11
- spec.summary = "Utility for looking up latest versions of open source libraries"
11
+ spec.summary = "Look up latest versions of open source libraries from your shell."
12
12
  spec.homepage = 'https://github.com/zubin/latest_version'
13
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
14
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'thor'
4
4
  require 'latest_version'
5
+ require 'latest_version/completion'
5
6
 
6
7
  module LatestVersion
7
8
  class CLI < Thor
@@ -11,9 +12,15 @@ module LatestVersion
11
12
 
12
13
  LatestVersion.supported_libraries.each do |library|
13
14
  desc library, "Returns latest version of #{library}"
14
- define_method(library) do
15
- puts LatestVersion.call(library)
16
- end
15
+ define_method(library) { puts LatestVersion.call(library) }
16
+ end
17
+
18
+ desc 'completion SHELL', "Installs shell completion"
19
+ subcommand 'completion', Completion::Install
20
+
21
+ desc 'completions', "Lists supported completions"
22
+ def completions
23
+ puts Completion::SUPPORTED.keys.join("\n")
17
24
  end
18
25
  end
19
26
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+
5
+ module LatestVersion
6
+ module Completion
7
+ SOURCE_DIR = File.expand_path('../../completions', __dir__)
8
+ SUPPORTED = Dir[File.join(SOURCE_DIR, 'latest_version.*')].sort.each_with_object({}) do |path, result|
9
+ result.merge!(File.extname(path)[1..-1] => path)
10
+ end
11
+
12
+ class Install < Thor
13
+ TARGET_DIRS = {
14
+ bash: "#{ENV['HOME']}/.bash_completion.d",
15
+ fish: "#{ENV['HOME']}/.config/fish/completions",
16
+ }.freeze
17
+ private_constant :TARGET_DIRS
18
+
19
+ Completion::SUPPORTED.each do |shell, source_path|
20
+ desc shell, "Installs #{shell} completion"
21
+ define_method shell do
22
+ target_path = File.join(TARGET_DIRS[shell.to_sym], File.basename(source_path))
23
+ FileUtils.mkdir_p(File.dirname(target_path))
24
+ FileUtils.cp(source_path, target_path)
25
+ puts "#{shell} completion was written to #{target_path}"
26
+ if shell == 'bash'
27
+ tilde_target_path = target_path.gsub(ENV['HOME'], '~')
28
+ return unless yes?(<<~MESSAGE)
29
+
30
+ To take effect, the completion file needs to be read by your .bash_profile, eg:
31
+
32
+ echo 'source "#{tilde_target_path}" >> ~/.bash_profile'
33
+
34
+ Would you like us to set that up?
35
+ MESSAGE
36
+
37
+ File.open("#{ENV['HOME']}/.bash_profile", 'a') do |f|
38
+ f << <<~SH
39
+ # Completion for latest_version (https://rubygems.org/gems/latest_version)
40
+ source "#{tilde_target_path}"
41
+ SH
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LatestVersion
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: latest_version
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zubin Henner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-14 00:00:00.000000000 Z
11
+ date: 2020-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -127,10 +127,13 @@ files:
127
127
  - Rakefile
128
128
  - bin/console
129
129
  - bin/setup
130
+ - completions/latest_version.bash
131
+ - completions/latest_version.fish
130
132
  - exe/latest_version
131
133
  - latest_version.gemspec
132
134
  - lib/latest_version.rb
133
135
  - lib/latest_version/cli.rb
136
+ - lib/latest_version/completion.rb
134
137
  - lib/latest_version/version.rb
135
138
  homepage: https://github.com/zubin/latest_version
136
139
  licenses: []
@@ -153,8 +156,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
156
  - !ruby/object:Gem::Version
154
157
  version: '0'
155
158
  requirements: []
156
- rubygems_version: 3.0.3
159
+ rubyforge_project:
160
+ rubygems_version: 2.5.2
157
161
  signing_key:
158
162
  specification_version: 4
159
- summary: Utility for looking up latest versions of open source libraries
163
+ summary: Look up latest versions of open source libraries from your shell.
160
164
  test_files: []