rip 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -281,7 +281,7 @@ Currently it's UNIX-only. This is because Rip needs to manipulate the RUBYLIB
281
281
  and PATH environment variables so that Ruby knows where to find installed Rip
282
282
  packages.
283
283
 
284
- As a result, the setup script expects you to be running bash or zshell.
284
+ As a result, the setup script expects you to be running bash, zshell, or fish.
285
285
 
286
286
  Contributors
287
287
  ------------
@@ -305,6 +305,7 @@ Contributors
305
305
  * Andre Arko
306
306
  * Rick Olson
307
307
  * Ben Burkert
308
+ * James Adam
308
309
 
309
310
  Special Thanks
310
311
  --------------
data/bin/rip CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w( .. lib ))
3
4
  require 'rip'
4
5
  require 'rip/commands'
5
6
 
data/lib/rip.rb CHANGED
@@ -12,7 +12,7 @@ module Rip
12
12
  else
13
13
  dir = File.expand_path(env)
14
14
  end
15
-
15
+
16
16
  FileUtils.mkdir_p dir unless File.exists? dir
17
17
  @dir = dir
18
18
  end
@@ -28,7 +28,7 @@ module Rip
28
28
  def self.ui=(io)
29
29
  @ui = Rip::UI.new(io)
30
30
  end
31
-
31
+
32
32
  def self.user_home
33
33
  @home ||= ENV['HOME']
34
34
  end
@@ -47,6 +47,7 @@ require 'rip/package'
47
47
  require 'rip/package_manager'
48
48
  require 'rip/setup'
49
49
  require 'rip/sh/git'
50
+ require 'rip/sh/gem'
50
51
 
51
52
 
52
53
  # load rip packages - order is important
@@ -5,6 +5,8 @@
5
5
 
6
6
  module Rip
7
7
  module Commands
8
+ o 'rip build PACKAGE'
9
+ x "Attempts to build a package using extconf.rb"
8
10
  def build(options={}, *packages)
9
11
  packages.each do |package_name|
10
12
  package = manager.package(package_name)
@@ -20,7 +22,7 @@ module Rip
20
22
  Dir.chdir(build_dir) do
21
23
  system "ruby extconf.rb"
22
24
  system "make clean"
23
- system "make install RUBYARCHDIR=#{manager.dir}/lib"
25
+ system "make install sitearchdir=#{manager.dir}/lib"
24
26
  end
25
27
  end
26
28
 
@@ -37,8 +37,7 @@ module Rip
37
37
  end
38
38
 
39
39
  o 'rip use RIPENV'
40
- x 'Activate a ripenv.'
41
- x 'Shortcut for `rip env use`'
40
+ x 'Activates a ripenv. Shortcut for `rip env use`.'
42
41
  def use(options = {}, ripenv = nil, *args)
43
42
  puts 'ripenv: ' + Rip::Env.use(ripenv.to_s)
44
43
  end
@@ -63,7 +62,7 @@ module Rip
63
62
  method =~ /-/ || %w( help version ).include?(method)
64
63
  end
65
64
 
66
- show_help nil, commands
65
+ show_help nil, commands.sort
67
66
 
68
67
  ui.puts
69
68
  ui.puts "For more information on a a command use:"
@@ -19,12 +19,13 @@ module Rip
19
19
  end
20
20
 
21
21
  package = Rip::Package.for(source, version)
22
- installed_package = manager.package(package.name)
23
22
 
24
23
  if !package
25
24
  ui.abort "I don't know how to install #{source}"
26
25
  end
27
26
 
27
+ installed_package = manager.package(package.name)
28
+
28
29
  if options[:f] && installed_package
29
30
  Installer.new.uninstall(installed_package) if installed_package.installed?
30
31
  Installer.new.install(package)
@@ -0,0 +1,28 @@
1
+ module Rip
2
+ module Commands
3
+ o 'rip show PACKAGE'
4
+ x 'Displays information about an installed package'
5
+ def show(options = {}, name = nil, *args)
6
+ if name.to_s.empty?
7
+ ui.abort "Please give me the name of a package."
8
+ end
9
+
10
+ installed_package = manager.package(name)
11
+ if installed_package.nil?
12
+ ui.abort "The package '#{name}' doesn't seem to be installed"
13
+ end
14
+
15
+ ui.puts installed_package
16
+ ui.puts "Depends on: #{display_package_list(manager.dependencies_for(name))}"
17
+ ui.puts "Required by: #{display_package_list(manager.packages_that_depend_on(name))}"
18
+
19
+ ui.puts "Files:\n\t#{manager.files(name).join("\n\t")}" if options[:f]
20
+ end
21
+
22
+ private
23
+ def display_package_list(packages)
24
+ return "Nothing" unless packages && packages.any?
25
+ packages.join(", ")
26
+ end
27
+ end
28
+ end
@@ -25,8 +25,6 @@ module Rip
25
25
  begin
26
26
  installed = @installed[package.name] || package.installed?
27
27
 
28
- manager.add_package(package, parent) unless package.meta_package?
29
-
30
28
  return if installed
31
29
  @installed[package.name] = package
32
30
 
@@ -36,6 +34,10 @@ module Rip
36
34
 
37
35
  package.fetch
38
36
  package.unpack
37
+
38
+ parent_package = (parent && parent.meta_package?) ? parent.actual_package : parent
39
+ manager.add_package(package, parent)
40
+
39
41
  install_dependencies(package)
40
42
  build_extensions(package)
41
43
  copy_files(package)
@@ -91,6 +91,10 @@ module Rip
91
91
  def packages_that_depend_on(name)
92
92
  (@dependents[name] || []).map { |name| package(name) }
93
93
  end
94
+
95
+ def dependencies_for(name)
96
+ (@dependencies[name] || []).map { |name| package(name) }
97
+ end
94
98
 
95
99
  def files(name)
96
100
  Array(@files[name])
@@ -112,6 +116,10 @@ module Rip
112
116
  raise VersionConflict.new(name, version, parent, @versions[name], @dependents[name].to_a)
113
117
  end
114
118
 
119
+ if parent && parent.meta_package? && parent.actual_package != package
120
+ parent = parent.actual_package
121
+ end
122
+
115
123
  if parent && !parent.meta_package?
116
124
  @dependents[name] ||= Set.new
117
125
  @dependents[name].add(parent.name)
@@ -20,9 +20,7 @@ module Rip
20
20
  end
21
21
 
22
22
  def exists?
23
- if `which #{gembin}`.strip.empty?
24
- ui.abort "you don't have #{gembin} installed"
25
- end
23
+ ui.abort "can't find your gem command" unless Sh::Gem.check?
26
24
 
27
25
  File.exists?(source)
28
26
  end
@@ -32,7 +30,11 @@ module Rip
32
30
  end
33
31
 
34
32
  def unpack!
35
- system "'#{gembin}' unpack '#{cache_file}' --target='#{packages_path}' > /dev/null"
33
+ Sh::Gem.rgem("unpack '#{cache_file}' --target='#{packages_path}' > /dev/null")
34
+ end
35
+
36
+ def dependencies!
37
+ Sh::Gem.dependencies(name)
36
38
  end
37
39
 
38
40
  memoize :metadata
@@ -40,9 +42,5 @@ module Rip
40
42
  parts = source.split('/').last.chomp('.gem').split('-')
41
43
  { :name => parts[0...-1].join('-'), :version => parts[-1] }
42
44
  end
43
-
44
- def gembin
45
- ENV['GEMBIN'] || 'gem'
46
- end
47
45
  end
48
46
  end
@@ -6,7 +6,7 @@ module Rip
6
6
  RemoteGemPackage.new(source).exists?
7
7
  end
8
8
 
9
- @@remotes = %w( gems.github.com gems.rubyforge.org )
9
+ @@remotes = %w( gems.github.com gemcutter.org gems.rubyforge.org )
10
10
  @@exists_cache = {}
11
11
 
12
12
  def exists?
@@ -17,27 +17,24 @@ module Rip
17
17
 
18
18
  Dir.chdir cache_path do
19
19
  @@remotes.each do |remote|
20
- ui.puts "Searching %s for %s..." % [ remote, source ]
20
+ # hack: every github gem has a dash in its name
21
+ next if remote =~ /github/ && !source.include?('-')
22
+
23
+ ui.vputs "Searching %s for %s..." % [ remote, source ]
21
24
 
22
25
  source_flag = "--source=http://#{remote}/"
23
- if rgem("fetch #{source} #{source_flag}") =~ /Downloaded (.+)/
26
+ if Sh::Gem.rgem("fetch #{source} #{source_flag}") =~ /Downloaded (.+)/
27
+ ui.vputs "Found #{source} at #{remote}"
24
28
  @@exists_cache[source] = $1
25
29
  return true
26
30
  end
27
31
  end
28
32
  end
29
33
 
34
+ FileUtils.rm_rf cache_path
30
35
  false
31
36
  end
32
37
 
33
- def rgem(command)
34
- Timeout.timeout(5) do
35
- `#{gembin} #{command}`
36
- end
37
- rescue Timeout::Error
38
- ''
39
- end
40
-
41
38
  def meta_package?
42
39
  true
43
40
  end
@@ -47,11 +44,15 @@ module Rip
47
44
 
48
45
  def unpack!
49
46
  installer = Installer.new
50
- installer.install actual_package
47
+ installer.install actual_package, self
51
48
  installer.manager.sources[actual_package.name] = source
52
49
  installer.manager.save
53
50
  end
54
51
 
52
+ def dependencies!
53
+ actual_package.dependencies
54
+ end
55
+
55
56
  def version
56
57
  actual_package ? actual_package.version : super
57
58
  end
@@ -60,9 +61,5 @@ module Rip
60
61
  def actual_package
61
62
  Package.for(Dir[cache_path + '/*'].first)
62
63
  end
63
-
64
- def gembin
65
- ENV['GEMBIN'] || 'gem'
66
- end
67
64
  end
68
65
  end
@@ -0,0 +1,39 @@
1
+ module Rip
2
+ module Sh
3
+ module Gem
4
+ extend self
5
+
6
+ def check?
7
+ `which #{gembin}`.strip.any?
8
+ end
9
+
10
+ def rgem(command)
11
+ Timeout.timeout(30) do
12
+ `#{gembin} #{command} 2> /dev/null`
13
+ end
14
+ rescue Timeout::Error
15
+ ''
16
+ end
17
+
18
+ def dependencies(name)
19
+ if rgem("dependency #{name} --remote") =~ /(Gem #{name}-.*?)(Gem|\z)/m
20
+ $1.split("\n").grep(/runtime\s*\)/).map do |line|
21
+ line =~ /([\w-]+)\s*\([~><=]+\s*((?:\d+\.?)+\d+|\d)/
22
+ source, version = $1, $2
23
+ if source
24
+ Package.for(source, version)
25
+ else
26
+ nil
27
+ end
28
+ end.compact
29
+ else
30
+ []
31
+ end
32
+ end
33
+
34
+ def gembin
35
+ ENV['GEMBIN'] || 'gem'
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,7 +1,8 @@
1
1
  module Rip
2
2
  class UI
3
- def initialize(io=nil)
3
+ def initialize(io = nil, verbose = false)
4
4
  @io = io
5
+ @verbose = verbose
5
6
  end
6
7
 
7
8
  def puts(*args)
@@ -20,5 +21,9 @@ module Rip
20
21
  def abort(msg)
21
22
  @io && Kernel.abort("rip: #{msg}")
22
23
  end
24
+
25
+ def vputs(*args)
26
+ puts(*args) if @verbose
27
+ end
23
28
  end
24
29
  end
@@ -1,6 +1,6 @@
1
1
  module Rip
2
2
  module Version
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
 
5
5
  def self.to_s
6
6
  VERSION
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.3
4
+ version: 0.0.4
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-08-06 00:00:00 -07:00
12
+ date: 2009-08-13 00:00:00 -07:00
13
13
  default_executable: ""
14
14
  dependencies: []
15
15
 
@@ -37,6 +37,7 @@ files:
37
37
  - lib/rip/commands/install.rb
38
38
  - lib/rip/commands/ruby.rb
39
39
  - lib/rip/commands/setup.rb
40
+ - lib/rip/commands/show.rb
40
41
  - lib/rip/commands/uninstall.rb
41
42
  - lib/rip/env.rb
42
43
  - lib/rip/help.rb
@@ -53,6 +54,7 @@ files:
53
54
  - lib/rip/packages/remote_gem_package.rb
54
55
  - lib/rip/packages/ripfile_package.rb
55
56
  - lib/rip/setup.rb
57
+ - lib/rip/sh/gem.rb
56
58
  - lib/rip/sh/git.rb
57
59
  - lib/rip/ui.rb
58
60
  - lib/rip/version.rb