rsh 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/rsh.rb +17 -9
  3. data/rsh.gemspec +1 -1
  4. metadata +3 -3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
data/lib/rsh.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Creates and operates an 'rsh' command call instance. Parameters to rsh may
4
4
  # be specified through either constructor or attribute accessors. Result of
5
- # rsh execution (_String_) is either returned in functional style (<tt>execute</tt> method call)
5
+ # rsh execution (_String_) is either returned in functional style (<tt>execute!</tt> method call)
6
6
  # or in special attribute, _result_.
7
7
  #
8
8
  # == Synopsis
@@ -12,10 +12,12 @@
12
12
  # rsh = Rsh.new(:host => "c7206", :ruser => "bill",
13
13
  # :command => "show clock")
14
14
  #
15
- # rsh.execute do |line| puts line end
15
+ # rsh.execute! do |line| puts line end
16
16
  #
17
17
  # 18:30:46.799 MSD Fri Oct 22 2010
18
18
  #
19
+ # * See c) case in execute! method comment.
20
+ #
19
21
  # === Example:
20
22
  #
21
23
  # This is an example of rsh in action usin interactive Ruby.
@@ -27,7 +29,7 @@
27
29
  # :command => "show clock")
28
30
  # => #<Rsh:0x2853f390 @ruser="bill", @executable="/usr/bin/rsh", @result="", @command="show clock", @nullr=false, @host="c7206", @to=3>
29
31
  #
30
- # irb(main):003:0> rsh.execute do |line| puts line end
32
+ # irb(main):003:0> rsh.execute! do |line| puts line end
31
33
  #
32
34
  # 18:30:46.799 MSD Fri Oct 22 2010
33
35
  # => "\r\n18:30:46.799 MSD Fri Oct 22 2010\n"
@@ -61,7 +63,7 @@ class Rsh
61
63
  attr_accessor :nullr
62
64
 
63
65
  # The Constructor. Checks the presence of rsh in the system (running,
64
- # naturally, 'which rsh') and prepares the command to be run with <tt>execute</tt>.
66
+ # naturally, 'which rsh') and prepares the command to be run with <tt>execute!</tt>.
65
67
  # rsh CLI arguments are either having default values, being collected from constructor
66
68
  # call or specified via accessors.
67
69
  #
@@ -108,18 +110,22 @@ class Rsh
108
110
  # Call sequence:
109
111
  #
110
112
  # a)
111
- # rsh_inst.execute do |line|
113
+ # rsh_inst.execute! do |line|
112
114
  # puts line
113
- # done -> complete_result_String
115
+ # done #=> complete_result_String
114
116
  # b)
115
- # rsh_inst.execute -> complete_result_String
117
+ # rsh_inst.execute! #=> complete_result_String
118
+ # c)
119
+ # rsh_inst.execute! "remote_command" #=> same as above, but replacing
120
+ # @command with the given string
116
121
  #
117
122
  # Returns:: the complete rsh output as one _String_. The result is also
118
123
  # stored and available via _result_ attribute.
119
124
  #
120
- def execute
125
+ def execute!(command=nil)
126
+ @command = command if command
121
127
  @result = ""
122
- open "|#{executable} #{"-n" if @nullr} -l#{ruser} -t#{to} #{host} #{command}" do |io|
128
+ open "|#{@executable} #{"-n" if @nullr} -l#{@ruser} -t#{@to} #{@host} #{@command}" do |io|
123
129
  io.each do |line|
124
130
  yield(line) if block_given?
125
131
  @result << line
@@ -128,4 +134,6 @@ class Rsh
128
134
  @result
129
135
  end
130
136
 
137
+ alias :execute :execute!
138
+
131
139
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rsh}
8
- s.version = "0.1.2"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Pavel Argentov"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsh
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
8
  - 2
10
- version: 0.1.2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pavel Argentov