gem-compare 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -2
- data/lib/rubygems/comparator.rb +1 -1
- data/lib/rubygems/comparator/dependency_comparator.rb +1 -1
- data/lib/rubygems/comparator/dir_utils.rb +39 -37
- data/lib/rubygems/comparator/file_list_comparator.rb +4 -4
- data/lib/rubygems/comparator/gemfile_comparator.rb +2 -2
- data/lib/rubygems/comparator/monitor.rb +2 -3
- data/lib/rubygems/comparator/spec_comparator.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f7e261523b147248e2f35ab4b15e6f03a12a73b
|
4
|
+
data.tar.gz: 3f698da159dd70d2946b94f53dae8f90dd697cd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 760fa57013b4c92894ef4ec4a993249c19370affa9f4c4c1f18f0ed1f36172bcfcbdd1c23614c24096b1bdc97f919fce7efc097dbd74042e60ae7a677164ec2b
|
7
|
+
data.tar.gz: b3ef20d96057c89b906fcaaff3e2585ca442cf2bc6fdf62cded6b990eee5f7e874e3ed2b2ff5780e07c74bd32f1e7f6bb42cd3e0afeaaf1514e1606817ae284c
|
data/Rakefile
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'rubygems/package_task'
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rdoc/task'
|
4
|
+
require_relative 'lib/rubygems/comparator'
|
4
5
|
|
5
6
|
gemspec = Gem::Specification.new do |s|
|
6
7
|
s.name = 'gem-compare'
|
7
|
-
s.version =
|
8
|
+
s.version = Gem::Comparator::VERSION
|
8
9
|
s.platform = Gem::Platform::RUBY
|
9
10
|
s.summary = 'RubyGems plugin for comparing gem versions'
|
10
11
|
s.description = <<-EOF
|
@@ -20,7 +21,7 @@ gemspec = Gem::Specification.new do |s|
|
|
20
21
|
s.required_ruby_version = '>= 2.0.0'
|
21
22
|
s.required_rubygems_version = '>= 2.0.0'
|
22
23
|
s.add_runtime_dependency 'json'
|
23
|
-
s.add_runtime_dependency '
|
24
|
+
s.add_runtime_dependency 'curb'
|
24
25
|
s.add_runtime_dependency 'diffy'
|
25
26
|
s.add_runtime_dependency 'rainbow'
|
26
27
|
s.add_runtime_dependency 'gemnasium-parser'
|
data/lib/rubygems/comparator.rb
CHANGED
@@ -36,7 +36,7 @@ class Gem::Comparator
|
|
36
36
|
ver = "#{specs[index-1].version}->#{specs[index].version}"
|
37
37
|
|
38
38
|
report[param][ver].section do
|
39
|
-
set_header "#{Rainbow(specs[index-1].version).
|
39
|
+
set_header "#{Rainbow(specs[index-1].version).cyan}->#{Rainbow(s.version).cyan}:"
|
40
40
|
|
41
41
|
nest('deleted').section do
|
42
42
|
set_header '* Deleted:'
|
@@ -1,51 +1,53 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
class Gem::Comparator
|
4
|
+
module DirUtils
|
5
|
+
SHEBANG_REGEX = /\A#!.*/
|
5
6
|
|
6
|
-
|
7
|
+
attr_accessor :files_first_line
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def self.file_first_line(file)
|
10
|
+
File.open(file){ |f| f.readline }.gsub(/(.*)\n/, '\1')
|
11
|
+
rescue
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
def self.file_has_shebang?(file)
|
15
|
+
file_first_line(file) =~ SHEBANG_REGEX
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def self.files_same_first_line?(file1, file2)
|
19
|
+
file_first_line(file1) == file_first_line(file2)
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
def self.file_permissions(file)
|
23
|
+
sprintf("%o", File.stat(file).mode)
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def self.gem_bin_file?(file)
|
27
|
+
file =~ /(\A|.*\/)bin\/.*/
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
##
|
31
|
+
# Returns a unique list of directories and top level files
|
32
|
+
# out of an array of files
|
33
|
+
|
34
|
+
def self.dirs_of_files(file_list)
|
35
|
+
dirs_of_files = []
|
36
|
+
file_list.each do |file|
|
37
|
+
unless Pathname.new(file).dirname.to_s == '.'
|
38
|
+
dirs_of_files << "#{Pathname.new(file).dirname.to_s}/"
|
39
|
+
else
|
40
|
+
dirs_of_files << file
|
41
|
+
end
|
40
42
|
end
|
43
|
+
dirs_of_files.uniq
|
41
44
|
end
|
42
|
-
dirs_of_files.uniq
|
43
|
-
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
def self.remove_subdirs(dirs)
|
47
|
+
dirs.dup.sort_by(&:length).reverse.each do |dir|
|
48
|
+
dirs.delete_if{ |d| d =~ /#{dir}\/.+/ }
|
49
|
+
end
|
50
|
+
dirs
|
48
51
|
end
|
49
|
-
dirs
|
50
52
|
end
|
51
|
-
end
|
53
|
+
end
|
@@ -64,8 +64,8 @@ class Gem::Comparator
|
|
64
64
|
report[param].set_header "#{different} #{param}:"
|
65
65
|
|
66
66
|
report[param][vers].section do
|
67
|
-
set_header "#{Rainbow(packages[index-1].spec.version).
|
68
|
-
"#{Rainbow(packages[index].spec.version).
|
67
|
+
set_header "#{Rainbow(packages[index-1].spec.version).cyan}->" +
|
68
|
+
"#{Rainbow(packages[index].spec.version).cyan}:"
|
69
69
|
nest('deleted').section do
|
70
70
|
set_header '* Deleted:'
|
71
71
|
puts deleted unless deleted.empty?
|
@@ -85,8 +85,8 @@ class Gem::Comparator
|
|
85
85
|
all_same = false unless same_files
|
86
86
|
|
87
87
|
if previous == current && same_files && !all_same
|
88
|
-
report[param][vers] << "#{Rainbow(packages[index-1].spec.version).
|
89
|
-
"#{Rainbow(packages[index].spec.version).
|
88
|
+
report[param][vers] << "#{Rainbow(packages[index-1].spec.version).cyan}->" + \
|
89
|
+
"#{Rainbow(packages[index].spec.version).cyan}: No change"
|
90
90
|
end
|
91
91
|
|
92
92
|
end
|
@@ -37,8 +37,8 @@ class Gem::Comparator
|
|
37
37
|
curr_gemfile = File.join(unpacked_gem_dirs[@packages[index].spec.version], 'Gemfile')
|
38
38
|
|
39
39
|
vers = "#{@packages[index-1].spec.version}->#{@packages[index].spec.version}"
|
40
|
-
report['gemfiles'][vers].set_header "#{Rainbow(packages[index-1].spec.version).
|
41
|
-
"#{Rainbow(packages[index].spec.version).
|
40
|
+
report['gemfiles'][vers].set_header "#{Rainbow(packages[index-1].spec.version).cyan}->" +
|
41
|
+
"#{Rainbow(packages[index].spec.version).cyan}:"
|
42
42
|
|
43
43
|
added, deleted, updated = compare_gemfiles(prev_gemfile, curr_gemfile)
|
44
44
|
|
@@ -43,11 +43,10 @@ class Gem::Comparator
|
|
43
43
|
|
44
44
|
if file_permissions != '100644'
|
45
45
|
unless (DirUtils.gem_bin_file?(file) && file_permissions == '100755')
|
46
|
-
" (!) Unexpected permissions: #{file_permissions}"
|
46
|
+
return " (!) Unexpected permissions: #{file_permissions}"
|
47
47
|
end
|
48
|
-
else
|
49
|
-
''
|
50
48
|
end
|
49
|
+
''
|
51
50
|
end
|
52
51
|
|
53
52
|
def self.files_executability_changes(prev_file, curr_file)
|
@@ -29,7 +29,7 @@ class Gem::Comparator
|
|
29
29
|
report[param].set_header "#{different} #{param}:"
|
30
30
|
values.each_with_index do |value, index|
|
31
31
|
report[param] << \
|
32
|
-
"#{Rainbow(specs[index].version).
|
32
|
+
"#{Rainbow(specs[index].version).cyan}: #{value}"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem-compare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josef Stribny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: curb
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '>='
|