rye 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -1,9 +1,12 @@
1
1
  RYE, CHANGES
2
2
 
3
- TODO
4
3
 
5
- * Re-implement Rye::Rap as an Observable StringIO object for dynamic printing of output.
6
- * Fingerprints: ssh-keygen -l -f id_rsa_repos.pub
4
+ #### 0.8.7 (2009-08-11) #############################
5
+
6
+ * FIXED: Rye::Box info level output is cleaner
7
+ * FIXED: file_upload / download now expanding local tildas when safemode is disabled
8
+ * ADDED: Interactive handling for removing gems
9
+ * ADDED: dir_upload and dir_download
7
10
 
8
11
 
9
12
  #### 0.8.6 (2009-08-04) #############################
@@ -277,3 +280,8 @@ Rye.shell and Rye::Box.run_command (SSH) commands.
277
280
 
278
281
  Initial public release
279
282
 
283
+
284
+ #### TODO ###########################################
285
+
286
+ * Re-implement Rye::Rap as an Observable StringIO object for dynamic printing of output.
287
+ * Fingerprints: ssh-keygen -l -f id_rsa_repos.pub
data/lib/rye.rb CHANGED
@@ -43,7 +43,7 @@ module Rye
43
43
  extend self
44
44
 
45
45
  unless defined?(SYSINFO)
46
- VERSION = "0.8.6".freeze
46
+ VERSION = "0.8.7".freeze
47
47
  SYSINFO = SysInfo.new.freeze
48
48
  end
49
49
 
data/lib/rye/box.rb CHANGED
@@ -169,7 +169,7 @@ module Rye
169
169
  @rye_current_working_directory = fpath
170
170
  end
171
171
  end
172
- info "CWD: #{@rye_current_working_directory}"
172
+ debug "CWD: #{@rye_current_working_directory}"
173
173
  self
174
174
  end
175
175
  # Like [] except it returns an empty Rye::Rap object to mimick
@@ -720,7 +720,7 @@ module Rye
720
720
  ## raise Rye::CommandNotFound unless self.can?(cmd)
721
721
 
722
722
  begin
723
- info "COMMAND: #{cmd_internal}"
723
+ debug "COMMAND: #{cmd_internal}"
724
724
 
725
725
  if !@rye_quiet && @rye_pre_command_hook.is_a?(Proc)
726
726
  @rye_pre_command_hook.call(cmd_clean, user, host, nickname)
@@ -802,11 +802,11 @@ module Rye
802
802
  #
803
803
  def net_ssh_exec!(command)
804
804
 
805
- block ||= Proc.new do |channel, type, data|
805
+ block ||= Proc.new do |channel, type, data, tt|
806
806
 
807
807
  channel[:stdout] ||= ""
808
808
  channel[:stderr] ||= ""
809
- channel[:stdout] << data if type == :stdout
809
+
810
810
 
811
811
  if type == :stderr
812
812
  # NOTE: Use sudo to test this since it prompts for a passwords.
@@ -824,7 +824,15 @@ module Rye
824
824
  # return the following error and appear to hang. We
825
825
  # catch it and raise the appropriate exception.
826
826
  raise Rye::NoPty if data =~ /Pseudo-terminal will not/
827
-
827
+ elsif type == :stdout
828
+ if data =~ /Select gem to uninstall/i
829
+ puts data
830
+ ret = Annoy.get_user_input('')
831
+ raise "No input given" if ret.nil?
832
+ channel.send_data "#{ret}\n"
833
+ else
834
+ channel[:stdout] << data
835
+ end
828
836
  end
829
837
 
830
838
  end
@@ -865,6 +873,7 @@ module Rye
865
873
 
866
874
 
867
875
  # * +direction+ is one of :upload, :download
876
+ # * +recursive+ should be true for directories and false for files.
868
877
  # * +files+ is an Array of file paths, the content is direction specific.
869
878
  # For downloads, +files+ is a list of files to download. The last element
870
879
  # must be the local directory to download to. If downloading a single file
@@ -878,14 +887,14 @@ module Rye
878
887
  # parameters. An exception is raised and no files are transferred.
879
888
  # Uploads always return nil. Downloads return nil or a StringIO object if
880
889
  # one is specified for the target.
881
- def net_scp_transfer!(direction, *files)
882
- direction ||= ''
890
+ def net_scp_transfer!(direction, recursive, *files)
891
+
883
892
  unless [:upload, :download].member?(direction.to_sym)
884
893
  raise "Must be one of: upload, download"
885
894
  end
886
895
 
887
896
  if @rye_current_working_directory
888
- info "CWD (#{@rye_current_working_directory})"
897
+ debug "CWD (#{@rye_current_working_directory})"
889
898
  end
890
899
 
891
900
  files = [files].flatten.compact || []
@@ -911,7 +920,10 @@ module Rye
911
920
 
912
921
  # Expand fileglobs (e.g. path/*.rb becomes [path/1.rb, path/2.rb]).
913
922
  # This should happen after checking files.size to determine the target
914
- files = files.collect { |file| Dir.glob file }.flatten unless @rye_safe
923
+ unless @rye_safe
924
+ files.collect! { |file| Dir.glob File.expand_path(file) }
925
+ files.flatten!
926
+ end
915
927
  end
916
928
 
917
929
  # Fail early. We check whether the StringIO object is available to read
@@ -924,10 +936,10 @@ module Rye
924
936
  end
925
937
  end
926
938
 
927
- info "#{direction.to_s.upcase} TO: #{target}"
939
+ info "#{direction.to_s} to: #{target}"
928
940
  debug "FILES: " << files.join(', ')
929
941
 
930
- # Make sure the remote directory exists. We can do this only when
942
+ # Make sure the target directory exists. We can do this only when
931
943
  # there's more than one file because "target" could be a file name
932
944
  if files.size > 1 && !target.is_a?(StringIO)
933
945
  debug "CREATING TARGET DIRECTORY: #{target}"
@@ -936,14 +948,20 @@ module Rye
936
948
 
937
949
  Net::SCP.start(@rye_host, @rye_opts[:user], @rye_opts || {}) do |scp|
938
950
  transfers = []
951
+ prev = ""
939
952
  files.each do |file|
940
953
  debug file.to_s
941
- transfers << scp.send(direction, file, target) do |ch, n, s, t|
942
- pinfo "#{n}: #{s}/#{t}b\r" # update line: "file: sent/total"
954
+ prev = ""
955
+ transfers << scp.send(direction, file, target, :recursive => recursive) do |ch, n, s, t|
956
+ line = "%-50s %6d/%-6d bytes" % [n, s, t]
957
+ spaces = (prev.size > line.size) ? ' '*(prev.size - line.size) : ''
958
+ pinfo "%s %s \r" % [line, spaces] # update line: "file: sent/total"
943
959
  @rye_info.flush if @rye_info # make sure every line is printed
960
+ prev = line
944
961
  end
945
962
  end
946
963
  transfers.each { |t| t.wait } # Run file transfers in parallel
964
+ pinfo (' '*prev.size) << "\r"
947
965
  info $/
948
966
  end
949
967
 
data/lib/rye/cmd.rb CHANGED
@@ -25,11 +25,11 @@ module Rye;
25
25
 
26
26
  # NOTE: See Rye::Box for the implementation of cd
27
27
  #def cd(*args); cmd('cd', args); end
28
+ #def rm(*args); cmd('rm', args); end
28
29
  def wc(*args); cmd('wc', args); end
29
30
  def cp(*args); cmd("cp", args); end
30
31
  def mv(*args); cmd("mv", args); end
31
32
  def ls(*args); cmd('ls', args); end
32
- #def rm(*args); cmd('rm', args); end
33
33
  def ps(*args); cmd('ps', args); end
34
34
  def sh(*args); cmd('sh', args); end
35
35
  def df(*args); cmd('df', args); end
@@ -47,6 +47,7 @@ module Rye;
47
47
  def tar(*args); cmd('tar', args); end
48
48
 
49
49
  #def kill(*args); cmd('kill', args); end
50
+ def rake(*args); cmd('sudo', args); end
50
51
  def sudo(*args); cmd('sudo', args); end
51
52
  def grep(*args); cmd('grep', args); end
52
53
  def date(*args); cmd('date', args); end
@@ -83,11 +84,11 @@ module Rye;
83
84
  def printenv(*args); cmd('printenv', args); end
84
85
  def hostname(*args); cmd('hostname', args); end
85
86
  def rudy_ec2(*args); cmd('rudy-ec2', args); end
86
- def rudy_edb(*args); cmd('rudy-sdb', args); end
87
+ def rudy_sdb(*args); cmd('rudy-sdb', args); end
87
88
  def configure(*args); cmd('./configure', args); end
88
89
 
89
90
  # Transfer files to a machine via Net::SCP.
90
- # * +files+ is an Array of files to upload. The last element is the
91
+ # * +paths+ is an Array of files to upload. The last element is the
91
92
  # directory to upload to. If uploading a single file, the last element
92
93
  # can be a file path. The list of files can also include StringIO objects.
93
94
  # The target directory will be created if it does not exist, but only
@@ -97,10 +98,10 @@ module Rye;
97
98
  # Always return nil.
98
99
  #
99
100
  # NOTE: Changes to current working directory with +cd+ or +[]+ are ignored.
100
- def file_upload(*files); net_scp_transfer!(:upload, *files); end
101
+ def file_upload(*paths); net_scp_transfer!(:upload, false, *paths); end
101
102
 
102
103
  # Transfer files from a machine via Net::SCP.
103
- # * +files+ is an Array of files to download. The last element must be the
104
+ # * +paths+ is an Array of files to download. The last element must be the
104
105
  # local directory to download to. If downloading a single file the last
105
106
  # element can be a file path. The target can also be a StringIO object.
106
107
  # The target directory will be created if it does not exist, but only
@@ -110,13 +111,25 @@ module Rye;
110
111
  # Return nil or a StringIO object, if specified as the target.
111
112
  #
112
113
  # NOTE: Changes to current working directory with +cd+ or +[]+ are ignored.
113
- def file_download(*files); net_scp_transfer!(:download, *files); end
114
+ def file_download(*paths); net_scp_transfer!(:download, false, *paths); end
115
+
116
+ # Same as file_upload except directories are processed recursively. If
117
+ # any supplied paths are directories you need to use this method and not
118
+ # file_upload.
119
+ def dir_upload(*paths); net_scp_transfer!(:upload, true, *paths); end
120
+ alias_method :directory_upload, :dir_upload
121
+
122
+ # Same as file_download except directories are processed recursively. If
123
+ # any supplied paths are directories you need to use this method and not
124
+ # file_download.
125
+ def dir_download(*paths); net_scp_transfer!(:download, true, *paths); end
126
+ alias_method :directory_download, :dir_download
114
127
 
115
128
  # Shorthand for +file_download('remote/path').string+
116
129
  #
117
- # Returns a String containing the content of all remote *files*.
118
- def string_download(*files)
119
- net_scp_transfer!(:download, *files).string
130
+ # Returns a String containing the content of all remote *paths*.
131
+ def string_download(*paths)
132
+ net_scp_transfer!(:download, *paths).string
120
133
  end
121
134
  alias_method :str_download, :string_download
122
135
 
data/rye.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  @spec = Gem::Specification.new do |s|
2
2
  s.name = "rye"
3
3
  s.rubyforge_project = "rye"
4
- s.version = "0.8.6"
4
+ s.version = "0.8.7"
5
5
  s.summary = "Rye: Safely run SSH commands on a bunch of machines at the same time (from Ruby)."
6
6
  s.description = s.summary
7
7
  s.author = "Delano Mandelbaum"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rye
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.6
4
+ version: 0.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-04 00:00:00 -04:00
12
+ date: 2009-08-11 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency