gem_version_check 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6bacf8957dc58f781ec32e8f1f9e03e9e9e881c8
4
- data.tar.gz: 37b5459d0975ebba21a85baa2a6689dbe644789f
3
+ metadata.gz: c03eea86fa0f3b9e3756ce66dd8a772a41a57cff
4
+ data.tar.gz: c3b3089a5be7c6e47ef5b81fd9ae6ff77b534a15
5
5
  SHA512:
6
- metadata.gz: cd7dcaf3cc78cad11e378d227c74e1ff897df2d6ff45f50784d5ad4d360c49366fd7e2f220fa14aea17fbb94e17cd9d0e0eb5e45492d77c19f7d945c101431a0
7
- data.tar.gz: 10b7882ad5a21a00d393451dd3677aac266fdce82042b5d34038189b05f074d15957f6f4d10a0991f03dcb4c67abc4a5d273f5bcb6c8e82eeb99c2b365783238
6
+ metadata.gz: 6fa06d9b640dfc253f48e6fdb0f0cf72379d855f0490c9b83607f9ba5e4b9466d01e1f651d3e7928c532c2fba93c54bf5208c7e9daca9e79a367b393f836ae70
7
+ data.tar.gz: 1337d3a96d01edeee344bebb8939e920c8759bf100cc61e240a33a6b2561ac06f9ab2aae239df78f082c2d8580d92e49573971302717ec1a646657e30d555204
data/README.md CHANGED
@@ -28,6 +28,10 @@ Use --only option if you want to specify the list of gems
28
28
 
29
29
  gem_version_check fdietz/team_dashboard --only activesupport,rspec
30
30
 
31
+ Use --except option if you want to exclude certain gems from the check
32
+
33
+ gem_version_check fdietz/team_dashboard --except activesupport,rspec
34
+
31
35
  Use --output-format if you want different formats
32
36
 
33
37
  gem_version_check fdietz/team_dashboard --output-format=json
@@ -29,6 +29,10 @@ module GemVersionCheck
29
29
  options[:only] = list
30
30
  end
31
31
 
32
+ opts.on("--except gem1,gem2,gem3", Array, "List of ruby gems") do |list|
33
+ options[:except] = list
34
+ end
35
+
32
36
  opts.on("--host github.com", String, "Github host name") do |host|
33
37
  options[:host] = host
34
38
  end
@@ -5,9 +5,10 @@ require "net/https"
5
5
  module GemVersionCheck
6
6
  class Project
7
7
 
8
- def initialize(project, spec_names = [])
8
+ def initialize(project, options = {})
9
9
  @project = project
10
- @spec_names = spec_names
10
+ @only = options[:only] || []
11
+ @except = options[:except] || []
11
12
  end
12
13
 
13
14
  def name
@@ -66,7 +67,13 @@ module GemVersionCheck
66
67
  end
67
68
 
68
69
  def spec_names
69
- @spec_names.any? ? @spec_names : all_spec_names
70
+ if @only.any?
71
+ @only
72
+ elsif @except.any?
73
+ all_spec_names - @except
74
+ else
75
+ all_spec_names
76
+ end
70
77
  end
71
78
 
72
79
  def all_spec_names
@@ -5,12 +5,13 @@ module GemVersionCheck
5
5
  @project_names = project_names
6
6
  @options = options
7
7
  @only = options[:only] || []
8
+ @except = options[:except] || []
8
9
  end
9
10
 
10
11
  def generate
11
12
  @check_failed = false
12
13
  @project_names.inject([]) do |result, project_name|
13
- project = Project.new(project_name, @only)
14
+ project = Project.new(project_name, only: @only, except: @except)
14
15
  project.report
15
16
  @check_failed = true if project.check_failed?
16
17
  result << project
@@ -22,4 +23,4 @@ module GemVersionCheck
22
23
  end
23
24
 
24
25
  end
25
- end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module GemVersionCheck
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -6,34 +6,61 @@ module GemVersionCheck
6
6
  let(:url) { "https://github.com/toadkicker/teststrap/raw/master/Gemfile.lock" }
7
7
  let(:redirect_url) { "https://raw.github.com/toadkicker/teststrap/master/Gemfile.lock" }
8
8
  let(:lock_file) { Lockfile.new(lock_file_content("rails_app_example.lock")) }
9
+ let(:options) { {} }
9
10
  let(:project) do
10
11
  Dependency.any_instance.stubs(:latest_version).returns("1.0")
11
- project = Project.new("toadkicker/teststrap", %w(actionpack not_existing))
12
+ project = Project.new("toadkicker/teststrap", options)
12
13
  project.stubs(:lock_file).returns(lock_file)
13
14
  project
14
15
  end
15
16
 
16
17
  context "#report" do
17
- it "returns array of given dependencies" do
18
- project.report.size.should == 2
19
- project.report.first.name.should == "actionpack"
20
- project.report.last.name.should == "not_existing"
18
+ context "with whitelisted gems" do
19
+ let(:options) { { only: %w(actionpack not_existing) } }
20
+
21
+ it "returns array of given dependencies" do
22
+ project.report.size.should == 2
23
+ project.report.first.name.should == "actionpack"
24
+ project.report.last.name.should == "not_existing"
25
+ end
21
26
  end
22
27
 
23
- it "returns array of all dependencies" do
24
- Dependency.any_instance.stubs(:latest_version).returns("1.0")
25
- project = Project.new("toadkicker/teststrap")
26
- project.stubs(:lock_file).returns(lock_file)
28
+ context "with blacklisted gems" do
29
+ let(:options) { { except: %w(actionpack not_existing) } }
30
+
31
+ it "returns array of all dependencies except the given ones" do
32
+ project.report.size.should == 46
33
+ project.report.map(&:name).should_not include("actionpack")
34
+ end
35
+ end
27
36
 
28
- project.report.size.should == 47
37
+ context "without black- or whitelisting" do
38
+ it "returns array of all dependencies" do
39
+ project.report.size.should == 47
40
+ end
29
41
  end
30
42
  end
31
43
 
32
- context "#check_failed?" do
44
+ shared_examples "check_failed" do
33
45
  it "returns true if at least one dependency is not up to date or non existing" do
34
46
  project.check_failed? == true
35
47
  end
36
48
  end
37
49
 
50
+ context "#check_failed?" do
51
+ context "with whitelisted gems" do
52
+ let(:options) { { only: "actionpack" } }
53
+ include_examples "check_failed"
54
+ end
55
+
56
+ context "with blacklisted gems" do
57
+ let(:options) { { except: "actionpack" } }
58
+ include_examples "check_failed"
59
+ end
60
+
61
+ context "without black- or whitelisting" do
62
+ include_examples "check_failed"
63
+ end
64
+ end
38
65
  end
39
- end
66
+ end
@@ -8,7 +8,7 @@ module GemVersionCheck
8
8
  Project.any_instance.stubs(:report)
9
9
  end
10
10
 
11
- let (:report) do
11
+ let(:report) do
12
12
  report = Report.new(%w(proj1, proj2))
13
13
  report.generate
14
14
  report
@@ -32,4 +32,4 @@ module GemVersionCheck
32
32
  end
33
33
 
34
34
  end
35
- end
35
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_version_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frederik Dietz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-22 00:00:00.000000000 Z
11
+ date: 2015-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  requirements: []
135
135
  rubyforge_project:
136
- rubygems_version: 2.4.7
136
+ rubygems_version: 2.4.8
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Check your gem dependencies