gem_dating 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -1
- data/README.md +24 -18
- data/lib/gem_dating/cli.rb +30 -7
- data/lib/gem_dating/input.rb +4 -3
- data/lib/gem_dating/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebf7931775d179eea359a6c01e14d3a194a4de2071d32bafbc9571a244459eb0
|
4
|
+
data.tar.gz: 9b24ce47c704e0184cdb426828b8af87171fa7097f268a83ac02992c43131e26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4284c4873a6e5ec38181b7a09f0ac66830831b7cfe3513b3f30ab3aa8b477825608cb42d3c529f32fa47c3487c6e9bda7a57c303921d26a6f7deca53d8bfab6
|
7
|
+
data.tar.gz: c975b8fb6164e3f99c9049bc59b92d5456b33c2370f91ac32b86539d3227b71646d6648975d6764bd0eb19a56e7575e22ad882c415ef8cf26b9bf47e4904a5fa
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,47 +1,53 @@
|
|
1
1
|
# GemDating
|
2
2
|
|
3
|
-
|
3
|
+
`gem_dating` is a library for determining the relative age of a set of gems.
|
4
4
|
|
5
|
-
The primary use case is when evaluating a codebase for upgrades - a gem from 2017 may effectively be abandoned and could
|
6
|
-
|
5
|
+
The primary use case is when evaluating a codebase for upgrades - a gem from 2017 may effectively be abandoned and could cause trouble if you're targeting an upgrade to Ruby 4.1
|
6
|
+
|
7
|
+
`gem_dating` avoids utilizing Bundler, and intends to be useful where you want to evaluate a set of gems without
|
8
|
+
the overhead of a full bundle install. If you've got a valid bundle you should consider the built in
|
9
|
+
[bundle-outdated](https://bundler.io/v2.4/man/bundle-outdated.1.html), or other available tools for interacting
|
10
|
+
with your Gemfile, like [libyear-bundler](https://github.com/jaredbeck/libyear-bundler).
|
7
11
|
|
8
12
|
## Usage
|
9
13
|
|
10
|
-
|
14
|
+
If you have rubygems 3.4.8 or later installed, you can skip installation and just run via `gem exec gem_dating [[path/to/Gemfile]`
|
15
|
+
|
16
|
+
|
17
|
+
### Gem Installation
|
11
18
|
|
12
19
|
`gem install gem_dating` or add it to your Gemfile:
|
13
20
|
|
14
21
|
```ruby
|
15
|
-
gem 'gem_dating', group: [:development]
|
22
|
+
gem 'gem_dating', group: [:development], require: false
|
16
23
|
```
|
17
24
|
|
18
25
|
### Running GemDating
|
19
26
|
|
20
|
-
This gem provides a
|
27
|
+
This gem provides a small command line interface. It may be invoked with:
|
21
28
|
|
22
29
|
```bash
|
23
|
-
$ gem_dating
|
30
|
+
$ gem_dating
|
24
31
|
```
|
25
32
|
|
26
|
-
|
33
|
+
By default, GemDating will look for a Gemfile in the current directory.
|
34
|
+
If it finds one, it will output a list of gems and their relative ages to the stdout stream.
|
27
35
|
|
28
|
-
|
36
|
+
You may also pass a path to a Gemfile as an argument:
|
29
37
|
|
30
38
|
```bash
|
31
39
|
$ gem_dating ~/code/my_app/Gemfile
|
32
40
|
```
|
33
|
-
to read the output in your terminal.
|
34
41
|
|
35
|
-
|
42
|
+
GemDating leans on `$stdout`, so you can pipe the output to a file if you'd like:
|
36
43
|
```bash
|
37
44
|
$ gem_dating ~/code/my_app/Gemfile > ~/code/my_app/gem_ages.txt
|
38
45
|
```
|
39
|
-
which will pipe the output into a text file.
|
40
46
|
|
41
|
-
|
47
|
+
[TablePrint](https://github.com/arches/table_print) formats the output to something like this:
|
42
48
|
|
43
49
|
```bash
|
44
|
-
NAME | VERSION | DATE
|
50
|
+
NAME | VERSION | DATE
|
45
51
|
------------|---------|-----------
|
46
52
|
rest-client | 2.1.0 | 2019-08-21
|
47
53
|
rails | 7.0.5 | 2023-05-24
|
@@ -53,7 +59,7 @@ passing in a string of a gem name, or a path to a Gemfile. You can then parse th
|
|
53
59
|
a minimal hash, or the Table output you'd see in the CLI.
|
54
60
|
|
55
61
|
```ruby
|
56
|
-
# irb
|
62
|
+
# irb
|
57
63
|
# #:001 >
|
58
64
|
|
59
65
|
require "gem_dating"
|
@@ -64,16 +70,16 @@ more_dating = GemDating.from_file("path/to/Gemfile")
|
|
64
70
|
|
65
71
|
|
66
72
|
dating.to_a
|
67
|
-
# => [Gem::Specification.new do |s|
|
73
|
+
# => [Gem::Specification.new do |s|
|
68
74
|
# s.name = "rails"
|
69
75
|
# s.version = Gem::Version.new("7.0.5")
|
70
76
|
# s.installed_by_version = Gem::Version.new("0") ...etc
|
71
77
|
|
72
78
|
dating.to_h
|
73
|
-
# => {"rails"=>{"name"=>"rails", "version"=>"7.0.5", "date"=>"2023-05-24"}}
|
79
|
+
# => {"rails"=>{"name"=>"rails", "version"=>"7.0.5", "date"=>"2023-05-24"}}
|
74
80
|
|
75
81
|
more_dating.table_print
|
76
|
-
# =>
|
82
|
+
# =>
|
77
83
|
# NAME | VERSION | DATE
|
78
84
|
# ------------|---------|-----------
|
79
85
|
# rails | 7.0.5 | 2023-05-24
|
data/lib/gem_dating/cli.rb
CHANGED
@@ -3,19 +3,42 @@ module GemDating
|
|
3
3
|
SUCCESS = 0
|
4
4
|
GENERAL_ERROR = 1
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
HELP_TEXT =
|
7
|
+
<<~HELP
|
8
|
+
gem_dating [--help | -h] [<GEMFILE_FILEPATH>]
|
9
|
+
|
10
|
+
GEMFILE_FILEPATH defaults to ./Gemfile if not provided.
|
11
|
+
|
12
|
+
Options:
|
13
|
+
--help, -h Show this help message
|
14
|
+
HELP
|
15
|
+
|
16
|
+
def initialize(argv = [])
|
17
|
+
args, file_path = argv.partition { |arg| (arg =~ /--\w+/) || (arg =~ /(-[a-z])/) }
|
18
|
+
|
19
|
+
@args = args
|
20
|
+
@file_path = file_path.first
|
8
21
|
end
|
9
22
|
|
10
23
|
def run
|
11
|
-
if @
|
12
|
-
$stdout <<
|
13
|
-
return
|
24
|
+
if (@args & ['-h', '--help']).any?
|
25
|
+
$stdout << HELP_TEXT
|
26
|
+
return SUCCESS
|
14
27
|
end
|
15
28
|
|
16
|
-
|
29
|
+
unless @file_path
|
30
|
+
current_directory = Dir.pwd
|
31
|
+
file_path = File.join(current_directory, "Gemfile")
|
32
|
+
|
33
|
+
if File.exist?(file_path)
|
34
|
+
@file_path = file_path
|
35
|
+
else
|
36
|
+
$stdout << HELP_TEXT
|
37
|
+
return GENERAL_ERROR
|
38
|
+
end
|
39
|
+
end
|
17
40
|
|
18
|
-
$stdout << GemDating.from_file(
|
41
|
+
$stdout << GemDating.from_file(@file_path).table_print << "\n"
|
19
42
|
|
20
43
|
SUCCESS
|
21
44
|
end
|
data/lib/gem_dating/input.rb
CHANGED
@@ -19,17 +19,18 @@ module GemDating
|
|
19
19
|
lines.each_with_object([]) do |line, gems|
|
20
20
|
line = gem_line(line.strip)
|
21
21
|
gems << cleanup(line) if line
|
22
|
-
end
|
22
|
+
end.uniq
|
23
23
|
end
|
24
24
|
|
25
25
|
def gem_line(line)
|
26
|
-
|
26
|
+
single_word_ruby_statements = %w{end else # gemspec}
|
27
|
+
return if single_word_ruby_statements.include? line.strip
|
27
28
|
|
28
29
|
if line.start_with? "gem("
|
29
30
|
line.split("(")[1].split(",")[0]
|
30
31
|
elsif line.start_with? "gem"
|
31
32
|
line.split[1].split(",")[0]
|
32
|
-
elsif line.split.length == 1
|
33
|
+
elsif line.split.length == 1 # match "just" gemname
|
33
34
|
line
|
34
35
|
end
|
35
36
|
end
|
data/lib/gem_dating/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_dating
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Jackson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
|
-
rubygems_version: 3.4.
|
91
|
+
rubygems_version: 3.4.13
|
92
92
|
signing_key:
|
93
93
|
specification_version: 4
|
94
94
|
summary: How old is that anyway?
|