utils 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/bin/edit CHANGED
@@ -1,36 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'spruz/go'
4
+ include Spruz::GO
5
+ require 'utils/edit'
6
+ include Utils::Edit
3
7
  require 'tempfile'
4
8
 
5
- def cmd(*parts)
6
- command = parts.inject([]) do |a, p|
7
- case
8
- when p == nil, p == []
9
- a
10
- when p.respond_to?(:to_ary)
11
- a.concat p.to_ary
12
- else
13
- a << p.to_s
14
- end
15
- end
16
- $DEBUG and warn command * ' '
17
- command
18
- end
9
+ $opt = go 'w'
19
10
 
20
- case `uname -s`
21
- when /\Adarwin/i
22
- vim = if File.directory?('/Applications/Installed')
23
- '/Applications/Installed/MacVim.app/Contents/MacOS/Vim'
24
- elsif File.directory?('/Applications')
25
- '/Applications/MacVim.app/Contents/MacOS/Vim'
26
- else
27
- fail "cannot find MacVim.app"
28
- end
29
- else
30
- vim = 'gvim'
31
- geometry = [ '-geometry', '80x59' ]
32
- end
11
+ vim = locate_vim_binary
33
12
  servername = [ '--servername', "G#{ENV['USER'].upcase}" ]
13
+ serverlist = `#{vim} -g --serverlist`.split
14
+ remote = $opt['w'] ? '--remote-wait' : '--remote'
34
15
 
35
16
  argv = ARGV.dup
36
17
  if argv.empty?
@@ -42,12 +23,12 @@ if argv.empty?
42
23
  end
43
24
  file.close
44
25
  argv << file.path
45
- elsif `#{vim} -g --serverlist`.split.member?(servername)
46
- system *cmd(vim, '-g', geometry, servername, '--remote', "stupid_trick#{rand}")
26
+ elsif serverlist.member?(servername)
27
+ system *cmd(vim, '-g', servername, remote, "stupid_trick#{rand}")
47
28
  sleep 1
48
- exec *cmd(vim, '-g', geometry, servername, '--remote-send', '<ESC>:bw<CR>')
29
+ exec *cmd(vim, '-g', servername, '--remote-send', '<ESC>:bw<CR>')
49
30
  else
50
- exec *cmd(vim, '-g', geometry, servername)
31
+ exec *cmd(vim, '-g', servername, remote)
51
32
  end
52
33
  end
53
34
  unless argv.empty?
@@ -55,11 +36,11 @@ unless argv.empty?
55
36
  if argv.first =~ lineno_re
56
37
  for a in argv
57
38
  if a =~ lineno_re
58
- system *cmd(vim, '-g', geometry, servername, '--remote', $1)
39
+ system *cmd(vim, '-g', servername, remote, $1)
59
40
  sleep 1
60
- system *cmd(vim, '-g', geometry, servername, '--remote-send', "<ESC>:#$2<CR>")
41
+ system *cmd(vim, '-g', servername, '--remote-send', "<ESC>:#$2<CR>")
61
42
  else
62
- system *cmd(vim, '-g', geometry, servername, '--remote', a)
43
+ system *cmd(vim, '-g', servername, remote, a)
63
44
  end
64
45
  if a != argv.last
65
46
  STDOUT.print "Press enter to edit the next file."
@@ -68,7 +49,7 @@ unless argv.empty?
68
49
  end
69
50
  end
70
51
  else
71
- exec *cmd(vim, '-g', geometry, servername, '--remote', *argv)
52
+ exec *cmd(vim, '-g', servername, remote, *argv)
72
53
  end
73
54
  end
74
55
  exit 0
data/bin/edit_wait ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ exec 'edit', '-w', *$*
data/bin/path ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'spruz/go'
4
+ include Spruz::GO
5
+ require 'spruz/xt/write'
6
+ require 'tempfile'
7
+
8
+ path_separator = RUBY_PLATFORM =~ /mswin32/ ? ';' : ':'
9
+ path = (ENV['PATH'] || '').split(path_separator)
10
+ path.map! { |part| File.expand_path(part) }
11
+
12
+ $opt = go('e')
13
+
14
+ case cmd = ARGV.shift
15
+ when 'prefix', 'postfix'
16
+ part = ARGV.shift or fail 'need a path part to prefix'
17
+ part = File.expand_path(part)
18
+ path.delete part
19
+ if cmd == 'prefix'
20
+ path.unshift part
21
+ else
22
+ path.push part
23
+ end
24
+ when 'edit'
25
+ if path = ARGV.first
26
+ path = path.split(path_separator)
27
+ path.map! { |part| File.expand_path(part) }
28
+ end
29
+ path_file = File.join(Dir.tmpdir, "path_temp.#$$")
30
+ File.write path_file, path * "\n"
31
+ system "edit -w #{path_file.inspect}"
32
+ path = File.read(path_file).split(/\n/)
33
+ path.map! { |part| File.expand_path(part) }
34
+ end
35
+
36
+ path.uniq!
37
+
38
+ puts "#{'export ' if $opt['e']}PATH=#{path * path_separator}"
data/lib/utils/edit.rb ADDED
@@ -0,0 +1,33 @@
1
+ module Utils
2
+ module Edit
3
+ module_function
4
+
5
+ def locate_vim_binary
6
+ case `uname -s`
7
+ when /\Adarwin/i
8
+ if File.directory?('/Applications')
9
+ '/Applications/MacVim.app/Contents/MacOS/Vim'
10
+ else
11
+ 'gvim'
12
+ end
13
+ else
14
+ 'gvim'
15
+ end
16
+ end
17
+
18
+ def cmd(*parts)
19
+ command = parts.inject([]) do |a, p|
20
+ case
21
+ when p == nil, p == []
22
+ a
23
+ when p.respond_to?(:to_ary)
24
+ a.concat p.to_ary
25
+ else
26
+ a << p.to_s
27
+ end
28
+ end
29
+ $DEBUG and warn command * ' '
30
+ command
31
+ end
32
+ end
33
+ end
data/lib/utils/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
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,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{utils}
5
- s.version = "0.0.3"
5
+ s.version = "0.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [%q{Florian Frank}]
9
- s.date = %q{2011-06-24}
9
+ s.date = %q{2011-06-27}
10
10
  s.description = %q{This ruby gem provides some useful command line utilities}
11
11
  s.email = %q{flori@ping.de}
12
- s.executables = [%q{untest}, %q{chroot-libs}, %q{chroot-exec}, %q{number_files}, %q{search}, %q{edit}, %q{git-empty}, %q{classify}, %q{utils-install-config}, %q{xmp}, %q{discover}, %q{sshscreen}, %q{myex}, %q{errf}, %q{same_files}, %q{unquarantine_apps}, %q{vacuum_firefox_sqlite}, %q{sedit}]
13
- s.files = [%q{utils.gemspec}, %q{Rakefile}, %q{lib}, %q{lib/utils}, %q{lib/utils/config}, %q{lib/utils/config/screenrc}, %q{lib/utils/config/irbrc}, %q{lib/utils/config/rdebugrc}, %q{lib/utils/config/gdb}, %q{lib/utils/config/gdb/asm}, %q{lib/utils/config/gdb/ruby}, %q{lib/utils/config/vimrc}, %q{lib/utils/config/gdbinit}, %q{lib/utils/config/vim}, %q{lib/utils/config/vim/compiler}, %q{lib/utils/config/vim/compiler/rubyunit.vim}, %q{lib/utils/config/vim/compiler/ruby.vim}, %q{lib/utils/config/vim/compiler/eruby.vim}, %q{lib/utils/config/vim/syntax}, %q{lib/utils/config/vim/syntax/Decho.vim}, %q{lib/utils/config/vim/syntax/ruby.vim}, %q{lib/utils/config/vim/syntax/ragel.vim}, %q{lib/utils/config/vim/syntax/javascript.vim}, %q{lib/utils/config/vim/syntax/eruby.vim}, %q{lib/utils/config/vim/ftdetect}, %q{lib/utils/config/vim/ftdetect/ruby.vim}, %q{lib/utils/config/vim/ftdetect/ragel.vim}, %q{lib/utils/config/vim/autoload}, %q{lib/utils/config/vim/autoload/AlignMaps.vim}, %q{lib/utils/config/vim/autoload/rubycomplete.vim}, %q{lib/utils/config/vim/autoload/sqlcomplete.vim}, %q{lib/utils/config/vim/autoload/vimball.vim}, %q{lib/utils/config/vim/autoload/Align.vim}, %q{lib/utils/config/vim/autoload/rails.vim}, %q{lib/utils/config/vim/indent}, %q{lib/utils/config/vim/indent/IndentAnything_html.vim}, %q{lib/utils/config/vim/indent/ruby.vim}, %q{lib/utils/config/vim/indent/javascript.vim}, %q{lib/utils/config/vim/indent/eruby.vim}, %q{lib/utils/config/vim/colors}, %q{lib/utils/config/vim/colors/flori.vim}, %q{lib/utils/config/vim/plugin}, %q{lib/utils/config/vim/plugin/bufexplorer.vim}, %q{lib/utils/config/vim/plugin/AlignMapsPlugin.vim}, %q{lib/utils/config/vim/plugin/AlignPlugin.vim}, %q{lib/utils/config/vim/plugin/cecutil.vim}, %q{lib/utils/config/vim/plugin/taglist.vim}, %q{lib/utils/config/vim/plugin/Decho.vim}, %q{lib/utils/config/vim/plugin/IndentAnything.vim}, %q{lib/utils/config/vim/plugin/fugitive.vim}, %q{lib/utils/config/vim/plugin/test}, %q{lib/utils/config/vim/plugin/test/IndentAnything}, %q{lib/utils/config/vim/plugin/test/IndentAnything/test.js}, %q{lib/utils/config/vim/plugin/surround.vim}, %q{lib/utils/config/vim/plugin/lusty-explorer.vim}, %q{lib/utils/config/vim/plugin/vimballPlugin.vim}, %q{lib/utils/config/vim/plugin/rubyextra.vim}, %q{lib/utils/config/vim/plugin/rails.vim}, %q{lib/utils/config/vim/ftplugin}, %q{lib/utils/config/vim/ftplugin/ruby.vim}, %q{lib/utils/config/vim/ftplugin/xml.vim}, %q{lib/utils/config/vim/ftplugin/eruby.vim}, %q{lib/utils/version.rb}, %q{lib/utils/find.rb}, %q{lib/utils/config.rb}, %q{lib/utils/file_xt.rb}, %q{lib/utils/md5.rb}, %q{lib/utils/patterns.rb}, %q{lib/utils.rb}, %q{bin}, %q{bin/untest}, %q{bin/chroot-libs}, %q{bin/chroot-exec}, %q{bin/number_files}, %q{bin/search}, %q{bin/edit}, %q{bin/git-empty}, %q{bin/classify}, %q{bin/utils-install-config}, %q{bin/xmp}, %q{bin/discover}, %q{bin/sshscreen}, %q{bin/myex}, %q{bin/errf}, %q{bin/same_files}, %q{bin/unquarantine_apps}, %q{bin/vacuum_firefox_sqlite}, %q{bin/sedit}, %q{VERSION}]
12
+ s.executables = [%q{untest}, %q{chroot-libs}, %q{edit_wait}, %q{chroot-exec}, %q{number_files}, %q{search}, %q{path}, %q{edit}, %q{git-empty}, %q{classify}, %q{utils-install-config}, %q{xmp}, %q{discover}, %q{sshscreen}, %q{myex}, %q{errf}, %q{same_files}, %q{unquarantine_apps}, %q{vacuum_firefox_sqlite}, %q{sedit}]
13
+ s.files = [%q{utils.gemspec}, %q{Rakefile}, %q{lib}, %q{lib/utils}, %q{lib/utils/config}, %q{lib/utils/config/screenrc}, %q{lib/utils/config/irbrc}, %q{lib/utils/config/rdebugrc}, %q{lib/utils/config/gdb}, %q{lib/utils/config/gdb/asm}, %q{lib/utils/config/gdb/ruby}, %q{lib/utils/config/vimrc}, %q{lib/utils/config/gdbinit}, %q{lib/utils/config/vim}, %q{lib/utils/config/vim/compiler}, %q{lib/utils/config/vim/compiler/rubyunit.vim}, %q{lib/utils/config/vim/compiler/ruby.vim}, %q{lib/utils/config/vim/compiler/eruby.vim}, %q{lib/utils/config/vim/syntax}, %q{lib/utils/config/vim/syntax/Decho.vim}, %q{lib/utils/config/vim/syntax/ruby.vim}, %q{lib/utils/config/vim/syntax/ragel.vim}, %q{lib/utils/config/vim/syntax/javascript.vim}, %q{lib/utils/config/vim/syntax/eruby.vim}, %q{lib/utils/config/vim/ftdetect}, %q{lib/utils/config/vim/ftdetect/ruby.vim}, %q{lib/utils/config/vim/ftdetect/ragel.vim}, %q{lib/utils/config/vim/autoload}, %q{lib/utils/config/vim/autoload/AlignMaps.vim}, %q{lib/utils/config/vim/autoload/rubycomplete.vim}, %q{lib/utils/config/vim/autoload/sqlcomplete.vim}, %q{lib/utils/config/vim/autoload/vimball.vim}, %q{lib/utils/config/vim/autoload/Align.vim}, %q{lib/utils/config/vim/autoload/rails.vim}, %q{lib/utils/config/vim/indent}, %q{lib/utils/config/vim/indent/IndentAnything_html.vim}, %q{lib/utils/config/vim/indent/ruby.vim}, %q{lib/utils/config/vim/indent/javascript.vim}, %q{lib/utils/config/vim/indent/eruby.vim}, %q{lib/utils/config/vim/colors}, %q{lib/utils/config/vim/colors/flori.vim}, %q{lib/utils/config/vim/plugin}, %q{lib/utils/config/vim/plugin/bufexplorer.vim}, %q{lib/utils/config/vim/plugin/AlignMapsPlugin.vim}, %q{lib/utils/config/vim/plugin/AlignPlugin.vim}, %q{lib/utils/config/vim/plugin/cecutil.vim}, %q{lib/utils/config/vim/plugin/taglist.vim}, %q{lib/utils/config/vim/plugin/Decho.vim}, %q{lib/utils/config/vim/plugin/IndentAnything.vim}, %q{lib/utils/config/vim/plugin/fugitive.vim}, %q{lib/utils/config/vim/plugin/test}, %q{lib/utils/config/vim/plugin/test/IndentAnything}, %q{lib/utils/config/vim/plugin/test/IndentAnything/test.js}, %q{lib/utils/config/vim/plugin/surround.vim}, %q{lib/utils/config/vim/plugin/lusty-explorer.vim}, %q{lib/utils/config/vim/plugin/vimballPlugin.vim}, %q{lib/utils/config/vim/plugin/rubyextra.vim}, %q{lib/utils/config/vim/plugin/rails.vim}, %q{lib/utils/config/vim/ftplugin}, %q{lib/utils/config/vim/ftplugin/ruby.vim}, %q{lib/utils/config/vim/ftplugin/xml.vim}, %q{lib/utils/config/vim/ftplugin/eruby.vim}, %q{lib/utils/version.rb}, %q{lib/utils/find.rb}, %q{lib/utils/config.rb}, %q{lib/utils/edit.rb}, %q{lib/utils/file_xt.rb}, %q{lib/utils/md5.rb}, %q{lib/utils/patterns.rb}, %q{lib/utils.rb}, %q{bin}, %q{bin/untest}, %q{bin/chroot-libs}, %q{bin/edit_wait}, %q{bin/chroot-exec}, %q{bin/number_files}, %q{bin/search}, %q{bin/path}, %q{bin/edit}, %q{bin/git-empty}, %q{bin/classify}, %q{bin/utils-install-config}, %q{bin/xmp}, %q{bin/discover}, %q{bin/sshscreen}, %q{bin/myex}, %q{bin/errf}, %q{bin/same_files}, %q{bin/unquarantine_apps}, %q{bin/vacuum_firefox_sqlite}, %q{bin/sedit}, %q{VERSION}]
14
14
  s.homepage = %q{http://flori.github.com/utils}
15
15
  s.require_paths = [%q{lib}]
16
16
  s.rubygems_version = %q{1.8.5}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utils
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Florian Frank
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-24 00:00:00 Z
18
+ date: 2011-06-27 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: spruz
@@ -50,9 +50,11 @@ email: flori@ping.de
50
50
  executables:
51
51
  - untest
52
52
  - chroot-libs
53
+ - edit_wait
53
54
  - chroot-exec
54
55
  - number_files
55
56
  - search
57
+ - path
56
58
  - edit
57
59
  - git-empty
58
60
  - classify
@@ -121,15 +123,18 @@ files:
121
123
  - lib/utils/version.rb
122
124
  - lib/utils/find.rb
123
125
  - lib/utils/config.rb
126
+ - lib/utils/edit.rb
124
127
  - lib/utils/file_xt.rb
125
128
  - lib/utils/md5.rb
126
129
  - lib/utils/patterns.rb
127
130
  - lib/utils.rb
128
131
  - bin/untest
129
132
  - bin/chroot-libs
133
+ - bin/edit_wait
130
134
  - bin/chroot-exec
131
135
  - bin/number_files
132
136
  - bin/search
137
+ - bin/path
133
138
  - bin/edit
134
139
  - bin/git-empty
135
140
  - bin/classify