gem_version_check 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -5
- data/lib/gem_version_check/dependency.rb +10 -2
- data/lib/gem_version_check/formatter/pretty_print.rb +14 -8
- data/lib/gem_version_check/version.rb +1 -1
- data/spec/dependency_spec.rb +19 -4
- metadata +3 -3
data/README.md
CHANGED
@@ -12,23 +12,31 @@ At XING we use this gem in combination with jenkins to automatically check on ge
|
|
12
12
|
|
13
13
|
Use the Github project name:
|
14
14
|
|
15
|
-
gem_version_check fdietz/team_dashboard
|
15
|
+
gem_version_check fdietz/team_dashboard
|
16
16
|
|
17
17
|
Use any url to a Gemfile.lock:
|
18
18
|
|
19
|
-
gem_version_check https://raw.github.com/fdietz/team_dashboard/raw/master/Gemfile.lock
|
19
|
+
gem_version_check https://raw.github.com/fdietz/team_dashboard/raw/master/Gemfile.lock
|
20
20
|
|
21
21
|
## Configuration
|
22
22
|
|
23
|
-
Use
|
23
|
+
Use --host option if you use Enterprise Github:
|
24
24
|
|
25
|
-
|
25
|
+
gem_version_check fdietz/team_dashboard --host github.mycompany.com
|
26
|
+
|
27
|
+
Use --only option if you want to specify the list of gems
|
28
|
+
|
29
|
+
gem_version_check fdietz/team_dashboard --only activesupport,rspec
|
30
|
+
|
31
|
+
Use --output-format if you want different formats
|
32
|
+
|
33
|
+
gem_version_check fdietz/team_dashboard --output-format=json
|
26
34
|
|
27
35
|
## Example Report
|
28
36
|
|
29
37
|
### Pretty Print
|
30
38
|
|
31
|
-
Example command: gem_version_check fdietz/team_dashboard activesupport
|
39
|
+
Example command: gem_version_check fdietz/team_dashboard --only activesupport,rspec
|
32
40
|
|
33
41
|
Output:
|
34
42
|
|
@@ -7,7 +7,7 @@ module GemVersionCheck
|
|
7
7
|
|
8
8
|
def initialize(name, expected_version = nil)
|
9
9
|
@name = name
|
10
|
-
@expected_version = expected_version
|
10
|
+
@expected_version = expected_version
|
11
11
|
end
|
12
12
|
|
13
13
|
def check(lock_file)
|
@@ -15,7 +15,7 @@ module GemVersionCheck
|
|
15
15
|
@used = !!@version
|
16
16
|
return unless used?
|
17
17
|
|
18
|
-
@result =
|
18
|
+
@result = expected_version == @version
|
19
19
|
end
|
20
20
|
|
21
21
|
def valid?
|
@@ -26,6 +26,14 @@ module GemVersionCheck
|
|
26
26
|
@used
|
27
27
|
end
|
28
28
|
|
29
|
+
def gem_not_found?
|
30
|
+
expected_version.nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
def expected_version
|
34
|
+
@expected_version ||= latest_version
|
35
|
+
end
|
36
|
+
|
29
37
|
def latest_version
|
30
38
|
@latest_version ||= begin
|
31
39
|
spec = retrieve_spec
|
@@ -27,20 +27,26 @@ module GemVersionCheck
|
|
27
27
|
"Project: #{project.check_failed? ? red : green}#{project.name}#{black}"
|
28
28
|
end
|
29
29
|
|
30
|
-
def dependency_listitem(
|
31
|
-
"
|
30
|
+
def dependency_listitem(dep)
|
31
|
+
" #{dep.name}: #{ yield dep }\n"
|
32
32
|
end
|
33
33
|
|
34
|
-
def format_dependency(
|
35
|
-
|
34
|
+
def format_dependency(dep)
|
35
|
+
if dep.gem_not_found?
|
36
|
+
"not found"
|
37
|
+
elsif dep.valid?
|
38
|
+
valid_dependency(dep)
|
39
|
+
else
|
40
|
+
invalid_dependency(dep)
|
41
|
+
end
|
36
42
|
end
|
37
43
|
|
38
|
-
def valid_dependency(
|
39
|
-
"#{green}#{
|
44
|
+
def valid_dependency(dep)
|
45
|
+
"#{green}#{dep.expected_version} ✓#{black}"
|
40
46
|
end
|
41
47
|
|
42
|
-
def invalid_dependency(
|
43
|
-
"#{
|
48
|
+
def invalid_dependency(dep)
|
49
|
+
"#{dep.expected_version} != #{red}#{dep.version}#{black}"
|
44
50
|
end
|
45
51
|
|
46
52
|
def black
|
data/spec/dependency_spec.rb
CHANGED
@@ -9,8 +9,8 @@ module GemVersionCheck
|
|
9
9
|
|
10
10
|
let(:dependency) { Dependency.new("activesupport", "3.2.9") }
|
11
11
|
let(:invalid_dependency) { Dependency.new("activesupport", "3.2.10") }
|
12
|
-
let(:
|
13
|
-
|
12
|
+
let(:not_used_dependency) { Dependency.new("rails", "3.2.9") }
|
13
|
+
|
14
14
|
context "#valid?" do
|
15
15
|
it "is valid if current version == expected version" do
|
16
16
|
dependency.check(lock_file)
|
@@ -30,8 +30,23 @@ module GemVersionCheck
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "return false if not found in lock file" do
|
33
|
-
|
34
|
-
|
33
|
+
not_used_dependency.check(lock_file)
|
34
|
+
not_used_dependency.should_not be_used
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "#gem_not_found?" do
|
39
|
+
it "returns false if gem was found on gems server" do
|
40
|
+
dependency.check(lock_file)
|
41
|
+
dependency.should_not be_gem_not_found
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns true if gem was not found on gems server" do
|
45
|
+
dep = Dependency.new("non_existing_gem")
|
46
|
+
dep.expects(:retrieve_spec).returns(nil)
|
47
|
+
dep.check(lock_file)
|
48
|
+
|
49
|
+
dep.should be_gem_not_found
|
35
50
|
end
|
36
51
|
end
|
37
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_version_check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -139,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
139
|
version: '0'
|
140
140
|
segments:
|
141
141
|
- 0
|
142
|
-
hash:
|
142
|
+
hash: -4198302242782915360
|
143
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
144
|
none: false
|
145
145
|
requirements:
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
segments:
|
150
150
|
- 0
|
151
|
-
hash:
|
151
|
+
hash: -4198302242782915360
|
152
152
|
requirements: []
|
153
153
|
rubyforge_project:
|
154
154
|
rubygems_version: 1.8.24
|