libgems 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +14 -1
- data/lib/libgems.rb +19 -6
- data/lib/libgems/commands/fetch_command.rb +19 -5
- data/lib/libgems/commands/update_command.rb +3 -1
- data/lib/libgems/dependency_list.rb +1 -1
- data/lib/libgems/installer.rb +30 -0
- data/lib/libgems/requirement.rb +26 -0
- data/test/simple_gem.rb +7 -7
- data/test/test_gem_commands_fetch_command.rb +24 -0
- data/test/test_gem_commands_update_command.rb +25 -2
- data/test/test_gem_installer.rb +57 -2
- data/test/test_gem_silent_ui.rb +3 -4
- metadata +2 -3
- data/blah.rb +0 -5
data/History.txt
CHANGED
@@ -1,4 +1,17 @@
|
|
1
|
-
=== 1.3.
|
1
|
+
=== 1.3.9.1 / 2011-06-03
|
2
|
+
|
3
|
+
SlimGems is a drop-in replacement for RubyGems. See README.md for more.
|
4
|
+
|
5
|
+
* Fixes slimgems getting uninstalled when `gem uninstall GEM` is called.
|
6
|
+
|
7
|
+
=== 1.3.9 / 2011-06-02
|
8
|
+
|
9
|
+
SlimGems is reborn! SlimGems is a fork of RubyGems, see README.md for more.
|
10
|
+
|
11
|
+
This release fixes some minor issues in installing SlimGems in certain
|
12
|
+
environments.
|
13
|
+
|
14
|
+
=== 1.3.8 / 2011-06-01
|
2
15
|
|
3
16
|
SlimGems is born! SlimGems is a fork of RubyGems, see README.md for more.
|
4
17
|
|
data/lib/libgems.rb
CHANGED
@@ -98,8 +98,8 @@ require 'thread'
|
|
98
98
|
module LibGems
|
99
99
|
NAME = 'LibGems'
|
100
100
|
GEM_NAME = 'libgems'
|
101
|
-
VERSION = '1.3.
|
102
|
-
LIBGEMS_VERSION = '0.0
|
101
|
+
VERSION = '1.3.9.2'
|
102
|
+
LIBGEMS_VERSION = '0.1.0'
|
103
103
|
|
104
104
|
##
|
105
105
|
# Raised when SlimGems is unable to load or activate a gem. Contains the
|
@@ -662,10 +662,23 @@ module LibGems
|
|
662
662
|
# Loads YAML, preferring Psych
|
663
663
|
|
664
664
|
def self.load_yaml
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
665
|
+
begin
|
666
|
+
require 'psych' unless ENV['TEST_SYCK']
|
667
|
+
rescue ::LoadError
|
668
|
+
ensure
|
669
|
+
require 'yaml'
|
670
|
+
end
|
671
|
+
|
672
|
+
# Hack to handle syck's DefaultKey bug with psych.
|
673
|
+
# See the note at the top of lib/rubygems/requirement.rb for
|
674
|
+
# why we end up defining DefaultKey more than once.
|
675
|
+
if !defined? YAML::Syck
|
676
|
+
YAML.module_eval do
|
677
|
+
const_set 'Syck', Module.new {
|
678
|
+
const_set 'DefaultKey', Class.new
|
679
|
+
}
|
680
|
+
end
|
681
|
+
end
|
669
682
|
end
|
670
683
|
|
671
684
|
##
|
@@ -36,18 +36,32 @@ class LibGems::Commands::FetchCommand < LibGems::Command
|
|
36
36
|
version = options[:version] || LibGems::Requirement.default
|
37
37
|
all = LibGems::Requirement.default != version
|
38
38
|
|
39
|
+
platform = LibGems.platforms.last
|
39
40
|
gem_names = get_all_gem_names
|
40
41
|
|
41
42
|
gem_names.each do |gem_name|
|
42
43
|
dep = LibGems::Dependency.new gem_name, version
|
43
44
|
dep.prerelease = options[:prerelease]
|
44
45
|
|
45
|
-
|
46
|
-
|
46
|
+
# Because of the madness that is SpecFetcher, you can't
|
47
|
+
# set both all and prerelease to true. If you do, prerelease
|
48
|
+
# is ignored.
|
49
|
+
|
50
|
+
if dep.prerelease? and all
|
51
|
+
specs_and_sources, errors =
|
52
|
+
LibGems::SpecFetcher.fetcher.fetch_with_errors(dep, false, true,
|
53
|
+
dep.prerelease?)
|
54
|
+
else
|
55
|
+
specs_and_sources, errors =
|
56
|
+
LibGems::SpecFetcher.fetcher.fetch_with_errors(dep, all, true,
|
57
|
+
dep.prerelease?)
|
58
|
+
end
|
59
|
+
|
47
60
|
|
48
|
-
|
49
|
-
|
50
|
-
|
61
|
+
if platform then
|
62
|
+
filtered = specs_and_sources.select { |s,| s.platform == platform }
|
63
|
+
specs_and_sources = filtered unless filtered.empty?
|
64
|
+
end
|
51
65
|
|
52
66
|
spec, source_uri = specs_and_sources.sort_by { |s,| s.version }.last
|
53
67
|
|
@@ -121,10 +121,12 @@ class LibGems::Commands::UpdateCommand < LibGems::Command
|
|
121
121
|
gem_names.all? { |name| /#{name}/ !~ l_spec.name }
|
122
122
|
|
123
123
|
dependency = LibGems::Dependency.new l_spec.name, "> #{l_spec.version}"
|
124
|
+
dependency.prerelease = options[:prerelease]
|
124
125
|
|
125
126
|
begin
|
126
127
|
fetcher = LibGems::SpecFetcher.fetcher
|
127
|
-
spec_tuples = fetcher.find_matching dependency
|
128
|
+
spec_tuples = fetcher.find_matching dependency, false, true,
|
129
|
+
options[:prerelease]
|
128
130
|
rescue LibGems::RemoteFetcher::FetchError => e
|
129
131
|
raise unless fetcher.warn_legacy e do
|
130
132
|
require 'libgems/source_info_cache'
|
data/lib/libgems/installer.rb
CHANGED
@@ -338,6 +338,17 @@ class LibGems::Installer
|
|
338
338
|
##
|
339
339
|
# Generates a #! line for +bin_file_name+'s wrapper copying arguments if
|
340
340
|
# necessary.
|
341
|
+
#
|
342
|
+
# If the :custom_shebang config is set, then it is used as a template
|
343
|
+
# for how to create the shebang used for to run a gem's executables.
|
344
|
+
#
|
345
|
+
# The template supports 4 expansions:
|
346
|
+
#
|
347
|
+
# $env the path to the unix env utility
|
348
|
+
# $ruby the path to the currently running ruby interpreter
|
349
|
+
# $exec the path to the gem's executable
|
350
|
+
# $name the name of the gem the executable is for
|
351
|
+
#
|
341
352
|
|
342
353
|
def shebang(bin_file_name)
|
343
354
|
ruby_name = LibGems::ConfigMap[:ruby_install_name] if @env_shebang
|
@@ -351,6 +362,25 @@ class LibGems::Installer
|
|
351
362
|
shebang.strip! # Avoid nasty ^M issues.
|
352
363
|
end
|
353
364
|
|
365
|
+
if which = LibGems.configuration[:custom_shebang]
|
366
|
+
which = which.gsub(/\$(\w+)/) do
|
367
|
+
case $1
|
368
|
+
when "env"
|
369
|
+
@env_path ||= ENV_PATHS.find do |env_path|
|
370
|
+
File.executable? env_path
|
371
|
+
end
|
372
|
+
when "ruby"
|
373
|
+
"#{LibGems.ruby}#{opts}"
|
374
|
+
when "exec"
|
375
|
+
bin_file_name
|
376
|
+
when "name"
|
377
|
+
spec.name
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
return "#!#{which}"
|
382
|
+
end
|
383
|
+
|
354
384
|
if not ruby_name then
|
355
385
|
"#!#{LibGems.ruby}#{opts}"
|
356
386
|
elsif opts then
|
data/lib/libgems/requirement.rb
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
require "libgems/version"
|
2
2
|
|
3
|
+
# Hack to handle syck's DefaultKey bug with psych
|
4
|
+
#
|
5
|
+
# Quick note! If/when psych loads in 1.9, it will redefine
|
6
|
+
# YAML to point to Psych by removing the YAML constant.
|
7
|
+
# Thusly, over in LibGems.load_yaml, we define DefaultKey again
|
8
|
+
# after proper yaml library has been loaded.
|
9
|
+
#
|
10
|
+
# All this is so that there is always a YAML::Syck::DefaultKey
|
11
|
+
# class no matter if the full yaml library has loaded or not.
|
12
|
+
#
|
13
|
+
module YAML
|
14
|
+
if !defined? Syck
|
15
|
+
module Syck
|
16
|
+
class DefaultKey
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
3
22
|
##
|
4
23
|
# A Requirement is a set of one or more version restrictions. It supports a
|
5
24
|
# few (<tt>=, !=, >, <, >=, <=, ~></tt>) different restriction operators.
|
@@ -115,6 +134,13 @@ class LibGems::Requirement
|
|
115
134
|
|
116
135
|
def marshal_load array # :nodoc:
|
117
136
|
@requirements = array[0]
|
137
|
+
|
138
|
+
# Fixup the Syck DefaultKey bug
|
139
|
+
@requirements.each do |r|
|
140
|
+
if r[0].kind_of? YAML::Syck::DefaultKey
|
141
|
+
r[0] = "="
|
142
|
+
end
|
143
|
+
end
|
118
144
|
end
|
119
145
|
|
120
146
|
def prerelease?
|
data/test/simple_gem.rb
CHANGED
@@ -6,19 +6,19 @@ SIMPLE_GEM = <<-GEMDATA
|
|
6
6
|
options = {}
|
7
7
|
ARGV.options do |opts|
|
8
8
|
opts.on_tail("--help", "show this message") {puts opts; exit}
|
9
|
-
opts.on('--dir=DIRNAME', "Installation directory for the
|
10
|
-
opts.on('--force', "Force
|
11
|
-
opts.on('--gen-rdoc', "Generate RDoc documentation for the
|
9
|
+
opts.on('--dir=DIRNAME', "Installation directory for the Gem") {|options[:directory]|}
|
10
|
+
opts.on('--force', "Force Gem to intall, bypassing dependency checks") {|options[:force]|}
|
11
|
+
opts.on('--gen-rdoc', "Generate RDoc documentation for the Gem") {|options[:gen_rdoc]|}
|
12
12
|
opts.parse!
|
13
13
|
end
|
14
14
|
|
15
|
-
require '
|
16
|
-
@directory = options[:directory] ||
|
15
|
+
require 'rubygems'
|
16
|
+
@directory = options[:directory] || Gem.dir
|
17
17
|
@force = options[:force]
|
18
18
|
|
19
|
-
gem =
|
19
|
+
gem = Gem::Installer.new(__FILE__).install(@force, @directory)
|
20
20
|
if options[:gen_rdoc]
|
21
|
-
|
21
|
+
Gem::DocManager.new(gem).generate_rdoc
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -52,6 +52,30 @@ class TestGemCommandsFetchCommand < RubyGemTestCase
|
|
52
52
|
"#{@a2_pre.full_name} not fetched"
|
53
53
|
end
|
54
54
|
|
55
|
+
def test_execute_specific_prerelease
|
56
|
+
util_setup_fake_fetcher true
|
57
|
+
util_clear_gems
|
58
|
+
util_setup_spec_fetcher @a2, @a2_pre
|
59
|
+
|
60
|
+
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
61
|
+
File.read(File.join(@gemhome, 'cache', @a2.file_name))
|
62
|
+
@fetcher.data["#{@gem_repo}gems/#{@a2_pre.file_name}"] =
|
63
|
+
File.read(File.join(@gemhome, 'cache', @a2_pre.file_name))
|
64
|
+
|
65
|
+
@cmd.options[:args] = [@a2.name]
|
66
|
+
@cmd.options[:prerelease] = true
|
67
|
+
@cmd.options[:version] = "2.a"
|
68
|
+
|
69
|
+
use_ui @ui do
|
70
|
+
Dir.chdir @tempdir do
|
71
|
+
@cmd.execute
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
assert File.exist?(File.join(@tempdir, @a2_pre.file_name)),
|
76
|
+
"#{@a2_pre.full_name} not fetched"
|
77
|
+
end
|
78
|
+
|
55
79
|
def test_execute_version
|
56
80
|
util_setup_fake_fetcher
|
57
81
|
util_setup_spec_fetcher @a1, @a2
|
@@ -15,16 +15,18 @@ class TestGemCommandsUpdateCommand < RubyGemTestCase
|
|
15
15
|
@cmd.options[:generate_ri] = false
|
16
16
|
|
17
17
|
util_setup_fake_fetcher
|
18
|
+
util_setup_spec_fetcher @a1, @a2, @a3a
|
18
19
|
|
19
20
|
@a1_path = File.join @gemhome, 'cache', @a1.file_name
|
20
21
|
@a2_path = File.join @gemhome, 'cache', @a2.file_name
|
21
|
-
|
22
|
-
util_setup_spec_fetcher @a1, @a2
|
22
|
+
@a3a_path = File.join @gemhome, 'cache', @a3a.file_name
|
23
23
|
|
24
24
|
@fetcher.data["#{@gem_repo}gems/#{@a1.file_name}"] =
|
25
25
|
read_binary @a1_path
|
26
26
|
@fetcher.data["#{@gem_repo}gems/#{@a2.file_name}"] =
|
27
27
|
read_binary @a2_path
|
28
|
+
@fetcher.data["#{@gem_repo}gems/#{@a3a.file_name}"] =
|
29
|
+
read_binary @a3a_path
|
28
30
|
end
|
29
31
|
|
30
32
|
def teardown
|
@@ -186,6 +188,27 @@ class TestGemCommandsUpdateCommand < RubyGemTestCase
|
|
186
188
|
assert_empty out
|
187
189
|
end
|
188
190
|
|
191
|
+
def test_execute_named_up_to_date_prerelease
|
192
|
+
util_clear_gems
|
193
|
+
|
194
|
+
LibGems::Installer.new(@a2_path).install
|
195
|
+
|
196
|
+
@cmd.options[:args] = [@a2.name]
|
197
|
+
@cmd.options[:prerelease] = true
|
198
|
+
|
199
|
+
use_ui @ui do
|
200
|
+
@cmd.execute
|
201
|
+
end
|
202
|
+
|
203
|
+
out = @ui.output.split "\n"
|
204
|
+
assert_equal "Updating installed gems", out.shift
|
205
|
+
assert_equal "Updating #{@a3a.name}", out.shift
|
206
|
+
assert_equal "Successfully installed #{@a3a.full_name}", out.shift
|
207
|
+
assert_equal "Gems updated: #{@a3a.name}", out.shift
|
208
|
+
|
209
|
+
assert_empty out
|
210
|
+
end
|
211
|
+
|
189
212
|
def test_execute_up_to_date
|
190
213
|
util_clear_gems
|
191
214
|
|
data/test/test_gem_installer.rb
CHANGED
@@ -1,6 +1,31 @@
|
|
1
1
|
require File.expand_path('../gem_installer_test_case', __FILE__)
|
2
2
|
|
3
3
|
class TestGemInstaller < LibGemsInstallerTestCase
|
4
|
+
|
5
|
+
class StubbedConfigFile < LibGems::ConfigFile
|
6
|
+
def load_file(filename) {} end
|
7
|
+
end
|
8
|
+
|
9
|
+
def setup
|
10
|
+
super
|
11
|
+
if !defined?(@@test_num)
|
12
|
+
@@test_num = 0
|
13
|
+
@@total_tests = self.class.test_methods.size
|
14
|
+
@@config = LibGems.configuration
|
15
|
+
end
|
16
|
+
LibGems.configuration = StubbedConfigFile.new([])
|
17
|
+
LibGems.send(:set_home, @gemhome) # Config clears this
|
18
|
+
end
|
19
|
+
|
20
|
+
def run(runner)
|
21
|
+
result = super
|
22
|
+
ensure
|
23
|
+
@@test_num += 1
|
24
|
+
if @@test_num == @@total_tests
|
25
|
+
LibGems.configuration = @@config
|
26
|
+
end
|
27
|
+
result
|
28
|
+
end
|
4
29
|
|
5
30
|
def test_app_script_text
|
6
31
|
util_make_exec '2', ''
|
@@ -527,7 +552,7 @@ load LibGems.bin_path('a', 'my_exec', version)
|
|
527
552
|
end
|
528
553
|
|
529
554
|
LibGems.post_install do |installer|
|
530
|
-
assert File.exist?(cache_file),
|
555
|
+
assert File.exist?(cache_file), "cache file should exist: #{cache_file}"
|
531
556
|
end
|
532
557
|
|
533
558
|
build_rake_in do
|
@@ -640,7 +665,7 @@ load LibGems.bin_path('a', 'my_exec', version)
|
|
640
665
|
assert File.exist?(gemdir)
|
641
666
|
|
642
667
|
exe = File.join(gemdir, 'bin', 'executable')
|
643
|
-
assert File.exist?(exe)
|
668
|
+
assert File.exist?(exe), "#{exe} should exist"
|
644
669
|
exe_mode = File.stat(exe).mode & 0111
|
645
670
|
assert_equal 0111, exe_mode, "0%o" % exe_mode unless win_platform?
|
646
671
|
assert File.exist?(File.join(gemdir, 'lib', 'code.rb'))
|
@@ -817,6 +842,36 @@ load LibGems.bin_path('a', 'my_exec', version)
|
|
817
842
|
assert_equal "#!#{LibGems.ruby} -ws", shebang
|
818
843
|
end
|
819
844
|
|
845
|
+
def test_shebang_custom
|
846
|
+
LibGems.configuration[:custom_shebang] = 'test'
|
847
|
+
|
848
|
+
util_make_exec '2', "#!/usr/bin/ruby"
|
849
|
+
|
850
|
+
shebang = @installer.shebang 'my_exec'
|
851
|
+
|
852
|
+
assert_equal "#!test", shebang
|
853
|
+
end
|
854
|
+
|
855
|
+
def test_shebang_custom_with_expands
|
856
|
+
LibGems.configuration[:custom_shebang] = '1 $env 2 $ruby 3 $exec 4 $name'
|
857
|
+
|
858
|
+
util_make_exec '2', "#!/usr/bin/ruby"
|
859
|
+
|
860
|
+
shebang = @installer.shebang 'my_exec'
|
861
|
+
|
862
|
+
assert_equal "#!1 /usr/bin/env 2 #{LibGems.ruby} 3 my_exec 4 a", shebang
|
863
|
+
end
|
864
|
+
|
865
|
+
def test_shebang_custom_with_expands_and_arguments
|
866
|
+
LibGems.configuration[:custom_shebang] = '1 $env 2 $ruby 3 $exec'
|
867
|
+
|
868
|
+
util_make_exec '2', "#!/usr/bin/ruby -ws"
|
869
|
+
|
870
|
+
shebang = @installer.shebang 'my_exec'
|
871
|
+
|
872
|
+
assert_equal "#!1 /usr/bin/env 2 #{LibGems.ruby} -ws 3 my_exec", shebang
|
873
|
+
end
|
874
|
+
|
820
875
|
def test_unpack
|
821
876
|
util_setup_gem
|
822
877
|
|
data/test/test_gem_silent_ui.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
require 'rubygems/test_case' # Looks like it's defined somewhere else
|
2
1
|
require 'libgems/user_interaction'
|
3
2
|
require 'timeout'
|
4
3
|
|
5
|
-
class TestGemSilentUI <
|
4
|
+
class TestGemSilentUI < RubyGemTestCase
|
6
5
|
|
7
6
|
def setup
|
8
7
|
super
|
@@ -49,7 +48,7 @@ class TestGemSilentUI < Gem::TestCase
|
|
49
48
|
|
50
49
|
assert_empty out, 'No output'
|
51
50
|
assert_empty err, 'No output'
|
52
|
-
|
51
|
+
|
53
52
|
out, err = capture_io do
|
54
53
|
use_ui @sui do
|
55
54
|
value = @sui.ask_yes_no 'Problem?', true
|
@@ -60,7 +59,7 @@ class TestGemSilentUI < Gem::TestCase
|
|
60
59
|
assert_empty err, 'No output'
|
61
60
|
|
62
61
|
assert value, 'Value is true'
|
63
|
-
|
62
|
+
|
64
63
|
out, err = capture_io do
|
65
64
|
use_ui @sui do
|
66
65
|
value = @sui.ask_yes_no 'Problem?', false
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libgems
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2011-
|
15
|
+
date: 2011-08-10 00:00:00.000000000Z
|
16
16
|
dependencies: []
|
17
17
|
description: ! "# SlimGems\n\n* Website: http://slimgems.github.com/\n* Github: http://github.com/slimgems/slimgems\n*
|
18
18
|
Get gems from: http://rubygems.org\n\n## Description\n\nSlimGems is a drop-in replacement
|
@@ -229,7 +229,6 @@ files:
|
|
229
229
|
- test/test_kernel.rb
|
230
230
|
- History.txt
|
231
231
|
- LICENSE.txt
|
232
|
-
- blah.rb
|
233
232
|
- README.md
|
234
233
|
- Rakefile
|
235
234
|
- ChangeLog
|