javagems 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.4.0
data/bin/javagem CHANGED
@@ -2,14 +2,17 @@
2
2
  require 'rubygems'
3
3
  require 'javagems/commands/javagem_command'
4
4
  require 'rubygems/command_manager'
5
- $: << File.dirname(__FILE__)
5
+ require 'pathname'
6
+ $: << (Pathname(__FILE__).parent.parent + "lib").expand_path.to_s
7
+
6
8
  require "rubygems/commands/jeweler_command"
9
+ require "rubygems/commands/classpath_command"
7
10
 
8
11
  Gem::CommandManager.instance.register_command :jeweler
12
+ Gem::CommandManager.instance.register_command :classpath
9
13
 
10
14
  required_version = Gem::Requirement.new "> 1.8.3"
11
15
 
12
-
13
16
  unless required_version.satisfied_by? Gem.ruby_version then
14
17
  abort "Expected Ruby Version #{required_version}, was #{Gem.ruby_version}"
15
18
  end
data/javagems.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{javagems}
8
- s.version = "0.3.1"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["gabrielg", "jaknowlden"]
@@ -32,9 +32,17 @@ Gem::Specification.new do |s|
32
32
  "lib/javagems.rb",
33
33
  "lib/javagems/commands/javagem_command.rb",
34
34
  "lib/javagems/gem_overrides.rb",
35
+ "lib/rubygems/commands/classpath_command.rb",
35
36
  "lib/rubygems/commands/jeweler_command.rb",
36
- "test/gem_overrides_test.rb",
37
+ "test/aaaaagem_overrides_test.rb",
38
+ "test/classpath_command_test.rb",
37
39
  "test/jeweler_command_test.rb",
40
+ "test/test_app/Gemfile",
41
+ "test/test_app/vendor/gems/environment.rb",
42
+ "test/test_app/vendor/gems/specifications/test-gem-four-0.0.0.gemspec",
43
+ "test/test_app/vendor/gems/specifications/test-gem-one-0.0.0.gemspec",
44
+ "test/test_app/vendor/gems/specifications/test-gem-three-0.0.0.gemspec",
45
+ "test/test_app/vendor/gems/specifications/test-gem-two-0.0.0.gemspec",
38
46
  "test/test_helper.rb"
39
47
  ]
40
48
  s.homepage = %q{http://www.javagems.org/}
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'rubygems/gem_runner'
3
3
  require 'rubygems/exceptions'
4
+ require 'bundler'
4
5
 
5
6
  module Gem
6
7
  DefaultGemConfigName = ".javagemrc"
@@ -31,3 +32,13 @@ class Gem::AbstractCommand < Gem::Command
31
32
  end
32
33
 
33
34
  end
35
+
36
+ class Bundler::Environment
37
+
38
+ private
39
+
40
+ def default_sources
41
+ [Bundler::GemSource.new(:uri => "http://gems.javagems.org"), Bundler::SystemGemSource.instance]
42
+ end
43
+
44
+ end
@@ -0,0 +1,33 @@
1
+ require 'rubygems/command'
2
+ require 'bundler'
3
+
4
+ class Gem::Commands::ClasspathCommand < Gem::Command
5
+ Bundler.logger.level = Logger::FATAL
6
+
7
+ def initialize
8
+ super 'classpath', "Given a Gemfile, returns the classpath necessary to satisfy dependencies"
9
+ end
10
+
11
+ def usage
12
+ "#{program_name} [GEMFILE]"
13
+ end
14
+
15
+ def execute
16
+ bundler_env = Bundler::Environment.load(options[:args].first)
17
+ deps = bundler_env.dependencies.map {|dep| dep.to_gem_dependency }
18
+
19
+ cp = Bundler::Resolver.resolve(deps, sources).collect do |spec|
20
+ (Pathname(spec.full_gem_path) + "lib").expand_path.to_s
21
+ end.join(File::PATH_SEPARATOR)
22
+ say(cp)
23
+ end
24
+
25
+ private
26
+
27
+ # FIXME - Until we have actual bundler support, use the system source index.
28
+ def sources
29
+ [Bundler::SystemGemSource.instance]
30
+ end
31
+
32
+ end
33
+
@@ -1,4 +1,6 @@
1
1
  require 'test_helper'
2
+ # FIXME - ahahaha this test filename is a stupid hack so this test always runs last
3
+ # and doesn't run all the other tests.
2
4
 
3
5
  # We fork here so we don't mess up the current Gem environment
4
6
  # in the process of running our tests, because that's what
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+ require 'rubygems/commands/classpath_command'
3
+ require 'pathname'
4
+
5
+ context "the classpath command" do
6
+ context "given a valid Gemfile" do
7
+ setup do
8
+ @command = Gem::Commands::ClasspathCommand.new
9
+ # FIXME - ghetto-mock
10
+ def @command.sources
11
+ [Bundler::DirectorySource.new(:location => (TestRoot + "test_app/vendor").expand_path.to_s)]
12
+ end
13
+ end
14
+
15
+ should "return the expected classpath on stdout" do
16
+ capture_std_stream(:stdout) do
17
+ @command.invoke((TestRoot + "test_app/Gemfile").expand_path.to_s)
18
+ end.split(File::PATH_SEPARATOR).collect { |p| Pathname(p).parent.basename.to_s }
19
+ end.equals(["test-gem-two", "test-gem-three", "test-gem-one", "test-gem-four"])
20
+
21
+ end
22
+
23
+ end
24
+
25
+
26
+
@@ -0,0 +1,3 @@
1
+ gem "test-gem-one"
2
+ gem "test-gem-two"
3
+ gem "test-gem-four"
@@ -0,0 +1,107 @@
1
+ # DO NOT MODIFY THIS FILE
2
+ module Bundler
3
+ file = File.expand_path(__FILE__)
4
+ dir = File.dirname(file)
5
+
6
+ ENV["PATH"] = "#{dir}/../../bin:#{ENV["PATH"]}"
7
+ ENV["RUBYOPT"] = "-r#{file} #{ENV["RUBYOPT"]}"
8
+
9
+ $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/test-gem-two/bin")
10
+ $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/test-gem-two/lib")
11
+ $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/test-gem-three/bin")
12
+ $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/test-gem-three/lib")
13
+ $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/test-gem-one/bin")
14
+ $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/test-gem-one/lib")
15
+ $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/test-gem-four/bin")
16
+ $LOAD_PATH.unshift File.expand_path("#{dir}/dirs/test-gem-four/lib")
17
+
18
+ @gemfile = "#{dir}/../../Gemfile"
19
+
20
+ require "rubygems"
21
+
22
+ @bundled_specs = {}
23
+ @bundled_specs["test-gem-two"] = eval(File.read("#{dir}/specifications/test-gem-two-0.0.0.gemspec"))
24
+ @bundled_specs["test-gem-two"].loaded_from = "#{dir}/specifications/test-gem-two-0.0.0.gemspec"
25
+ @bundled_specs["test-gem-three"] = eval(File.read("#{dir}/specifications/test-gem-three-0.0.0.gemspec"))
26
+ @bundled_specs["test-gem-three"].loaded_from = "#{dir}/specifications/test-gem-three-0.0.0.gemspec"
27
+ @bundled_specs["test-gem-one"] = eval(File.read("#{dir}/specifications/test-gem-one-0.0.0.gemspec"))
28
+ @bundled_specs["test-gem-one"].loaded_from = "#{dir}/specifications/test-gem-one-0.0.0.gemspec"
29
+ @bundled_specs["test-gem-four"] = eval(File.read("#{dir}/specifications/test-gem-four-0.0.0.gemspec"))
30
+ @bundled_specs["test-gem-four"].loaded_from = "#{dir}/specifications/test-gem-four-0.0.0.gemspec"
31
+
32
+ def self.add_specs_to_loaded_specs
33
+ Gem.loaded_specs.merge! @bundled_specs
34
+ end
35
+
36
+ def self.add_specs_to_index
37
+ @bundled_specs.each do |name, spec|
38
+ Gem.source_index.add_spec spec
39
+ end
40
+ end
41
+
42
+ add_specs_to_loaded_specs
43
+ add_specs_to_index
44
+
45
+ def self.require_env(env = nil)
46
+ context = Class.new do
47
+ def initialize(env) @env = env && env.to_s ; end
48
+ def method_missing(*) ; yield if block_given? ; end
49
+ def only(*env)
50
+ old, @only = @only, _combine_only(env.flatten)
51
+ yield
52
+ @only = old
53
+ end
54
+ def except(*env)
55
+ old, @except = @except, _combine_except(env.flatten)
56
+ yield
57
+ @except = old
58
+ end
59
+ def gem(name, *args)
60
+ opt = args.last.is_a?(Hash) ? args.pop : {}
61
+ only = _combine_only(opt[:only] || opt["only"])
62
+ except = _combine_except(opt[:except] || opt["except"])
63
+ files = opt[:require_as] || opt["require_as"] || name
64
+ files = [files] unless files.respond_to?(:each)
65
+
66
+ return unless !only || only.any? {|e| e == @env }
67
+ return if except && except.any? {|e| e == @env }
68
+
69
+ if files = opt[:require_as] || opt["require_as"]
70
+ files = Array(files)
71
+ files.each { |f| require f }
72
+ else
73
+ begin
74
+ require name
75
+ rescue LoadError
76
+ # Do nothing
77
+ end
78
+ end
79
+ yield if block_given?
80
+ true
81
+ end
82
+ private
83
+ def _combine_only(only)
84
+ return @only unless only
85
+ only = [only].flatten.compact.uniq.map { |o| o.to_s }
86
+ only &= @only if @only
87
+ only
88
+ end
89
+ def _combine_except(except)
90
+ return @except unless except
91
+ except = [except].flatten.compact.uniq.map { |o| o.to_s }
92
+ except |= @except if @except
93
+ except
94
+ end
95
+ end
96
+ context.new(env && env.to_s).instance_eval(File.read(@gemfile), @gemfile, 1)
97
+ end
98
+ end
99
+
100
+ module Gem
101
+ @loaded_stacks = Hash.new { |h,k| h[k] = [] }
102
+
103
+ def source_index.refresh!
104
+ super
105
+ Bundler.add_specs_to_index
106
+ end
107
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{test-gem-four}
5
+ s.version = "0.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["ggironda"]
9
+ s.date = %q{2009-11-14}
10
+ s.description = %q{TODO: longer description of your gem}
11
+ s.email = %q{gabriel.gironda@centro.net}
12
+ s.extra_rdoc_files = ["LICENSE", "README.rdoc"]
13
+ s.files = [".document", ".gitignore", "LICENSE", "README.rdoc", "Rakefile", "VERSION", "lib/test-gem-four.rb", "test/helper.rb", "test/test_test-gem-four.rb"]
14
+ s.homepage = %q{http://github.com/gabrielg/test-gem-four}
15
+ s.rdoc_options = ["--charset=UTF-8"]
16
+ s.require_paths = ["lib"]
17
+ s.rubygems_version = %q{1.3.5}
18
+ s.summary = %q{TODO: one-line summary of your gem}
19
+ s.test_files = ["test/helper.rb", "test/test_test-gem-four.rb"]
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
27
+ else
28
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{test-gem-one}
5
+ s.version = "0.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["ggironda"]
9
+ s.date = %q{2009-11-14}
10
+ s.description = %q{TODO: longer description of your gem}
11
+ s.email = %q{gabriel.gironda@centro.net}
12
+ s.extra_rdoc_files = ["LICENSE", "README.rdoc"]
13
+ s.files = [".document", ".gitignore", "LICENSE", "README.rdoc", "Rakefile", "VERSION", "lib/test-gem-one.rb", "test/helper.rb", "test/test_test-gem-one.rb"]
14
+ s.homepage = %q{http://github.com/gabrielg/test-gem-one}
15
+ s.rdoc_options = ["--charset=UTF-8"]
16
+ s.require_paths = ["lib"]
17
+ s.rubygems_version = %q{1.3.5}
18
+ s.summary = %q{TODO: one-line summary of your gem}
19
+ s.test_files = ["test/helper.rb", "test/test_test-gem-one.rb"]
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_runtime_dependency(%q<test-gem-three>, [">= 0"])
27
+ else
28
+ s.add_dependency(%q<test-gem-three>, [">= 0"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<test-gem-three>, [">= 0"])
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{test-gem-three}
5
+ s.version = "0.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["ggironda"]
9
+ s.date = %q{2009-11-14}
10
+ s.description = %q{TODO: longer description of your gem}
11
+ s.email = %q{gabriel.gironda@centro.net}
12
+ s.extra_rdoc_files = ["LICENSE", "README.rdoc"]
13
+ s.files = [".document", ".gitignore", "LICENSE", "README.rdoc", "Rakefile", "VERSION", "lib/test-gem-three.rb", "test/helper.rb", "test/test_test-gem-three.rb"]
14
+ s.homepage = %q{http://github.com/gabrielg/test-gem-three}
15
+ s.rdoc_options = ["--charset=UTF-8"]
16
+ s.require_paths = ["lib"]
17
+ s.rubygems_version = %q{1.3.5}
18
+ s.summary = %q{TODO: one-line summary of your gem}
19
+ s.test_files = ["test/helper.rb", "test/test_test-gem-three.rb"]
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
27
+ else
28
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{test-gem-two}
5
+ s.version = "0.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["ggironda"]
9
+ s.date = %q{2009-11-14}
10
+ s.description = %q{TODO: longer description of your gem}
11
+ s.email = %q{gabriel.gironda@centro.net}
12
+ s.extra_rdoc_files = ["LICENSE", "README.rdoc"]
13
+ s.files = [".document", ".gitignore", "LICENSE", "README.rdoc", "Rakefile", "VERSION", "lib/test-gem-two.rb", "test/helper.rb", "test/test_test-gem-two.rb"]
14
+ s.homepage = %q{http://github.com/gabrielg/test-gem-two}
15
+ s.rdoc_options = ["--charset=UTF-8"]
16
+ s.require_paths = ["lib"]
17
+ s.rubygems_version = %q{1.3.5}
18
+ s.summary = %q{TODO: one-line summary of your gem}
19
+ s.test_files = ["test/helper.rb", "test/test_test-gem-two.rb"]
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
27
+ else
28
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
29
+ end
30
+ else
31
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
32
+ end
33
+ end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,24 @@
1
1
  require 'rubygems'
2
2
  require 'riot'
3
3
  require 'pathname'
4
+ require 'stringio'
5
+
6
+ TestRoot = Pathname(__FILE__).parent
7
+
8
+ module Kernel
9
+
10
+ def capture_std_stream(stream_name)
11
+ original_stream = Object.const_get(stream_name.to_s.upcase)
12
+ fake_stream = StringIO.new
13
+ Object.const_set(stream_name.to_s.upcase, fake_stream)
14
+ yield
15
+ fake_stream.rewind
16
+ fake_stream.read
17
+ ensure
18
+ Object.const_set(stream_name.to_s.upcase, original_stream)
19
+ end
20
+
21
+ end
4
22
 
5
23
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
24
  $LOAD_PATH.unshift(File.dirname(__FILE__))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: javagems
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - gabrielg
@@ -75,9 +75,17 @@ files:
75
75
  - lib/javagems.rb
76
76
  - lib/javagems/commands/javagem_command.rb
77
77
  - lib/javagems/gem_overrides.rb
78
+ - lib/rubygems/commands/classpath_command.rb
78
79
  - lib/rubygems/commands/jeweler_command.rb
79
- - test/gem_overrides_test.rb
80
+ - test/aaaaagem_overrides_test.rb
81
+ - test/classpath_command_test.rb
80
82
  - test/jeweler_command_test.rb
83
+ - test/test_app/Gemfile
84
+ - test/test_app/vendor/gems/environment.rb
85
+ - test/test_app/vendor/gems/specifications/test-gem-four-0.0.0.gemspec
86
+ - test/test_app/vendor/gems/specifications/test-gem-one-0.0.0.gemspec
87
+ - test/test_app/vendor/gems/specifications/test-gem-three-0.0.0.gemspec
88
+ - test/test_app/vendor/gems/specifications/test-gem-two-0.0.0.gemspec
81
89
  - test/test_helper.rb
82
90
  has_rdoc: true
83
91
  homepage: http://www.javagems.org/