skillnad 1.2.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 +7 -0
- data/LICENSE +20 -0
- data/README.md +172 -0
- data/Rakefile +17 -0
- data/lib/rubygems/commands/compare_command.rb +105 -0
- data/lib/rubygems/comparator/base.rb +45 -0
- data/lib/rubygems/comparator/dependency_comparator.rb +110 -0
- data/lib/rubygems/comparator/dir_utils.rb +51 -0
- data/lib/rubygems/comparator/file_list_comparator.rb +212 -0
- data/lib/rubygems/comparator/gemfile_comparator.rb +149 -0
- data/lib/rubygems/comparator/monitor.rb +140 -0
- data/lib/rubygems/comparator/report/entry.rb +40 -0
- data/lib/rubygems/comparator/report.rb +131 -0
- data/lib/rubygems/comparator/spec_comparator.rb +66 -0
- data/lib/rubygems/comparator/utils.rb +134 -0
- data/lib/rubygems/comparator/version.rb +5 -0
- data/lib/rubygems/comparator.rb +308 -0
- data/lib/rubygems_plugin.rb +4 -0
- data/test/gemfiles/lorem-0.0.1/Gemfile +4 -0
- data/test/gemfiles/lorem-0.0.1/LICENSE.txt +22 -0
- data/test/gemfiles/lorem-0.0.1/README.md +29 -0
- data/test/gemfiles/lorem-0.0.1/Rakefile +2 -0
- data/test/gemfiles/lorem-0.0.1/lib/lorem/version.rb +3 -0
- data/test/gemfiles/lorem-0.0.1/lib/lorem.rb +7 -0
- data/test/gemfiles/lorem-0.0.1/lorem.gemspec +24 -0
- data/test/gemfiles/lorem-0.0.1.gem +0 -0
- data/test/gemfiles/lorem-0.0.2/CHANGELOG.md +6 -0
- data/test/gemfiles/lorem-0.0.2/Gemfile +4 -0
- data/test/gemfiles/lorem-0.0.2/LICENSE.txt +3 -0
- data/test/gemfiles/lorem-0.0.2/README.md +29 -0
- data/test/gemfiles/lorem-0.0.2/Rakefile +2 -0
- data/test/gemfiles/lorem-0.0.2/lib/lorem/version.rb +3 -0
- data/test/gemfiles/lorem-0.0.2/lib/lorem.rb +11 -0
- data/test/gemfiles/lorem-0.0.2/lorem.gemspec +24 -0
- data/test/gemfiles/lorem-0.0.2.gem +0 -0
- data/test/gemfiles/lorem-0.0.3/CHANGELOG.md +14 -0
- data/test/gemfiles/lorem-0.0.3/Gemfile +7 -0
- data/test/gemfiles/lorem-0.0.3/LICENSE.txt +3 -0
- data/test/gemfiles/lorem-0.0.3/README.md +29 -0
- data/test/gemfiles/lorem-0.0.3/Rakefile +2 -0
- data/test/gemfiles/lorem-0.0.3/bin/lorem +3 -0
- data/test/gemfiles/lorem-0.0.3/lib/lorem/utils.rb +7 -0
- data/test/gemfiles/lorem-0.0.3/lib/lorem/version.rb +3 -0
- data/test/gemfiles/lorem-0.0.3/lib/lorem.rb +11 -0
- data/test/gemfiles/lorem-0.0.3/lorem.gemspec +25 -0
- data/test/gemfiles/lorem-0.0.3.gem +0 -0
- data/test/gemfiles/lorem-0.0.4/CHANGELOG.md +21 -0
- data/test/gemfiles/lorem-0.0.4/Gemfile +6 -0
- data/test/gemfiles/lorem-0.0.4/LICENSE.txt +3 -0
- data/test/gemfiles/lorem-0.0.4/README.md +29 -0
- data/test/gemfiles/lorem-0.0.4/Rakefile +2 -0
- data/test/gemfiles/lorem-0.0.4/bin/lorem +3 -0
- data/test/gemfiles/lorem-0.0.4/lib/lorem/utils.rb +7 -0
- data/test/gemfiles/lorem-0.0.4/lib/lorem/version.rb +3 -0
- data/test/gemfiles/lorem-0.0.4/lib/lorem.rb +11 -0
- data/test/gemfiles/lorem-0.0.4/lorem.gemspec +25 -0
- data/test/gemfiles/lorem-0.0.4.gem +0 -0
- data/test/rubygems/comparator/test_dependency_comparator.rb +32 -0
- data/test/rubygems/comparator/test_dir_utils.rb +47 -0
- data/test/rubygems/comparator/test_file_list_comparator.rb +29 -0
- data/test/rubygems/comparator/test_gemfile_comparator.rb +16 -0
- data/test/rubygems/comparator/test_monitor.rb +183 -0
- data/test/rubygems/comparator/test_report.rb +25 -0
- data/test/rubygems/comparator/test_spec_comparator.rb +150 -0
- data/test/rubygems/comparator/test_utils.rb +35 -0
- data/test/rubygems/test_gem_commands_compare_command.rb +41 -0
- data/test/test_helper.rb +53 -0
- metadata +165 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 99492a058a9870c0d9856a4bb3707b2897d6701bbfdbc0003c39944561e32d2d
|
|
4
|
+
data.tar.gz: b843677a5d7cb2397d05e9fcb2ca7d658e8c824481b453e59bc48358a7cbf841
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c115570ab3fae285961e3ff68dc0aac4d3a23db1bd283c96bd79670d70483ca905b95b6a872ad8dae34735ebc8554fd9cfcf4f45a7982a370d1b5a67c0fc6e46
|
|
7
|
+
data.tar.gz: 32d9715037c10509f0de5bab56f8a1ab47f8a56d18f35b9c9c491d6bca887d4fb5fdff9e1bbaf6761021a1ebdcd9c705c7b53c1a3e7abfe28f0dd3a4b91d3a4f
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) Josef Strzibny.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# skillnad
|
|
2
|
+
|
|
3
|
+
skillnad is a RubyGems plugin that compares different versions of the specified gem. It can help you to track changes in metadata through the time, see how dependencies were evolving and spot important changes in gem's files such as shebang or permissions modifications.
|
|
4
|
+
|
|
5
|
+
This is especially handy for:
|
|
6
|
+
|
|
7
|
+
- checking what goes into to a next gem release
|
|
8
|
+
- tracking dependencies and license changes before upgrades
|
|
9
|
+
- spotting anything suspicious and unusual
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
You can install `skillnad` as a gem from RubyGems.org:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
$ gem install skillnad
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
By default, `skillnad` compares specified versions of the given gem and includes only changes in the final report. If it's supposed to compare file lists or Gemfiles it will need to download the gems, otherwise it just downloads the specs. If you want to keep the downloaded `.gem` files, use `-k` (as 'keep') option. If you want to see the full report use `-a` (as 'all') switch:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
$ gem compare rails 3.0.0 4.0.0 -k
|
|
25
|
+
Compared versions: ["3.0.0", "4.0.0"]
|
|
26
|
+
DIFFERENT date:
|
|
27
|
+
3.0.0: 2010-08-29 00:00:00 UTC
|
|
28
|
+
4.0.0: 2013-06-25 00:00:00 UTC
|
|
29
|
+
DIFFERENT executables:
|
|
30
|
+
3.0.0: ["rails"]
|
|
31
|
+
4.0.0: []
|
|
32
|
+
DIFFERENT has_rdoc:
|
|
33
|
+
3.0.0: true
|
|
34
|
+
4.0.0:
|
|
35
|
+
DIFFERENT license:
|
|
36
|
+
3.0.0:
|
|
37
|
+
4.0.0: MIT
|
|
38
|
+
DIFFERENT licenses:
|
|
39
|
+
3.0.0: []
|
|
40
|
+
4.0.0: ["MIT"]
|
|
41
|
+
DIFFERENT required_ruby_version:
|
|
42
|
+
3.0.0: >= 1.8.7
|
|
43
|
+
4.0.0: >= 1.9.3
|
|
44
|
+
DIFFERENT required_rubygems_version:
|
|
45
|
+
3.0.0: >= 1.3.6
|
|
46
|
+
4.0.0: >= 1.8.11
|
|
47
|
+
DIFFERENT rubygems_version:
|
|
48
|
+
3.0.0: 1.3.7
|
|
49
|
+
4.0.0: 2.0.2
|
|
50
|
+
DIFFERENT version:
|
|
51
|
+
3.0.0: 3.0.0
|
|
52
|
+
4.0.0: 4.0.0
|
|
53
|
+
DIFFERENT files:
|
|
54
|
+
3.0.0->4.0.0:
|
|
55
|
+
* Deleted:
|
|
56
|
+
bin/rails
|
|
57
|
+
* Added:
|
|
58
|
+
README.md
|
|
59
|
+
guides/assets/images/belongs_to.png
|
|
60
|
+
guides/assets/images/book_icon.gif
|
|
61
|
+
(...)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
You can also specify what you are interested in by using -p (as 'param') option:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
$ gem compare activesupport 4.0.0 4.1.0 -p 'runtime_dependency'
|
|
68
|
+
Compared versions: ["4.0.0", "4.1.0"]
|
|
69
|
+
DIFFERENT runtime dependencies:
|
|
70
|
+
4.0.0->4.1.0:
|
|
71
|
+
* Deleted:
|
|
72
|
+
multi_json ["~> 1.3"] (runtime)
|
|
73
|
+
* Added:
|
|
74
|
+
json [">= 1.7.7", "~> 1.7"] (runtime)
|
|
75
|
+
* Updated:
|
|
76
|
+
i18n from: [">= 0.6.4", "~> 0.6"] to: [">= 0.6.9", "~> 0.6"]
|
|
77
|
+
tzinfo from: ["~> 0.3.37"] to: ["~> 1.1"]
|
|
78
|
+
minitest from: ["~> 4.2"] to: ["~> 5.1"]
|
|
79
|
+
```
|
|
80
|
+
There are also shortcuts for favourite options. Use `--runtime` for runtime dependencies, `--gemfiles` for comparing Gemfiles or `--files` for comparing file lists:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
$ gem compare rails 2.0.1 3.0.0 -k --files
|
|
84
|
+
Compared versions: ["2.0.1", "3.0.0"]
|
|
85
|
+
DIFFERENT files:
|
|
86
|
+
2.0.1->3.0.0:
|
|
87
|
+
* Deleted:
|
|
88
|
+
bin
|
|
89
|
+
builtin
|
|
90
|
+
CHANGELOG
|
|
91
|
+
configs
|
|
92
|
+
dispatches
|
|
93
|
+
doc
|
|
94
|
+
environments
|
|
95
|
+
fresh_rakefile
|
|
96
|
+
helpers
|
|
97
|
+
html
|
|
98
|
+
lib
|
|
99
|
+
MIT-LICENSE
|
|
100
|
+
(...)
|
|
101
|
+
* Changed:
|
|
102
|
+
bin/rails 7/17
|
|
103
|
+
(!) New permissions: 100644 -> 100755
|
|
104
|
+
(!) File is now executable!
|
|
105
|
+
(!) Shebang probably added: #!/usr/bin/env ruby
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
If you would like to see all development dependencies for `prawn` since `0.1` version, let *skillnad* expand the versions for you (`>=0.0` won't work as RubyGems asks for the latest spec only):
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
$ gem compare prawn '>=0.1' -k -a --development
|
|
112
|
+
Compared versions: ["0.1.0", "0.1.1", "0.1.2", "0.2.0", "0.2.1", "0.2.2", "0.2.3", "0.3.0", "0.4.0", "0.4.1", "0.5.0.1", "0.5.1", "0.6.1", "0.6.2", "0.6.3", "0.7.1", "0.7.2", "0.8.4", "0.11.1", "0.12.0", "0.13.0", "0.13.1", "0.13.2", "0.14.0", "0.15.0", "1.0.0", "1.1.0"]
|
|
113
|
+
DIFFERENT development dependencies:
|
|
114
|
+
0.12.0->0.13.0:
|
|
115
|
+
* Added:
|
|
116
|
+
pdf-inspector ["~> 1.1.0"] (development)
|
|
117
|
+
coderay ["~> 1.0.7"] (development)
|
|
118
|
+
rdoc [">= 0"] (development)
|
|
119
|
+
0.13.2->0.14.0:
|
|
120
|
+
* Deleted:
|
|
121
|
+
rdoc [">= 0"] (development)
|
|
122
|
+
* Added:
|
|
123
|
+
yard [">= 0"] (development)
|
|
124
|
+
rspec [">= 0"] (development)
|
|
125
|
+
mocha [">= 0"] (development)
|
|
126
|
+
rake [">= 0"] (development)
|
|
127
|
+
0.14.0->0.15.0:
|
|
128
|
+
* Added:
|
|
129
|
+
simplecov [">= 0"] (development)
|
|
130
|
+
pdf-reader ["~> 1.2"] (development)
|
|
131
|
+
1.0.0->1.1.0:
|
|
132
|
+
* Added:
|
|
133
|
+
prawn-manual_builder [">= 0.1.1"] (development)
|
|
134
|
+
rubocop ["= 0.20.1"] (development)
|
|
135
|
+
* Updated:
|
|
136
|
+
rspec from: [">= 0"] to: ["= 2.14.1"]
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Platforms
|
|
140
|
+
|
|
141
|
+
*skillnad* supports querying different gem platforms via standard `--platform` option. To compare
|
|
142
|
+
nokogiri gem on different platform run:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
$ gem compare nokogiri 1.5.6 1.6.1 -ak --platform java # for JRuby
|
|
146
|
+
$ gem compare nokogiri 1.5.6 1.6.1 -ak --platform x86-mingw32 # on Windows
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### Gems from different source server
|
|
150
|
+
|
|
151
|
+
If you run your own gem source server, you can override the RubyGems.org default with
|
|
152
|
+
`--sources SOURCE1,SOURCE2` option.
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
### Supported options
|
|
156
|
+
|
|
157
|
+
To see all possible options run:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
$ gem compare --help
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Requirements
|
|
164
|
+
|
|
165
|
+
Currently tested against RubyGems 3.x. Use the `0.0.7` release for RubyGems 2.x.
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
## Copyright
|
|
169
|
+
|
|
170
|
+
Made by [Josef Strzibny](https://strzibny.name).
|
|
171
|
+
|
|
172
|
+
Released under the MIT license. Feel free to contribute!
|
data/Rakefile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rake/testtask'
|
|
4
|
+
require 'rdoc/task'
|
|
5
|
+
|
|
6
|
+
Rake::RDocTask.new do |rd|
|
|
7
|
+
rd.main = 'README.md'
|
|
8
|
+
rd.rdoc_files.include('README.md', 'lib/**/*.rb')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Rake::TestTask.new('test') do |t|
|
|
12
|
+
t.libs << 'test'
|
|
13
|
+
t.pattern = 'test/**/test*.rb'
|
|
14
|
+
t.verbose = true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
task :default => [:test]
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rubygems/command'
|
|
4
|
+
require 'rubygems/version_option'
|
|
5
|
+
require 'rubygems/comparator'
|
|
6
|
+
|
|
7
|
+
class Gem::Commands::CompareCommand < Gem::Command
|
|
8
|
+
include Gem::VersionOption
|
|
9
|
+
|
|
10
|
+
def initialize
|
|
11
|
+
super 'compare', 'Compare gem\'s versions and generate a report of changes',
|
|
12
|
+
:output => Dir.pwd
|
|
13
|
+
|
|
14
|
+
add_option('-a', '--all', 'Show every comparison') do
|
|
15
|
+
options[:log_all] = true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
add_option('-k', '--keep-all', 'Keep downloaded and extracted gem files') do
|
|
19
|
+
options[:keep_all] = true
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
add_option('-n', '--no-color', 'Do not colorize output') do
|
|
23
|
+
options[:no_color] = true
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Speficy the platform using --platform=PLATFORM
|
|
27
|
+
add_platform_option
|
|
28
|
+
|
|
29
|
+
add_option('-pPARAM', '--param PARAM', 'Compare only a given gemspec parameter (like "version")') do |param, options|
|
|
30
|
+
options[:param] = param
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
add_option('-r', '--runtime', 'Compare only runtime dependencies') do
|
|
34
|
+
options[:param] = 'runtime_dependency'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
add_option('-d', '--development', 'Compare only development dependencies') do
|
|
38
|
+
options[:param] = 'development_dependency'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
add_option('-f', '--files', 'Compare only files for runtime') do
|
|
42
|
+
options[:param] = 'files'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
add_option('-F', '--diff', 'Diff file contents') do
|
|
46
|
+
options[:diff] = true
|
|
47
|
+
options[:param] = 'files'
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
add_option('-g', '--gemfiles', 'Compare only Gemfiles') do
|
|
51
|
+
options[:param] = 'gemfiles'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
add_option('-b', '--brief', 'Include only important changes in the report') do
|
|
55
|
+
options[:log_all] = false
|
|
56
|
+
options[:brief] = true
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
add_option('-sSOURCES', '--sources SOURCES', 'Use different source URIs for gems (separated by comma)') do |sources, options|
|
|
60
|
+
options[:sources] = sources.split ','
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def arguments # :nodoc:
|
|
66
|
+
args = <<-EOF
|
|
67
|
+
GEMNAME gem name
|
|
68
|
+
VERSION [VERSION ...] list of versions to compare
|
|
69
|
+
EOF
|
|
70
|
+
return args.gsub(/^\s+/, '')
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def description # :nodoc:
|
|
74
|
+
desc = <<-EOF
|
|
75
|
+
skillnad is a RubyGems plugin that compares versions of the given gem.
|
|
76
|
+
It searches for differences in metadata as well as in files.
|
|
77
|
+
EOF
|
|
78
|
+
return desc.gsub(/^\s+/, '')
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def usage # :nodoc:
|
|
82
|
+
"#{program_name} GEMNAME VERSION [VERSION ...]"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def execute
|
|
86
|
+
gem_name = options[:args].shift
|
|
87
|
+
versions = options[:args]
|
|
88
|
+
|
|
89
|
+
# No gem specified
|
|
90
|
+
unless gem_name
|
|
91
|
+
raise Gem::CommandLineError,
|
|
92
|
+
"Please specify a gem (e.g. gem compare foo VERSION [VERSION ...])"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# No versions specified
|
|
96
|
+
if versions.empty?
|
|
97
|
+
raise Gem::CommandLineError,
|
|
98
|
+
"Please specify versions you want to compare (e.g. gem compare foo 0.1.0 0.2.0)"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
comparator = Gem::Comparator.new(options)
|
|
102
|
+
comparator.compare_versions(gem_name, versions)
|
|
103
|
+
comparator.print_results
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rainbow'
|
|
4
|
+
require 'rubygems/comparator/utils'
|
|
5
|
+
require 'rubygems/comparator/report'
|
|
6
|
+
|
|
7
|
+
class Gem::Comparator
|
|
8
|
+
class Base
|
|
9
|
+
include Gem::Comparator::Utils
|
|
10
|
+
include Gem::Comparator::Report::Signs
|
|
11
|
+
|
|
12
|
+
attr_accessor :compares
|
|
13
|
+
|
|
14
|
+
##
|
|
15
|
+
# Compare Gem::Specification objects by default
|
|
16
|
+
#
|
|
17
|
+
# To override create your own initialize method and
|
|
18
|
+
# set expect(:packages) to expect Gem::Package objects.
|
|
19
|
+
|
|
20
|
+
def initialize
|
|
21
|
+
expect(:specs)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def expect(what)
|
|
27
|
+
@compares = what
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def extract_gem(package, target_dir)
|
|
31
|
+
gem_file = File.basename(package.spec.full_name, '.gem')
|
|
32
|
+
gem_dir = File.join(target_dir, gem_file)
|
|
33
|
+
|
|
34
|
+
if Dir.exist? gem_dir
|
|
35
|
+
info "Unpacked gem version exists, using #{gem_dir}."
|
|
36
|
+
return gem_dir
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
info "Unpacking gem '#{package.spec.full_name}' in " + gem_dir
|
|
40
|
+
package.extract_files gem_dir
|
|
41
|
+
gem_dir
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rubygems/comparator/base'
|
|
4
|
+
|
|
5
|
+
class Gem::Comparator
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Gem::Comparator::DependencyComparator can
|
|
9
|
+
# compare dependencies between gem's versions
|
|
10
|
+
# based on the given Gem::Specification objects
|
|
11
|
+
|
|
12
|
+
class DependencyComparator < Gem::Comparator::Base
|
|
13
|
+
|
|
14
|
+
##
|
|
15
|
+
# Compare dependencies in given +specs+ and
|
|
16
|
+
# write the changes to the +report+
|
|
17
|
+
#
|
|
18
|
+
# If +options[:param]+ is set, it compares only
|
|
19
|
+
# those dependencies
|
|
20
|
+
|
|
21
|
+
def compare(specs, report, options = {})
|
|
22
|
+
info 'Checking dependencies...'
|
|
23
|
+
|
|
24
|
+
filter_params(DEPENDENCY_PARAMS, options[:param]).each do |param|
|
|
25
|
+
all_same = true
|
|
26
|
+
type = param.gsub('_dependency', '').to_sym
|
|
27
|
+
specs.each_with_index do |s, index|
|
|
28
|
+
next if index == 0
|
|
29
|
+
|
|
30
|
+
prev_deps = specs[index-1].dependencies.select { |d| d.type == type }
|
|
31
|
+
curr_deps = specs[index].dependencies.select { |d| d.type == type }
|
|
32
|
+
added, deleted, updated = resolve_dependencies(prev_deps, curr_deps)
|
|
33
|
+
|
|
34
|
+
if (!deleted.empty? || !added.empty? || !updated.empty?)
|
|
35
|
+
all_same = false
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
ver = "#{specs[index-1].version}->#{specs[index].version}"
|
|
39
|
+
|
|
40
|
+
report[param][ver].section do
|
|
41
|
+
set_header "#{Rainbow(specs[index-1].version).cyan}->#{Rainbow(s.version).cyan}:"
|
|
42
|
+
|
|
43
|
+
nest('deleted').section do
|
|
44
|
+
set_header '* Deleted:'
|
|
45
|
+
puts deleted.map { |x| "#{x.name} #{x.requirements_list} (#{x.type})" } unless deleted.empty?
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
nest('added').section do
|
|
49
|
+
set_header '* Added:'
|
|
50
|
+
puts added.map { |x| "#{x.name} #{x.requirements_list} (#{x.type})" } unless added.empty?
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
nest('updated').section do
|
|
54
|
+
set_header '* Updated:'
|
|
55
|
+
puts updated unless updated.empty?
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
if all_same && options[:log_all]
|
|
60
|
+
report[param].set_header "#{same} #{type} dependencies:" if options[:log_all]
|
|
61
|
+
deps = specs[0].dependencies.select{ |d| d.type == type }.map{ |d| "#{d.name}: #{d.requirements_list}" }
|
|
62
|
+
deps = '[]' if deps.empty?
|
|
63
|
+
report[param] << deps
|
|
64
|
+
elsif !all_same
|
|
65
|
+
report[param].set_header "#{different} #{type} dependencies:"
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
report
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
private
|
|
73
|
+
|
|
74
|
+
##
|
|
75
|
+
# Find dependencies between +prev_deps+ and +curr_deps+
|
|
76
|
+
#
|
|
77
|
+
# Return [added, deleted, updated] deps
|
|
78
|
+
|
|
79
|
+
def resolve_dependencies(prev_deps, curr_deps)
|
|
80
|
+
added = curr_deps - prev_deps
|
|
81
|
+
deleted = prev_deps - curr_deps
|
|
82
|
+
split_dependencies(added, deleted)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
##
|
|
86
|
+
# Find updated dependencies between +added+ and
|
|
87
|
+
# +deleted+ deps and move them out to +updated+.
|
|
88
|
+
#
|
|
89
|
+
# Return [added, deleted, updated] deps
|
|
90
|
+
|
|
91
|
+
def split_dependencies(added, deleted)
|
|
92
|
+
updated = []
|
|
93
|
+
added.dup.each do |ad|
|
|
94
|
+
deleted.dup.each do |dd|
|
|
95
|
+
if ad.name == dd.name
|
|
96
|
+
unless ad.requirements_list == dd.requirements_list
|
|
97
|
+
updated << "#{ad.name} " +
|
|
98
|
+
"from: #{dd.requirements_list} " +
|
|
99
|
+
"to: #{ad.requirements_list}"
|
|
100
|
+
end
|
|
101
|
+
added.delete ad
|
|
102
|
+
deleted.delete dd
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
[added, deleted, updated]
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'pathname'
|
|
4
|
+
|
|
5
|
+
class Gem::Comparator
|
|
6
|
+
module DirUtils
|
|
7
|
+
SHEBANG_REGEX = /\A#!.*/
|
|
8
|
+
|
|
9
|
+
attr_accessor :files_first_line
|
|
10
|
+
|
|
11
|
+
def self.file_first_line(file)
|
|
12
|
+
File.open(file){ |f| f.readline }.gsub(/(.*)\n/, '\1')
|
|
13
|
+
rescue
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.file_has_shebang?(file)
|
|
17
|
+
file_first_line(file) =~ SHEBANG_REGEX
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.files_same_first_line?(file1, file2)
|
|
21
|
+
file_first_line(file1) == file_first_line(file2)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.gem_bin_file?(file)
|
|
25
|
+
file =~ /(\A|.*\/)bin\/.*/
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
##
|
|
29
|
+
# Returns a unique list of directories and top level files
|
|
30
|
+
# out of an array of files
|
|
31
|
+
|
|
32
|
+
def self.dirs_of_files(file_list)
|
|
33
|
+
dirs_of_files = []
|
|
34
|
+
file_list.each do |file|
|
|
35
|
+
unless Pathname.new(file).dirname.to_s == '.'
|
|
36
|
+
dirs_of_files << "#{Pathname.new(file).dirname.to_s}/"
|
|
37
|
+
else
|
|
38
|
+
dirs_of_files << file
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
dirs_of_files.uniq
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.remove_subdirs(dirs)
|
|
45
|
+
dirs.dup.sort_by(&:length).reverse.each do |dir|
|
|
46
|
+
dirs.delete_if{ |d| d =~ /#{dir}\/.+/ }
|
|
47
|
+
end
|
|
48
|
+
dirs
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|