cmd_tools 4.1.4 → 4.2.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/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'rake/testtask'
2
+ require 'ruby_patch'
3
+
4
+ ::Rake::TestTask.new do |t|
5
+ t.libs = ['lib', 'test'].map{|dir| File.join(__DIR__, dir)}
6
+ t.pattern = "test/**/test_*.rb"
7
+ end
data/bin/command/bak ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ cmd_tools backup "$@"
data/bin/command/e ADDED
@@ -0,0 +1,16 @@
1
+ #!/bin/sh
2
+
3
+ files="$@"
4
+ case $(uname) in
5
+ # emacs_launch do not work satisfactory on Mac.
6
+ "Darwin")
7
+ for file in ${files}
8
+ do
9
+ [ -e ${file} ] || touch ${file}
10
+ done
11
+ open -a /Applications/MacPorts/Emacs.app ${files}
12
+ ;;
13
+ *)
14
+ cmd_tools emacs_launch --mode=gui ${files}
15
+ ;;
16
+ esac
data/bin/command/em ADDED
@@ -0,0 +1,11 @@
1
+ #!/bin/sh
2
+
3
+ case $(uname) in
4
+ # emacs_launch do not work satisfactory on Mac.
5
+ "Darwin")
6
+ /Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs --no-window-system "$@"
7
+ ;;
8
+ *)
9
+ cmd_tools emacs_launch --mode=cui "$@"
10
+ ;;
11
+ esac
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ cmd_tools emacs_stop
data/bin/command/tsh ADDED
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ cmd_tools trash "$@"
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ sed -e '/^ *#/d' "$@"
@@ -4,6 +4,14 @@ class ::CmdTools::Application < Thor
4
4
  require 'ruby_patch'
5
5
  extend ::RubyPatch::AutoLoad
6
6
 
7
+ desc "min_max < FILE", "Return the minmum and maximum value of each column."
8
+ method_option :min_max_separator, default: "\t", aliases: "-m"
9
+ method_option :field_separator, default: "\t", aliases: "-f"
10
+ def min_max()
11
+ puts ::CmdTools::Commands::MinMax.run($stdin.read, options[:min_max_separator])\
12
+ .join(options[:field_separator])
13
+ end
14
+
7
15
  desc "backup FILE1 FILE2 ...", "Backup files and directories."
8
16
  def backup(*files)
9
17
  puts ::CmdTools::Commands::Backup.run(*files).join("\t")
@@ -0,0 +1,12 @@
1
+ module ::CmdTools::Commands::MinMax
2
+ require 'ruby_patch'
3
+ extend ::RubyPatch::AutoLoad
4
+
5
+ def self.run(str, min_max_separator = "\t")
6
+ str.split("\n")\
7
+ .map{|l| l.split.map{|field| field.to_f}}\
8
+ .transpose\
9
+ .map(&:minmax)\
10
+ .map{|min_max| min_max.join(min_max_separator)}
11
+ end
12
+ end
@@ -1,26 +1,6 @@
1
1
  module CmdTools
2
2
  RECOMMENDED_SHELL_SETTINGS = <<-EOS
3
3
  # CmdTools
4
- alias bak='cmd_tools backup'
5
- alias tsh='cmd_tools trash'
6
- alias emacs_stop='cmd_tools emacs_stop'
7
- case $(uname) in
8
- # emacs_launch do not work satisfactory on Mac.
9
- "Darwin")
10
- function e(){
11
- files="$@"
12
- for file in ${files}
13
- do
14
- [ -e ${file} ] || touch ${file}
15
- done
16
- open -a /Applications/MacPorts/Emacs.app ${files}
17
- }
18
- alias em='/Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs --no-window-system --no-init-file'
19
- ;;
20
- *)
21
- alias e='cmd_tools emacs_launch --mode=gui'
22
- alias em='cmd_tools emacs_launch --mode=cui'
23
- ;;
24
- esac
4
+ export PATH=${HOME}/.gem/ruby/1.9.1/gems/cmd_tools-#{CmdTools::VERSION}/bin/command:${PATH}
25
5
  EOS
26
6
  end
@@ -1,3 +1,3 @@
1
1
  module CmdTools
2
- VERSION = '4.1.4'
2
+ VERSION = '4.2.0'
3
3
  end
@@ -0,0 +1,7 @@
1
+ require 'minitest/pride'
2
+ require 'minitest/autorun'
3
+
4
+ lib = File.expand_path(File.join(File.dirname(__FILE__), '../lib'))
5
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+
7
+ require 'cmd_tools'
@@ -0,0 +1,12 @@
1
+ require 'helper_for_test'
2
+
3
+ class TestCommands < ::MiniTest::Unit::TestCase
4
+ def test_min_max
5
+ str = <<-EOS
6
+ 4 5 6
7
+ 1 2 3
8
+ 3 2 4
9
+ EOS
10
+ assert_equal(["1.0/4.0", "2.0/5.0", "3.0/6.0"], ::CmdTools::Commands::MinMax.run(str, '/'))
11
+ end
12
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmd_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.4
4
+ version: 4.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-09 00:00:00.000000000 Z
12
+ date: 2012-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby_patch
16
- requirement: &2157488660 !ruby/object:Gem::Requirement
16
+ requirement: &2152489040 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2157488660
24
+ version_requirements: *2152489040
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &2157488180 !ruby/object:Gem::Requirement
27
+ requirement: &2152487640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0.16'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2157488180
35
+ version_requirements: *2152487640
36
36
  description: ! 'Command line tools. Please type
37
37
 
38
38
 
@@ -49,28 +49,37 @@ extensions: []
49
49
  extra_rdoc_files: []
50
50
  files:
51
51
  - README.rdoc
52
+ - Rakefile
52
53
  - bin/cmd_tools
54
+ - bin/command/bak
55
+ - bin/command/e
56
+ - bin/command/em
57
+ - bin/command/emacs_stop
58
+ - bin/command/tsh
59
+ - bin/command/uncomment
53
60
  - cmd_tools.gemspec
54
61
  - lib/cmd_tools.rb
55
62
  - lib/cmd_tools/application.rb
56
63
  - lib/cmd_tools/commands.rb
57
64
  - lib/cmd_tools/commands/backup.rb
58
65
  - lib/cmd_tools/commands/emacs_launch.rb
66
+ - lib/cmd_tools/commands/min_max.rb
59
67
  - lib/cmd_tools/commands/trash.rb
60
68
  - lib/cmd_tools/config.rb
61
69
  - lib/cmd_tools/recommended_shell_settings.rb
62
70
  - lib/cmd_tools/version.rb
71
+ - test/helper_for_test.rb
72
+ - test/test_commands.rb
63
73
  homepage:
64
74
  licenses: []
65
- post_install_message: ! "\n# CmdTools\nalias bak='cmd_tools backup'\nalias tsh='cmd_tools
66
- trash'\nalias emacs_stop='cmd_tools emacs_stop'\ncase $(uname) in\n # emacs_launch
67
- do not work satisfactory on Mac.\n \"Darwin\")\n function e(){\n files=\"$@\"\n
68
- \ for file in ${files}\n do\n [ -e ${file} ]
69
- || touch ${file}\n done\n open -a /Applications/MacPorts/Emacs.app
70
- ${files}\n }\n alias em='/Applications/MacPorts/Emacs.app/Contents/MacOS/Emacs
71
- --no-window-system --no-init-file'\n ;;\n *)\n alias e='cmd_tools
72
- emacs_launch --mode=gui'\n alias em='cmd_tools emacs_launch --mode=cui'\n
73
- \ ;;\nesac\n\n"
75
+ post_install_message: ! '
76
+
77
+ # CmdTools
78
+
79
+ export PATH=${HOME}/.gem/ruby/1.9.1/gems/cmd_tools-4.2.0/bin/command:${PATH}
80
+
81
+
82
+ '
74
83
  rdoc_options: []
75
84
  require_paths:
76
85
  - lib