rip 0.0.1 → 0.0.2

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 (41) hide show
  1. data/README.markdown +18 -19
  2. data/lib/rip.rb +12 -6
  3. data/lib/rip/commands.rb +23 -8
  4. data/lib/rip/commands/build.rb +12 -3
  5. data/lib/rip/commands/core.rb +1 -3
  6. data/lib/rip/commands/install.rb +3 -1
  7. data/lib/rip/commands/ruby.rb +15 -0
  8. data/lib/rip/commands/setup.rb +21 -0
  9. data/lib/rip/commands/uninstall.rb +8 -1
  10. data/lib/rip/env.rb +18 -2
  11. data/lib/rip/installer.rb +13 -12
  12. data/lib/rip/package.rb +5 -1
  13. data/lib/rip/package_api.rb +8 -0
  14. data/lib/rip/package_manager.rb +21 -5
  15. data/lib/rip/packages/file_package.rb +7 -3
  16. data/lib/rip/packages/gem_package.rb +7 -3
  17. data/lib/rip/packages/git_package.rb +8 -3
  18. data/lib/rip/packages/http_package.rb +0 -1
  19. data/lib/rip/packages/remote_gem_package.rb +5 -1
  20. data/lib/rip/packages/ripfile_package.rb +23 -5
  21. data/lib/rip/setup.rb +120 -36
  22. data/lib/rip/sh/git.rb +6 -2
  23. data/lib/rip/version.rb +1 -1
  24. data/setup.rb +15 -1
  25. data/test/env_test.rb +23 -1
  26. data/test/file_test.rb +34 -0
  27. data/test/git_test.rb +20 -3
  28. data/test/mock_git.rb +7 -3
  29. data/test/repos/simple-file-3.2.1.rb +1 -0
  30. data/test/repos/simple.rip +2 -0
  31. data/test/repos/simple_c/dot_git/index +0 -0
  32. data/test/repos/simple_c/dot_git/logs/HEAD +1 -0
  33. data/test/repos/simple_c/dot_git/logs/refs/heads/master +1 -0
  34. data/test/repos/simple_c/dot_git/objects/4f/3f9a42a24970fb72e8a828d95652c08465b3a4 +0 -0
  35. data/test/repos/simple_c/dot_git/objects/64/38cb2cf06f0a0e96326f4223202bece66540a4 +0 -0
  36. data/test/repos/simple_c/dot_git/objects/9f/88aea8cd1b0da9b4d42188b7cf2014392344e6 +0 -0
  37. data/test/repos/simple_c/dot_git/objects/f1/050d684f583a32338ffd77ec37e1196e0d2cc7 +0 -0
  38. data/test/repos/simple_c/dot_git/refs/heads/master +1 -1
  39. data/test/ripfile_test.rb +19 -0
  40. data/test/test_helper.rb +35 -0
  41. metadata +19 -5
@@ -3,7 +3,7 @@ module Rip
3
3
  module Git
4
4
  extend self
5
5
 
6
- def git_ls_remote(source, version)
6
+ def git_ls_remote(source, version = nil)
7
7
  `git ls-remote #{source} #{version} 2> /dev/null`
8
8
  end
9
9
 
@@ -27,9 +27,13 @@ module Rip
27
27
  `git submodule update`
28
28
  end
29
29
 
30
- def git_revparse(repothing)
30
+ def git_rev_parse(repothing)
31
31
  `git rev-parse #{repothing}`
32
32
  end
33
+
34
+ def git_cat_file(object)
35
+ `git cat-file -p #{object} 2> /dev/null`
36
+ end
33
37
  end
34
38
  end
35
39
  end
@@ -1,6 +1,6 @@
1
1
  module Rip
2
2
  module Version
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
 
5
5
  def self.to_s
6
6
  VERSION
data/setup.rb CHANGED
@@ -2,6 +2,9 @@
2
2
  # installs rip like so:
3
3
  # ruby setup.rb
4
4
  #
5
+ # upgrades rip like so:
6
+ # ruby setup.rb upgrade
7
+ #
5
8
  # also uninstalls rip like so:
6
9
  # ruby setup.rb uninstall
7
10
  #
@@ -11,17 +14,28 @@
11
14
  __DIR__ = File.expand_path(File.dirname(__FILE__))
12
15
  $LOAD_PATH.unshift File.join(__DIR__, 'lib')
13
16
 
14
- require 'rip'
17
+ require "rip"
15
18
 
16
19
  include Rip::Setup
17
20
 
21
+ # TODO: Use, like, real option parsing. --rue
22
+
23
+ %w( bindir libdir ripdir ).each do |opt|
24
+ if given = ARGV.grep(/--#{opt}=\S+/).last
25
+ Rip::Setup.const_set(opt.upcase, File.expand_path(given.split("=").last))
26
+ end
27
+ end
28
+
18
29
  if ARGV.include? 'uninstall'
19
30
  uninstall :verbose
20
31
  elsif ARGV.include? 'reinstall'
21
32
  uninstall
22
33
  install
34
+ elsif ARGV.include? 'upgrade'
35
+ upgrade
23
36
  elsif installed?
24
37
  puts "rip: already installed"
25
38
  else
26
39
  install
27
40
  end
41
+
@@ -34,6 +34,11 @@ context "Creating a ripenv" do
34
34
  assert_equal 'must give a ripenv to create', Rip::Env.create(' ')
35
35
  assert_equal 'must give a ripenv to create', Rip::Env.create("\t")
36
36
  assert_equal 'must give a ripenv to create', Rip::Env.create("\t ")
37
+ assert_equal "must give a ripenv to create", Rip::Env.call(:create)
38
+ end
39
+
40
+ test 'fails if attempt to name env active' do
41
+ assert_equal 'invalid environment name', Rip::Env.create('active')
37
42
  end
38
43
  end
39
44
 
@@ -59,13 +64,17 @@ context "Using a ripenv" do
59
64
  assert_equal "fake doesn't exist", Rip::Env.use("fake")
60
65
  end
61
66
 
67
+ test "fails if the new env is named active " do
68
+ assert_equal "invalid environment name", Rip::Env.use("active")
69
+ end
70
+
62
71
  test 'fails if no ripenv is given' do
63
72
  assert_equal "must give a ripenv to use", Rip::Env.use('')
64
73
  assert_not_equal '', Rip::Env.active
65
74
  assert_equal 'must give a ripenv to use', Rip::Env.use(' ')
66
75
  assert_equal 'must give a ripenv to use', Rip::Env.use("\t")
67
76
  assert_equal 'must give a ripenv to use', Rip::Env.use("\t ")
68
-
77
+ assert_equal "must give a ripenv to use", Rip::Env.call(:use)
69
78
  end
70
79
  end
71
80
 
@@ -89,6 +98,10 @@ context "Deleting a ripenv" do
89
98
  assert_equal "can't delete active environment", Rip::Env.delete('base')
90
99
  end
91
100
 
101
+ test "fails if the ripenv is named active" do
102
+ assert_equal "invalid environment name", Rip::Env.delete('active')
103
+ end
104
+
92
105
  test "fails if it doesn't exist" do
93
106
  name = 'fake_env'
94
107
  assert_equal "can't find #{name}", Rip::Env.delete(name)
@@ -100,6 +113,7 @@ context "Deleting a ripenv" do
100
113
  assert_equal 'must give a ripenv to delete', Rip::Env.delete(' ')
101
114
  assert_equal 'must give a ripenv to delete', Rip::Env.delete("\t")
102
115
  assert_equal 'must give a ripenv to delete', Rip::Env.delete("\t ")
116
+ assert_equal "must give a ripenv to delete", Rip::Env.call(:delete)
103
117
  assert File.exists?(Rip.dir)
104
118
  end
105
119
  end
@@ -154,6 +168,13 @@ context "Copying the current ripenv" do
154
168
  assert_equal @name, Rip::Env.active
155
169
  end
156
170
 
171
+ test "properly renames the ripenv file" do
172
+ Rip::Env.copy(@name)
173
+
174
+ assert File.exists?(File.join(@ripenv, "#{@name}.ripenv"))
175
+ assert !File.exists?(File.join(@ripenv, "base.ripenv"))
176
+ end
177
+
157
178
  test "makes the new env a copy of the active env"
158
179
 
159
180
  test "fails if the new env exists" do
@@ -169,5 +190,6 @@ context "Copying the current ripenv" do
169
190
  assert_equal 'must give a ripenv to copy to', Rip::Env.copy(' ')
170
191
  assert_equal 'must give a ripenv to copy to', Rip::Env.copy("\t")
171
192
  assert_equal 'must give a ripenv to copy to', Rip::Env.copy("\t ")
193
+ assert_equal "must give a ripenv to copy to", Rip::Env.call(:copy)
172
194
  end
173
195
  end
@@ -0,0 +1,34 @@
1
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
2
+ require 'test_helper'
3
+
4
+ context 'Installing from a FilePackage' do
5
+ setup_with_fs do
6
+ @package = fresh_local_file('simple-file-3.2.1.rb')
7
+ @source = @package.source
8
+ end
9
+
10
+ test "installs the lib files" do
11
+ Rip::Commands.install({}, @source)
12
+
13
+ libpath = Rip.dir + '/active/lib/simple-file-3.2.1.rb'
14
+ assert File.exists?(libpath), 'simple-file-3.2.1.rb should be installed'
15
+ end
16
+
17
+ test "fetching into cache_path" do
18
+ @package.fetch!
19
+ assert File.exists?(File.join(@package.cache_path, @package.name)), 'should fetch package and put in local cache'
20
+ end
21
+
22
+ test "finds version from name suffix" do
23
+ assert_equal '1.2', fresh_local_file('simple-file-1.2.rb').version
24
+ assert_equal '1.2.3', fresh_local_file('simple-file-1.2.3.rb').version
25
+ assert_equal '1.2.3.4', fresh_local_file('simple-file-1.2.3.4.rb').version
26
+ end
27
+
28
+ test "defaults to date if not named properly" do
29
+ date = Date.today
30
+ fake Date, :today, :with => date do
31
+ assert_equal date.to_s, fresh_local_file('simple-file.rb').version
32
+ end
33
+ end
34
+ end
@@ -4,6 +4,8 @@ require 'test_helper'
4
4
  context 'Installing from a remote git repo' do
5
5
  setup_with_fs do
6
6
  @source = fresh_remote_git('simple_c')
7
+ @libpath = Rip.dir + '/active/lib/simple_c.rb'
8
+ @addedrb = Rip.dir + '/active/lib/added.rb'
7
9
  end
8
10
 
9
11
  teardown do
@@ -12,9 +14,24 @@ context 'Installing from a remote git repo' do
12
14
 
13
15
  test "installs the lib files" do
14
16
  Rip::Commands.install({}, @source)
17
+ assert File.exists?(@libpath), 'simple_c.rb should be installed'
18
+ end
15
19
 
16
- libpath = Rip.dir + '/active/lib/simple_c.rb'
17
- assert File.exists?(libpath), 'simple_c.rb should be installed'
20
+ test "fails on an unknown version" do
21
+ Rip::Commands.install({}, @source, 'deadbeef')
22
+ assert !File.exists?(@libpath), 'simple_c.rb should not be installed'
23
+ end
24
+
25
+ test "works with a real version" do
26
+ Rip::Commands.install({}, @source, 'master')
27
+ assert File.exists?(@addedrb), 'added.rb should be installed'
28
+ assert File.exists?(@libpath), 'simple_c.rb should be installed'
29
+ end
30
+
31
+ test "works with an existing sha" do
32
+ Rip::Commands.install({}, @source, '3f1d6da')
33
+ assert !File.exists?(@addedrb), 'added.rb should not be installed'
34
+ assert File.exists?(@libpath), 'simple_c.rb should be installed'
18
35
  end
19
36
  end
20
37
 
@@ -26,7 +43,7 @@ context 'Installing from a local git repo' do
26
43
  teardown do
27
44
  Rip::GitPackage.unmock_git
28
45
  end
29
-
46
+
30
47
  test 'local installs the lib files' do
31
48
  Rip::Commands.install({}, @sources)
32
49
  libpath = Rip.dir + '/active/lib/simple_c.rb'
@@ -1,7 +1,7 @@
1
1
  module Rip
2
2
  module Sh
3
3
  module MockGit
4
- def git_ls_remote(source, version)
4
+ def git_ls_remote(source, version=nil)
5
5
  match_errors = []
6
6
  if source != real_source
7
7
  match_errors << "source was #{source} instead of #{real_source}"
@@ -13,9 +13,9 @@ module Rip
13
13
 
14
14
  "67be542ddad55c502daf12fde4f784d88a248617\tHEAD\n67be542ddad55c502daf12fde4f784d88a248617\trefs/heads/master"
15
15
  end
16
-
16
+
17
17
  def git_fetch(repothing)
18
- end
18
+ end
19
19
 
20
20
  def git_clone(source, cache_name)
21
21
  match_errors = []
@@ -39,6 +39,10 @@ module Rip
39
39
  def git_reset_hard(version)
40
40
  end
41
41
 
42
+ def git_cat_file(object)
43
+ ''
44
+ end
45
+
42
46
  def real_repo_name
43
47
  raise NotImplementedError
44
48
  end
@@ -0,0 +1 @@
1
+ require 'simp'
@@ -0,0 +1,2 @@
1
+ ./simple-file-3.2.1.rb
2
+ ./simple_c
@@ -1 +1,2 @@
1
1
  0000000000000000000000000000000000000000 3f1d6dacdedf75058e9edf23f48de03fa451f7ce Jeff Hodges <jeff@somethingsimilar.com> 1243833746 -0700 commit (initial): simple_c extension initial commit
2
+ 3f1d6dacdedf75058e9edf23f48de03fa451f7ce f1050d684f583a32338ffd77ec37e1196e0d2cc7 Chris Wanstrath <chris@ozmm.org> 1248239402 -0700 commit: add a file
@@ -1 +1,2 @@
1
1
  0000000000000000000000000000000000000000 3f1d6dacdedf75058e9edf23f48de03fa451f7ce Jeff Hodges <jeff@somethingsimilar.com> 1243833746 -0700 commit (initial): simple_c extension initial commit
2
+ 3f1d6dacdedf75058e9edf23f48de03fa451f7ce f1050d684f583a32338ffd77ec37e1196e0d2cc7 Chris Wanstrath <chris@ozmm.org> 1248239402 -0700 commit: add a file
@@ -1 +1 @@
1
- 3f1d6dacdedf75058e9edf23f48de03fa451f7ce
1
+ f1050d684f583a32338ffd77ec37e1196e0d2cc7
@@ -0,0 +1,19 @@
1
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
2
+ require 'test_helper'
3
+
4
+ context 'Installing from a RipfilePackage' do
5
+ setup_with_fs do
6
+ @package = fresh_ripfile('simple.rip')
7
+ @source = @package.source
8
+ end
9
+
10
+ test "installs the lib files" do
11
+ Rip::Commands.install({}, @source)
12
+
13
+ filelibpath = Rip.dir + '/active/lib/simple-file-3.2.1.rb'
14
+ assert File.exists?(filelibpath), 'FilePackage should be installed'
15
+
16
+ dirlibpath = Rip.dir + '/active/lib/simple_c.rb'
17
+ assert File.exists?(dirlibpath), 'DirPackage should be installed'
18
+ end
19
+ end
@@ -12,6 +12,27 @@ require 'fakefs'
12
12
  require 'test/unit'
13
13
  require 'test/spec/mini'
14
14
 
15
+ begin; require 'redgreen'; rescue LoadError; end
16
+
17
+ # For super rudimentary mocking...
18
+ def fake(object, method_name, options={})
19
+ method = object.method(method_name)
20
+ metaclass = class << object; self end
21
+ return_value = options[:with]
22
+
23
+ metaclass.class_eval do
24
+ define_method(method_name) { |*args| return_value }
25
+ end
26
+
27
+ begin
28
+ yield
29
+ ensure
30
+ metaclass.class_eval do
31
+ define_method(method_name, method)
32
+ end
33
+ end
34
+ end
35
+
15
36
  def repo_path(repo_name)
16
37
  RealFile.expand_path(RealFile.dirname(__FILE__) + '/repos/' + repo_name)
17
38
  end
@@ -28,6 +49,10 @@ class Test::Unit::TestCase
28
49
  Rip::Env.create('other')
29
50
  Rip::Setup.setup_ripenv(Rip.dir)
30
51
  Rip::Env.create('base')
52
+
53
+ Rip::PackageManager.new('other').save
54
+ Rip::PackageManager.new('base').save
55
+
31
56
  setup_block
32
57
  end
33
58
 
@@ -46,6 +71,16 @@ class Test::Unit::TestCase
46
71
  FakeFS::FileSystem.clone(repo_path(repo_name))
47
72
  Rip::DirPackage.new(repo_path(repo_name))
48
73
  end
74
+
75
+ def fresh_local_file(repo_name)
76
+ FakeFS::FileSystem.clone(repo_path(repo_name))
77
+ Rip::FilePackage.new(repo_path(repo_name))
78
+ end
79
+
80
+ def fresh_ripfile(repo_name)
81
+ FakeFS::FileSystem.clone(repo_path(''))
82
+ Rip::RipfilePackage.new(repo_path(repo_name))
83
+ end
49
84
  end
50
85
 
51
86
  module Rip
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-10 00:00:00 -07:00
12
+ date: 2009-07-21 00:00:00 -07:00
13
13
  default_executable: ""
14
14
  dependencies: []
15
15
 
@@ -35,6 +35,8 @@ files:
35
35
  - lib/rip/commands/build.rb
36
36
  - lib/rip/commands/core.rb
37
37
  - lib/rip/commands/install.rb
38
+ - lib/rip/commands/ruby.rb
39
+ - lib/rip/commands/setup.rb
38
40
  - lib/rip/commands/uninstall.rb
39
41
  - lib/rip/env.rb
40
42
  - lib/rip/installer.rb
@@ -58,8 +60,11 @@ files:
58
60
  - test/dev.rip
59
61
  - test/dir_test.rb
60
62
  - test/env_test.rb
63
+ - test/file_test.rb
61
64
  - test/git_test.rb
62
65
  - test/mock_git.rb
66
+ - test/repos/simple-file-3.2.1.rb
67
+ - test/repos/simple.rip
63
68
  - test/repos/simple_c/dot_git/HEAD
64
69
  - test/repos/simple_c/dot_git/config
65
70
  - test/repos/simple_c/dot_git/description
@@ -79,18 +84,23 @@ files:
79
84
  - test/repos/simple_c/dot_git/logs/refs/heads/master
80
85
  - test/repos/simple_c/dot_git/objects/2d/94227280db3ac66875f52592c6a736b4526084
81
86
  - test/repos/simple_c/dot_git/objects/3f/1d6dacdedf75058e9edf23f48de03fa451f7ce
87
+ - test/repos/simple_c/dot_git/objects/4f/3f9a42a24970fb72e8a828d95652c08465b3a4
82
88
  - test/repos/simple_c/dot_git/objects/53/23e9a7ff897fe7bfc3357d9274775b67f9ade4
83
89
  - test/repos/simple_c/dot_git/objects/55/31db58bd71148661c400dc48815bf06b366128
90
+ - test/repos/simple_c/dot_git/objects/64/38cb2cf06f0a0e96326f4223202bece66540a4
91
+ - test/repos/simple_c/dot_git/objects/9f/88aea8cd1b0da9b4d42188b7cf2014392344e6
84
92
  - test/repos/simple_c/dot_git/objects/d7/55c6f119520808609a8d79bac1a8dbe0c57424
85
93
  - test/repos/simple_c/dot_git/objects/d7/58739ea968ac8e8fe0cbbf1f6451af47f04964
86
94
  - test/repos/simple_c/dot_git/objects/e6/7b81a24f0ce4bff84c3599b5c9ba7093f554d8
87
95
  - test/repos/simple_c/dot_git/objects/ec/be0a80dc841c16beb2c733bbdd320b45565d89
96
+ - test/repos/simple_c/dot_git/objects/f1/050d684f583a32338ffd77ec37e1196e0d2cc7
88
97
  - test/repos/simple_c/dot_git/refs/heads/master
89
98
  - test/repos/simple_c/ext/simp/extconf.rb
90
99
  - test/repos/simple_c/ext/simp/simp.c
91
100
  - test/repos/simple_c/lib/simple_c.rb
92
101
  - test/repos/simple_d-1.2.3/lib/simple_d.rb
93
102
  - test/rip_test.rb
103
+ - test/ripfile_test.rb
94
104
  - test/test_helper.rb
95
105
  - test/ui_test.rb
96
106
  has_rdoc: true
@@ -101,10 +111,11 @@ post_install_message: |
101
111
  ****************************************************
102
112
  So far so good...
103
113
 
104
- Run `rip check` to be sure Rip installed successfully
114
+ Rip needs certain env variables to run. We've tried
115
+ to install them automatically but may have failed.
105
116
 
106
- NOTE: You may need to source your ~/.bashrc
107
- or start a new shell session.
117
+ Run `rip check` to check the status of your
118
+ installation.
108
119
 
109
120
  Get started: `rip -h` or http://hellorip.com/
110
121
 
@@ -137,12 +148,15 @@ test_files:
137
148
  - test/commands_test.rb
138
149
  - test/dir_test.rb
139
150
  - test/env_test.rb
151
+ - test/file_test.rb
140
152
  - test/git_test.rb
141
153
  - test/mock_git.rb
154
+ - test/repos/simple-file-3.2.1.rb
142
155
  - test/repos/simple_c/ext/simp/extconf.rb
143
156
  - test/repos/simple_c/lib/simple_c.rb
144
157
  - test/repos/simple_d-1.2.3/lib/simple_d.rb
145
158
  - test/rip_test.rb
159
+ - test/ripfile_test.rb
146
160
  - test/test_helper.rb
147
161
  - test/ui_test.rb
148
162
  - examples/debug.rb