libgems 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -98,7 +98,7 @@ require 'thread'
98
98
  module LibGems
99
99
  NAME = 'LibGems'
100
100
  GEM_NAME = 'libgems'
101
- VERSION = '0.0.1'
101
+ VERSION = '0.0.2'
102
102
  GEM_VERSION = '1.3.8'
103
103
 
104
104
  ##
@@ -417,7 +417,7 @@ module LibGems
417
417
  # The standard configuration object for gems.
418
418
 
419
419
  def self.configuration
420
- @configuration ||= LibGems::ConfigFile.new []
420
+ @configuration || load_configuration
421
421
  end
422
422
 
423
423
  ##
@@ -425,7 +425,15 @@ module LibGems
425
425
  # protocol) as the standard configuration object.
426
426
 
427
427
  def self.configuration=(config)
428
- @configuration = config
428
+ load_configuration(config)
429
+ end
430
+
431
+ def self.load_configuration(config=nil)
432
+ @configuration = config || LibGems::ConfigFile.new([])
433
+ LibGems.use_paths(@configuration[:gemhome], @configuration[:gempath])
434
+ LibGems::Command.extra_args = @configuration[:gem]
435
+ LibGems::DocManager.configured_args = @configuration[:rdoc]
436
+ @configuration
429
437
  end
430
438
 
431
439
  ##
@@ -450,7 +458,6 @@ module LibGems
450
458
  # The path where gems are to be installed.
451
459
 
452
460
  def self.dir
453
- @gem_home ||= nil
454
461
  set_home(ENV['LIBGEMS_HOME'] || ENV['GEM_HOME'] || LibGems.configuration.home || default_dir) unless @gem_home
455
462
  @gem_home
456
463
  end
@@ -1149,6 +1156,8 @@ module LibGems
1149
1156
  autoload :Platform, 'libgems/platform'
1150
1157
  autoload :Builder, 'libgems/builder'
1151
1158
  autoload :ConfigFile, 'libgems/config_file'
1159
+ autoload :Command, 'libgems/command'
1160
+ autoload :DocManager, 'libgems/doc_manager'
1152
1161
  end
1153
1162
 
1154
1163
  module ::Kernel
@@ -1243,4 +1252,4 @@ class << LibGems
1243
1252
  end
1244
1253
 
1245
1254
  LibGems.clear_paths
1246
-
1255
+ LibGems.load_configuration
@@ -178,16 +178,7 @@ class LibGems::Installer
178
178
  FileUtils.cp @gem, File.join(@gem_home, "cache")
179
179
  end
180
180
 
181
- unless @spec.post_install_message.nil?
182
- # Only for SlimGems
183
- if @spec.name == LibGems::GEM_NAME
184
- lines = @spec.post_install_message.split("\n")
185
- lines.shift if lines.first.include?("Upgraded from #{LibGems::NAME}")
186
- say lines.join("\n")
187
- else
188
- say @spec.post_install_message
189
- end
190
- end
181
+ say @spec.post_install_message unless @spec.post_install_message.nil?
191
182
 
192
183
  @spec.loaded_from = File.join(@gem_home, 'specifications', @spec.spec_name)
193
184
 
@@ -703,11 +703,12 @@ class LibGems::Specification
703
703
  if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck? then
704
704
  super.gsub(/ !!null \n/, " \n")
705
705
  else
706
- YAML.quick_emit object_id, opts do |out|
706
+ ret = YAML.quick_emit object_id, opts do |out|
707
707
  out.map taguri, to_yaml_style do |map|
708
708
  encode_with map
709
709
  end
710
710
  end
711
+ ret.gsub("!ruby/object:LibGems", "!ruby/object:Gem")
711
712
  end
712
713
  end
713
714
 
@@ -734,7 +735,7 @@ class LibGems::Specification
734
735
  result = []
735
736
  result << "# -*- encoding: utf-8 -*-"
736
737
  result << nil
737
- result << "LibGems::Specification.new do |s|"
738
+ result << "Gem::Specification.new do |s|"
738
739
 
739
740
  result << " s.name = #{ruby_code name}"
740
741
  result << " s.version = #{ruby_code version}"
@@ -769,7 +770,7 @@ class LibGems::Specification
769
770
  result << " s.specification_version = #{specification_version}"
770
771
  result << nil
771
772
 
772
- result << " if LibGems::Version.new(LibGems::GEM_VERSION) >= LibGems::Version.new('1.2.0') then"
773
+ result << " if Gem::Version.new(Gem::GEM_VERSION) >= Gem::Version.new('1.2.0') then"
773
774
 
774
775
  unless dependencies.empty? then
775
776
  dependencies.each do |dep|
@@ -1041,13 +1042,13 @@ class LibGems::Specification
1041
1042
  case obj
1042
1043
  when String then '%q{' + obj + '}'
1043
1044
  when Array then obj.inspect
1044
- when LibGems::Version then obj.to_s.inspect
1045
+ when LibGems::Version then obj.to_s.inspect.gsub("LibGems", "Gem")
1045
1046
  when Date then '%q{' + obj.strftime('%Y-%m-%d') + '}'
1046
1047
  when Time then '%q{' + obj.strftime('%Y-%m-%d') + '}'
1047
1048
  when Numeric then obj.inspect
1048
1049
  when true, false, nil then obj.inspect
1049
- when LibGems::Platform then "LibGems::Platform.new(#{obj.to_a.inspect})"
1050
- when LibGems::Requirement then "LibGems::Requirement.new(#{obj.to_s.inspect})"
1050
+ when LibGems::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
1051
+ when LibGems::Requirement then "Gem::Requirement.new(#{obj.to_s.inspect})"
1051
1052
  else raise LibGems::Exception, "ruby_code case not handled: #{obj.class}"
1052
1053
  end
1053
1054
  end
@@ -135,6 +135,32 @@ class TestGem < RubyGemTestCase
135
135
  assert_equal expected, LibGems.configuration
136
136
  end
137
137
 
138
+ def test_do_configuration
139
+ LibGems.clear_paths
140
+
141
+ temp_conf = File.join @tempdir, '.gemrc'
142
+
143
+ other_gem_path = File.join @tempdir, 'other_gem_path'
144
+ other_gem_home = File.join @tempdir, 'other_gem_home'
145
+
146
+ LibGems.ensure_gem_subdirectories other_gem_path
147
+ LibGems.ensure_gem_subdirectories other_gem_home
148
+
149
+ File.open temp_conf, 'w' do |fp|
150
+ fp.puts "gem: --commands"
151
+ fp.puts "gemhome: #{other_gem_home}"
152
+ fp.puts "gempath:"
153
+ fp.puts " - #{other_gem_path}"
154
+ fp.puts "rdoc: --all"
155
+ end
156
+
157
+ LibGems.configuration = LibGems::ConfigFile.new %W[--config-file #{temp_conf}]
158
+
159
+ assert_equal [other_gem_path, other_gem_home], LibGems.path
160
+ assert_equal %w[--commands], LibGems::Command.extra_args
161
+ assert_equal %w[--all], LibGems::DocManager.configured_args
162
+ end
163
+
138
164
  def test_self_datadir
139
165
  foo = nil
140
166
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: libgems
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jim Weirich
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2011-06-08 00:00:00 Z
16
+ date: 2011-06-11 00:00:00 Z
17
17
  dependencies: []
18
18
 
19
19
  description: |
@@ -163,7 +163,6 @@ files:
163
163
  - lib/libgems/format.rb
164
164
  - lib/libgems/gem_openssl.rb
165
165
  - lib/libgems/gem_path_searcher.rb
166
- - lib/libgems/gem_runner.rb
167
166
  - lib/libgems/gemcutter_utilities.rb
168
167
  - lib/libgems/indexer.rb
169
168
  - lib/libgems/install_update_options.rb
@@ -256,7 +255,6 @@ files:
256
255
  - test/test_gem_ext_rake_builder.rb
257
256
  - test/test_gem_format.rb
258
257
  - test/test_gem_gem_path_searcher.rb
259
- - test/test_gem_gem_runner.rb
260
258
  - test/test_gem_gemcutter_utilities.rb
261
259
  - test/test_gem_indexer.rb
262
260
  - test/test_gem_install_update_options.rb
@@ -292,7 +290,7 @@ files:
292
290
  homepage: http://rubygems.org
293
291
  licenses: []
294
292
 
295
- post_install_message: "Upgraded from LibGems to LibGems 0.0.1\n\
293
+ post_install_message: "Upgraded from LibGems to LibGems 0.0.2\n\
296
294
  \xEF\xBB\xBF=== 1.3.8 / 2011-05-16\n\n\
297
295
  SlimGems is born! SlimGems is a fork of RubyGems, see README.md for more.\n\n"
298
296
  rdoc_options: []
@@ -372,7 +370,6 @@ test_files:
372
370
  - test/test_gem_ext_rake_builder.rb
373
371
  - test/test_gem_format.rb
374
372
  - test/test_gem_gem_path_searcher.rb
375
- - test/test_gem_gem_runner.rb
376
373
  - test/test_gem_gemcutter_utilities.rb
377
374
  - test/test_gem_indexer.rb
378
375
  - test/test_gem_install_update_options.rb
@@ -1,79 +0,0 @@
1
- #--
2
- # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3
- # All rights reserved.
4
- # See LICENSE.txt for permissions.
5
- #++
6
-
7
- require 'libgems/command_manager'
8
- require 'libgems/config_file'
9
- require 'libgems/doc_manager'
10
-
11
- ##
12
- # Run an instance of the gem program.
13
- #
14
- # LibGems::GemRunner is only intended for internal use by SlimGems itself. It
15
- # does not form any public API and may change at any time for any reason.
16
- #
17
- # If you would like to duplicate functionality of `gem` commands, use the
18
- # classes they call directly.
19
-
20
- class LibGems::GemRunner
21
-
22
- def initialize(options={})
23
- @command_manager_class = options[:command_manager] || LibGems::CommandManager
24
- @config_file_class = options[:config_file] || LibGems::ConfigFile
25
- @doc_manager_class = options[:doc_manager] || LibGems::DocManager
26
- end
27
-
28
- ##
29
- # Run the gem command with the following arguments.
30
-
31
- def run(args)
32
- start_time = Time.now
33
-
34
- if args.include?('--')
35
- # We need to preserve the original ARGV to use for passing gem options
36
- # to source gems. If there is a -- in the line, strip all options after
37
- # it...its for the source building process.
38
- build_args = args[args.index("--") + 1...args.length]
39
- args = args[0...args.index("--")]
40
- end
41
-
42
- LibGems::Command.build_args = build_args if build_args
43
-
44
- do_configuration args
45
- cmd = @command_manager_class.instance
46
-
47
- cmd.command_names.each do |command_name|
48
- config_args = LibGems.configuration[command_name]
49
- config_args = case config_args
50
- when String
51
- config_args.split ' '
52
- else
53
- Array(config_args)
54
- end
55
- LibGems::Command.add_specific_extra_args command_name, config_args
56
- end
57
-
58
- cmd.run LibGems.configuration.args
59
- end_time = Time.now
60
-
61
- if LibGems.configuration.benchmark then
62
- printf "\nExecution time: %0.2f seconds.\n", end_time - start_time
63
- puts "Press Enter to finish"
64
- STDIN.gets
65
- end
66
- end
67
-
68
- private
69
-
70
- def do_configuration(args)
71
- LibGems.configuration = @config_file_class.new(args)
72
- LibGems.use_paths(LibGems.configuration[:gemhome], LibGems.configuration[:gempath])
73
- LibGems::Command.extra_args = LibGems.configuration[:gem]
74
- @doc_manager_class.configured_args = LibGems.configuration[:rdoc]
75
- end
76
-
77
- end
78
-
79
- LibGems.load_plugins
@@ -1,45 +0,0 @@
1
- require File.expand_path('../gemutilities', __FILE__)
2
- require 'libgems/gem_runner'
3
-
4
- class TestGemGemRunner < RubyGemTestCase
5
-
6
- def test_do_configuration
7
- LibGems.clear_paths
8
-
9
- temp_conf = File.join @tempdir, '.gemrc'
10
-
11
- other_gem_path = File.join @tempdir, 'other_gem_path'
12
- other_gem_home = File.join @tempdir, 'other_gem_home'
13
-
14
- LibGems.ensure_gem_subdirectories other_gem_path
15
- LibGems.ensure_gem_subdirectories other_gem_home
16
-
17
- File.open temp_conf, 'w' do |fp|
18
- fp.puts "gem: --commands"
19
- fp.puts "gemhome: #{other_gem_home}"
20
- fp.puts "gempath:"
21
- fp.puts " - #{other_gem_path}"
22
- fp.puts "rdoc: --all"
23
- end
24
-
25
- gr = LibGems::GemRunner.new
26
- gr.send :do_configuration, %W[--config-file #{temp_conf}]
27
-
28
- assert_equal [other_gem_path, other_gem_home], LibGems.path
29
- assert_equal %w[--commands], LibGems::Command.extra_args
30
- assert_equal %w[--all], LibGems::DocManager.configured_args
31
- end
32
-
33
- def test_build_args__are_handled
34
- LibGems.clear_paths
35
-
36
- gr = LibGems::GemRunner.new
37
- assert_raises(LibGems::SystemExitException) do
38
- gr.run(%W[--help -- --build_arg1 --build_arg2])
39
- end
40
-
41
- assert_equal %w[--build_arg1 --build_arg2], LibGems::Command.build_args
42
- end
43
-
44
- end
45
-