rush 0.4 → 0.4.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.
data/Rakefile CHANGED
@@ -31,7 +31,7 @@ require 'rake/rdoctask'
31
31
  require 'fileutils'
32
32
  include FileUtils
33
33
 
34
- version = "0.4"
34
+ version = "0.4.1"
35
35
  name = "rush"
36
36
 
37
37
  spec = Gem::Specification.new do |s|
@@ -24,3 +24,4 @@ require 'rush/local'
24
24
  require 'rush/remote'
25
25
  require 'rush/ssh_tunnel'
26
26
  require 'rush/box'
27
+ require 'rush/embeddable_shell'
@@ -0,0 +1,26 @@
1
+ require 'rush/shell'
2
+
3
+ module Rush
4
+ # This is a class that can be embedded in other applications
5
+ # rake tasks, utility scripts, etc
6
+ #
7
+ # Delegates unknown method calls to a Rush::Shell instance
8
+ class EmbeddableShell
9
+ attr_accessor :shell
10
+ def initialize(suppress_output = true)
11
+ self.shell = Rush::Shell.new
12
+ shell.suppress_output = suppress_output
13
+ end
14
+
15
+ # evalutes and unkown method call agains the rush shell
16
+ def method_missing(sym, *args, &block)
17
+ shell.execute sym.to_s
18
+ $last_res
19
+ end
20
+
21
+ # take a whole block and execute it as if it were inside a shell
22
+ def execute_in_shell(&block)
23
+ self.instance_eval(&block)
24
+ end
25
+ end
26
+ end
@@ -3,6 +3,7 @@ require 'readline'
3
3
  # Rush::Shell is used to create an interactive shell. It is invoked by the rush binary.
4
4
  module Rush
5
5
  class Shell
6
+ attr_accessor :suppress_output
6
7
  # Set up the user's environment, including a pure binding into which
7
8
  # env.rb and commands.rb are mixed.
8
9
  def initialize
@@ -68,6 +69,7 @@ module Rush
68
69
 
69
70
  # Nice printing of different return types, particularly Rush::SearchResults.
70
71
  def print_result(res)
72
+ return if self.suppress_output
71
73
  if res.kind_of? String
72
74
  puts res
73
75
  elsif res.kind_of? Rush::SearchResults
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/base'
2
+
3
+ describe Rush::EmbeddableShell do
4
+ before do
5
+ @shell = Rush::EmbeddableShell.new
6
+ end
7
+
8
+ it "should execute unknown methods against a Rush::Shell instance" do
9
+ @shell.root.class.should == Rush::Dir
10
+ end
11
+
12
+ it "should executes a block as if it were inside the shell" do
13
+ @shell.execute_in_shell {
14
+ root.class.should == Rush::Dir
15
+ }
16
+ end
17
+ 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"
4
+ version: 0.4.1
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-07-14 00:00:00 -07:00
12
+ date: 2008-09-10 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -55,48 +55,50 @@ files:
55
55
  - Rakefile
56
56
  - bin/rush
57
57
  - bin/rushd
58
- - lib/rush.rb
59
58
  - lib/rush
59
+ - lib/rush/access.rb
60
+ - lib/rush/array_ext.rb
61
+ - lib/rush/box.rb
62
+ - lib/rush/commands.rb
60
63
  - lib/rush/config.rb
61
- - lib/rush/head_tail.rb
62
- - lib/rush/search_results.rb
64
+ - lib/rush/dir.rb
65
+ - lib/rush/embeddable_shell.rb
63
66
  - lib/rush/entry.rb
64
- - lib/rush/find_by.rb
67
+ - lib/rush/exceptions.rb
65
68
  - lib/rush/file.rb
69
+ - lib/rush/find_by.rb
70
+ - lib/rush/fixnum_ext.rb
71
+ - lib/rush/head_tail.rb
66
72
  - lib/rush/local.rb
67
- - lib/rush/ssh_tunnel.rb
68
- - lib/rush/shell.rb
69
- - lib/rush/server.rb
73
+ - lib/rush/process.rb
70
74
  - lib/rush/process_set.rb
71
- - lib/rush/array_ext.rb
72
75
  - lib/rush/remote.rb
73
- - lib/rush/fixnum_ext.rb
74
- - lib/rush/commands.rb
75
- - lib/rush/process.rb
76
- - lib/rush/dir.rb
76
+ - lib/rush/search_results.rb
77
+ - lib/rush/server.rb
78
+ - lib/rush/shell.rb
79
+ - lib/rush/ssh_tunnel.rb
77
80
  - lib/rush/string_ext.rb
78
- - lib/rush/box.rb
79
- - lib/rush/exceptions.rb
80
- - lib/rush/access.rb
81
- - spec/remote_spec.rb
82
- - spec/base.rb
83
- - spec/ssh_tunnel_spec.rb
84
- - spec/local_spec.rb
81
+ - lib/rush.rb
85
82
  - spec/access_spec.rb
86
- - spec/file_spec.rb
87
- - spec/string_ext_spec.rb
88
83
  - spec/array_ext_spec.rb
84
+ - spec/base.rb
85
+ - spec/box_spec.rb
89
86
  - spec/commands_spec.rb
90
87
  - spec/config_spec.rb
91
- - spec/fixnum_ext_spec.rb
92
- - spec/search_results_spec.rb
93
- - spec/process_spec.rb
94
- - spec/shell_spec.rb
95
88
  - spec/dir_spec.rb
89
+ - spec/embeddable_shell_spec.rb
96
90
  - spec/entry_spec.rb
91
+ - spec/file_spec.rb
97
92
  - spec/find_by_spec.rb
98
- - spec/box_spec.rb
93
+ - spec/fixnum_ext_spec.rb
94
+ - spec/local_spec.rb
99
95
  - spec/process_set_spec.rb
96
+ - spec/process_spec.rb
97
+ - spec/remote_spec.rb
98
+ - spec/search_results_spec.rb
99
+ - spec/shell_spec.rb
100
+ - spec/ssh_tunnel_spec.rb
101
+ - spec/string_ext_spec.rb
100
102
  has_rdoc: true
101
103
  homepage: http://rush.heroku.com/
102
104
  post_install_message: