alloy-microgem 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. data/LICENSE +21 -0
  2. data/README.rdoc +55 -0
  3. data/Rakefile +24 -0
  4. data/TODO +13 -0
  5. data/bin/zinflate +17 -0
  6. data/bin//302/265gem +14 -0
  7. data/lib/microgem.rb +56 -0
  8. data/lib/microgem/bare_specification.rb +40 -0
  9. data/lib/microgem/bin_wrapper_emitter.rb +58 -0
  10. data/lib/microgem/config.rb +96 -0
  11. data/lib/microgem/dependency.rb +37 -0
  12. data/lib/microgem/downloader.rb +48 -0
  13. data/lib/microgem/installer.rb +147 -0
  14. data/lib/microgem/options_parser.rb +67 -0
  15. data/lib/microgem/requirement.rb +36 -0
  16. data/lib/microgem/source.rb +108 -0
  17. data/lib/microgem/specification.rb +65 -0
  18. data/lib/microgem/specification_emitter.rb +75 -0
  19. data/lib/microgem/unpacker.rb +55 -0
  20. data/lib/microgem/utils.rb +51 -0
  21. data/lib/microgem/version.rb +35 -0
  22. data/lib/microgem/yamlable.rb +32 -0
  23. data/test/bare_specification_test.rb +43 -0
  24. data/test/bin_wrapper_emitter_test.rb +57 -0
  25. data/test/config_test.rb +131 -0
  26. data/test/dependency_test.rb +41 -0
  27. data/test/downloader_test.rb +100 -0
  28. data/test/fixtures/gems.github.com +0 -0
  29. data/test/fixtures/gems.rubyforge.org +0 -0
  30. data/test/fixtures/gems/rake-0.8.0/rake.rb +1 -0
  31. data/test/fixtures/gems/rake-0.8.1/rake.rb +1 -0
  32. data/test/fixtures/gems/test-spec-0.3.0/test-spec.rb +1 -0
  33. data/test/fixtures/gems/test-spec-mock-0.3.0/test-spec-mock.rb +1 -0
  34. data/test/fixtures/rails-2.1.1.gemspec +26 -0
  35. data/test/fixtures/rails-2.1.1.gemspec.marshal +0 -0
  36. data/test/fixtures/rake-0.8.1.gem +0 -0
  37. data/test/fixtures/rake-0.8.1.gemspec +20 -0
  38. data/test/fixtures/rake-0.8.1.gemspec.marshal +0 -0
  39. data/test/fixtures/rake-0.8.1.gemspec.rz +2 -0
  40. data/test/fixtures/specs.4.8.gz +0 -0
  41. data/test/installer_test.rb +198 -0
  42. data/test/microgem_test.rb +34 -0
  43. data/test/options_parser_test.rb +36 -0
  44. data/test/requirement_test.rb +40 -0
  45. data/test/source_test.rb +153 -0
  46. data/test/specification_emitter_test.rb +139 -0
  47. data/test/specification_test.rb +45 -0
  48. data/test/test_helper.rb +71 -0
  49. data/test/unpacker_test.rb +91 -0
  50. data/test/utils_test.rb +42 -0
  51. data/test/version_test.rb +27 -0
  52. data/test/yamlable_test.rb +15 -0
  53. metadata +114 -0
@@ -0,0 +1,91 @@
1
+ ##!/usr/bin/env macruby
2
+
3
+ require File.expand_path('../test_helper', __FILE__)
4
+
5
+ describe "Unpacker, in simple mode" do
6
+ include Gem::Micro::Utils
7
+
8
+ def setup
9
+ config.stubs(:simple_unpacker?).returns(true)
10
+ end
11
+
12
+ def teardown
13
+ remove_microgem_tmpdir!
14
+ end
15
+
16
+ it "should unpack a file using tar _without_ gzip decompression" do
17
+ path = File.join(tmpdir, 'rake-0.8.1')
18
+ Gem::Micro::Unpacker.tar(fixture('rake-0.8.1.gem'), path, false)
19
+ File.should.exist File.join(path, 'data.tar.gz')
20
+ end
21
+
22
+ it "should unpack a file using tar _with_ gzip decompression" do
23
+ path = File.join(tmpdir, 'rake-0.8.1')
24
+ Gem::Micro::Unpacker.tar(fixture('rake-0.8.1.gem'), path, false)
25
+
26
+ archive = File.join(path, 'data.tar.gz')
27
+ path = File.join(path, 'data')
28
+ Gem::Micro::Unpacker.tar(archive, path, true)
29
+ File.should.exist File.join(path, 'README')
30
+ end
31
+
32
+ it "should raise an UnpackError if tar failed to extract an archive" do
33
+ lambda do
34
+ Gem::Micro::Unpacker.tar('/does/not/exist/rake-0.8.1.gem', tmpdir, false)
35
+ end.should.raise Gem::Micro::Unpacker::UnpackError
36
+ end
37
+
38
+ it "should force unpack a file using gunzip" do
39
+ dir = File.join(tmpdir, 'specs')
40
+ ensure_dir(dir)
41
+ FileUtils.cp(fixture('specs.4.8.gz'), dir)
42
+
43
+ Gem::Micro::Unpacker.gzip(File.join(dir, 'specs.4.8.gz'))
44
+ File.should.exist File.join(dir, 'specs.4.8')
45
+ Marshal.load(File.read(File.join(dir, 'specs.4.8'))).should.be.instance_of Array
46
+
47
+ # try again to make sure we are forcing
48
+ FileUtils.cp(fixture('specs.4.8.gz'), dir)
49
+ Gem::Micro::Unpacker.gzip(File.join(dir, 'specs.4.8.gz'))
50
+ end
51
+
52
+ it "should raise an UnpackError if gunzip failed to extract an archive" do
53
+ lambda do
54
+ Gem::Micro::Unpacker.gzip('/does/not/exist/specs.4.8.gz')
55
+ end.should.raise Gem::Micro::Unpacker::UnpackError
56
+ end
57
+
58
+ it "should unpack a Z archive using bin/zinflate" do
59
+ zinflate = File.expand_path('../../bin/zinflate', __FILE__)
60
+ archive = fixture('rake-0.8.1.gemspec.rz')
61
+ out_file = File.join(tmpdir, 'marshalled_gemspec')
62
+
63
+ Gem::Micro::Unpacker.expects(:inflate_with_zlib).never
64
+ Gem::Micro::Unpacker.inflate(archive, out_file)
65
+ Marshal.load(File.read(out_file)).should.be.instance_of Gem::Specification
66
+ end
67
+
68
+ it "should raise an UnpackError if zinflate failed to extract an archive" do
69
+ lambda do
70
+ Gem::Micro::Unpacker.inflate('/does/not/exist/rake-0.8.1.gemspec.rz', '/tmp')
71
+ end.should.raise Gem::Micro::Unpacker::UnpackError
72
+ end
73
+ end
74
+
75
+ describe "Unpacker, in complex mode" do
76
+ include Gem::Micro::Utils
77
+
78
+ def setup
79
+ config.stubs(:simple_unpacker?).returns(false)
80
+ end
81
+
82
+ def teardown
83
+ remove_microgem_tmpdir!
84
+ end
85
+
86
+ it "should inflate a Z archive using Ruby's Zlib" do
87
+ out_file = File.join(tmpdir, 'marshalled_gemspec')
88
+ Gem::Micro::Unpacker.inflate(fixture('rake-0.8.1.gemspec.rz'), out_file)
89
+ Marshal.load(File.read(out_file)).should.be.instance_of Gem::Specification
90
+ end
91
+ end
@@ -0,0 +1,42 @@
1
+ ##!/usr/bin/env macruby
2
+
3
+ require File.expand_path('../test_helper', __FILE__)
4
+
5
+ describe "Gem::Micro::Utils" do
6
+ include Gem::Micro::Utils
7
+
8
+ def teardown
9
+ remove_microgem_tmpdir!
10
+ end
11
+
12
+ it "should ensure a directory exists and return it" do
13
+ dir = File.join(Dir.tmpdir, 'nice', 'and', 'deep')
14
+ ensure_dir(dir).should == dir
15
+ File.should.exist dir
16
+ end
17
+
18
+ it "should remove an existing directory (or file) before moving a new directory to the location" do
19
+ old_dir = File.join(Dir.tmpdir, 'existing_directory')
20
+ new_dir = File.join(Dir.tmpdir, 'new_directory')
21
+ ensure_dir(old_dir)
22
+ ensure_dir(new_dir)
23
+
24
+ file_in_old_dir = File.join(old_dir, 'file')
25
+ File.open(file_in_old_dir, 'w') { |f| f << 'foo' }
26
+
27
+ replace(new_dir, old_dir)
28
+ File.should.exist old_dir
29
+ File.should.not.exist file_in_old_dir
30
+ end
31
+
32
+ it "should create a temporary directory if it doesn't exist and return it" do
33
+ expected_path = File.join(Dir.tmpdir, 'microgem')
34
+
35
+ tmpdir.should == expected_path
36
+ File.should.exist expected_path
37
+ end
38
+
39
+ it "should return Gem::Micro::Config.instance" do
40
+ config.should.be Gem::Micro::Config
41
+ end
42
+ end
@@ -0,0 +1,27 @@
1
+ ##!/usr/bin/env macruby
2
+
3
+ require File.expand_path('../test_helper', __FILE__)
4
+
5
+ describe "Gem::Version" do
6
+ it "should be comparable" do
7
+ Gem::Version[:version => '0.1.2'].should == Gem::Version[:version => '0.1.2']
8
+ Gem::Version[:version => '0.1.2'].should.not == Gem::Version[:version => '0.1.3']
9
+
10
+ Gem::Version[:version => '0.1.2'].should >= Gem::Version[:version => '0.1.1']
11
+ Gem::Version[:version => '0.1.2'].should >= Gem::Version[:version => '0.1.2']
12
+
13
+ Gem::Version[:version => '0.1.2'].should <= Gem::Version[:version => '0.1.2']
14
+ Gem::Version[:version => '0.1.1'].should <= Gem::Version[:version => '0.1.2']
15
+ end
16
+
17
+ it "should instantiate from a gem directory name" do
18
+ Gem::Version.from_gem_dirname('rake-0.8.1').should == Gem::Version[:version => '0.8.1']
19
+ Gem::Version.from_gem_dirname('rake').should.be nil
20
+ end
21
+
22
+ it "should return if any version would be good or not" do
23
+ assert Gem::Version[:version => '0'].any?
24
+ assert Gem::Version[:version => 0].any?
25
+ assert !Gem::Version[:version => '0.1.2'].any?
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ ##!/usr/bin/env macruby
2
+
3
+ require File.expand_path('../test_helper', __FILE__)
4
+
5
+ class YAMLableSubclass < Gem::Micro::YAMLable
6
+ attr_reader :foo, :bar
7
+ end
8
+
9
+ describe "YAMLable" do
10
+ it "should instantiate and assign the given values as instance variables" do
11
+ obj = YAMLableSubclass[:foo => 'foo', :bar => ['bar']]
12
+ obj.foo.should == 'foo'
13
+ obj.bar.should == ['bar']
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alloy-microgem
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - Eloy Duran
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-11 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: "MicroGem provides a simple naive replacement for the `gem install' command in the form of the `\xC2\xB5gem' commandline utility."
17
+ email: eloy.de.enige@gmail.com
18
+ executables:
19
+ - "\xC2\xB5gem"
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ - LICENSE
25
+ - TODO
26
+ files:
27
+ - lib/microgem.rb
28
+ - lib/microgem/yamlable.rb
29
+ - lib/microgem/specification_emitter.rb
30
+ - lib/microgem/config.rb
31
+ - lib/microgem/requirement.rb
32
+ - lib/microgem/dependency.rb
33
+ - lib/microgem/installer.rb
34
+ - lib/microgem/source.rb
35
+ - lib/microgem/downloader.rb
36
+ - lib/microgem/bin_wrapper_emitter.rb
37
+ - lib/microgem/specification.rb
38
+ - lib/microgem/bare_specification.rb
39
+ - lib/microgem/options_parser.rb
40
+ - lib/microgem/version.rb
41
+ - lib/microgem/unpacker.rb
42
+ - lib/microgem/utils.rb
43
+ - bin/zinflate
44
+ - "bin/\xC2\xB5gem"
45
+ - TODO
46
+ - LICENSE
47
+ - Rakefile
48
+ - README.rdoc
49
+ - test/version_test.rb
50
+ - test/source_test.rb
51
+ - test/config_test.rb
52
+ - test/requirement_test.rb
53
+ - test/utils_test.rb
54
+ - test/bare_specification_test.rb
55
+ - test/fixtures
56
+ - test/fixtures/gems
57
+ - test/fixtures/gems/test-spec-mock-0.3.0
58
+ - test/fixtures/gems/test-spec-mock-0.3.0/test-spec-mock.rb
59
+ - test/fixtures/gems/test-spec-0.3.0
60
+ - test/fixtures/gems/test-spec-0.3.0/test-spec.rb
61
+ - test/fixtures/gems/rake-0.8.0
62
+ - test/fixtures/gems/rake-0.8.0/rake.rb
63
+ - test/fixtures/gems/rake-0.8.1
64
+ - test/fixtures/gems/rake-0.8.1/rake.rb
65
+ - test/fixtures/specs.4.8.gz
66
+ - test/fixtures/gems.github.com
67
+ - test/fixtures/gems.rubyforge.org
68
+ - test/fixtures/rake-0.8.1.gem
69
+ - test/fixtures/rails-2.1.1.gemspec.marshal
70
+ - test/fixtures/rake-0.8.1.gemspec.marshal
71
+ - test/fixtures/rails-2.1.1.gemspec
72
+ - test/fixtures/rake-0.8.1.gemspec.rz
73
+ - test/fixtures/rake-0.8.1.gemspec
74
+ - test/downloader_test.rb
75
+ - test/specification_emitter_test.rb
76
+ - test/specification_test.rb
77
+ - test/installer_test.rb
78
+ - test/dependency_test.rb
79
+ - test/microgem_test.rb
80
+ - test/bin_wrapper_emitter_test.rb
81
+ - test/test_helper.rb
82
+ - test/unpacker_test.rb
83
+ - test/options_parser_test.rb
84
+ - test/yamlable_test.rb
85
+ has_rdoc: true
86
+ homepage:
87
+ post_install_message:
88
+ rdoc_options:
89
+ - --charset=utf-8
90
+ - --main
91
+ - README.rdoc
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ version:
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: "0"
105
+ version:
106
+ requirements: []
107
+
108
+ rubyforge_project:
109
+ rubygems_version: 1.2.0
110
+ signing_key:
111
+ specification_version: 2
112
+ summary: "MicroGem provides a simple naive replacement for the `gem install' command in the form of the `\xC2\xB5gem' commandline utility."
113
+ test_files: []
114
+