gem_dating 0.1.0 → 0.1.1

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
2
  SHA256:
3
- metadata.gz: 240b4b51a3ff7ea51e8f5133c5980b857656499d37cb9dca2e427f084f5d8e9f
4
- data.tar.gz: 3bee7a49cb6cff56b5ca793cd49103c2e16f60a74dcb8c98313e83c4c3bde008
3
+ metadata.gz: ebf7931775d179eea359a6c01e14d3a194a4de2071d32bafbc9571a244459eb0
4
+ data.tar.gz: 9b24ce47c704e0184cdb426828b8af87171fa7097f268a83ac02992c43131e26
5
5
  SHA512:
6
- metadata.gz: 350ac78f61900661889eeb66bb3f4ccf9d54d752d8d9034aa910e40827aa3faf0ff8e96c67db75df8a67413e8f18dcdae3359685a45a48d26e68f67133228962
7
- data.tar.gz: b03e680f2824c6e8a6a67bc3a8664946e00e5bf881ce1a4977b9e851b5a0596806b55abd6c6272ce737e43c5e499e276e2bb7f3784001c5533c1ad3ffa3cef86
6
+ metadata.gz: c4284c4873a6e5ec38181b7a09f0ac66830831b7cfe3513b3f30ab3aa8b477825608cb42d3c529f32fa47c3487c6e9bda7a57c303921d26a6f7deca53d8bfab6
7
+ data.tar.gz: c975b8fb6164e3f99c9049bc59b92d5456b33c2370f91ac32b86539d3227b71646d6648975d6764bd0eb19a56e7575e22ad882c415ef8cf26b9bf47e4904a5fa
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gem_dating (0.1.0)
4
+ gem_dating (0.1.1)
5
5
  bundler
6
6
  table_print
7
7
 
@@ -56,6 +56,7 @@ GEM
56
56
  unicode-display_width (2.4.2)
57
57
 
58
58
  PLATFORMS
59
+ arm64-darwin-21
59
60
  arm64-darwin-22
60
61
  x86_64-linux
61
62
 
data/README.md CHANGED
@@ -1,47 +1,53 @@
1
1
  # GemDating
2
2
 
3
- GemDating is a library for determining the relative age of a set of gems.
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
- cause trouble if you're targeting an upgrade to Ruby 4.1
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
- ### Installation
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 *very* limited command line interface. It may be invoked with:
27
+ This gem provides a small command line interface. It may be invoked with:
21
28
 
22
29
  ```bash
23
- $ gem_dating [path/to/Gemfile]
30
+ $ gem_dating
24
31
  ```
25
32
 
26
- Given a path to a Gemfile, GemDating will output a list of gems and their relative ages to the stdout stream.
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
- For example:
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
- Or you can run
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
- The command line output will look something like this:
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
@@ -3,19 +3,42 @@ module GemDating
3
3
  SUCCESS = 0
4
4
  GENERAL_ERROR = 1
5
5
 
6
- def initialize(argv)
7
- @argv = argv
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 @argv.empty?
12
- $stdout << "Usage: gem_dating [GEMFILE_FILEPATH]\n"
13
- return GENERAL_ERROR
24
+ if (@args & ['-h', '--help']).any?
25
+ $stdout << HELP_TEXT
26
+ return SUCCESS
14
27
  end
15
28
 
16
- path = @argv.first
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(path).table_print << "\n"
41
+ $stdout << GemDating.from_file(@file_path).table_print << "\n"
19
42
 
20
43
  SUCCESS
21
44
  end
@@ -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
- return if line.strip == "end"
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
@@ -1,3 +1,3 @@
1
1
  module GemDating
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-07-19 00:00:00.000000000 Z
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.6
91
+ rubygems_version: 3.4.13
92
92
  signing_key:
93
93
  specification_version: 4
94
94
  summary: How old is that anyway?