lapidario 0.3beta.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -2
- data/Gemfile.lock +52 -49
- data/README.md +244 -14
- data/lapidario.gemspec +1 -1
- data/lib/cli.rb +12 -2
- data/lib/helper.rb +24 -0
- data/lib/lapidario/version.rb +1 -1
- data/lib/lapidario.rb +8 -2
- data/lib/lockfile_info.rb +26 -5
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac6351fd6287f63d313277b313231b9f1e5fe809982162b94b5d832f40169536
|
4
|
+
data.tar.gz: dac1e885c62aeb6dc898501cf76fe8e9feab2f7fe9fb309a2d5d2c3e5e764fe9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32712f93027f79fc4ca2139c29a9fea8edac5e0a1eb67ea0400bc169fef1fff4c346592b1a10afb96a16be3eea06b82d90a68f3ac876235f61875ad0fd38b0cf
|
7
|
+
data.tar.gz: c1cc7582ef0b8dd17ddc837b3236a086e4a5bceb43e43bfd34da9bfaeb934b36df6b98306a8efbf0c9ea9f3c6e9e2a3976c1425bf5d3e058ae0be628af31f9c7
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,57 +1,60 @@
|
|
1
|
-
|
2
|
-
remote: .
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/ClearlyClaire/webpush.git
|
3
|
+
revision: f14a4d52e201128b1b00245d11b6de80d6cfdcd9
|
4
|
+
ref: f14a4d52e201128b1b00245d11b6de80d6cfdcd9
|
3
5
|
specs:
|
4
|
-
|
6
|
+
webpush (0.3.8)
|
7
|
+
hkdf (~> 0.2)
|
8
|
+
jwt (~> 2.0)
|
9
|
+
|
10
|
+
GIT
|
11
|
+
remote: https://github.com/jhawthorn/nsa.git
|
12
|
+
revision: e020fcc3a54d993ab45b7194d89ab720296c111b
|
13
|
+
ref: e020fcc3a54d993ab45b7194d89ab720296c111b
|
14
|
+
specs:
|
15
|
+
nsa (0.2.8)
|
16
|
+
activesupport (>= 4.2, < 7.2)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
sidekiq (>= 3.5)
|
19
|
+
statsd-ruby (~> 1.4, >= 1.4.0)
|
20
|
+
|
21
|
+
GIT
|
22
|
+
remote: https://github.com/mastodon/rails-settings-cached.git
|
23
|
+
revision: 86328ef0bd04ce21cc0504ff5e334591e8c2ccab
|
24
|
+
branch: v0.6.6-aliases-true
|
25
|
+
specs:
|
26
|
+
rails-settings-cached (0.6.6)
|
27
|
+
rails (>= 4.2.0)
|
28
|
+
|
29
|
+
GIT
|
30
|
+
remote: https://github.com/stanhu/omniauth-cas.git
|
31
|
+
revision: 4211e6d05941b4a981f9a36b49ec166cecd0e271
|
32
|
+
ref: 4211e6d05941b4a981f9a36b49ec166cecd0e271
|
33
|
+
specs:
|
34
|
+
omniauth-cas (2.0.0)
|
35
|
+
addressable (~> 2.3)
|
36
|
+
nokogiri (~> 1.5)
|
37
|
+
omniauth (>= 1.2, < 3)
|
5
38
|
|
6
39
|
GEM
|
7
40
|
remote: https://rubygems.org/
|
8
41
|
specs:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
regexp_parser (2.8.2)
|
26
|
-
rexml (3.2.6)
|
27
|
-
rspec (3.12.0)
|
28
|
-
rspec-core (~> 3.12.0)
|
29
|
-
rspec-expectations (~> 3.12.0)
|
30
|
-
rspec-mocks (~> 3.12.0)
|
31
|
-
rspec-core (3.12.2)
|
32
|
-
rspec-support (~> 3.12.0)
|
33
|
-
rspec-expectations (3.12.3)
|
34
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.12.0)
|
36
|
-
rspec-mocks (3.12.6)
|
37
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.12.0)
|
39
|
-
rspec-support (3.12.1)
|
40
|
-
rubocop (1.57.2)
|
41
|
-
json (~> 2.3)
|
42
|
-
language_server-protocol (>= 3.17.0)
|
43
|
-
parallel (~> 1.10)
|
44
|
-
parser (>= 3.2.2.4)
|
45
|
-
rainbow (>= 2.2.2, < 4.0)
|
46
|
-
regexp_parser (>= 1.8, < 3.0)
|
47
|
-
rexml (>= 3.2.5, < 4.0)
|
48
|
-
rubocop-ast (>= 1.28.1, < 2.0)
|
49
|
-
ruby-progressbar (~> 1.7)
|
50
|
-
unicode-display_width (>= 2.4.0, < 3.0)
|
51
|
-
rubocop-ast (1.30.0)
|
52
|
-
parser (>= 3.2.1.0)
|
53
|
-
ruby-progressbar (1.13.0)
|
54
|
-
unicode-display_width (2.5.0)
|
42
|
+
actioncable (7.1.2)
|
43
|
+
actionpack (= 7.1.2)
|
44
|
+
activesupport (= 7.1.2)
|
45
|
+
nio4r (~> 2.0)
|
46
|
+
websocket-driver (>= 0.6.1)
|
47
|
+
zeitwerk (~> 2.6)
|
48
|
+
actionmailbox (7.1.2)
|
49
|
+
actionpack (= 7.1.2)
|
50
|
+
activejob (= 7.1.2)
|
51
|
+
activerecord (= 7.1.2)
|
52
|
+
activestorage (= 7.1.2)
|
53
|
+
activesupport (= 7.1.2)
|
54
|
+
mail (>= 2.7.1)
|
55
|
+
net-imap
|
56
|
+
net-pop
|
57
|
+
net-smtp
|
55
58
|
|
56
59
|
PLATFORMS
|
57
60
|
x86_64-darwin-22
|
data/README.md
CHANGED
@@ -1,36 +1,266 @@
|
|
1
1
|
# Lapidario
|
2
|
-
'Lapidario' is a noun that is derived from the Latin 'lapidarius,
|
3
|
-
It is also a Gemfile and Gemfile.lock static analyzer made to help with edition and management of Gemfiles.
|
4
|
-
The idea for it was conceived while upgrading gem versions for a lot of Rails microservices at once.
|
5
|
-
Its main use is to make a Gemfile better reflect the current state of versions used in a project, and also to specify or maintain explicit gem versions in order to better avoid [dependency hell](https://en.wikipedia.org/wiki/Dependency_hell).
|
2
|
+
'***Lapidario***' is a noun that is derived from the Latin '***lapidarius***', which means "***of or relating to engraved stones or inscriptions***." It can also mean "***one who engraves stones or inscriptions***".
|
6
3
|
|
7
|
-
|
8
|
-
Let's suppose you have a project that has not been updated in a while. You would like to update every gem version in your gemfile except for, say, RSpec.
|
9
|
-
<add # LOCK to the right of rspec, run lapidario reset, run bundle >
|
4
|
+
It is also a Gemfile and Gemfile.lock static analyzer made to help with updating and managing of Gemfiles.
|
10
5
|
|
11
|
-
|
6
|
+
The idea for it was conceived while upgrading gem versions for a lot of Rails microservices at once.
|
12
7
|
|
8
|
+
Its main use is to make a Gemfile better reflect the current state of versions used in a project, and to specify or maintain explicit gem versions in order to better avoid [dependency hell](https://en.wikipedia.org/wiki/Dependency_hell).
|
13
9
|
|
14
10
|
## Installation
|
15
11
|
|
16
|
-
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
17
|
-
|
18
12
|
Install lts version:
|
19
|
-
|
13
|
+
```
|
14
|
+
gem install lapidario
|
15
|
+
```
|
20
16
|
|
21
17
|
Install pre-release version:
|
22
|
-
|
18
|
+
```
|
19
|
+
gem install lapidario --pre
|
20
|
+
```
|
21
|
+
|
22
|
+
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
26
|
-
|
26
|
+
We'll start with example workflows as Lapidario's functionality and utility are clearer when presented in a context, and then go through explanations on what each option does.
|
27
|
+
|
28
|
+
### Example Workflow #1 : Performing a Minor Update
|
29
|
+
|
30
|
+
Little Johnny wants to update his Ruby project and hard-code all gems as static versions to make sure everyone working on it will have the exact same dependencies.
|
31
|
+
|
32
|
+
He has a pretty robust Gemfile with most versions organized so this is very unlikely to break any functionality.
|
33
|
+
|
34
|
+
First he runs `bundle update` and notices that some gems indeed switched versions in the Lockfile. He runs `bundle exec rspec` and verifies that no tests are breaking, so the Gemfile is good to be updated.
|
35
|
+
|
36
|
+
He will then run Lapidario to get versions from Gemfile.lock up to patch, have no version sign (meaning the version installed will be exact) and will just print the new Gemfile to the console:
|
37
|
+
|
38
|
+
```lapidario -l -d 3 -v 5```
|
39
|
+
|
40
|
+
After checking everything is OK, he'll run the same command with the addition of the `-w` (write) flag, which will also keep the original as backup:
|
41
|
+
|
42
|
+
```lapidario -l -d 3 -v 5 -w```
|
43
|
+
|
44
|
+
`-l` tells lapidario to get version information from the Gemfile, `-d` specifies the depth of the version precision, `-v 5` specifies that the version sign will be empty and `-w` specifies that the newly built Gemfile should overwrite the current Gemfile.
|
45
|
+
|
46
|
+
So if he had a line in his Gemfile that looked like this:
|
47
|
+
```ruby
|
48
|
+
gem 'rspec', '~> 3'
|
49
|
+
```
|
50
|
+
It will now look somewhat like this:
|
51
|
+
```ruby
|
52
|
+
gem 'rspec', '3.2.0'
|
53
|
+
```
|
54
|
+
|
55
|
+
He checks the new Gemfile and everything looks good. If that wasn't the case,lapidario conveniently created `Gemfile.original` for easy restoration.
|
56
|
+
|
57
|
+
|
58
|
+
### Example Workflow #2 : Deep Updating Many Gems
|
59
|
+
Some years go by and Little Johnny decided he must once again update his project.
|
60
|
+
He must update pretty much every gem, but decides to keep the RSpec version to better check if any new test failures are being caused by new gem features and changes in interfaces other than RSpec's own possible deprecations coming with a version bump.
|
61
|
+
|
62
|
+
So, in order to keep the gem line specifying RSpec, he adds a `# LOCK` comment to the right side of the line:
|
63
|
+
```ruby
|
64
|
+
gem 'rspec', '3.2.0' # LOCK
|
65
|
+
```
|
66
|
+
|
67
|
+
Now, he'll run `lapidario -r` to clear all version information from his gem lines, except for locked lines. So if he had lines that looked like this:
|
68
|
+
```ruby
|
69
|
+
gem 'pry', '0.14.0'
|
70
|
+
gem 'rspec', '3.2.0' # LOCK
|
71
|
+
```
|
72
|
+
|
73
|
+
They'll now look like this:
|
74
|
+
```ruby
|
75
|
+
gem 'pry'
|
76
|
+
gem 'rspec', '3.2.0' # LOCK
|
77
|
+
```
|
78
|
+
|
79
|
+
He will then run `bundle update` and, deciding to give the gems some room, will write the lockfile versions up to the minor version and using the tilde-greater-than sign to keep versions as updated as possible within their major versions. Both of these the default options (`depth = 2`, `sign = ~>`), so he'll just use the `-l` option:
|
80
|
+
|
81
|
+
```
|
82
|
+
lapidario -l
|
83
|
+
```
|
84
|
+
|
85
|
+
Now the output Gemfile will look something like this:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
gem 'pry', '~> 0.17'
|
89
|
+
gem 'rspec', '3.2.0' # LOCK
|
90
|
+
```
|
91
|
+
|
92
|
+
Looks great! He'll now save the Gemfile and skip the backup, to avoid saving a Gemfile.original :
|
93
|
+
|
94
|
+
```
|
95
|
+
lapidario -l -w -s
|
96
|
+
```
|
97
|
+
|
98
|
+
Such a tedious work avoided!
|
99
|
+
|
100
|
+
|
101
|
+
## Options
|
102
|
+
Lapidario is made to be extremely simple and easy to use. Here are all the available options:
|
103
|
+
|
104
|
+
### # LOCK
|
105
|
+
Not a command option, but add `# LOCK` to the right-side of the gem line you want ignored by Lapidario. Lines that do not specify gems, such as `ruby '3.2.2'`, `group :development do` and `end` are ignored by default.
|
106
|
+
|
107
|
+
### -h, --help
|
108
|
+
Shows the help message in the console.
|
109
|
+
|
110
|
+
### -w, --write
|
111
|
+
Writes output directly to Gemfile. Also backs up previous Gemfile to Gemfile.original, remember to remove it later.
|
112
|
+
|
113
|
+
### -s, --skip-backup
|
114
|
+
|
115
|
+
Skips creation of backup Gemfile.original if writing to Gemfile. Does nothing if not used alongside the write option.
|
116
|
+
|
117
|
+
### -d, --depth NUMBER
|
118
|
+
Selects depth (major = 1, minor = 2, patch = 3) of version string; min = 1, max = 3, default = 2;
|
119
|
+
Example: `3` has depth 1, `3.2` has depth 2 and `3.2.1` has depth 3.
|
120
|
+
|
121
|
+
### -v, --version-sign NUMBER
|
122
|
+
Selects sign to use for version specification; this will be mapped from a number (0 = '~>', 1 = '>=', 2 = '<=', 3 = '>', 4 = '<', 5 = no sign). Default is `~>`. Note that it will write the same sign to all lines, so remember to lock the lines you don't want the sign applied to.
|
123
|
+
|
124
|
+
### -p, --path STRING
|
125
|
+
Define path in which `Gemfile` and `Gemfile.lock` are located. Defaults to current directory.
|
126
|
+
|
127
|
+
### -g, --git-gems
|
128
|
+
Include GIT gems from Gemfile.lock in Gemfile reconstruction. This is off by default and will only affect the `--lock` command.
|
129
|
+
Note: This is not guaranteed to support branch or commit specification.
|
130
|
+
Gem lines are normalized to have the version and the remote under the `git:` key, like in this example:
|
131
|
+
|
132
|
+
#### Input (Gemfile.lock fragment)
|
133
|
+
```
|
134
|
+
GIT
|
135
|
+
remote: https://github.com/jhawthorn/nsa.git
|
136
|
+
revision: e020fcc3a54d993ab45b7194d89ab720296c111b
|
137
|
+
ref: e020fcc3a54d993ab45b7194d89ab720296c111b
|
138
|
+
specs:
|
139
|
+
nsa (0.2.8)
|
140
|
+
```
|
141
|
+
#### Output
|
142
|
+
```ruby
|
143
|
+
gem 'nsa', '0.2.8', git: 'https://github.com/jhawthorn/nsa.git'
|
144
|
+
```
|
145
|
+
|
146
|
+
### -l, --lock
|
147
|
+
Rebuilds Gemfile using versions specified in Gemfile.lock; default sign for versions is '~>' and default depth is 2 (major & minor versions, ignores patch version).
|
148
|
+
|
149
|
+
##### Input Gemfile
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
# ...
|
153
|
+
gem "rake"
|
154
|
+
|
155
|
+
group :development, :test do
|
156
|
+
gem "pry", require: true
|
157
|
+
|
158
|
+
gem "rspec"
|
159
|
+
|
160
|
+
gem "rubocop"
|
161
|
+
end
|
162
|
+
```
|
163
|
+
|
164
|
+
##### Output Gemfile
|
165
|
+
|
166
|
+
```ruby
|
167
|
+
# ...
|
168
|
+
|
169
|
+
gem 'rake', '~> 13.1'
|
170
|
+
|
171
|
+
group :development, :test do
|
172
|
+
gem 'pry', '~> 0.14', require: true
|
173
|
+
|
174
|
+
gem 'rspec', '~> 3.12'
|
175
|
+
|
176
|
+
gem 'rubocop', '~> 1.57'
|
177
|
+
end
|
178
|
+
```
|
179
|
+
|
180
|
+
### -r, --reset
|
181
|
+
Rebuilds Gemfile without gem versions, keeping other information present on the line.
|
182
|
+
|
183
|
+
###### Input Gemfile
|
184
|
+
```ruby
|
185
|
+
# ...
|
186
|
+
gem 'rake', '~> 13.1'
|
187
|
+
|
188
|
+
group :development, :test do
|
189
|
+
gem 'pry', '~> 0.14', require: true
|
190
|
+
|
191
|
+
gem 'rspec', '~> 3.12'
|
192
|
+
|
193
|
+
gem 'rubocop', '~> 1.57'
|
194
|
+
end
|
195
|
+
```
|
196
|
+
|
197
|
+
##### Output Gemfile
|
198
|
+
|
199
|
+
```ruby
|
200
|
+
# ...
|
201
|
+
gem "rake"
|
202
|
+
|
203
|
+
group :development, :test do
|
204
|
+
gem "pry", require: true
|
205
|
+
|
206
|
+
gem "rspec"
|
207
|
+
|
208
|
+
gem "rubocop"
|
209
|
+
end
|
210
|
+
```
|
211
|
+
|
212
|
+
**NOTE**: if a gem line has a ranged version only the first version will be excluded.
|
213
|
+
|
214
|
+
For example:
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
gem 'rails', '> 6', '<= 7.1'
|
218
|
+
```
|
219
|
+
|
220
|
+
Will become
|
221
|
+
|
222
|
+
```ruby
|
223
|
+
gem 'rails', '<= 7.1'
|
224
|
+
```
|
225
|
+
|
226
|
+
### -f, --full-reset
|
227
|
+
Rebuilds Gemfile, removing all info but gem names (also applies to ranged versions).
|
228
|
+
|
229
|
+
###### Input Gemfile
|
230
|
+
```ruby
|
231
|
+
# ...
|
232
|
+
gem 'rake', '>= 13.1', '<= 14'
|
233
|
+
|
234
|
+
group :development, :test do
|
235
|
+
gem 'pry', '~> 0.14', require: true
|
236
|
+
|
237
|
+
gem 'rspec', '~> 3.12'
|
238
|
+
|
239
|
+
gem 'rubocop', '~> 1.57'
|
240
|
+
end
|
241
|
+
```
|
242
|
+
|
243
|
+
##### Output Gemfile
|
244
|
+
|
245
|
+
```ruby
|
246
|
+
# ...
|
247
|
+
gem "rake"
|
248
|
+
|
249
|
+
group :development, :test do
|
250
|
+
gem "pry"
|
251
|
+
|
252
|
+
gem "rspec"
|
253
|
+
|
254
|
+
gem "rubocop"
|
255
|
+
end
|
256
|
+
```
|
27
257
|
|
28
258
|
## TO DO:
|
29
259
|
- [x] Backup system: keep `Gemfile.original` stashed persistently
|
30
260
|
- [x] Add option to ignore Gemfile lines with `# LOCK` commented to the right end of the line
|
31
261
|
- [x] Normalize git gems with rubygems from Gemfile.lock
|
32
262
|
- [x] Add logic to ignore any comments in Gemfile gem lines
|
33
|
-
- [
|
263
|
+
- [x] Normalize git gems with rubygems-sourced gems from Gemfile.lock
|
34
264
|
|
35
265
|
## Development
|
36
266
|
|
data/lapidario.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
spec.metadata["homepage_uri"] = spec.homepage
|
20
20
|
spec.metadata["source_code_uri"] = "https://github.com/octehren/lapidario"
|
21
|
-
spec.metadata["changelog_uri"] = "https://
|
21
|
+
spec.metadata["changelog_uri"] = "https://github.com/octehren/lapidario/blob/master/CHANGELOG.md" # Put your gem's CHANGELOG.md URL here.
|
22
22
|
|
23
23
|
# Specify which files should be added to the gem when it is released.
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/lib/cli.rb
CHANGED
@@ -14,6 +14,7 @@ module Lapidario
|
|
14
14
|
@version_sign ||= '~>'
|
15
15
|
@save_new_gemfile ||= false
|
16
16
|
@save_backup ||= true if @save_backup.nil? # conditional assignment also executes on non-nil falsey values
|
17
|
+
@include_git_gems ||= false
|
17
18
|
end
|
18
19
|
|
19
20
|
def parse_options(options)
|
@@ -28,7 +29,7 @@ module Lapidario
|
|
28
29
|
exit
|
29
30
|
end
|
30
31
|
|
31
|
-
opts.on("-w", "--write", "
|
32
|
+
opts.on("-w", "--write", "Write command output to Gemfile. Backs up previous Gemfile to new file Gemfile.original") do
|
32
33
|
@save_new_gemfile = true
|
33
34
|
end
|
34
35
|
|
@@ -48,6 +49,10 @@ module Lapidario
|
|
48
49
|
@project_path_hash = { project_path: project_path }
|
49
50
|
end
|
50
51
|
|
52
|
+
opts.on("-g", "--git-gems", "Include GIT gems from Gemfile.lock in Gemfile reconstruction") do
|
53
|
+
@include_git_gems = true
|
54
|
+
end
|
55
|
+
|
51
56
|
opts.on("-l", "--lock", "Rebuild Gemfile using versions specified in Gemfile.lock; default sign is '~>' and default depth is 2 (major & minor versions, ignores patch)") do
|
52
57
|
@lock_gemfile = true
|
53
58
|
end
|
@@ -61,12 +66,17 @@ module Lapidario
|
|
61
66
|
end
|
62
67
|
end
|
63
68
|
|
69
|
+
if options.empty?
|
70
|
+
puts "Run `lapidario --help` if you would like to check the command line options or visit https://github.com/octehren/lapidario for a more in-depth explanation of the gem."
|
71
|
+
exit
|
72
|
+
end
|
73
|
+
|
64
74
|
# Parse the command-line arguments
|
65
75
|
opt_parser.parse!(options)
|
66
76
|
end
|
67
77
|
|
68
78
|
def start
|
69
|
-
info_instances = Lapidario.get_gemfile_and_lockfile_info(@project_path_hash)
|
79
|
+
info_instances = Lapidario.get_gemfile_and_lockfile_info(@project_path_hash, @include_git_gems)
|
70
80
|
gemfile_info = info_instances[0]
|
71
81
|
lockfile_info = info_instances[1]
|
72
82
|
original_gemfile_lines = gemfile_info.original_gemfile
|
data/lib/helper.rb
CHANGED
@@ -78,5 +78,29 @@ module Lapidario
|
|
78
78
|
# {4}: Indicates exactly 4 occurrences of the preceding character (whitespace in this case).
|
79
79
|
line.match?(/\A\x20{4}[A-Za-z0-9]/)
|
80
80
|
end
|
81
|
+
|
82
|
+
def self.extract_git_gem_info(git_gem_fragment)
|
83
|
+
remote = ""
|
84
|
+
# extract repo address
|
85
|
+
git_gem_fragment.each do |line|
|
86
|
+
if line.match?(/^\s*remote:\s/)
|
87
|
+
remote = line.split(":", 2)[1].strip
|
88
|
+
break
|
89
|
+
end
|
90
|
+
end
|
91
|
+
name = ""
|
92
|
+
version = ""
|
93
|
+
# extract gem name and version
|
94
|
+
git_gem_fragment.each_with_index do |line, index|
|
95
|
+
if line.match?(/^\s*specs:$/) # gem name will come immediately after 'specs'
|
96
|
+
gem_name_line = git_gem_fragment[index + 1].gsub(/\s/, '')
|
97
|
+
name = gem_name_line.split("(")[0]
|
98
|
+
version = gem_name_line.split("(")[1].sub(")", '')
|
99
|
+
break
|
100
|
+
end
|
101
|
+
end
|
102
|
+
version_and_remote = "#{version}, git: '#{remote}'"
|
103
|
+
[name, version_and_remote]
|
104
|
+
end
|
81
105
|
end
|
82
106
|
end
|
data/lib/lapidario/version.rb
CHANGED
data/lib/lapidario.rb
CHANGED
@@ -13,7 +13,7 @@ module Lapidario
|
|
13
13
|
|
14
14
|
# first step: build gemfile and lockfile info instances
|
15
15
|
# input: project_path_hash; has either :project_path key or both :gemfile_path and :lockfile_path; returns GemfileInfo and LockfileInfo instances
|
16
|
-
def self.get_gemfile_and_lockfile_info(project_path_hash)
|
16
|
+
def self.get_gemfile_and_lockfile_info(project_path_hash, include_git_gems = false)
|
17
17
|
project_path = project_path_hash[:project_path]
|
18
18
|
if (project_path && !project_path.empty?)
|
19
19
|
gemfile_path, lockfile_path = Lapidario::Helper.format_path(project_path, false), Lapidario::Helper.format_path(project_path, true)
|
@@ -24,7 +24,7 @@ module Lapidario
|
|
24
24
|
end
|
25
25
|
|
26
26
|
gemfile_info = Lapidario::GemfileInfo.new(Lapidario::Helper.get_file_as_array_of_lines(gemfile_path))
|
27
|
-
lockfile_info = Lapidario::LockfileInfo.new(Lapidario::Helper.get_file_as_array_of_lines(lockfile_path))
|
27
|
+
lockfile_info = Lapidario::LockfileInfo.new(Lapidario::Helper.get_file_as_array_of_lines(lockfile_path), include_git_gems)
|
28
28
|
[gemfile_info, lockfile_info]
|
29
29
|
end
|
30
30
|
|
@@ -62,6 +62,12 @@ module Lapidario
|
|
62
62
|
new_gemfile_info.each do |gem_info|
|
63
63
|
lock_version = lockfile_primary_gems[gem_info[:name]]
|
64
64
|
if lock_version
|
65
|
+
# if git version, add remote to extra info before extracting version
|
66
|
+
if lock_version.match?(/git:/)
|
67
|
+
remote = lock_version.split(",")[1].strip
|
68
|
+
lock_version = lock_version.split(",")[0]
|
69
|
+
gem_info[:extra_info] << remote
|
70
|
+
end
|
65
71
|
gem_info[:current_version] = lock_version
|
66
72
|
gem_info[:current_version] = Lapidario::Helper.format_version_based_on_depth(lock_version, default_depth) if default_depth
|
67
73
|
gem_info[:version_sign] = default_sign
|
data/lib/lockfile_info.rb
CHANGED
@@ -4,13 +4,14 @@ require_relative "helper"
|
|
4
4
|
|
5
5
|
module Lapidario
|
6
6
|
class LockfileInfo
|
7
|
-
attr_accessor :primary_gems
|
7
|
+
attr_accessor :primary_gems, :git_gems, :rubygems_gems
|
8
8
|
|
9
|
-
def initialize(gemfile_lock_as_strings)
|
10
|
-
@git_gems =
|
9
|
+
def initialize(gemfile_lock_as_strings, include_git = true)
|
10
|
+
@git_gems = Lapidario::LockfileInfo.get_git_gems_from_gemfile_lock(gemfile_lock_as_strings) if include_git
|
11
|
+
@git_gems ||= {}
|
11
12
|
@rubygems_gems = Lapidario::LockfileInfo.get_rubygems_from_gemfile_lock(gemfile_lock_as_strings)
|
12
13
|
# joins gem names and versions from git/rubygems/other sources in a single format
|
13
|
-
@primary_gems = @rubygems_gems
|
14
|
+
@primary_gems = @git_gems.merge(@rubygems_gems)
|
14
15
|
end
|
15
16
|
|
16
17
|
def puts_versionless_rubygems_info
|
@@ -22,7 +23,7 @@ module Lapidario
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def git_gems?
|
25
|
-
|
26
|
+
@git_gems && !@git_gems.empty?
|
26
27
|
end
|
27
28
|
|
28
29
|
# gets gems installed from rubygems; in the future check also for other remote sources
|
@@ -47,5 +48,25 @@ module Lapidario
|
|
47
48
|
end
|
48
49
|
gem_names_and_versions
|
49
50
|
end
|
51
|
+
|
52
|
+
# gets gems under GIT namespace
|
53
|
+
def self.get_git_gems_from_gemfile_lock(gemfile_lock_as_strings)
|
54
|
+
git_gem_sections = []
|
55
|
+
gem_names_and_versions = {}
|
56
|
+
gemfile_lock_as_strings.each_with_index do |line, index|
|
57
|
+
git_gem_sections << Helper.slice_up_to_next_empty_line(index, gemfile_lock_as_strings) if line == "GIT"
|
58
|
+
end
|
59
|
+
|
60
|
+
return [] if git_gem_sections.empty?
|
61
|
+
|
62
|
+
git_gem_sections.each do |git_gem|
|
63
|
+
git_gem_info = Lapidario::Helper.extract_git_gem_info git_gem
|
64
|
+
|
65
|
+
name = git_gem_info[0]
|
66
|
+
version_and_remote = git_gem_info[1]
|
67
|
+
gem_names_and_versions[name] = version_and_remote
|
68
|
+
end
|
69
|
+
gem_names_and_versions
|
70
|
+
end
|
50
71
|
end
|
51
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lapidario
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- octehren
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,7 +74,7 @@ metadata:
|
|
74
74
|
allowed_push_host: https://rubygems.org
|
75
75
|
homepage_uri: https://github.com/octehren/lapidario
|
76
76
|
source_code_uri: https://github.com/octehren/lapidario
|
77
|
-
changelog_uri: https://
|
77
|
+
changelog_uri: https://github.com/octehren/lapidario/blob/master/CHANGELOG.md
|
78
78
|
post_install_message:
|
79
79
|
rdoc_options: []
|
80
80
|
require_paths:
|
@@ -87,9 +87,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: 2.6.0
|
88
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
|
-
- - "
|
90
|
+
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
92
|
+
version: '0'
|
93
93
|
requirements: []
|
94
94
|
rubygems_version: 3.4.10
|
95
95
|
signing_key:
|