A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rubygems/rubygems/commit/3864a56b10 below:

Initial revision · rubygems/rubygems@3864a56 · GitHub

File tree Expand file treeCollapse file tree 11 files changed

+835

-0

lines changed

Filter options

Expand file treeCollapse file tree 11 files changed

+835

-0

lines changed Original file line number Diff line number Diff line change

@@ -0,0 +1,71 @@

1 +

#!/usr/bin/env ruby

2 + 3 +

require 'getoptlong'

4 +

require 'rubygems'

5 + 6 +

opts = GetoptLong.new([ '--build', '-b', GetoptLong::REQUIRED_ARGUMENT ],

7 +

[ '--install', '-i', GetoptLong::REQUIRED_ARGUMENT ],

8 +

[ '--uninstall', '-u', GetoptLong::REQUIRED_ARGUMENT ],

9 +

[ '--info', GetoptLong::REQUIRED_ARGUMENT ],

10 +

[ '--list', GetoptLong::NO_ARGUMENT ],

11 +

[ '--remote-install', GetoptLong::REQUIRED_ARGUMENT ])

12 + 13 + 14 +

opts.each do |opt, arg|

15 +

case opt

16 +

when '--build'

17 +

@spec_file = arg

18 +

when '--install'

19 +

@install_file = arg

20 +

when '--uninstall'

21 +

@gem = arg

22 +

when '--info'

23 +

@info = arg

24 +

when '--list'

25 +

@list = true

26 +

when '--remote-install'

27 +

@remote_install = arg

28 +

end

29 +

end

30 + 31 +

if @spec_file

32 +

load @spec_file

33 +

Gem::Specification.list.each do |spec|

34 +

Gem::Builder.new(spec).build

35 +

end

36 +

end

37 + 38 +

if @install_file

39 +

unless File.exist?(@install_file)

40 +

if File.exist?(@install_file+".gem")

41 +

@install_file = @install_file+".gem"

42 +

else

43 +

puts "Unknown gem file #{@install_file}"

44 +

end

45 +

end

46 +

Gem::Installer.new(@install_file).install

47 +

end

48 + 49 +

if @gem

50 +

Gem::Uninstaller.new(@gem).uninstall

51 +

end

52 + 53 +

if @info

54 +

gem_spec = Gem::Cache.from_installed_gems.search_by_name(@info)

55 +

if gem_spec

56 +

require 'yaml'

57 +

puts gem_spec.to_yaml

58 +

else

59 +

puts "Unkown gem #{@info}"

60 +

end

61 +

end

62 + 63 +

if @list

64 +

Gem::Cache.from_installed_gems.each do |gem_name, gem_spec|

65 +

puts gem_name

66 +

end

67 +

end

68 + 69 +

if @remote_install

70 +

Gem::RemoteInstaller.new(@remote_install).install

71 +

end

Original file line number Diff line number Diff line change

@@ -0,0 +1,41 @@

1 +

#!/usr/bin/env ruby

2 + 3 +

require 'webrick'

4 +

require 'getopts'

5 +

require 'rubygems'

6 +

require 'yaml'

7 + 8 +

getopts "", 'p:8808', "d:#{Gem.dir}"

9 + 10 + 11 +

class GemYamlServlet < WEBrick::HTTPServlet::AbstractServlet

12 +

def initialize(config)

13 +

@config = config

14 +

end

15 + 16 +

def do_POST(req,res)

17 +

do_GET(req,res)

18 +

end

19 + 20 +

def do_GET(req, res)

21 +

res['content-type'] = 'text/yaml'

22 +

gems = Gem::Cache.from_installed_gems(File.join($OPT_d, "specifications"))

23 +

res.body << gems.to_yaml

24 +

end

25 + 26 + 27 +

end

28 + 29 +

if __FILE__ == $0

30 +

s = WEBrick::HTTPServer.new(

31 +

:Port => $OPT_p.to_i,

32 +

:StartThreads => 1,

33 +

:Logger => WEBrick::Log::new($stderr, WEBrick::Log::DEBUG)

34 +

)

35 +

s.mount("/yaml", GemYamlServlet)

36 +

s.mount("/", WEBrick::HTTPServlet::FileHandler, File.join($OPT_d, "/specifications/"), true)

37 +

s.mount("/gems", WEBrick::HTTPServlet::FileHandler, File.join($OPT_d, "/cache/"), true)

38 +

trap("INT"){ s.shutdown }

39 +

s.start

40 +

end

41 + Original file line number Diff line number Diff line change

@@ -0,0 +1,40 @@

1 +

require 'rbconfig'

2 +

require 'find'

3 +

require 'ftools'

4 + 5 +

include Config

6 + 7 +

$srcdir = CONFIG["srcdir"]

8 +

$version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]

9 +

$libdir = File.join(CONFIG["libdir"], "ruby", $version)

10 +

$archdir = File.join($libdir, CONFIG["arch"])

11 +

$site_libdir = $:.find {|x| x =~ /site_ruby$/}

12 +

if !$site_libdir

13 +

$site_libdir = File.join($libdir, "site_ruby")

14 +

elsif $site_libdir !~ Regexp.quote($version)

15 +

$site_libdir = File.join($site_libdir, $version)

16 +

end

17 + 18 +

def install_rb(srcdir = nil)

19 +

libdir = "lib"

20 +

libdir = File.join(srcdir, libdir) if srcdir

21 +

path = []

22 +

dir = []

23 +

Find.find(libdir) do |f|

24 +

next unless FileTest.file?(f)

25 +

next if (f = f[libdir.length+1..-1]) == nil

26 +

next if (/CVS$/ =~ File.dirname(f))

27 +

path.push f

28 +

dir |= [File.dirname(f)]

29 +

end

30 +

for f in dir

31 +

next if f == "."

32 +

next if f == "CVS"

33 +

File::makedirs(File.join($site_libdir, f))

34 +

end

35 +

for f in path

36 +

File::install(File.join("lib", f), File.join($site_libdir, f), 0644, true)

37 +

end

38 +

end

39 + 40 +

install_rb

Original file line number Diff line number Diff line change

@@ -0,0 +1,72 @@

1 +

module Kernel

2 +

def require_gem(gem, version_requirement="> 0.0.0")

3 +

unless gem.respond_to?(:name) && gem.respond_to?(:version_requirement)

4 +

gem = Gem::Dependency.new(gem, version_requirement)

5 +

end

6 + 7 +

error_message = "\nCould not find RubyGem #{gem.name}\n"

8 + 9 +

Gem.specifications.each do |spec|

10 +

next unless spec.name == gem.name

11 + 12 +

if gem.version_requirement.satisfied_by?(spec.version)

13 + 14 +

return false if spec.loaded?

15 + 16 +

spec.loaded = true

17 +

spec.require_paths.each do |path|

18 +

$:.unshift File.join(Gem.dir, spec.full_name, path)

19 +

end

20 + 21 +

# Load dependent gems first

22 +

spec.dependencies.each do |dep_gem|

23 +

require_gem(dep_gem)

24 +

end

25 + 26 +

require spec.autorequire if spec.autorequire

27 + 28 +

return true

29 +

else

30 +

error_message = "\nRubyGem version error: #{gem.name}(#{spec.version} not #{gem.version_requirement.version})\n"

31 +

end

32 +

end

33 + 34 +

raise LoadError.new(error_message)

35 +

end

36 +

end

37 + 38 +

module Gem

39 +

RubyGemsVersion = "1.0"

40 + 41 +

@@specification_list = []

42 + 43 +

def self.specifications

44 +

return @@specification_list if @@specification_list.size > 0

45 +

require 'yaml'

46 +

Dir[File.join("#{Gem.dir}","specifications","*.gemspec")].each do |specfile|

47 +

@@specification_list << YAML.load(File.read(specfile))

48 +

end

49 +

@@specification_list

50 +

end

51 + 52 +

def self.dir

53 +

require 'rbconfig'

54 +

dir = File.join(Config::CONFIG['libdir'], 'ruby', 'gems', Config::CONFIG['ruby_version'])

55 +

unless File.exist?(File.join(dir, 'specifications'))

56 +

require 'fileutils'

57 +

FileUtils.mkdir_p(File.join(dir, 'specifications'))

58 +

end

59 +

unless File.exist?(File.join(dir, 'cache'))

60 +

require 'fileutils'

61 +

FileUtils.mkdir_p(File.join(dir, 'cache'))

62 +

end

63 +

dir

64 +

end

65 +

end

66 + 67 +

require 'rubygems/cache'

68 +

require 'rubygems/builder'

69 +

require 'rubygems/installer'

70 +

require 'rubygems/specification'

71 +

require 'rubygems/version'

72 +

require 'rubygems/remote_installer'

Original file line number Diff line number Diff line change

@@ -0,0 +1,57 @@

1 +

module Gem

2 + 3 +

class Builder

4 +

def initialize(spec)

5 +

@spec = spec

6 +

end

7 + 8 +

def build

9 +

require 'yaml'

10 +

File.open(@spec.full_name+".gem", "w") do |file|

11 +

ruby_header(file)

12 +

file.puts @spec.to_yaml

13 +

write_files_to(file)

14 +

puts "Successfully built RubyGem\n Name: #{@spec.name}\n Version: #{@spec.version}\n File: #{@spec.full_name+'.gem'}"

15 +

end

16 +

end

17 + 18 +

def write_files_to(file)

19 +

require 'zlib'

20 +

file_header = []

21 +

@spec.files.each do |file_name|

22 +

next if File.directory? file_name

23 +

file_header << { "path" => file_name,

24 +

"size" => File.size(file_name),

25 +

"mode" => File.stat(file_name).mode & 0777

26 +

}

27 +

end

28 +

file.puts file_header.to_yaml

29 +

file_header.each do |entry|

30 +

data = [Zlib::Deflate.deflate(File.read(entry['path']))].pack("m")

31 +

file.puts "---"

32 +

file.puts data

33 +

end

34 +

end

35 + 36 +

def ruby_header(file)

37 +

file.puts <<-EOS

38 +

if $0 == __FILE__

39 +

require 'getoptlong'

40 +

require 'rubygems'

41 + 42 +

opts = GetoptLong.new([ '--force', '-f', GetoptLong::NO_ARGUMENT ])

43 +

@force = false

44 +

opts.each do |opt, arg|

45 +

case opt

46 +

when '--force'

47 +

@force = true

48 +

end

49 +

end

50 +

Gem::Installer.new(__FILE__).install(@force)

51 +

end

52 +

__END__

53 +

EOS

54 +

end

55 +

end

56 + 57 +

end

Original file line number Diff line number Diff line change

@@ -0,0 +1,34 @@

1 +

module Gem

2 + 3 +

class Cache

4 +

def initialize(specifications)

5 +

@gems = specifications

6 +

end

7 + 8 +

def self.from_installed_gems(source_dir = File.join(Gem.dir, "specifications"))

9 +

require 'yaml'

10 +

gems = {}

11 +

Dir[File.join(source_dir, "*")].each do |file_name|

12 +

gem = YAML.load(File.read(file_name))

13 +

key = File.basename(file_name).gsub(/\.gemspec/, "")

14 +

gems[key] = gem

15 +

end

16 +

self.new(gems)

17 +

end

18 + 19 +

def each(&block)

20 +

@gems.each(&block)

21 +

end

22 + 23 +

def search_by_name(gem_name)

24 +

result = []

25 +

@gems.each do |key, value|

26 +

if(key =~ /#{gem_name}/) then

27 +

result << value

28 +

end

29 +

end

30 +

result

31 +

end

32 +

end

33 + 34 +

end

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4