gem-dependent 0.1.7 → 0.2.0

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.
data/Gemfile CHANGED
@@ -1,7 +1,5 @@
1
- source 'http://rubygems.org'
1
+ source :rubygems
2
+ gemspec
2
3
 
3
- group :dev do
4
- gem 'rake'
5
- gem 'rspec', '~>2'
6
- gem 'jeweler'
7
- end
4
+ gem 'rake'
5
+ gem 'rspec', '~>2'
data/Gemfile.lock CHANGED
@@ -1,14 +1,12 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gem-dependent (0.2.0)
5
+
1
6
  GEM
2
7
  remote: http://rubygems.org/
3
8
  specs:
4
9
  diff-lcs (1.1.2)
5
- gemcutter (0.6.1)
6
- git (1.2.5)
7
- jeweler (1.4.0)
8
- gemcutter (>= 0.1.0)
9
- git (>= 1.2.5)
10
- rubyforge (>= 2.0.0)
11
- json_pure (1.4.6)
12
10
  rake (0.8.7)
13
11
  rspec (2.0.1)
14
12
  rspec-core (~> 2.0.1)
@@ -20,13 +18,11 @@ GEM
20
18
  rspec-mocks (2.0.1)
21
19
  rspec-core (~> 2.0.1)
22
20
  rspec-expectations (~> 2.0.1)
23
- rubyforge (2.0.4)
24
- json_pure (>= 1.1.7)
25
21
 
26
22
  PLATFORMS
27
23
  ruby
28
24
 
29
25
  DEPENDENCIES
30
- jeweler
26
+ gem-dependent!
31
27
  rake
32
28
  rspec (~> 2)
data/Rakefile CHANGED
@@ -1,20 +1,22 @@
1
- task :default => :spec
2
- require "rspec/core/rake_task"
3
- RSpec::Core::RakeTask.new(:spec) do |t|
4
- t.rspec_opts = '--backtrace --color'
5
- end
6
-
7
- begin
8
- require 'jeweler'
9
- Jeweler::Tasks.new do |gem|
10
- gem.name = 'gem-dependent'
11
- gem.summary = "See which gems depend on your gems"
12
- gem.email = "grosser.michael@gmail.com"
13
- gem.homepage = "http://github.com/grosser/#{gem.name}"
14
- gem.authors = ["Michael Grosser"]
15
- end
16
-
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
20
- end
1
+ require 'bundler/gem_tasks'
2
+
3
+ task :default do
4
+ sh "rspec spec/"
5
+ end
6
+
7
+ # extracted from https://github.com/grosser/project_template
8
+ rule /^version:bump:.*/ do |t|
9
+ sh "git status | grep 'nothing to commit'" # ensure we are not dirty
10
+ index = ['major', 'minor','patch'].index(t.name.split(':').last)
11
+ file = 'lib/rubygems/dependent/version.rb'
12
+
13
+ version_file = File.read(file)
14
+ old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
15
+ version_parts[index] = version_parts[index].to_i + 1
16
+ version_parts[2] = 0 if index < 2 # remove patch for minor
17
+ version_parts[1] = 0 if index < 1 # remove minor for major
18
+ new_version = version_parts * '.'
19
+ File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
20
+
21
+ sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
22
+ end
data/Readme.md CHANGED
@@ -4,7 +4,7 @@ Install
4
4
 
5
5
  Usage
6
6
  =====
7
- The first run can take looooong, but after the caches are filled, its pretty fast.
7
+ The first run can take looooong, but after the caches are filled, its pretty fast. Checking all versions will take significantly longer.
8
8
 
9
9
  gem dependent my_gem
10
10
 
@@ -12,6 +12,7 @@ The first run can take looooong, but after the caches are filled, its pretty fas
12
12
  --no-progress Do not show progress
13
13
  --fetch-limit N Fetch specs for max N gems (for fast debugging)
14
14
  --parallel N Make N requests in parallel
15
+ --all-versions Check against all versions of gems
15
16
 
16
17
 
17
18
  Output
@@ -37,6 +38,7 @@ Output
37
38
 
38
39
  TODO
39
40
  =====
41
+ - NOTE: Dependency.new w/ a regexp is deprecated. Dependency.new called from gem-dependent/lib/rubygems/dependent.rb:70
40
42
  - include nested dependencies (a > b > c --> a = [b,c])
41
43
  - add tests for cli interface
42
44
  - add `--type development` support
@@ -1,46 +1,11 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
+ require "rubygems/dependent/version"
5
3
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{gem-dependent}
8
- s.version = "0.1.7"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
+ Gem::Specification.new "gem-dependent", Gem::Dependent::VERSION do |s|
5
+ s.summary = "See which gems depend on your gems"
11
6
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2011-08-21}
13
- s.email = %q{grosser.michael@gmail.com}
14
- s.files = [
15
- "Gemfile",
16
- "Gemfile.lock",
17
- "Rakefile",
18
- "Readme.md",
19
- "VERSION",
20
- "gem-dependent.gemspec",
21
- "lib/rubygems/commands/dependent_command.rb",
22
- "lib/rubygems/dependent.rb",
23
- "lib/rubygems/dependent_parallel.rb",
24
- "lib/rubygems_plugin.rb",
25
- "spec/dependent_spec.rb",
26
- "spec/fixtures/gemcutter_specs.yml"
27
- ]
28
- s.homepage = %q{http://github.com/grosser/gem-dependent}
29
- s.rdoc_options = ["--charset=UTF-8"]
30
- s.require_paths = ["lib"]
31
- s.rubygems_version = %q{1.6.2}
32
- s.summary = %q{See which gems depend on your gems}
33
- s.test_files = [
34
- "spec/dependent_spec.rb"
35
- ]
36
-
37
- if s.respond_to? :specification_version then
38
- s.specification_version = 3
39
-
40
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
- else
42
- end
43
- else
44
- end
7
+ s.email = "michael@grosser.it"
8
+ s.homepage = "http://github.com/grosser/#{s.name}"
9
+ s.files = `git ls-files`.split("\n")
10
+ s.license = "MIT"
45
11
  end
46
-
@@ -19,6 +19,10 @@ class Gem::Commands::DependentCommand < Gem::Command
19
19
  add_option('--parallel N', Integer, 'Make N requests in parallel') do |n, _|
20
20
  options[:parallel] = n
21
21
  end
22
+
23
+ add_option('--all-versions', 'Check against all versions of gems') do
24
+ options[:all_versions] = true
25
+ end
22
26
  end
23
27
 
24
28
  def arguments
@@ -36,11 +40,12 @@ class Gem::Commands::DependentCommand < Gem::Command
36
40
 
37
41
  gem = get_all_gem_names.first
38
42
  gems_and_dependencies = Gem::Dependent.find(gem, options)
39
- gems_and_dependencies.each do |gem, dependencies|
43
+ gems_and_dependencies.each do |gem, version, dependencies|
40
44
  requirements = dependencies.map do |dependency|
41
45
  formatted_dependency(dependency)
42
46
  end.join(', ')
43
- puts "#{gem} #{requirements}"
47
+ version = (options[:all_versions] ? " (v#{version})" : "")
48
+ puts "#{gem}#{version} #{requirements}"
44
49
  end
45
50
  rescue Object => e
46
51
  $stderr.puts e
@@ -53,4 +58,4 @@ class Gem::Commands::DependentCommand < Gem::Command
53
58
  type = " (#{dependency.type})" if dependency.type == :development
54
59
  "#{dependency.requirement}#{type}"
55
60
  end
56
- end
61
+ end
@@ -0,0 +1,5 @@
1
+ module Gem
2
+ class Dependent
3
+ VERSION = Version = '0.2.0'
4
+ end
5
+ end
@@ -1,14 +1,13 @@
1
- require 'rubygems/dependent_parallel'
1
+ require 'rubygems/dependent/version'
2
+ require 'rubygems/dependent/parallel'
2
3
  require 'rubygems/spec_fetcher'
3
4
 
4
5
  module Gem
5
6
  class Dependent
6
- VERSION = File.read( File.join(File.dirname(__FILE__),'..','..','VERSION') ).strip
7
-
8
7
  def self.find(gem, options={})
9
8
  # get all gems
10
9
  specs_and_sources = with_changed_gem_source(options[:source]) do
11
- all_specs_and_sources
10
+ all_specs_and_sources(:all_versions => options[:all_versions])
12
11
  end
13
12
 
14
13
  if options[:fetch_limit]
@@ -33,27 +32,27 @@ module Gem
33
32
  parallel = (options[:parallel] || 15)
34
33
  Gem::Dependent::Parallel.map(specs_and_sources, :in_processes => parallel) do |spec, source|
35
34
  yield if block_given?
36
- name = spec.first
37
- dependencies = fetch_dependencies(spec, source)
38
- [name, dependencies]
35
+ name, version = spec[0,2]
36
+ dependencies = fetch_dependencies(spec, source, options)
37
+ [name, version, dependencies]
39
38
  end
40
39
  end
41
40
 
42
- def self.fetch_dependencies(spec, source)
41
+ def self.fetch_dependencies(spec, source, options)
43
42
  begin
44
43
  fetcher = Gem::SpecFetcher.fetcher
45
44
  fetcher.fetch_spec(spec, URI.parse(source)).dependencies
46
45
  rescue Object => e
47
- $stderr.puts e
46
+ $stderr.puts e unless options[:all_versions]
48
47
  []
49
48
  end
50
49
  end
51
50
 
52
51
  def self.select_dependent(gems_and_dependencies, gem)
53
- gems_and_dependencies.map do |name, dependencies|
54
- matching_dependencies = dependencies.select{|d| d.name == gem }
52
+ gems_and_dependencies.map do |name, version, dependencies|
53
+ matching_dependencies = dependencies.select{|d| d.name == gem } rescue []
55
54
  next if matching_dependencies.empty?
56
- [name, matching_dependencies]
55
+ [name, version, matching_dependencies]
57
56
  end.compact
58
57
  end
59
58
 
@@ -62,14 +61,19 @@ module Gem
62
61
  $stderr.flush if rand(20) == 0 # make progress visible
63
62
  end
64
63
 
65
- def self.all_specs_and_sources
64
+ def self.all_specs_and_sources(options={})
66
65
  fetcher = Gem::SpecFetcher.fetcher
67
66
  all = true
68
67
  matching_platform = false
69
68
  prerelease = false
70
69
  matcher = Gem::Dependency.new(//, Gem::Requirement.default) # any name, any version
71
70
  specs_and_sources = fetcher.find_matching matcher, all, matching_platform, prerelease
72
- uniq_by(specs_and_sources){|a| a.first.first }
71
+
72
+ if options[:all_versions]
73
+ specs_and_sources
74
+ else
75
+ uniq_by(specs_and_sources){|a| a.first.first }
76
+ end
73
77
  end
74
78
 
75
79
  # get unique elements from an array (last found is used)
@@ -10,44 +10,46 @@ describe Gem::Dependent do
10
10
  let(:fixture){ YAML.load(File.read('spec/fixtures/gemcutter_specs.yml')) }
11
11
  let(:hoe_gems){
12
12
  [
13
- ["7digital", ["hoe"]],
14
- ["abingo_port", ["hoe"]],
15
- ["abundance", ["hoe"]],
16
- ["actionview-data", ["hoe"]],
17
- ["active_link_to", ["hoe"]],
18
- ["activemerchant-paymentech-orbital", ["hoe"]],
19
- ["active_nomad", ["hoe"]],
20
- ["active_presenter", ["hoe"]],
21
- ["activerecord-fast-import", ["hoe"]],
13
+ ["_", ["hoe"]],
14
+ ["1234567890_", ["hoe"]],
15
+ ["actionmailer-javamail", ["hoe"]],
16
+ ["ActiveExcel", ["hoe"]],
17
+ ["activefacts", ["hoe"]],
18
+ ["activeldap", ["hoe"]],
19
+ ["active_mac", ["hoe"]],
20
+ ["activemdb", ["hoe"]],
21
+ ["activerdf_rules", ["hoe"]],
22
22
  ["activerecord-jdbc-adapter", ["hoe"]]
23
23
  ]
24
24
  }
25
25
 
26
- def simplify(dependencies)
27
- dependencies.map{|name, deps| [name, deps.map{|d| d.name}] }
26
+ def simplify_gem_results(dependencies)
27
+ dependencies.map{|name, version, deps| [name, deps.map{|d| d.name}] }
28
28
  end
29
29
 
30
- def stub_source(gem_source = nil)
31
- gem_source ||= 'http://gemcutter.org'
32
- Gem::SpecFetcher.fetcher.should_receive(:load_specs).with(URI.parse(gem_source), 'specs').and_return(fixture)
30
+ def stub_source(options={})
31
+ gem_source = options[:source] || 'http://gemcutter.org'
32
+ if !options[:live]
33
+ Gem::SpecFetcher.fetcher.should_receive(:load_specs).with(URI.parse(gem_source), 'specs').and_return(fixture)
34
+ end
33
35
  Gem.sources = [gem_source]
34
36
  end
35
37
 
36
38
  it 'finds dependencies for given gem' do
37
39
  stub_source
38
- dependencies = simplify(Gem::Dependent.find('hoe'))
40
+ dependencies = simplify_gem_results(Gem::Dependent.find('hoe'))
39
41
  dependencies.should == hoe_gems
40
42
  end
41
43
 
42
44
  it "obeys fetch-limit" do
43
45
  stub_source
44
- dependencies = simplify(Gem::Dependent.find('hoe', :fetch_limit => 100))
45
- dependencies.should == hoe_gems.first(4)
46
+ dependencies = simplify_gem_results(Gem::Dependent.find('hoe', :fetch_limit => 100))
47
+ dependencies.should == hoe_gems.first(3)
46
48
  end
47
49
 
48
50
  it "can use given source" do
49
51
  source = 'http://rubygems.org'
50
- stub_source(source)
52
+ stub_source(:source => source)
51
53
  Gem::Dependent.find('hoe', :source => source)
52
54
  end
53
55
 
@@ -57,6 +59,12 @@ describe Gem::Dependent do
57
59
  Gem::Dependent.find('hoe', :parallel => 3)
58
60
  end
59
61
 
62
+ it "obeys all versions option" do
63
+ stub_source :live => true
64
+ Gem::Dependent.should_receive(:all_specs_and_sources).with(:all_versions => true)
65
+ Gem::Dependent.find('hoe', :all_versions => true)
66
+ end
67
+
60
68
  it "has a VERSION" do
61
69
  Gem::Dependent::VERSION.should =~ /^\d+\.\d+\.\d+$/
62
70
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-dependent
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 7
10
- version: 0.1.7
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,12 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-21 00:00:00 +02:00
19
- default_executable:
18
+ date: 2012-05-08 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
21
  description:
23
- email: grosser.michael@gmail.com
22
+ email: michael@grosser.it
24
23
  executables: []
25
24
 
26
25
  extensions: []
@@ -36,17 +35,17 @@ files:
36
35
  - gem-dependent.gemspec
37
36
  - lib/rubygems/commands/dependent_command.rb
38
37
  - lib/rubygems/dependent.rb
39
- - lib/rubygems/dependent_parallel.rb
38
+ - lib/rubygems/dependent/parallel.rb
39
+ - lib/rubygems/dependent/version.rb
40
40
  - lib/rubygems_plugin.rb
41
41
  - spec/dependent_spec.rb
42
42
  - spec/fixtures/gemcutter_specs.yml
43
- has_rdoc: true
44
43
  homepage: http://github.com/grosser/gem-dependent
45
- licenses: []
46
-
44
+ licenses:
45
+ - MIT
47
46
  post_install_message:
48
- rdoc_options:
49
- - --charset=UTF-8
47
+ rdoc_options: []
48
+
50
49
  require_paths:
51
50
  - lib
52
51
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -70,9 +69,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
69
  requirements: []
71
70
 
72
71
  rubyforge_project:
73
- rubygems_version: 1.6.2
72
+ rubygems_version: 1.8.24
74
73
  signing_key:
75
74
  specification_version: 3
76
75
  summary: See which gems depend on your gems
77
- test_files:
78
- - spec/dependent_spec.rb
76
+ test_files: []
77
+