Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial pass -- imported gem_resolver and started taking a look at re…

…quired steps
  • Loading branch information...
commit 4adaf3c79f1b08c92a827fcad1a9ff14288a32f1 1 parent 0df5eb4
Yehuda Katz + Carl Lerche authored
20 LICENSE
View
@@ -0,0 +1,20 @@
+Copyright (c) 2009 YOUR NAME
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3  README.rdoc
View
@@ -0,0 +1,3 @@
+== bundler
+
+A gem that provides...
51 Rakefile
View
@@ -0,0 +1,51 @@
+require 'rubygems' unless ENV['NO_RUBYGEMS']
+require 'rake/gempackagetask'
+require 'rubygems/specification'
+require 'date'
+require 'spec/rake/spectask'
+
+spec = Gem::Specification.new do |s|
+ s.name = "bundler"
+ s.version = "0.0.1"
+ s.author = "Your Name"
+ s.email = "Your Email"
+ s.homepage = "http://example.com"
+ s.description = s.summary = "A gem that provides..."
+
+ s.platform = Gem::Platform::RUBY
+ s.has_rdoc = true
+ s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
+ s.summary = SUMMARY
+
+ # Uncomment this to add a dependency
+ # s.add_dependency "foo"
+
+ s.require_path = 'lib'
+ s.autorequire = GEM
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
+end
+
+task :default => :spec
+
+desc "Run specs"
+Spec::Rake::SpecTask.new do |t|
+ t.spec_files = FileList['spec/**/*_spec.rb']
+ t.spec_opts = %w(-fs --color)
+end
+
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.gem_spec = spec
+end
+
+desc "install the gem locally"
+task :install => [:package] do
+ sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
+end
+
+desc "create a gemspec file"
+task :make_spec do
+ File.open("#{GEM}.gemspec", "w") do |file|
+ file.puts spec.to_ruby
+ end
+end
4 TODO
View
@@ -0,0 +1,4 @@
+TODO:
+Fix LICENSE with your name
+Fix Rakefile with your name and contact info
+Add your code to lib/<%= name %>.rb
69 lib/bundler.rb
View
@@ -0,0 +1,69 @@
+require "rubygems"
+require "rubygems/remote_fetcher"
+require "pp"
+
+# $time = 0
+#
+# module Bundler
+# class LazySourceIndex
+#
+# def initialize
+# @cache = Hash.new
+# @cache_two = Hash.new do |h,(gem_info,uri)|
+# puts "FETCHING: #{gem_info}"
+# h[[gem_info,uri]] = Gem::SpecFetcher.fetcher.fetch_spec(gem_info, URI.parse(uri))
+# end
+# end
+#
+# def search(gem_pattern, platform_only = false)
+# start = Time.now
+# retval = @cache[gem_pattern.hash] ||= begin
+# Gem::SpecFetcher.fetcher.find_matching(gem_pattern, true, true).map do |result|
+# @cache_two[result]
+# end
+# end
+# $time += Time.now - start
+# retval
+# end
+#
+# end
+# end
+
+# index = Bundler::LazySourceIndex.new
+# pp index.search(Gem::Dependency.new("merb-core", "> 0"))
+
+# time = Time.now
+# deflated = Gem::RemoteFetcher.fetcher.fetch_path("#{Gem.sources.first}/Marshal.4.8.Z"); nil
+# inflated = Gem.inflate deflated; nil
+# index = Marshal.load(inflated); nil
+# File.open("dumped", "w") do |f|
+# f.puts inflated
+# end
+# puts "FINISHED INFLATING: #{Time.now - time}s"
+
+index = nil
+File.open("dumped", "r") do |f|
+ index = Marshal.load(f.read)
+end
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "gem_resolver", "lib", "gem_resolver"))
+# ENV["GEM_RESOLVER_DEBUG"] = "true"
+
+require "ruby-prof"
+
+RubyProf.start
+
+resolved = GemResolver.resolve([Gem::Dependency.new("rails", "> 0")], index)
+
+result = RubyProf.stop
+
+printer = RubyProf::GraphPrinter.new(result)
+printer.print
+
+pp resolved.all_specs.map {|x| [x.name, x.version]}
+
+# Gem::SpecFetcher.fetcher.find_matching(dependency) returns
+# [[["merb-core", #<Gem::Version "1.0.12">, "ruby"], "http://gems.rubyforge.org/"]]
+#
+# Gem::SpecFetcher.fetcher.fetch_spec(["merb-core", Gem::Version.new("0.9.2"), "ruby"], URI.parse("http://gems.rubyforge.org/"))
+# Gem::Specification
BIN  lib/dumped
View
Binary file not shown
14 script/destroy
View
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+begin
+ require 'rubigen'
+rescue LoadError
+ require 'rubygems'
+ require 'rubigen'
+end
+require 'rubigen/scripts/destroy'
+
+ARGV.shift if ['--help', '-h'].include?(ARGV[0])
+RubiGen::Base.use_component_sources! [:newgem_simple, :test_unit]
+RubiGen::Scripts::Destroy.new.run(ARGV)
14 script/generate
View
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+begin
+ require 'rubigen'
+rescue LoadError
+ require 'rubygems'
+ require 'rubigen'
+end
+require 'rubigen/scripts/generate'
+
+ARGV.shift if ['--help', '-h'].include?(ARGV[0])
+RubiGen::Base.use_component_sources! [:newgem_simple, :test_unit]
+RubiGen::Scripts::Generate.new.run(ARGV)
7 spec/bundler_spec.rb
View
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe "bundler" do
+ it "should do nothing" do
+ true.should == true
+ end
+end
2  spec/spec_helper.rb
View
@@ -0,0 +1,2 @@
+$TESTING=true
+$:.push File.join(File.dirname(__FILE__), '..', 'lib')
Please sign in to comment.
Something went wrong with that request. Please try again.