rye 0.8.19 → 0.9.0
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/CHANGES.txt +17 -1
- data/README.rdoc +2 -29
- data/bin/try +42 -13
- data/lib/rye/box.rb +318 -224
- data/lib/rye/cmd.rb +156 -78
- data/lib/rye/rap.rb +10 -6
- data/lib/rye.rb +32 -5
- data/rye.gemspec +4 -7
- metadata +68 -49
- data/bin/rye +0 -147
    
        data/lib/rye/cmd.rb
    CHANGED
    
    | @@ -11,7 +11,7 @@ module Rye; | |
| 11 11 | 
             
              #
         | 
| 12 12 | 
             
              #     require 'rye'
         | 
| 13 13 | 
             
              #     module Rye::Box::Cmd
         | 
| 14 | 
            -
              #       def special(*args);  | 
| 14 | 
            +
              #       def special(*args); run_command("/your/special/command", args); end
         | 
| 15 15 | 
             
              #     end
         | 
| 16 16 | 
             
              #
         | 
| 17 17 | 
             
              #     rbox = Rye::Box.new('somehost')
         | 
| @@ -19,83 +19,120 @@ module Rye; | |
| 19 19 | 
             
              #
         | 
| 20 20 | 
             
              module Cmd
         | 
| 21 21 |  | 
| 22 | 
            +
                def __shell(cmd, *args, &blk)
         | 
| 23 | 
            +
                  self.rye_shell = true
         | 
| 24 | 
            +
                  rap = run_command cmd, *args, &blk
         | 
| 25 | 
            +
                  self.rye_shell = false
         | 
| 26 | 
            +
                  rap
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
                private :__shell
         | 
| 29 | 
            +
                
         | 
| 30 | 
            +
                # When called without a block this will open an 
         | 
| 31 | 
            +
                # interactive shell session. 
         | 
| 32 | 
            +
                def bash(*args, &blk)
         | 
| 33 | 
            +
                  setenv('PS1', "(rye) \\h:\\w \\u\\$\ ")
         | 
| 34 | 
            +
                  __shell 'bash', *args, &blk
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
                
         | 
| 37 | 
            +
                # When called without a block this will open an 
         | 
| 38 | 
            +
                # interactive shell session.
         | 
| 39 | 
            +
                def irb(*args, &blk)
         | 
| 40 | 
            +
                    __shell 'irb', *args, &blk
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
                
         | 
| 43 | 
            +
                # When called without a block this will open an 
         | 
| 44 | 
            +
                # interactive shell session.
         | 
| 45 | 
            +
                def sh(*args, &blk)
         | 
| 46 | 
            +
                  setenv('PS1', "(rye) $\ ")
         | 
| 47 | 
            +
                  __shell 'sh', *args, &blk
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
                
         | 
| 22 50 | 
             
                # NOTE: See Rye::Box for the implementation of cd
         | 
| 23 | 
            -
                #def cd(*args) | 
| 24 | 
            -
                #def rm(*args) | 
| 25 | 
            -
                def wc(*args) | 
| 26 | 
            -
                def cp(*args) | 
| 27 | 
            -
                def mv(*args) | 
| 28 | 
            -
                def ls(*args) | 
| 29 | 
            -
                def ps(*args) | 
| 30 | 
            -
                def  | 
| 31 | 
            -
                def  | 
| 32 | 
            -
                def  | 
| 33 | 
            -
                def  | 
| 34 | 
            -
                def  | 
| 35 | 
            -
                def  | 
| 36 | 
            -
                def  | 
| 51 | 
            +
                #def cd(*args) run_command('cd', args) end
         | 
| 52 | 
            +
                #def rm(*args) run_command('rm', args) end
         | 
| 53 | 
            +
                def wc(*args) run_command('wc', args) end
         | 
| 54 | 
            +
                def cp(*args) run_command("cp", args) end
         | 
| 55 | 
            +
                def mv(*args) run_command("mv", args) end
         | 
| 56 | 
            +
                def ls(*args) run_command('ls', args) end
         | 
| 57 | 
            +
                def ps(*args) run_command('ps', args) end
         | 
| 58 | 
            +
                def df(*args) run_command('df', args) end
         | 
| 59 | 
            +
                def du(*args) run_command('du', args) end
         | 
| 60 | 
            +
                def su(*args) run_command('su', args) end
         | 
| 61 | 
            +
                def ln(*args) run_command('ln', args) end
         | 
| 62 | 
            +
                def ab(*args) run_command('ab', args) end
         | 
| 63 | 
            +
                def hg(*args) run_command('hg', args) end
         | 
| 64 | 
            +
                def xz(*args) run_command('xz', args) end
         | 
| 37 65 |  | 
| 38 | 
            -
                def env | 
| 39 | 
            -
                def rye(*args) | 
| 40 | 
            -
                def pwd(*args) | 
| 41 | 
            -
                def svn(*args) | 
| 42 | 
            -
                def cvs(*args) | 
| 43 | 
            -
                def git(*args) | 
| 44 | 
            -
                def sed(*args) | 
| 45 | 
            -
                def awk(*args) | 
| 46 | 
            -
                def cat(*args) | 
| 47 | 
            -
                def tar(*args) | 
| 66 | 
            +
                def env()      run_command('env')       end
         | 
| 67 | 
            +
                def rye(*args) run_command('rye', args) end
         | 
| 68 | 
            +
                def pwd(*args) run_command('pwd', args) end
         | 
| 69 | 
            +
                def svn(*args) run_command('svn', args) end
         | 
| 70 | 
            +
                def cvs(*args) run_command('cvs', args) end
         | 
| 71 | 
            +
                def git(*args) run_command('git', args) end
         | 
| 72 | 
            +
                def sed(*args) run_command('sed', args) end
         | 
| 73 | 
            +
                def awk(*args) run_command('awk', args) end
         | 
| 74 | 
            +
                def cat(*args) run_command('cat', args) end
         | 
| 75 | 
            +
                def tar(*args) run_command('tar', args) end
         | 
| 76 | 
            +
                def try(*args) run_command('tar', args) end
         | 
| 48 77 |  | 
| 49 | 
            -
                #def kill(*args) | 
| 50 | 
            -
                def rake(*args) | 
| 51 | 
            -
                def grep(*args) | 
| 52 | 
            -
                def date(*args) | 
| 53 | 
            -
                def  | 
| 54 | 
            -
                def  | 
| 55 | 
            -
                def  | 
| 56 | 
            -
                def  | 
| 57 | 
            -
                def  | 
| 58 | 
            -
                def  | 
| 59 | 
            -
                def  | 
| 60 | 
            -
                def  | 
| 61 | 
            -
                def  | 
| 62 | 
            -
                def  | 
| 63 | 
            -
                def  | 
| 78 | 
            +
                #def kill(*args) run_command('kill', args) end
         | 
| 79 | 
            +
                def rake(*args) run_command('rake', args) end
         | 
| 80 | 
            +
                def grep(*args) run_command('grep', args) end
         | 
| 81 | 
            +
                def date(*args) run_command('date', args) end
         | 
| 82 | 
            +
                def rudy(*args) run_command('rudy', args) end
         | 
| 83 | 
            +
                def perl(*args) run_command('perl', args) end
         | 
| 84 | 
            +
                def ruby(*args) run_command('ruby', args) end
         | 
| 85 | 
            +
                def echo(*args) run_command('echo', args) end
         | 
| 86 | 
            +
                def test(*args) run_command('test', args) end
         | 
| 87 | 
            +
                def mkfs(*args) run_command('mkfs', args) end
         | 
| 88 | 
            +
                def gzip(*args) run_command('gzip', args) end
         | 
| 89 | 
            +
                def make(*args) run_command('make', args) end
         | 
| 90 | 
            +
                def wget(*args) run_command('wget', args) end
         | 
| 91 | 
            +
                def curl(*args) run_command('curl', args) end
         | 
| 92 | 
            +
                def dpkg(*args) run_command('dpkg', args) end
         | 
| 93 | 
            +
                def tail(*args) run_command('tail', args) end
         | 
| 94 | 
            +
                def unxz(*args) run_command('unxz', args) end
         | 
| 64 95 |  | 
| 65 | 
            -
                def mount(*args) | 
| 66 | 
            -
                def sleep(*args) | 
| 67 | 
            -
                def mkdir(*args) | 
| 68 | 
            -
                def touch(*args) | 
| 69 | 
            -
                def uname(*args) | 
| 70 | 
            -
                def chmod(*args) | 
| 71 | 
            -
                def chown(*args) | 
| 72 | 
            -
                def unzip(*args) | 
| 73 | 
            -
                def bzip2(*args) | 
| 74 | 
            -
                def which(*args) | 
| 75 | 
            -
                def siege(*args) | 
| 96 | 
            +
                def mount(*args) run_command("mount", args) end
         | 
| 97 | 
            +
                def sleep(*args) run_command("sleep", args) end
         | 
| 98 | 
            +
                def mkdir(*args) run_command('mkdir', args) end
         | 
| 99 | 
            +
                def touch(*args) run_command('touch', args) end
         | 
| 100 | 
            +
                def uname(*args) run_command('uname', args) end
         | 
| 101 | 
            +
                def chmod(*args) run_command('chmod', args) end
         | 
| 102 | 
            +
                def chown(*args) run_command('chown', args) end
         | 
| 103 | 
            +
                def unzip(*args) run_command('unzip', args) end
         | 
| 104 | 
            +
                def bzip2(*args) run_command('bzip2', args) end
         | 
| 105 | 
            +
                def which(*args) run_command('which', args) end
         | 
| 106 | 
            +
                def siege(*args) run_command("siege", args) end
         | 
| 76 107 |  | 
| 77 | 
            -
                def  | 
| 78 | 
            -
                def  | 
| 79 | 
            -
                def  | 
| 80 | 
            -
                def  | 
| 81 | 
            -
                def  | 
| 82 | 
            -
                def  | 
| 83 | 
            -
                def  | 
| 84 | 
            -
             | 
| 85 | 
            -
                def  | 
| 86 | 
            -
                def  | 
| 87 | 
            -
                def  | 
| 88 | 
            -
                def  | 
| 89 | 
            -
                def  | 
| 90 | 
            -
             | 
| 91 | 
            -
                def  | 
| 108 | 
            +
                def stella(*args) run_command("stella", args) end
         | 
| 109 | 
            +
                def umount(*args) run_command("umount", args) end
         | 
| 110 | 
            +
                def stella(*args) run_command('stella', args) end
         | 
| 111 | 
            +
                def uptime(*args) run_command("uptime", args) end
         | 
| 112 | 
            +
                def python(*args) run_command('python', args) end
         | 
| 113 | 
            +
                def gunzip(*args) run_command('gunzip', args) end
         | 
| 114 | 
            +
                def whoami(*args) run_command('whoami', args) end
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                def useradd(*args) run_command('useradd', args) end
         | 
| 117 | 
            +
                def bunzip2(*args) run_command('bunzip2', args) end
         | 
| 118 | 
            +
                def getconf(*args) run_command('getconf', args) end
         | 
| 119 | 
            +
                def history(*args) run_command('history', args) end
         | 
| 120 | 
            +
                def rudy_s3(*args) run_command('rudy-s3', args) end
         | 
| 121 | 
            +
             | 
| 122 | 
            +
                def aptitude(*args) run_command('aptitude', args) end
         | 
| 123 | 
            +
                def printenv(*args) run_command('printenv', args) end
         | 
| 124 | 
            +
                def hostname(*args) run_command('hostname', args) end
         | 
| 125 | 
            +
                def ldconfig(*args) run_command('ldconfig', args) end
         | 
| 126 | 
            +
                def rudy_ec2(*args) run_command('rudy-ec2', args) end
         | 
| 127 | 
            +
                def rudy_sdb(*args) run_command('rudy-sdb', args) end
         | 
| 128 | 
            +
                  
         | 
| 129 | 
            +
                def configure(*args) run_command('./configure', args) end
         | 
| 92 130 |  | 
| 93 131 | 
             
                #--
         | 
| 94 132 | 
             
                # WINDOWS
         | 
| 95 133 | 
             
                #++
         | 
| 96 | 
            -
                def dir(*args);  | 
| 97 | 
            -
             | 
| 98 | 
            -
                
         | 
| 134 | 
            +
                def dir(*args); run_command('cmd', args); end
         | 
| 135 | 
            +
                    
         | 
| 99 136 | 
             
                # Transfer files to a machine via Net::SCP. 
         | 
| 100 137 | 
             
                # * +paths+ is an Array of files to upload. The last element is the 
         | 
| 101 138 | 
             
                # directory to upload to. If uploading a single file, the last element
         | 
| @@ -149,11 +186,20 @@ module Rye; | |
| 149 186 | 
             
                  net_scp_transfer!(:upload, StringIO.new(str), remote_path)
         | 
| 150 187 | 
             
                end
         | 
| 151 188 | 
             
                alias_method :str_upload, :string_upload
         | 
| 152 | 
            -
                  
         | 
| 153 189 |  | 
| 190 | 
            +
                # Shorthand for +file_append('remote/path', StringIO.new('file content'))+
         | 
| 191 | 
            +
                #
         | 
| 192 | 
            +
                # Appends the content of the String +str+ to +remote_path+. Returns nil
         | 
| 193 | 
            +
                def string_append(filepath, newcontent, backup=false)
         | 
| 194 | 
            +
                  file_append(remote_path, StringIO.new(str), backup)
         | 
| 195 | 
            +
                end
         | 
| 196 | 
            +
                alias_method :str_upload, :string_upload
         | 
| 197 | 
            +
                    
         | 
| 154 198 | 
             
                # Append +newcontent+ to remote +filepath+. If the file doesn't exist
         | 
| 155 199 | 
             
                # it will be created. If +backup+ is specified, +filepath+ will be 
         | 
| 156 200 | 
             
                # copied to +filepath-previous+ before appending. 
         | 
| 201 | 
            +
                #
         | 
| 202 | 
            +
                # NOTE: Not recommended for large files. It downloads the contents.
         | 
| 157 203 | 
             
                def file_append(filepath, newcontent, backup=false)
         | 
| 158 204 | 
             
                  content = StringIO.new
         | 
| 159 205 |  | 
| @@ -185,22 +231,54 @@ module Rye; | |
| 185 231 | 
             
                  self.file_upload content, filepath
         | 
| 186 232 | 
             
                end
         | 
| 187 233 |  | 
| 188 | 
            -
                 | 
| 189 | 
            -
                 | 
| 190 | 
            -
             | 
| 191 | 
            -
                 | 
| 192 | 
            -
                 | 
| 234 | 
            +
                
         | 
| 235 | 
            +
                def template_write(filepath, template)
         | 
| 236 | 
            +
                  template_upload template, filepath
         | 
| 237 | 
            +
                end
         | 
| 238 | 
            +
                
         | 
| 239 | 
            +
                # Parse a template and upload that as a file to remote_path.
         | 
| 240 | 
            +
                def template_upload(*paths)
         | 
| 241 | 
            +
                  remote_path = paths.pop
         | 
| 242 | 
            +
                  templates = []
         | 
| 243 | 
            +
                  paths.collect! do |path|      
         | 
| 244 | 
            +
                    if StringIO === path
         | 
| 245 | 
            +
                      path.rewind
         | 
| 246 | 
            +
                      template = Rye::Tpl.new(path.read, "inline-template")
         | 
| 247 | 
            +
                    elsif String === path
         | 
| 248 | 
            +
                      raise "No such file: #{Dir.pwd}/#{path}" unless File.exists?(path)
         | 
| 249 | 
            +
                      template = Rye::Tpl.new(File.read(path), File.basename(path))
         | 
| 250 | 
            +
                    end
         | 
| 251 | 
            +
                    template.result!(binding)
         | 
| 252 | 
            +
                    templates << template
         | 
| 253 | 
            +
                    template.path
         | 
| 254 | 
            +
                  end
         | 
| 255 | 
            +
                  paths << remote_path
         | 
| 256 | 
            +
                  ret = self.file_upload *paths
         | 
| 257 | 
            +
                  templates.each { |template| 
         | 
| 258 | 
            +
                    tmp_path = File.join(remote_path, File.basename(template.path))
         | 
| 259 | 
            +
                    if file_exists?(tmp_path)
         | 
| 260 | 
            +
                      mv tmp_path, File.join(remote_path, template.basename)
         | 
| 261 | 
            +
                    end
         | 
| 262 | 
            +
                    template.delete 
         | 
| 263 | 
            +
                  }
         | 
| 264 | 
            +
                  ret
         | 
| 265 | 
            +
                end
         | 
| 266 | 
            +
                
         | 
| 267 | 
            +
                def file_modify(filepath, regexp, replace=nil)
         | 
| 268 | 
            +
                  raise "File not found: #{filepath}" unless file_exists?(filepath)
         | 
| 269 | 
            +
                  sed :i, :r, "s/#{regexp}/#{replace}/", filepath
         | 
| 270 | 
            +
                end
         | 
| 193 271 |  | 
| 194 272 | 
             
                # Does +path+ from the current working directory?
         | 
| 195 273 | 
             
                def file_exists?(path)
         | 
| 196 274 | 
             
                  begin
         | 
| 197 275 | 
             
                    ret = self.quietly { ls(path) }
         | 
| 198 | 
            -
                  rescue Rye:: | 
| 276 | 
            +
                  rescue Rye::Err => ex
         | 
| 199 277 | 
             
                    ret = ex.rap
         | 
| 200 278 | 
             
                  end
         | 
| 201 279 | 
             
                  # "ls" returns a 0 exit code regardless of success in Linux
         | 
| 202 280 | 
             
                  # But on OSX exit code is 1. This is why we look at STDERR. 
         | 
| 203 | 
            -
                  ret.stderr.empty?
         | 
| 281 | 
            +
                  !(ret.exit_status > 0) || ret.stderr.empty?
         | 
| 204 282 | 
             
                end
         | 
| 205 283 |  | 
| 206 284 | 
             
                # Does the calculated digest of +path+ match the known +expected_digest+?
         | 
| @@ -275,7 +353,7 @@ module Rye; | |
| 275 353 | 
             
                    define_method(meth) do |*args|
         | 
| 276 354 | 
             
                      local_args = hard_args.clone
         | 
| 277 355 | 
             
                      local_args += args
         | 
| 278 | 
            -
                       | 
| 356 | 
            +
                      run_command(path, *local_args)
         | 
| 279 357 | 
             
                    end        
         | 
| 280 358 | 
             
                  end
         | 
| 281 359 | 
             
                end
         | 
    
        data/lib/rye/rap.rb
    CHANGED
    
    | @@ -20,7 +20,7 @@ module Rye; | |
| 20 20 |  | 
| 21 21 | 
             
                 # An array containing any STDERR output 
         | 
| 22 22 | 
             
                attr_reader :stderr
         | 
| 23 | 
            -
                attr_reader : | 
| 23 | 
            +
                attr_reader :exit_status
         | 
| 24 24 | 
             
                  # Only populated when calling via Rye::Shell 
         | 
| 25 25 | 
             
                attr_reader :pid 
         | 
| 26 26 | 
             
                attr_accessor :exit_signal
         | 
| @@ -32,7 +32,7 @@ module Rye; | |
| 32 32 | 
             
                # * +args+ anything that can sent to Array#new
         | 
| 33 33 | 
             
                def initialize(obj, *args)
         | 
| 34 34 | 
             
                  @obj = obj
         | 
| 35 | 
            -
                  @ | 
| 35 | 
            +
                  @exit_status = -1
         | 
| 36 36 | 
             
                  @stderr = []
         | 
| 37 37 | 
             
                  super *args
         | 
| 38 38 | 
             
                end
         | 
| @@ -40,6 +40,10 @@ module Rye; | |
| 40 40 | 
             
                alias :box :obj
         | 
| 41 41 | 
             
                alias :set :obj
         | 
| 42 42 |  | 
| 43 | 
            +
                def inspect
         | 
| 44 | 
            +
                  "[%s, %s, %s, %s]" % [self.join("").tr("\r", ''), @stderr.join("; ").tr("\r", ''), exit_status, exit_signal]
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
                
         | 
| 43 47 | 
             
                # Returns a reference to the Rye::Rap object (which 
         | 
| 44 48 | 
             
                # acts like an Array that contains the STDOUT from the
         | 
| 45 49 | 
             
                # command executed over SSH). This is available to 
         | 
| @@ -79,16 +83,16 @@ module Rye; | |
| 79 83 | 
             
                # set to -1 (JRuby doesn't return the pid).   
         | 
| 80 84 | 
             
                #
         | 
| 81 85 | 
             
                # Returns the exit code as an Integer. 
         | 
| 82 | 
            -
                def  | 
| 86 | 
            +
                def add_exit_status(code)
         | 
| 83 87 | 
             
                  code = 0 if code.nil?
         | 
| 84 88 | 
             
                  if code.is_a?(Process::Status)
         | 
| 85 | 
            -
                    @ | 
| 89 | 
            +
                    @exit_status = code.exitstatus.to_i
         | 
| 86 90 | 
             
                    @pid = Rye.sysinfo.vm == :java ? '-1' : code.pid
         | 
| 87 91 | 
             
                  else
         | 
| 88 | 
            -
                    @ | 
| 92 | 
            +
                    @exit_status = code.to_i
         | 
| 89 93 | 
             
                  end
         | 
| 90 94 | 
             
                end
         | 
| 91 | 
            -
                def code; @ | 
| 95 | 
            +
                def code; @exit_status; end
         | 
| 92 96 |  | 
| 93 97 | 
             
                # Returns the first element if there's only the
         | 
| 94 98 | 
             
                # one, an empty String if there's none. Returns
         | 
    
        data/lib/rye.rb
    CHANGED
    
    | @@ -42,7 +42,7 @@ require 'esc' | |
| 42 42 | 
             
            module Rye
         | 
| 43 43 | 
             
              extend self
         | 
| 44 44 |  | 
| 45 | 
            -
              VERSION = "0. | 
| 45 | 
            +
              VERSION = "0.9.0".freeze unless defined?(VERSION)
         | 
| 46 46 |  | 
| 47 47 | 
             
              @@sysinfo = nil
         | 
| 48 48 | 
             
              @@agent_env = Hash.new  # holds ssh-agent env vars
         | 
| @@ -68,18 +68,18 @@ module Rye | |
| 68 68 | 
             
              class NoPty < RyeError
         | 
| 69 69 | 
             
                def message; "Could not obtain pty (i.e. an interactive ssh session)"; end
         | 
| 70 70 | 
             
              end
         | 
| 71 | 
            -
              class  | 
| 71 | 
            +
              class Err < RyeError
         | 
| 72 72 | 
             
                attr_reader :rap
         | 
| 73 73 | 
             
                # * +rap+ a Rye::Rap object
         | 
| 74 74 | 
             
                def initialize(rap)
         | 
| 75 75 | 
             
                  @rap = rap
         | 
| 76 76 | 
             
                end
         | 
| 77 77 | 
             
                def message
         | 
| 78 | 
            -
                  "%s ( | 
| 78 | 
            +
                  "%s (cmd: %s; status: %s)" % [@rap.stderr.join($/), @rap.cmd, @rap.exit_status]
         | 
| 79 79 | 
             
                end
         | 
| 80 80 | 
             
                def stderr; @rap.stderr if @rap; end
         | 
| 81 81 | 
             
                def stdout; @rap.stdout if @rap; end
         | 
| 82 | 
            -
                def  | 
| 82 | 
            +
                def exit_status; @rap.exit_status if @rap; end
         | 
| 83 83 | 
             
              end
         | 
| 84 84 |  | 
| 85 85 | 
             
              # Reload Rye dynamically. Useful with irb. 
         | 
| @@ -223,7 +223,7 @@ module Rye | |
| 223 223 | 
             
                rap = Rye::Rap.new(self)
         | 
| 224 224 | 
             
                rap.add_stdout(stdout || '')
         | 
| 225 225 | 
             
                rap.add_stderr(stderr || '')
         | 
| 226 | 
            -
                rap. | 
| 226 | 
            +
                rap.add_exit_status($?)
         | 
| 227 227 | 
             
                rap
         | 
| 228 228 | 
             
              end
         | 
| 229 229 |  | 
| @@ -259,6 +259,33 @@ module Rye | |
| 259 259 | 
             
                 str
         | 
| 260 260 | 
             
              end
         | 
| 261 261 |  | 
| 262 | 
            +
              class Tpl
         | 
| 263 | 
            +
                attr_reader :src, :result, :basename
         | 
| 264 | 
            +
                def initialize(src, basename='rye-template')
         | 
| 265 | 
            +
                  @basename = basename
         | 
| 266 | 
            +
                  src = src.to_s
         | 
| 267 | 
            +
                  @src, @template = src, ERB.new(src)
         | 
| 268 | 
            +
                end
         | 
| 269 | 
            +
                def path
         | 
| 270 | 
            +
                  if @tf.nil?
         | 
| 271 | 
            +
                    @tf = Tempfile.new basename
         | 
| 272 | 
            +
                    @tf.write @result
         | 
| 273 | 
            +
                    @tf.close
         | 
| 274 | 
            +
                  end
         | 
| 275 | 
            +
                  @tf.path
         | 
| 276 | 
            +
                end
         | 
| 277 | 
            +
                def delete
         | 
| 278 | 
            +
                  File.delete(@tf.path) if File.exists?(@tf.path)
         | 
| 279 | 
            +
                end
         | 
| 280 | 
            +
                def result!(binding)
         | 
| 281 | 
            +
                  @result = result(binding)
         | 
| 282 | 
            +
                end
         | 
| 283 | 
            +
                def result(binding)
         | 
| 284 | 
            +
                  @template.result(binding)
         | 
| 285 | 
            +
                end
         | 
| 286 | 
            +
                def to_s() src end
         | 
| 287 | 
            +
              end
         | 
| 288 | 
            +
              
         | 
| 262 289 | 
             
              private 
         | 
| 263 290 |  | 
| 264 291 | 
             
              Rye.reload
         | 
    
        data/rye.gemspec
    CHANGED
    
    | @@ -1,18 +1,16 @@ | |
| 1 1 | 
             
            @spec = Gem::Specification.new do |s|
         | 
| 2 2 | 
             
              s.name = "rye"
         | 
| 3 3 | 
             
              s.rubyforge_project = "rye"
         | 
| 4 | 
            -
              s.version = "0. | 
| 4 | 
            +
              s.version = "0.9.0"
         | 
| 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"
         | 
| 8 8 | 
             
              s.email = "delano@solutious.com"
         | 
| 9 | 
            -
              s.homepage = "http:// | 
| 9 | 
            +
              s.homepage = "http://github.com/delano/rye/"
         | 
| 10 10 |  | 
| 11 11 | 
             
              # = DEPENDENCIES =
         | 
| 12 12 | 
             
              # Add all gem dependencies
         | 
| 13 | 
            -
              s.add_dependency ' | 
| 14 | 
            -
              s.add_dependency 'sysinfo'
         | 
| 15 | 
            -
              s.add_dependency 'storable'
         | 
| 13 | 
            +
              s.add_dependency 'annoy'
         | 
| 16 14 | 
             
              s.add_dependency 'sysinfo', '>= 0.7.0'
         | 
| 17 15 |  | 
| 18 16 | 
             
              s.add_dependency 'highline', '>= 1.5.1'
         | 
| @@ -24,7 +22,7 @@ | |
| 24 22 | 
             
              # = EXECUTABLES =
         | 
| 25 23 | 
             
              # The list of executables in your project (if any). Don't include the path, 
         | 
| 26 24 | 
             
              # just the base filename.
         | 
| 27 | 
            -
              s.executables = %w[ | 
| 25 | 
            +
              s.executables = %w[]
         | 
| 28 26 |  | 
| 29 27 | 
             
              # = MANIFEST =
         | 
| 30 28 | 
             
              # The complete list of files to be included in the release. When GitHub packages your gem, 
         | 
| @@ -38,7 +36,6 @@ | |
| 38 36 | 
             
              README.rdoc
         | 
| 39 37 | 
             
              Rakefile
         | 
| 40 38 | 
             
              Rudyfile
         | 
| 41 | 
            -
              bin/rye
         | 
| 42 39 | 
             
              bin/try
         | 
| 43 40 | 
             
              lib/esc.rb
         | 
| 44 41 | 
             
              lib/rye.rb
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: rye
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
               | 
| 4 | 
            +
              hash: 59
         | 
| 5 | 
            +
              prerelease: false
         | 
| 6 | 
            +
              segments: 
         | 
| 7 | 
            +
              - 0
         | 
| 8 | 
            +
              - 9
         | 
| 9 | 
            +
              - 0
         | 
| 10 | 
            +
              version: 0.9.0
         | 
| 5 11 | 
             
            platform: ruby
         | 
| 6 12 | 
             
            authors: 
         | 
| 7 13 | 
             
            - Delano Mandelbaum
         | 
| @@ -9,83 +15,91 @@ autorequire: | |
| 9 15 | 
             
            bindir: bin
         | 
| 10 16 | 
             
            cert_chain: []
         | 
| 11 17 |  | 
| 12 | 
            -
            date: 2010- | 
| 18 | 
            +
            date: 2010-08-19 00:00:00 -04:00
         | 
| 13 19 | 
             
            default_executable: 
         | 
| 14 20 | 
             
            dependencies: 
         | 
| 15 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 16 | 
            -
              name:  | 
| 17 | 
            -
               | 
| 18 | 
            -
               | 
| 19 | 
            -
             | 
| 22 | 
            +
              name: annoy
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 25 | 
            +
                none: false
         | 
| 20 26 | 
             
                requirements: 
         | 
| 21 27 | 
             
                - - ">="
         | 
| 22 28 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 29 | 
            +
                    hash: 3
         | 
| 30 | 
            +
                    segments: 
         | 
| 31 | 
            +
                    - 0
         | 
| 23 32 | 
             
                    version: "0"
         | 
| 24 | 
            -
                version: 
         | 
| 25 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 26 | 
            -
              name: sysinfo
         | 
| 27 33 | 
             
              type: :runtime
         | 
| 28 | 
            -
               | 
| 29 | 
            -
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 30 | 
            -
                requirements: 
         | 
| 31 | 
            -
                - - ">="
         | 
| 32 | 
            -
                  - !ruby/object:Gem::Version 
         | 
| 33 | 
            -
                    version: "0"
         | 
| 34 | 
            -
                version: 
         | 
| 35 | 
            -
            - !ruby/object:Gem::Dependency 
         | 
| 36 | 
            -
              name: storable
         | 
| 37 | 
            -
              type: :runtime
         | 
| 38 | 
            -
              version_requirement: 
         | 
| 39 | 
            -
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 40 | 
            -
                requirements: 
         | 
| 41 | 
            -
                - - ">="
         | 
| 42 | 
            -
                  - !ruby/object:Gem::Version 
         | 
| 43 | 
            -
                    version: "0"
         | 
| 44 | 
            -
                version: 
         | 
| 34 | 
            +
              version_requirements: *id001
         | 
| 45 35 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 46 36 | 
             
              name: sysinfo
         | 
| 47 | 
            -
               | 
| 48 | 
            -
               | 
| 49 | 
            -
             | 
| 37 | 
            +
              prerelease: false
         | 
| 38 | 
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         | 
| 39 | 
            +
                none: false
         | 
| 50 40 | 
             
                requirements: 
         | 
| 51 41 | 
             
                - - ">="
         | 
| 52 42 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 43 | 
            +
                    hash: 3
         | 
| 44 | 
            +
                    segments: 
         | 
| 45 | 
            +
                    - 0
         | 
| 46 | 
            +
                    - 7
         | 
| 47 | 
            +
                    - 0
         | 
| 53 48 | 
             
                    version: 0.7.0
         | 
| 54 | 
            -
             | 
| 49 | 
            +
              type: :runtime
         | 
| 50 | 
            +
              version_requirements: *id002
         | 
| 55 51 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 56 52 | 
             
              name: highline
         | 
| 57 | 
            -
               | 
| 58 | 
            -
               | 
| 59 | 
            -
             | 
| 53 | 
            +
              prerelease: false
         | 
| 54 | 
            +
              requirement: &id003 !ruby/object:Gem::Requirement 
         | 
| 55 | 
            +
                none: false
         | 
| 60 56 | 
             
                requirements: 
         | 
| 61 57 | 
             
                - - ">="
         | 
| 62 58 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 59 | 
            +
                    hash: 1
         | 
| 60 | 
            +
                    segments: 
         | 
| 61 | 
            +
                    - 1
         | 
| 62 | 
            +
                    - 5
         | 
| 63 | 
            +
                    - 1
         | 
| 63 64 | 
             
                    version: 1.5.1
         | 
| 64 | 
            -
             | 
| 65 | 
            +
              type: :runtime
         | 
| 66 | 
            +
              version_requirements: *id003
         | 
| 65 67 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 66 68 | 
             
              name: net-ssh
         | 
| 67 | 
            -
               | 
| 68 | 
            -
               | 
| 69 | 
            -
             | 
| 69 | 
            +
              prerelease: false
         | 
| 70 | 
            +
              requirement: &id004 !ruby/object:Gem::Requirement 
         | 
| 71 | 
            +
                none: false
         | 
| 70 72 | 
             
                requirements: 
         | 
| 71 73 | 
             
                - - ">="
         | 
| 72 74 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 75 | 
            +
                    hash: 21
         | 
| 76 | 
            +
                    segments: 
         | 
| 77 | 
            +
                    - 2
         | 
| 78 | 
            +
                    - 0
         | 
| 79 | 
            +
                    - 13
         | 
| 73 80 | 
             
                    version: 2.0.13
         | 
| 74 | 
            -
             | 
| 81 | 
            +
              type: :runtime
         | 
| 82 | 
            +
              version_requirements: *id004
         | 
| 75 83 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 76 84 | 
             
              name: net-scp
         | 
| 77 | 
            -
               | 
| 78 | 
            -
               | 
| 79 | 
            -
             | 
| 85 | 
            +
              prerelease: false
         | 
| 86 | 
            +
              requirement: &id005 !ruby/object:Gem::Requirement 
         | 
| 87 | 
            +
                none: false
         | 
| 80 88 | 
             
                requirements: 
         | 
| 81 89 | 
             
                - - ">="
         | 
| 82 90 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 91 | 
            +
                    hash: 19
         | 
| 92 | 
            +
                    segments: 
         | 
| 93 | 
            +
                    - 1
         | 
| 94 | 
            +
                    - 0
         | 
| 95 | 
            +
                    - 2
         | 
| 83 96 | 
             
                    version: 1.0.2
         | 
| 84 | 
            -
             | 
| 97 | 
            +
              type: :runtime
         | 
| 98 | 
            +
              version_requirements: *id005
         | 
| 85 99 | 
             
            description: "Rye: Safely run SSH commands on a bunch of machines at the same time (from Ruby)."
         | 
| 86 100 | 
             
            email: delano@solutious.com
         | 
| 87 | 
            -
            executables: 
         | 
| 88 | 
            -
             | 
| 101 | 
            +
            executables: []
         | 
| 102 | 
            +
             | 
| 89 103 | 
             
            extensions: []
         | 
| 90 104 |  | 
| 91 105 | 
             
            extra_rdoc_files: 
         | 
| @@ -97,7 +111,6 @@ files: | |
| 97 111 | 
             
            - README.rdoc
         | 
| 98 112 | 
             
            - Rakefile
         | 
| 99 113 | 
             
            - Rudyfile
         | 
| 100 | 
            -
            - bin/rye
         | 
| 101 114 | 
             
            - bin/try
         | 
| 102 115 | 
             
            - lib/esc.rb
         | 
| 103 116 | 
             
            - lib/rye.rb
         | 
| @@ -108,7 +121,7 @@ files: | |
| 108 121 | 
             
            - lib/rye/set.rb
         | 
| 109 122 | 
             
            - rye.gemspec
         | 
| 110 123 | 
             
            has_rdoc: true
         | 
| 111 | 
            -
            homepage: http:// | 
| 124 | 
            +
            homepage: http://github.com/delano/rye/
         | 
| 112 125 | 
             
            licenses: []
         | 
| 113 126 |  | 
| 114 127 | 
             
            post_install_message: 
         | 
| @@ -121,21 +134,27 @@ rdoc_options: | |
| 121 134 | 
             
            require_paths: 
         | 
| 122 135 | 
             
            - lib
         | 
| 123 136 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 137 | 
            +
              none: false
         | 
| 124 138 | 
             
              requirements: 
         | 
| 125 139 | 
             
              - - ">="
         | 
| 126 140 | 
             
                - !ruby/object:Gem::Version 
         | 
| 141 | 
            +
                  hash: 3
         | 
| 142 | 
            +
                  segments: 
         | 
| 143 | 
            +
                  - 0
         | 
| 127 144 | 
             
                  version: "0"
         | 
| 128 | 
            -
              version: 
         | 
| 129 145 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 146 | 
            +
              none: false
         | 
| 130 147 | 
             
              requirements: 
         | 
| 131 148 | 
             
              - - ">="
         | 
| 132 149 | 
             
                - !ruby/object:Gem::Version 
         | 
| 150 | 
            +
                  hash: 3
         | 
| 151 | 
            +
                  segments: 
         | 
| 152 | 
            +
                  - 0
         | 
| 133 153 | 
             
                  version: "0"
         | 
| 134 | 
            -
              version: 
         | 
| 135 154 | 
             
            requirements: []
         | 
| 136 155 |  | 
| 137 156 | 
             
            rubyforge_project: rye
         | 
| 138 | 
            -
            rubygems_version: 1.3. | 
| 157 | 
            +
            rubygems_version: 1.3.7
         | 
| 139 158 | 
             
            signing_key: 
         | 
| 140 159 | 
             
            specification_version: 2
         | 
| 141 160 | 
             
            summary: "Rye: Safely run SSH commands on a bunch of machines at the same time (from Ruby)."
         |