rush 0.4.2 → 0.5

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.
data/Rakefile CHANGED
@@ -31,7 +31,7 @@ require 'rake/rdoctask'
31
31
  require 'fileutils'
32
32
  include FileUtils
33
33
 
34
- version = "0.4.2"
34
+ version = "0.5"
35
35
  name = "rush"
36
36
 
37
37
  spec = Gem::Specification.new do |s|
@@ -76,11 +76,11 @@ Rake::TestTask.new do |t|
76
76
  end
77
77
 
78
78
  Rake::RDocTask.new do |t|
79
- t.rdoc_dir = 'doc'
79
+ t.rdoc_dir = 'rdoc'
80
80
  t.title = "rush, a Ruby replacement for bash+ssh"
81
81
  t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
82
82
  t.options << '--charset' << 'utf-8'
83
- t.rdoc_files.include('README')
83
+ t.rdoc_files.include('README.rdoc')
84
84
  t.rdoc_files.include('lib/rush.rb')
85
85
  t.rdoc_files.include('lib/rush/*.rb')
86
86
  end
data/lib/rush.rb CHANGED
@@ -1,6 +1,61 @@
1
1
  require 'rubygems'
2
2
 
3
- module Rush; end
3
+ # The top-level Rush module has some convenience methods for accessing the
4
+ # local box.
5
+ module Rush
6
+ # Access the root filesystem of the local box. Example:
7
+ #
8
+ # Rush['/etc/hosts'].contents
9
+ #
10
+ def self.[](key)
11
+ box[key]
12
+ end
13
+
14
+ # Create a dir object from the path of a provided file. Example:
15
+ #
16
+ # Rush.dir(__FILE__).files
17
+ #
18
+ def self.dir(filename)
19
+ box[::File.expand_path(::File.dirname(filename)) + '/']
20
+ end
21
+
22
+ # Create a dir object based on the shell's current working directory at the
23
+ # time the program was run. Example:
24
+ #
25
+ # Rush.launch_dir.files
26
+ #
27
+ def self.launch_dir
28
+ box[::Dir.pwd + '/']
29
+ end
30
+
31
+ # Run a bash command in the root of the local machine. Equivalent to
32
+ # Rush::Box.new.bash.
33
+ def self.bash(command, options={})
34
+ box.bash(command, options)
35
+ end
36
+
37
+ # Pull the process list for the local machine. Example:
38
+ #
39
+ # Rush.processes.filter(:cmdline => /ruby/)
40
+ #
41
+ def self.processes
42
+ box.processes
43
+ end
44
+
45
+ # Get the process object for this program's PID. Example:
46
+ #
47
+ # puts "I'm using #{Rush.my_process.mem} blocks of memory"
48
+ #
49
+ def self.my_process
50
+ box.processes.filter(:pid => ::Process.pid).first
51
+ end
52
+
53
+ # Create a box object for localhost.
54
+ def self.box
55
+ @@box = Rush::Box.new
56
+ end
57
+ end
58
+
4
59
  module Rush::Connection; end
5
60
 
6
61
  $LOAD_PATH.unshift(File.dirname(__FILE__))
data/lib/rush/box.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  #
7
7
  # Example:
8
8
  #
9
- # local = Rush::Box.new('localhost')
9
+ # local = Rush::Box.new
10
10
  # local['/etc/hosts'].contents
11
11
  # local.processes
12
12
  #
data/spec/process_spec.rb CHANGED
@@ -34,7 +34,7 @@ describe Rush::Process do
34
34
  end
35
35
 
36
36
  it "knows the executed binary" do
37
- @process.command.should match(/^ruby/)
37
+ @process.command.should match(/ruby/)
38
38
  end
39
39
 
40
40
  it "knows the command line" do
@@ -59,8 +59,8 @@ describe Rush::Process do
59
59
  end
60
60
 
61
61
  it "can kill itself" do
62
- system "sleep 30 &"
63
- process = Rush::Process.all.detect { |p| p.command == "sleep" }
62
+ process = Rush.bash("sleep 30", :background => true)
63
+ process.alive?.should be_true
64
64
  process.kill
65
65
  sleep 0.1
66
66
  process.alive?.should be_false
data/spec/rush_spec.rb ADDED
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + '/base'
2
+
3
+ describe Rush do
4
+ it "fetches a local file path" do
5
+ Rush['/etc/hosts'].full_path.should == '/etc/hosts'
6
+ end
7
+
8
+ it "fetches the dir of __FILE__" do
9
+ Rush.dir(__FILE__).name.should == 'spec'
10
+ end
11
+
12
+ it "fetches the launch dir (aka current working directory or pwd)" do
13
+ Dir.stub!(:pwd).and_return('/tmp')
14
+ Rush.launch_dir.should == Rush::Box.new['/tmp/']
15
+ end
16
+
17
+ it "runs a bash command" do
18
+ Rush.bash('echo hi').should == "hi\n"
19
+ end
20
+
21
+ it "gets the list of local processes" do
22
+ Rush.processes.should be_kind_of(Rush::ProcessSet)
23
+ end
24
+
25
+ it "gets my process" do
26
+ Rush.my_process.pid.should == Process.pid
27
+ end
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: "0.5"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Wiggins
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-22 00:00:00 -07:00
12
+ date: 2008-12-30 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -45,50 +45,51 @@ files:
45
45
  - Rakefile
46
46
  - bin/rush
47
47
  - bin/rushd
48
+ - lib/rush.rb
48
49
  - lib/rush
49
- - lib/rush/access.rb
50
- - lib/rush/array_ext.rb
51
- - lib/rush/box.rb
52
- - lib/rush/commands.rb
53
- - lib/rush/config.rb
54
- - lib/rush/dir.rb
55
50
  - lib/rush/embeddable_shell.rb
51
+ - lib/rush/config.rb
52
+ - lib/rush/head_tail.rb
53
+ - lib/rush/search_results.rb
56
54
  - lib/rush/entry.rb
57
- - lib/rush/exceptions.rb
58
- - lib/rush/file.rb
59
55
  - lib/rush/find_by.rb
60
- - lib/rush/fixnum_ext.rb
61
- - lib/rush/head_tail.rb
56
+ - lib/rush/file.rb
62
57
  - lib/rush/local.rb
63
- - lib/rush/process.rb
58
+ - lib/rush/ssh_tunnel.rb
59
+ - lib/rush/shell.rb
60
+ - lib/rush/server.rb
64
61
  - lib/rush/process_set.rb
62
+ - lib/rush/array_ext.rb
65
63
  - lib/rush/remote.rb
66
- - lib/rush/search_results.rb
67
- - lib/rush/server.rb
68
- - lib/rush/shell.rb
69
- - lib/rush/ssh_tunnel.rb
64
+ - lib/rush/fixnum_ext.rb
65
+ - lib/rush/commands.rb
66
+ - lib/rush/process.rb
67
+ - lib/rush/dir.rb
70
68
  - lib/rush/string_ext.rb
71
- - lib/rush.rb
69
+ - lib/rush/box.rb
70
+ - lib/rush/exceptions.rb
71
+ - lib/rush/access.rb
72
+ - spec/remote_spec.rb
73
+ - spec/rush_spec.rb
74
+ - spec/base.rb
75
+ - spec/ssh_tunnel_spec.rb
76
+ - spec/local_spec.rb
77
+ - spec/embeddable_shell_spec.rb
72
78
  - spec/access_spec.rb
79
+ - spec/file_spec.rb
80
+ - spec/string_ext_spec.rb
73
81
  - spec/array_ext_spec.rb
74
- - spec/base.rb
75
- - spec/box_spec.rb
76
82
  - spec/commands_spec.rb
77
83
  - spec/config_spec.rb
84
+ - spec/fixnum_ext_spec.rb
85
+ - spec/search_results_spec.rb
86
+ - spec/process_spec.rb
87
+ - spec/shell_spec.rb
78
88
  - spec/dir_spec.rb
79
- - spec/embeddable_shell_spec.rb
80
89
  - spec/entry_spec.rb
81
- - spec/file_spec.rb
82
90
  - spec/find_by_spec.rb
83
- - spec/fixnum_ext_spec.rb
84
- - spec/local_spec.rb
91
+ - spec/box_spec.rb
85
92
  - spec/process_set_spec.rb
86
- - spec/process_spec.rb
87
- - spec/remote_spec.rb
88
- - spec/search_results_spec.rb
89
- - spec/shell_spec.rb
90
- - spec/ssh_tunnel_spec.rb
91
- - spec/string_ext_spec.rb
92
93
  has_rdoc: true
93
94
  homepage: http://rush.heroku.com/
94
95
  post_install_message:
@@ -111,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  requirements: []
112
113
 
113
114
  rubyforge_project: ruby-shell
114
- rubygems_version: 1.2.0
115
+ rubygems_version: 1.3.1
115
116
  signing_key:
116
117
  specification_version: 2
117
118
  summary: A Ruby replacement for bash+ssh.