transdeps 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +50 -0
  7. data/Rakefile +3 -0
  8. data/lib/transdeps/cli.rb +17 -0
  9. data/lib/transdeps/inconsistency.rb +11 -0
  10. data/lib/transdeps/reconciler.rb +24 -0
  11. data/lib/transdeps/spec_list.rb +31 -0
  12. data/lib/transdeps/spec_list_factory.rb +8 -0
  13. data/lib/transdeps/specification.rb +20 -0
  14. data/lib/transdeps/tasks.rb +12 -0
  15. data/lib/transdeps/version.rb +3 -0
  16. data/lib/transdeps.rb +4 -0
  17. data/spec/dummy/Gemfile +27 -0
  18. data/spec/dummy/Gemfile.lock +160 -0
  19. data/spec/dummy/components/invalid-sub-dependencies/Gemfile +4 -0
  20. data/spec/dummy/components/invalid-sub-dependencies/Gemfile.lock +38 -0
  21. data/spec/dummy/components/invalid-sub-dependencies/invalid-sub-dependencies.gemspec +25 -0
  22. data/spec/dummy/components/invalid-sub-dependencies/lib/invalid/sub/dependencies/version.rb +7 -0
  23. data/spec/dummy/components/invalid-sub-dependencies/lib/invalid/sub/dependencies.rb +9 -0
  24. data/spec/dummy/components/obviously-invalid-dependencies/Gemfile +4 -0
  25. data/spec/dummy/components/obviously-invalid-dependencies/Gemfile.lock +31 -0
  26. data/spec/dummy/components/obviously-invalid-dependencies/lib/obviously/invalid/dependencies/version.rb +7 -0
  27. data/spec/dummy/components/obviously-invalid-dependencies/lib/obviously/invalid/dependencies.rb +9 -0
  28. data/spec/dummy/components/obviously-invalid-dependencies/obviously-invalid-dependencies.gemspec +24 -0
  29. data/spec/dummy/components/obviously-valid-dependencies/Gemfile +4 -0
  30. data/spec/dummy/components/obviously-valid-dependencies/Gemfile.lock +17 -0
  31. data/spec/dummy/components/obviously-valid-dependencies/lib/obviously/valid/dependencies/version.rb +7 -0
  32. data/spec/dummy/components/obviously-valid-dependencies/lib/obviously/valid/dependencies.rb +9 -0
  33. data/spec/dummy/components/obviously-valid-dependencies/obviously-valid-dependencies.gemspec +23 -0
  34. data/spec/dummy/lib/dummy.rb +0 -0
  35. data/spec/spec_helper.rb +13 -0
  36. data/spec/transdeps/cli_spec.rb +13 -0
  37. data/spec/transdeps/reconciler_spec.rb +29 -0
  38. data/spec/transdeps/spec_list_factory_spec.rb +16 -0
  39. data/spec/transdeps/spec_list_spec.rb +60 -0
  40. data/spec/transdeps/specification_spec.rb +75 -0
  41. data/spec/transdeps/tasks_spec.rb +35 -0
  42. data/transdeps.gemspec +24 -0
  43. metadata +152 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 44689d8f950baffc3dba68f7f9f62cb0d6c4a659
4
+ data.tar.gz: 08412e7b78116c5b84149ff4aa56650042ed986d
5
+ SHA512:
6
+ metadata.gz: e23a2fca6794682c9e0de6b2375e150a42298198db70824bfa171d393b44b03fce62377a51cb2783759f0c6b34ef6726cab628b09656b8de19ec04851390c613
7
+ data.tar.gz: af2855ec10c5c501f9b61b43af243344d97b608c2ea4d2ca2d5be238d69d6a8ac72602f607f597bb56210cca224b1e88d01387647fd3196f48710ca05e7ea813
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in transdeps.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TJ Taylor
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Transdeps
2
+
3
+ A gem to find inconsistent dependency versions in component-based
4
+ Ruby apps.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'transdeps'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install transdeps
21
+
22
+ ## Usage
23
+
24
+ Add this line to application's Rakefile:
25
+
26
+ ```ruby
27
+ require 'transdeps/tasks'
28
+ ```
29
+
30
+ Then run:
31
+
32
+ ```bash
33
+ bundle exec rake[/path/to/my/components,/path/to/my/project]
34
+ ```
35
+
36
+ Since you are presumably running this task from the root of your project,
37
+ you can leave the second argument to the Rake task off, and the
38
+ first argument would be a relative path. Something like:
39
+
40
+ ```bash
41
+ bundle exec rake[components]
42
+ ```
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it ( https://github.com/dugancathal/transdeps/fork )
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'transdeps/tasks'
@@ -0,0 +1,17 @@
1
+ require 'pathname'
2
+ require 'transdeps/reconciler'
3
+
4
+ module Transdeps
5
+ class Cli
6
+ attr_reader :component_dir, :project_root, :reconciler
7
+ def initialize(component_dir, project_root=Pathname('.'), reconciler=Reconciler.new)
8
+ @component_dir = Pathname(component_dir)
9
+ @project_root = Pathname(project_root)
10
+ @reconciler = reconciler
11
+ end
12
+
13
+ def run
14
+ reconciler.call(component_dir, project_root)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module Transdeps
2
+ class Inconsistency < Struct.new(:expected, :actual)
3
+ def to_s
4
+ "%-<expected>30s != %-<actual>30s (%-<component>30s)" % {
5
+ expected: expected,
6
+ component: actual.project_path.split('/').last,
7
+ actual: actual,
8
+ }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,24 @@
1
+ require 'transdeps/spec_list_factory'
2
+ require 'transdeps/inconsistency'
3
+
4
+ module Transdeps
5
+ class Reconciler < Struct.new(:factory)
6
+ def initialize(factory=SpecListFactory.new)
7
+ super
8
+ end
9
+
10
+ def call(component_dir, project_dir)
11
+ project_specs = specs_for(project_dir)
12
+ all_component_specs = component_dir.children.map { |dir| specs_for(dir) }
13
+ all_component_specs.flat_map do |component_specs|
14
+ project_specs - component_specs
15
+ end.compact
16
+ end
17
+
18
+ private
19
+
20
+ def specs_for(dir)
21
+ factory.call(dir)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ require 'bundler/lockfile_parser'
2
+ require 'transdeps/specification'
3
+ require 'transdeps/inconsistency'
4
+
5
+ module Transdeps
6
+ class SpecList < Struct.new(:lock_file_path, :lock_file_contents, :parser)
7
+ def initialize(lock_file_path, lock_file_contents, parser=Bundler::LockfileParser.new(lock_file_contents.to_s))
8
+ lock_file_path = Pathname(lock_file_path)
9
+ super(lock_file_path, lock_file_contents, parser)
10
+ end
11
+
12
+ def specs
13
+ parser.specs.map do |spec|
14
+ Specification.from_lock(spec.to_s, lock_file_path.dirname.to_s)
15
+ end
16
+ end
17
+
18
+ def -(other)
19
+ specs.map do |spec|
20
+ next unless other[spec.name]
21
+ unless spec =~ other[spec.name]
22
+ Inconsistency.new(spec, other[spec.name])
23
+ end
24
+ end.compact
25
+ end
26
+
27
+ def [](name)
28
+ specs.find{|spec| spec.name == name }
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,8 @@
1
+ require 'transdeps/spec_list'
2
+ module Transdeps
3
+ class SpecListFactory
4
+ def call(dir)
5
+ SpecList.new(dir + 'Gemfile.lock', File.read(dir + 'Gemfile.lock'))
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ module Transdeps
2
+ class Specification < Struct.new(:name, :version, :project_path)
3
+ def self.from_lock(lock, path='')
4
+ match = lock.match(/^(?<name>[\w\-]+) \((?<version>.*)\)/)
5
+ new(match[:name], match[:version], path)
6
+ end
7
+
8
+ def same_gem_as?(other)
9
+ name == other.name
10
+ end
11
+
12
+ def =~(other)
13
+ same_gem_as?(other) && version == other.version
14
+ end
15
+
16
+ def to_s
17
+ "#{name} (#{version})"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ require 'rake'
2
+ require 'transdeps/cli'
3
+
4
+ desc 'Print all the dependency inconsistencies. root_dir is optional.'
5
+ task :transdeps, [:component_dir, :root_dir] do |_, args|
6
+ if args[:root_dir]
7
+ puts Transdeps::Cli.new(args[:component_dir], args[:root_dir]).run
8
+ else
9
+ warn 'WARNING: Using PWD as project root_dir'
10
+ puts Transdeps::Cli.new(args[:component_dir]).run
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module Transdeps
2
+ VERSION = "0.1.0"
3
+ end
data/lib/transdeps.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "transdeps/version"
2
+
3
+ module Transdeps
4
+ end
@@ -0,0 +1,27 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ gem 'rails', '4.1.8'
5
+ gem 'sqlite3'
6
+ gem 'sass-rails', '~> 4.0.3'
7
+ gem 'uglifier', '>= 1.3.0'
8
+ gem 'coffee-rails', '~> 4.0.0'
9
+
10
+ gem 'jquery-rails'
11
+ gem 'turbolinks'
12
+ gem 'jbuilder', '~> 2.0'
13
+ gem 'sdoc', '~> 0.4.0', group: :doc
14
+
15
+ gem 'spring', group: :development
16
+
17
+ path './components' do
18
+ gem 'obviously-invalid-dependencies'
19
+ gem 'obviously-valid-dependencies'
20
+ gem 'invalid-sub-dependencies'
21
+ end
22
+
23
+ group :development, :test do
24
+ gem 'rspec', '~> 3.1'
25
+ gem 'capybara-webkit', '~> 1.3.1'
26
+ gem 'capybara', '~> 2.1'
27
+ end
@@ -0,0 +1,160 @@
1
+ PATH
2
+ remote: ./components
3
+ specs:
4
+ invalid-sub-dependencies (0.0.1)
5
+ obviously-invalid-dependencies (0.0.1)
6
+ obviously-valid-dependencies (0.0.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionmailer (4.1.8)
12
+ actionpack (= 4.1.8)
13
+ actionview (= 4.1.8)
14
+ mail (~> 2.5, >= 2.5.4)
15
+ actionpack (4.1.8)
16
+ actionview (= 4.1.8)
17
+ activesupport (= 4.1.8)
18
+ rack (~> 1.5.2)
19
+ rack-test (~> 0.6.2)
20
+ actionview (4.1.8)
21
+ activesupport (= 4.1.8)
22
+ builder (~> 3.1)
23
+ erubis (~> 2.7.0)
24
+ activemodel (4.1.8)
25
+ activesupport (= 4.1.8)
26
+ builder (~> 3.1)
27
+ activerecord (4.1.8)
28
+ activemodel (= 4.1.8)
29
+ activesupport (= 4.1.8)
30
+ arel (~> 5.0.0)
31
+ activesupport (4.1.8)
32
+ i18n (~> 0.6, >= 0.6.9)
33
+ json (~> 1.7, >= 1.7.7)
34
+ minitest (~> 5.1)
35
+ thread_safe (~> 0.1)
36
+ tzinfo (~> 1.1)
37
+ arel (5.0.1.20140414130214)
38
+ builder (3.2.2)
39
+ capybara (2.4.4)
40
+ mime-types (>= 1.16)
41
+ nokogiri (>= 1.3.3)
42
+ rack (>= 1.0.0)
43
+ rack-test (>= 0.5.4)
44
+ xpath (~> 2.0)
45
+ capybara-webkit (1.3.1)
46
+ capybara (>= 2.0.2, < 2.5.0)
47
+ json
48
+ coffee-rails (4.0.1)
49
+ coffee-script (>= 2.2.0)
50
+ railties (>= 4.0.0, < 5.0)
51
+ coffee-script (2.3.0)
52
+ coffee-script-source
53
+ execjs
54
+ coffee-script-source (1.8.0)
55
+ diff-lcs (1.2.5)
56
+ erubis (2.7.0)
57
+ execjs (2.2.2)
58
+ hike (1.2.3)
59
+ i18n (0.7.0)
60
+ jbuilder (2.2.6)
61
+ activesupport (>= 3.0.0, < 5)
62
+ multi_json (~> 1.2)
63
+ jquery-rails (3.1.2)
64
+ railties (>= 3.0, < 5.0)
65
+ thor (>= 0.14, < 2.0)
66
+ json (1.8.1)
67
+ mail (2.6.3)
68
+ mime-types (>= 1.16, < 3)
69
+ mime-types (2.4.3)
70
+ mini_portile (0.6.1)
71
+ minitest (5.5.0)
72
+ multi_json (1.10.1)
73
+ nokogiri (1.6.5)
74
+ mini_portile (~> 0.6.0)
75
+ rack (1.5.2)
76
+ rack-test (0.6.2)
77
+ rack (>= 1.0)
78
+ rails (4.1.8)
79
+ actionmailer (= 4.1.8)
80
+ actionpack (= 4.1.8)
81
+ actionview (= 4.1.8)
82
+ activemodel (= 4.1.8)
83
+ activerecord (= 4.1.8)
84
+ activesupport (= 4.1.8)
85
+ bundler (>= 1.3.0, < 2.0)
86
+ railties (= 4.1.8)
87
+ sprockets-rails (~> 2.0)
88
+ railties (4.1.8)
89
+ actionpack (= 4.1.8)
90
+ activesupport (= 4.1.8)
91
+ rake (>= 0.8.7)
92
+ thor (>= 0.18.1, < 2.0)
93
+ rake (10.4.2)
94
+ rdoc (4.2.0)
95
+ json (~> 1.4)
96
+ rspec (3.1.0)
97
+ rspec-core (~> 3.1.0)
98
+ rspec-expectations (~> 3.1.0)
99
+ rspec-mocks (~> 3.1.0)
100
+ rspec-core (3.1.7)
101
+ rspec-support (~> 3.1.0)
102
+ rspec-expectations (3.1.2)
103
+ diff-lcs (>= 1.2.0, < 2.0)
104
+ rspec-support (~> 3.1.0)
105
+ rspec-mocks (3.1.3)
106
+ rspec-support (~> 3.1.0)
107
+ rspec-support (3.1.2)
108
+ sass (3.2.19)
109
+ sass-rails (4.0.5)
110
+ railties (>= 4.0.0, < 5.0)
111
+ sass (~> 3.2.2)
112
+ sprockets (~> 2.8, < 3.0)
113
+ sprockets-rails (~> 2.0)
114
+ sdoc (0.4.1)
115
+ json (~> 1.7, >= 1.7.7)
116
+ rdoc (~> 4.0)
117
+ spring (1.2.0)
118
+ sprockets (2.12.3)
119
+ hike (~> 1.2)
120
+ multi_json (~> 1.0)
121
+ rack (~> 1.0)
122
+ tilt (~> 1.1, != 1.3.0)
123
+ sprockets-rails (2.2.2)
124
+ actionpack (>= 3.0)
125
+ activesupport (>= 3.0)
126
+ sprockets (>= 2.8, < 4.0)
127
+ sqlite3 (1.3.10)
128
+ thor (0.19.1)
129
+ thread_safe (0.3.4)
130
+ tilt (1.4.1)
131
+ turbolinks (2.5.3)
132
+ coffee-rails
133
+ tzinfo (1.2.2)
134
+ thread_safe (~> 0.1)
135
+ uglifier (2.6.0)
136
+ execjs (>= 0.3.0)
137
+ json (>= 1.8.0)
138
+ xpath (2.0.0)
139
+ nokogiri (~> 1.3)
140
+
141
+ PLATFORMS
142
+ ruby
143
+
144
+ DEPENDENCIES
145
+ capybara (~> 2.1)
146
+ capybara-webkit (~> 1.3.1)
147
+ coffee-rails (~> 4.0.0)
148
+ invalid-sub-dependencies!
149
+ jbuilder (~> 2.0)
150
+ jquery-rails
151
+ obviously-invalid-dependencies!
152
+ obviously-valid-dependencies!
153
+ rails (= 4.1.8)
154
+ rspec (~> 3.1)
155
+ sass-rails (~> 4.0.3)
156
+ sdoc (~> 0.4.0)
157
+ spring
158
+ sqlite3
159
+ turbolinks
160
+ uglifier (>= 1.3.0)
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in invalid-sub-dependencies.gemspec
4
+ gemspec
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ invalid-sub-dependencies (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ capybara (2.1.0)
10
+ mime-types (>= 1.16)
11
+ nokogiri (>= 1.3.3)
12
+ rack (>= 1.0.0)
13
+ rack-test (>= 0.5.4)
14
+ xpath (~> 2.0)
15
+ capybara-webkit (1.1.1)
16
+ capybara (>= 2.0.2, < 2.2.0)
17
+ json
18
+ json (1.8.1)
19
+ mime-types (2.4.3)
20
+ mini_portile (0.6.1)
21
+ nokogiri (1.6.5)
22
+ mini_portile (~> 0.6.0)
23
+ rack (1.6.0)
24
+ rack-test (0.6.2)
25
+ rack (>= 1.0)
26
+ rake (10.4.2)
27
+ xpath (2.0.0)
28
+ nokogiri (~> 1.3)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ bundler (~> 1.7)
35
+ capybara (= 2.1)
36
+ capybara-webkit (~> 1.1.0)
37
+ invalid-sub-dependencies!
38
+ rake (~> 10.0)
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'invalid/sub/dependencies/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "invalid-sub-dependencies"
8
+ spec.version = Invalid::Sub::Dependencies::VERSION
9
+ spec.authors = ["TJ Taylor"]
10
+ spec.email = ["dugancathal@gmail.com"]
11
+ spec.summary = %q{Write a short summary. Required.}
12
+ spec.description = %q{Write a longer description. Optional.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "capybara-webkit", "~> 1.1.0"
24
+ spec.add_development_dependency "capybara", "= 2.1"
25
+ end
@@ -0,0 +1,7 @@
1
+ module Invalid
2
+ module Sub
3
+ module Dependencies
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require "invalid/sub/dependencies/version"
2
+
3
+ module Invalid
4
+ module Sub
5
+ module Dependencies
6
+ # Your code goes here...
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in obviously-invalid-dependencies.gemspec
4
+ gemspec
@@ -0,0 +1,31 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ obviously-invalid-dependencies (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.2.5)
10
+ rake (10.4.2)
11
+ rspec (3.0.0)
12
+ rspec-core (~> 3.0.0)
13
+ rspec-expectations (~> 3.0.0)
14
+ rspec-mocks (~> 3.0.0)
15
+ rspec-core (3.0.4)
16
+ rspec-support (~> 3.0.0)
17
+ rspec-expectations (3.0.4)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.0.0)
20
+ rspec-mocks (3.0.4)
21
+ rspec-support (~> 3.0.0)
22
+ rspec-support (3.0.4)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ bundler (~> 1.7)
29
+ obviously-invalid-dependencies!
30
+ rake (~> 10.0)
31
+ rspec (= 3.0)
@@ -0,0 +1,7 @@
1
+ module Obviously
2
+ module Invalid
3
+ module Dependencies
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require "obviously/invalid/dependencies/version"
2
+
3
+ module Obviously
4
+ module Invalid
5
+ module Dependencies
6
+ # Your code goes here...
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'obviously/invalid/dependencies/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "obviously-invalid-dependencies"
8
+ spec.version = Obviously::Invalid::Dependencies::VERSION
9
+ spec.authors = ["TJ Taylor"]
10
+ spec.email = ["dugancathal@gmail.com"]
11
+ spec.summary = %q{Write a short summary. Required.}
12
+ spec.description = %q{Write a longer description. Optional.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "= 3.0"
24
+ end
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in obviously-valid-dependencies.gemspec
4
+ gemspec
@@ -0,0 +1,17 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ obviously-valid-dependencies (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.4.2)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.7)
16
+ obviously-valid-dependencies!
17
+ rake (~> 10.0)
@@ -0,0 +1,7 @@
1
+ module Obviously
2
+ module Valid
3
+ module Dependencies
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require "obviously/valid/dependencies/version"
2
+
3
+ module Obviously
4
+ module Valid
5
+ module Dependencies
6
+ # Your code goes here...
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'obviously/valid/dependencies/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "obviously-valid-dependencies"
8
+ spec.version = Obviously::Valid::Dependencies::VERSION
9
+ spec.authors = ["TJ Taylor"]
10
+ spec.email = ["dugancathal@gmail.com"]
11
+ spec.summary = %q{Write a short summary. Required.}
12
+ spec.description = %q{Write a longer description. Optional.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
File without changes
@@ -0,0 +1,13 @@
1
+ require 'pathname'
2
+
3
+ DUMMY_APP_PATH = Pathname(File.expand_path('../dummy', __FILE__))
4
+
5
+ RSpec.configure do |config|
6
+ config.expect_with :rspec do |expectations|
7
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
8
+ end
9
+
10
+ config.mock_with :rspec do |mocks|
11
+ mocks.verify_partial_doubles = true
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'transdeps/cli'
3
+
4
+ module Transdeps
5
+ describe Cli do
6
+ it 'uses the reconciles dependencies' do
7
+ reconciler = double('Reconciler', call: [])
8
+ cli = Cli.new('components', 'root', reconciler)
9
+ expect(reconciler).to receive(:call).with(Pathname('components'), Pathname('root'))
10
+ cli.run
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'transdeps/reconciler'
3
+
4
+ module Transdeps
5
+ describe Reconciler do
6
+ it 'returns the set of specs that are inconsistent between the components' do
7
+ factory = SpecListFactory.new
8
+ rec = Reconciler.new(factory)
9
+ component_dir = double(Dir, children: [DUMMY_APP_PATH + 'components/invalid-sub-dependencies'])
10
+
11
+ ten_dot_oh = Specification.from_lock('rake (10.0.0)')
12
+ ten_dot_one = Specification.from_lock('rake (10.1.0)')
13
+ expect(factory).to receive(:call).with(DUMMY_APP_PATH) do
14
+ list = SpecList.new('Gemfile.lock', double)
15
+ allow(list).to receive(:specs).and_return([ten_dot_oh])
16
+ list
17
+ end
18
+ expect(factory).to receive(:call).with(DUMMY_APP_PATH + 'components/invalid-sub-dependencies') do
19
+ list = SpecList.new('Gemfile.lock', double)
20
+ allow(list).to receive(:specs).and_return([ten_dot_one])
21
+ list
22
+ end
23
+
24
+ result = rec.call(component_dir, DUMMY_APP_PATH)
25
+
26
+ expect(result).to eq [Inconsistency.new(ten_dot_oh, ten_dot_one)]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'transdeps/spec_list_factory'
3
+
4
+ module Transdeps
5
+ describe SpecListFactory do
6
+ it 'returns a speclist for given dir' do
7
+ lockfile = DUMMY_APP_PATH + 'Gemfile.lock'
8
+ expect(File).to receive(:read).with(lockfile).and_return('stuff')
9
+
10
+ speclist = SpecList.new DUMMY_APP_PATH + 'Gemfile.lock', 'stuff'
11
+ result = SpecListFactory.new.call(DUMMY_APP_PATH)
12
+ expect(result.lock_file_path).to eq(speclist.lock_file_path)
13
+ expect(result.lock_file_contents).to eq(speclist.lock_file_contents)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+ require 'transdeps/spec_list'
3
+
4
+ module Transdeps
5
+ describe SpecList do
6
+ it 'delegates the :specs method to the generator' do
7
+ generator = double(Bundler::LockfileParser, new: nil, specs: [])
8
+ expect(generator).to receive(:specs)
9
+ list = SpecList.new('Gemfile.lock', 'contents', generator)
10
+ list.specs
11
+ end
12
+
13
+ it 'returns a Specification for each spec' do
14
+ generator = double(Bundler::LockfileParser, specs: ['rake (10.0.0)'])
15
+ list = SpecList.new('Gemfile.lock', 'contents', generator)
16
+ allow(list).to receive(:parser).and_return(generator)
17
+ expect(list.specs).to eq([Specification.from_lock('rake (10.0.0)', '.')])
18
+ end
19
+
20
+ it "sets the specification project_path to the lock_file's directory" do
21
+ generator = double(Bundler::LockfileParser, specs: ['rake (10.0.0)'])
22
+ list = SpecList.new('/path/to/Gemfile.lock', 'contents', generator)
23
+ allow(list).to receive(:parser).and_return(generator)
24
+ expect(list.specs).to eq([Specification.from_lock('rake (10.0.0)', '/path/to')])
25
+ end
26
+
27
+ it 'allows findingy by gem name' do
28
+ generator = double(Bundler::LockfileParser, specs: ['rake (10.0.0)'])
29
+ list = SpecList.new('/path/to/Gemfile.lock', 'contents', generator)
30
+ allow(list).to receive(:parser).and_return(generator)
31
+ expect(list['rake']).to eq(Specification.from_lock('rake (10.0.0)', '/path/to'))
32
+ end
33
+
34
+ describe '-=' do
35
+ it 'returns a list of the inconsistencies' do
36
+ ten_dot_oh = Specification.from_lock('rake (10.0.0)', '.')
37
+ ten_dot_one = Specification.from_lock('rake (10.1.0)', '.')
38
+ project_generator = double(Bundler::LockfileParser, specs: [ten_dot_oh])
39
+ project_list = SpecList.new('Gemfile.lock', 'contents', project_generator)
40
+
41
+ component_generator = double(Bundler::LockfileParser, specs: [ten_dot_one])
42
+ component_list = SpecList.new('Gemfile.lock', 'contents', component_generator)
43
+
44
+ expect(project_list - component_list).to eq([Inconsistency.new(ten_dot_oh, ten_dot_one)])
45
+ end
46
+
47
+ it 'is agnostic to project_path' do
48
+ ten_dot_oh = Specification.from_lock('rake (10.0.0)', '/first/path')
49
+ ten_dot_one = Specification.from_lock('rake (10.0.0)', '/other/path')
50
+ project_generator = double(Bundler::LockfileParser, specs: [ten_dot_oh])
51
+ project_list = SpecList.new('/first/Gemfile.lock', 'contents', project_generator)
52
+
53
+ component_generator = double(Bundler::LockfileParser, specs: [ten_dot_one])
54
+ component_list = SpecList.new('/other/Gemfile.lock', 'contents', component_generator)
55
+
56
+ expect(project_list - component_list).to eq([])
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+ require 'transdeps/specification'
3
+
4
+ describe Transdeps::Specification do
5
+ describe '.from_lock' do
6
+ it 'initializes the name and version from the lock string' do
7
+ lock = 'rake (10.0.0)'
8
+ spec = Transdeps::Specification.from_lock(lock)
9
+ expect(spec.name).to eq 'rake'
10
+ expect(spec.version).to eq '10.0.0'
11
+ end
12
+
13
+ it 'works for dasherized spec-names' do
14
+ lock = 'rake-lib (10.0.0)'
15
+ spec = Transdeps::Specification.from_lock(lock)
16
+ expect(spec.name).to eq 'rake-lib'
17
+ expect(spec.version).to eq '10.0.0'
18
+ end
19
+
20
+ it 'works for underscored names' do
21
+ lock = 'rake_lib (10.0.0)'
22
+ spec = Transdeps::Specification.from_lock(lock)
23
+ expect(spec.name).to eq 'rake_lib'
24
+ expect(spec.version).to eq '10.0.0'
25
+ end
26
+ end
27
+
28
+ describe 'match-y-ness' do
29
+ it 'matches when the name is the same' do
30
+ version1 = Transdeps::Specification.new('rake', '10.0.0')
31
+ version2 = Transdeps::Specification.new('rake', '10.0.0')
32
+ expect(version1 =~ version2).to be_truthy
33
+ end
34
+
35
+ it 'does not match when the name is the same and the version is different' do
36
+ version1 = Transdeps::Specification.new('rake', '10.0.0')
37
+ version2 = Transdeps::Specification.new('rake', '10.1.0')
38
+ expect(version1 =~ version2).to be_falsey
39
+ end
40
+
41
+ it 'does not care what the project path is' do
42
+ version1 = Transdeps::Specification.new('rake', '10.0.0', 'path1')
43
+ version2 = Transdeps::Specification.new('rake', '10.0.0', 'path2')
44
+ expect(version1 =~ version2).to be_truthy
45
+ end
46
+ end
47
+
48
+ describe 'equality' do
49
+ it 'is equal when the name, version, and project_path are equal' do
50
+ version1 = Transdeps::Specification.new('rake', '10.0.0', 'path')
51
+ version2 = Transdeps::Specification.new('rake', '10.0.0', 'path')
52
+ expect(version1 === version2).to be_truthy
53
+ end
54
+ end
55
+
56
+ describe '#same_gem_as?' do
57
+ it 'returns true when the gem names are the same' do
58
+ version1 = Transdeps::Specification.new('rake', '10.0.0')
59
+ version2 = Transdeps::Specification.new('rake', '10.0.0')
60
+ expect(version1).to be_same_gem_as version2
61
+ end
62
+
63
+ it 'returns true when the gem names are the same and versions are different' do
64
+ version1 = Transdeps::Specification.new('rake', '10.1.0')
65
+ version2 = Transdeps::Specification.new('rake', '10.0.0')
66
+ expect(version1).to be_same_gem_as version2
67
+ end
68
+
69
+ it 'returns false when the gem names are the different' do
70
+ version1 = Transdeps::Specification.new('rake', '10.0.0')
71
+ version2 = Transdeps::Specification.new('rack', '10.0.0')
72
+ expect(version1).to_not be_same_gem_as version2
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,35 @@
1
+ require 'transdeps/tasks'
2
+
3
+ describe 'rake' do
4
+ describe 'transdeps' do
5
+ let(:cli) { double(Transdeps::Cli, run: nil) }
6
+ before do
7
+ Rake::Task['transdeps'].reenable
8
+ allow(Transdeps::Cli).to receive(:new).and_return(cli)
9
+ end
10
+
11
+ context 'with two arguments' do
12
+ it 'calls Cli.run' do
13
+ Rake.application.invoke_task 'transdeps[component_dir,root_dir]'
14
+
15
+ expect(Transdeps::Cli).to have_received(:new).with 'component_dir', 'root_dir'
16
+ expect(cli).to have_received(:run)
17
+ end
18
+ end
19
+
20
+ context 'with one argument' do
21
+ it 'calls Cli.run' do
22
+ Rake.application.invoke_task 'transdeps[component_dir]'
23
+
24
+ expect(Transdeps::Cli).to have_received(:new).with 'component_dir'
25
+ expect(cli).to have_received(:run)
26
+ end
27
+
28
+ it 'prints a warning that the root dir is PWD' do
29
+ expect do
30
+ Rake.application.invoke_task 'transdeps[component_dir]'
31
+ end.to output(/WARNING: Using PWD as project root_dir/).to_stderr
32
+ end
33
+ end
34
+ end
35
+ end
data/transdeps.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'transdeps/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "transdeps"
8
+ spec.version = Transdeps::VERSION
9
+ spec.authors = ["TJ Taylor"]
10
+ spec.email = ["dugancathal@gmail.com"]
11
+ spec.description = %q{A tool to manage unbuilt gems' dependencies}
12
+ spec.summary = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ end
metadata ADDED
@@ -0,0 +1,152 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: transdeps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - TJ Taylor
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: A tool to manage unbuilt gems' dependencies
56
+ email:
57
+ - dugancathal@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/transdeps.rb
69
+ - lib/transdeps/cli.rb
70
+ - lib/transdeps/inconsistency.rb
71
+ - lib/transdeps/reconciler.rb
72
+ - lib/transdeps/spec_list.rb
73
+ - lib/transdeps/spec_list_factory.rb
74
+ - lib/transdeps/specification.rb
75
+ - lib/transdeps/tasks.rb
76
+ - lib/transdeps/version.rb
77
+ - spec/dummy/Gemfile
78
+ - spec/dummy/Gemfile.lock
79
+ - spec/dummy/components/invalid-sub-dependencies/Gemfile
80
+ - spec/dummy/components/invalid-sub-dependencies/Gemfile.lock
81
+ - spec/dummy/components/invalid-sub-dependencies/invalid-sub-dependencies.gemspec
82
+ - spec/dummy/components/invalid-sub-dependencies/lib/invalid/sub/dependencies.rb
83
+ - spec/dummy/components/invalid-sub-dependencies/lib/invalid/sub/dependencies/version.rb
84
+ - spec/dummy/components/obviously-invalid-dependencies/Gemfile
85
+ - spec/dummy/components/obviously-invalid-dependencies/Gemfile.lock
86
+ - spec/dummy/components/obviously-invalid-dependencies/lib/obviously/invalid/dependencies.rb
87
+ - spec/dummy/components/obviously-invalid-dependencies/lib/obviously/invalid/dependencies/version.rb
88
+ - spec/dummy/components/obviously-invalid-dependencies/obviously-invalid-dependencies.gemspec
89
+ - spec/dummy/components/obviously-valid-dependencies/Gemfile
90
+ - spec/dummy/components/obviously-valid-dependencies/Gemfile.lock
91
+ - spec/dummy/components/obviously-valid-dependencies/lib/obviously/valid/dependencies.rb
92
+ - spec/dummy/components/obviously-valid-dependencies/lib/obviously/valid/dependencies/version.rb
93
+ - spec/dummy/components/obviously-valid-dependencies/obviously-valid-dependencies.gemspec
94
+ - spec/dummy/lib/dummy.rb
95
+ - spec/spec_helper.rb
96
+ - spec/transdeps/cli_spec.rb
97
+ - spec/transdeps/reconciler_spec.rb
98
+ - spec/transdeps/spec_list_factory_spec.rb
99
+ - spec/transdeps/spec_list_spec.rb
100
+ - spec/transdeps/specification_spec.rb
101
+ - spec/transdeps/tasks_spec.rb
102
+ - transdeps.gemspec
103
+ homepage: ''
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.2.2
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: ''
127
+ test_files:
128
+ - spec/dummy/Gemfile
129
+ - spec/dummy/Gemfile.lock
130
+ - spec/dummy/components/invalid-sub-dependencies/Gemfile
131
+ - spec/dummy/components/invalid-sub-dependencies/Gemfile.lock
132
+ - spec/dummy/components/invalid-sub-dependencies/invalid-sub-dependencies.gemspec
133
+ - spec/dummy/components/invalid-sub-dependencies/lib/invalid/sub/dependencies.rb
134
+ - spec/dummy/components/invalid-sub-dependencies/lib/invalid/sub/dependencies/version.rb
135
+ - spec/dummy/components/obviously-invalid-dependencies/Gemfile
136
+ - spec/dummy/components/obviously-invalid-dependencies/Gemfile.lock
137
+ - spec/dummy/components/obviously-invalid-dependencies/lib/obviously/invalid/dependencies.rb
138
+ - spec/dummy/components/obviously-invalid-dependencies/lib/obviously/invalid/dependencies/version.rb
139
+ - spec/dummy/components/obviously-invalid-dependencies/obviously-invalid-dependencies.gemspec
140
+ - spec/dummy/components/obviously-valid-dependencies/Gemfile
141
+ - spec/dummy/components/obviously-valid-dependencies/Gemfile.lock
142
+ - spec/dummy/components/obviously-valid-dependencies/lib/obviously/valid/dependencies.rb
143
+ - spec/dummy/components/obviously-valid-dependencies/lib/obviously/valid/dependencies/version.rb
144
+ - spec/dummy/components/obviously-valid-dependencies/obviously-valid-dependencies.gemspec
145
+ - spec/dummy/lib/dummy.rb
146
+ - spec/spec_helper.rb
147
+ - spec/transdeps/cli_spec.rb
148
+ - spec/transdeps/reconciler_spec.rb
149
+ - spec/transdeps/spec_list_factory_spec.rb
150
+ - spec/transdeps/spec_list_spec.rb
151
+ - spec/transdeps/specification_spec.rb
152
+ - spec/transdeps/tasks_spec.rb