utils 0.0.72 → 0.0.73

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 272f15d17775ad53ee538f56dcbd7155f01b4475
4
- data.tar.gz: cc71c73c94a73b7fde073866b1ac01e2057ae5be
3
+ metadata.gz: 3f84a7cb62fc30ec50975afed3993c85e1e75f85
4
+ data.tar.gz: 05bd623454afa06895fe78afe24a887dce12aec4
5
5
  SHA512:
6
- metadata.gz: 3c9045a504b98e3641216eee232589b2b35872f6c32eacafeb81f62c5265714c20589eef1de2ea9b36ae422b1b020607c48b062c997960d6ce58bcaf37e8f086
7
- data.tar.gz: 14b6b06dea7616ba5afa3c78b1151665abf46986800a7c36485b41721d77361d9b52325d23dee541aedd3fcdfa8a7fb559fd0a91fd2aa0e7b563d39d5921a6d3
6
+ metadata.gz: 51e718468925a4976022cf87a58ec13db90fce4b7ce241d024e0110fabf939010b0724fe449159ebd6514e21906136d9c65d074f174e9642b4dd02642cc64916
7
+ data.tar.gz: a99d6d83f9bcac7ae21b74818d4f6b6b9d85544b092221d470a49f86b4e7a72d13b032ef9d3ccbc5ea35df1264e2fe528eefff995f2ab4130974cabd16f2f2ec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.72
1
+ 0.0.73
data/bin/remote_copy ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'socket'
4
+
5
+ copy_remote_host_port = ENV['COPY_REMOTE_HOST_PORT'] and
6
+ copy_remote_host_port =~ /\A([^:]+):([^:]+)\z/ or
7
+ fail "environment variable COPY_REMOTE_HOST_PORT of form host:port required"
8
+ copy_remote_host, copy_remote_port = $1, $2
9
+
10
+ clipboard = TCPSocket.new(copy_remote_host, copy_remote_port)
11
+ until STDIN.eof?
12
+ clipboard.write STDIN.read(1 << 16)
13
+ end
data/bin/ssh-tunnel CHANGED
@@ -21,8 +21,9 @@ Usage: #{File.basename($0)} [OPTS] [user@]remote[:port]"
21
21
 
22
22
  OPTS is one of
23
23
  -N list all session names on the specified remote
24
- -n NAME name of the multplexer session to attach to (defaults to $USER)
24
+ -n NAME name of the multiplexer session to attach to (defaults to $USER)
25
25
  -t [HOST[:PORT]] host:port to tunnel if different from LOCALPORT
26
+ -m screen|tmux use sshscreen or tmux as a terminal multiplexer
26
27
  -l LOCALPORT the localport to forward to
27
28
  -C (ssh|rc)-default|rc output ssh or rc config file
28
29
  -h to display this help
@@ -34,7 +35,7 @@ end
34
35
  config = Utils::Config::ConfigFile.new
35
36
 
36
37
  arguments = ARGV
37
- opts = go 'l:t:n:C:hN', arguments
38
+ opts = go 'l:t:n:C:m:hN', arguments
38
39
 
39
40
  case opts['C']
40
41
  when 'ssh-default'
@@ -50,6 +51,10 @@ config.configure_from_paths
50
51
 
51
52
  usage if opts['h'] or arguments.size != 1
52
53
 
54
+ if multiplexer = opts['m']
55
+ config.ssh_tunnel.terminal_multiplexer = multiplexer
56
+ end
57
+
53
58
  user_remote = arguments.shift
54
59
  user, remote, rport =
55
60
  case user_remote
@@ -84,13 +89,22 @@ else
84
89
  end
85
90
  if opts['N']
86
91
  exec "ssh -p #{rport} -S #{sock_file} #{user}@#{remote} #{config.ssh_tunnel.multiplexer_list}"
87
- elsif lport
88
- rm_f sock_file
89
- exec "ssh -p #{rport} -Mt -L localhost:#{lport}:#{tunnel}:#{tport}"\
90
- " -S #{sock_file} #{user}@#{remote} #{config.ssh_tunnel.multiplexer_attach} #{opts['n']}"
91
92
  else
93
+ env = []
92
94
  File.exist? sock_file and rm_f sock_file
93
- exec "ssh -p #{rport} -Mt -S #{sock_file} #{user}@#{remote} "\
94
- "'#{config.ssh_tunnel.multiplexer_new(opts['n'])} || "\
95
- "#{config.ssh_tunnel.multiplexer_attach(opts['n'])}'"
95
+ r = config.ssh_tunnel.copy_paste.full? do |t|
96
+ env << "COPY_REMOTE_HOST_PORT='#{t.bind_address}:#{t.port}'"
97
+ " -R #{t}"
98
+ end
99
+ env *= ' '
100
+ if lport
101
+ exec "ssh -p #{rport} -Mt -L localhost:#{lport}:#{tunnel}:#{tport}#{r} "\
102
+ "-S #{sock_file} #{user}@#{remote} "\
103
+ "'env #{env} #{config.ssh_tunnel.multiplexer_new(opts['n'])} || "\
104
+ "#{config.ssh_tunnel.multiplexer_attach(opts['n'])}'"
105
+ else
106
+ exec "ssh -p #{rport} -Mt -S #{sock_file} #{user}@#{remote}#{r} "\
107
+ "'env #{env} #{config.ssh_tunnel.multiplexer_new(opts['n'])} || "\
108
+ "#{config.ssh_tunnel.multiplexer_attach(opts['n'])}'"
109
+ end
96
110
  end
@@ -49,26 +49,31 @@ class Utils::Config::ConfigFile
49
49
  end
50
50
 
51
51
  def config(name, *r, &block)
52
- self.dsl_attributes ||= []
53
- dsl_attributes << name.to_sym
52
+ self.config_settings ||= []
53
+ config_settings << name.to_sym
54
54
  dsl_accessor name, *r, &block
55
55
  self
56
56
  end
57
57
 
58
- attr_accessor :dsl_attributes
58
+ attr_accessor :config_settings
59
59
  end
60
60
 
61
61
  def initialize(&block)
62
62
  block and instance_eval(&block)
63
63
  end
64
64
 
65
- def to_ruby
65
+ def to_ruby(depth = 0)
66
66
  result = ''
67
- result << "#{self.class.name[/::([^:]+)\z/, 1].underscore} do\n"
68
- for da in self.class.dsl_attributes
69
- result << " #{da} #{Array(__send__(da)).map(&:inspect) * ', '}\n"
67
+ result << ' ' * 2 * depth << "#{self.class.name[/::([^:]+)\z/, 1].underscore} do\n"
68
+ for name in self.class.config_settings
69
+ value = __send__(name)
70
+ if value.respond_to?(:to_ruby)
71
+ result << ' ' * 2 * (depth + 1) << value.to_ruby(depth + 1)
72
+ else
73
+ result << ' ' * 2 * (depth + 1) << "#{name} #{Array(value).map(&:inspect) * ', '}\n"
74
+ end
70
75
  end
71
- result << "end\n"
76
+ result << ' ' * 2 * depth << "end\n"
72
77
  end
73
78
  end
74
79
 
@@ -149,18 +154,22 @@ class Utils::Config::ConfigFile
149
154
  end
150
155
 
151
156
  class SshTunnel < BlockConfig
152
- config :terminal_multiplexer, 'sshscreen'
157
+ config :terminal_multiplexer, 'screen'
153
158
 
154
159
  def initialize
155
160
  super
161
+ self.terminal_multiplexer = terminal_multiplexer
162
+ end
163
+
164
+ def terminal_multiplexer=(terminal_multiplexer)
156
165
  @multiplexer = terminal_multiplexer.to_s
157
- @multiplexer =~ /\A(sshscreen|tmux)\z/ or
166
+ @multiplexer =~ /\A(screen|tmux)\z/ or
158
167
  fail "invalid terminal_multiplexer #{terminal_multiplexer.inspect} was configured"
159
168
  end
160
169
 
161
170
  def multiplexer_list
162
171
  case @multiplexer
163
- when 'sshscreen'
172
+ when 'screen'
164
173
  'screen -ls'
165
174
  when 'tmux'
166
175
  'tmux ls'
@@ -169,7 +178,7 @@ class Utils::Config::ConfigFile
169
178
 
170
179
  def multiplexer_new(session)
171
180
  case @multiplexer
172
- when 'sshscreen'
181
+ when 'screen'
173
182
  'false'
174
183
  when 'tmux'
175
184
  'tmux -u new -s "%s"' % session
@@ -178,12 +187,39 @@ class Utils::Config::ConfigFile
178
187
 
179
188
  def multiplexer_attach(session)
180
189
  case @multiplexer
181
- when 'sshscreen'
190
+ when 'screen'
182
191
  'screen -DUR "%s"' % session
183
192
  when 'tmux'
184
193
  'tmux -u attach -t "%s"' % session
185
194
  end
186
195
  end
196
+
197
+ class CopyPaste < BlockConfig
198
+ config :bind_address, 'localhost'
199
+
200
+ config :port, 6166
201
+
202
+ config :host, 'localhost'
203
+
204
+ config :host_port, 6166
205
+
206
+ def to_s
207
+ [ bind_address, port, host, host_port ] * ':'
208
+ end
209
+ end
210
+
211
+ def copy_paste(enable = false, &block)
212
+ if @copy_paste
213
+ @copy_paste
214
+ else
215
+ if block
216
+ @copy_paste = CopyPaste.new(&block)
217
+ elsif enable
218
+ @copy_paste = CopyPaste.new {}
219
+ end
220
+ end
221
+ end
222
+ self.config_settings << :copy_paste
187
223
  end
188
224
 
189
225
  def ssh_tunnel(&block)
data/lib/utils/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.0.72'
3
+ VERSION = '0.0.73'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/utils.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "utils"
5
- s.version = "0.0.72"
5
+ s.version = "0.0.73"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Florian Frank"]
9
- s.date = "2013-02-28"
9
+ s.date = "2013-03-08"
10
10
  s.description = "This ruby gem provides some useful command line utilities"
11
11
  s.email = "flori@ping.de"
12
- s.executables = ["create_tags", "untest", "chroot-libs", "edit_wait", "chroot-exec", "irb_connect", "number_files", "search", "strip_spaces", "path", "enum", "edit", "git-empty", "classify", "utils-install-config", "xmp", "discover", "ssh-tunnel", "myex", "probe", "errf", "same_files", "utils-utilsrc", "unquarantine_apps", "vacuum_firefox_sqlite", "on_change", "sedit"]
12
+ s.executables = ["create_tags", "untest", "chroot-libs", "edit_wait", "chroot-exec", "irb_connect", "number_files", "search", "strip_spaces", "path", "enum", "edit", "git-empty", "classify", "utils-install-config", "xmp", "discover", "ssh-tunnel", "myex", "probe", "remote_copy", "errf", "same_files", "utils-utilsrc", "unquarantine_apps", "vacuum_firefox_sqlite", "on_change", "sedit"]
13
13
  s.extra_rdoc_files = ["README.rdoc", "lib/utils.rb", "lib/utils/config.rb", "lib/utils/config/config_file.rb", "lib/utils/editor.rb", "lib/utils/file_xt.rb", "lib/utils/finder.rb", "lib/utils/grepper.rb", "lib/utils/irb.rb", "lib/utils/md5.rb", "lib/utils/patterns.rb", "lib/utils/version.rb"]
14
- s.files = [".gitignore", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "TODO", "VERSION", "bin/chroot-exec", "bin/chroot-libs", "bin/classify", "bin/create_tags", "bin/discover", "bin/edit", "bin/edit_wait", "bin/enum", "bin/errf", "bin/git-empty", "bin/irb_connect", "bin/myex", "bin/number_files", "bin/on_change", "bin/path", "bin/probe", "bin/same_files", "bin/search", "bin/sedit", "bin/ssh-tunnel", "bin/strip_spaces", "bin/unquarantine_apps", "bin/untest", "bin/utils-install-config", "bin/utils-utilsrc", "bin/vacuum_firefox_sqlite", "bin/xmp", "lib/utils.rb", "lib/utils/config.rb", "lib/utils/config/config_file.rb", "lib/utils/config/gdb/asm", "lib/utils/config/gdb/ruby", "lib/utils/config/gdbinit", "lib/utils/config/irbrc", "lib/utils/config/rdebugrc", "lib/utils/config/rvmrc", "lib/utils/config/screenrc", "lib/utils/config/utilsrc", "lib/utils/editor.rb", "lib/utils/file_xt.rb", "lib/utils/finder.rb", "lib/utils/grepper.rb", "lib/utils/irb.rb", "lib/utils/md5.rb", "lib/utils/patterns.rb", "lib/utils/version.rb", "utils.gemspec"]
14
+ s.files = [".gitignore", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "TODO", "VERSION", "bin/chroot-exec", "bin/chroot-libs", "bin/classify", "bin/create_tags", "bin/discover", "bin/edit", "bin/edit_wait", "bin/enum", "bin/errf", "bin/git-empty", "bin/irb_connect", "bin/myex", "bin/number_files", "bin/on_change", "bin/path", "bin/probe", "bin/remote_copy", "bin/same_files", "bin/search", "bin/sedit", "bin/ssh-tunnel", "bin/strip_spaces", "bin/unquarantine_apps", "bin/untest", "bin/utils-install-config", "bin/utils-utilsrc", "bin/vacuum_firefox_sqlite", "bin/xmp", "lib/utils.rb", "lib/utils/config.rb", "lib/utils/config/config_file.rb", "lib/utils/config/gdb/asm", "lib/utils/config/gdb/ruby", "lib/utils/config/gdbinit", "lib/utils/config/irbrc", "lib/utils/config/rdebugrc", "lib/utils/config/rvmrc", "lib/utils/config/screenrc", "lib/utils/config/utilsrc", "lib/utils/editor.rb", "lib/utils/file_xt.rb", "lib/utils/finder.rb", "lib/utils/grepper.rb", "lib/utils/irb.rb", "lib/utils/md5.rb", "lib/utils/patterns.rb", "lib/utils/version.rb", "utils.gemspec"]
15
15
  s.homepage = "http://github.com/flori/utils"
16
16
  s.rdoc_options = ["--title", "Utils - Some useful command line utilities", "--main", "README.rdoc"]
17
17
  s.require_paths = ["lib"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.72
4
+ version: 0.0.73
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-02-28 00:00:00.000000000 Z
11
+ date: 2013-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -103,6 +103,7 @@ executables:
103
103
  - ssh-tunnel
104
104
  - myex
105
105
  - probe
106
+ - remote_copy
106
107
  - errf
107
108
  - same_files
108
109
  - utils-utilsrc
@@ -148,6 +149,7 @@ files:
148
149
  - bin/on_change
149
150
  - bin/path
150
151
  - bin/probe
152
+ - bin/remote_copy
151
153
  - bin/same_files
152
154
  - bin/search
153
155
  - bin/sedit