utils 0.0.22 → 0.0.23

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.22
1
+ 0.0.23
data/bin/probe CHANGED
@@ -13,8 +13,9 @@ Usage: #{File.basename($0)} [OPTS] FILENAME[:LINENO]
13
13
 
14
14
  Options are
15
15
 
16
- -n TESTNAME run the test TESTNAME in file FILENAME
17
- -h display this help
16
+ -n TESTNAME run the test TESTNAME in file FILENAME
17
+ -t FRAMEWORK use test framework FRAMEWORK (rspec or test-unit)
18
+ -h display this help
18
19
 
19
20
  Version is #{File.basename($0)} #{Utils::VERSION}.
20
21
  EOT
@@ -26,22 +27,38 @@ def cmd(*args)
26
27
  exec *args
27
28
  end
28
29
 
30
+ $config = Utils::Config::ConfigFile.new
31
+ $config.parse_config_file File.expand_path('~/.utilsrc')
32
+ $opt = go 't:n:h'
29
33
  filename = ARGV.shift or fail "require filename or filename:line_number as first argument"
30
- $opt = go 'n:h'
31
34
  $opt['h'] and usage
32
- if testname = $opt['n']
33
- cmd "testrb", '-I', 'lib:test:ext', '-n', testname , filename
34
- elsif filename =~ /^\s*([^:]+):(\d+)/
35
- filename, line_number = $1, $2
36
- lf = Tins::LinesFile.for_filename filename, line_number.to_i
37
- if testname = lf.match_backward(/def\s+(\S+?)(?:\(|\s*$)/).full?(:first)
38
- puts "Running test #{testname.inspect} at #{filename}:#{lf.line_number}"
39
- cmd "testrb", '-I', 'lib:test:ext', '-n', testname , filename
35
+ case ($opt['t'] || $config.probe.test_framework).to_sym
36
+ when :rspec
37
+ if line_number = $opt['n']
38
+ cmd "rspec", '-I', $config.probe.include_dirs_argument, '-l', line_number , filename
39
+ elsif filename =~ /^\s*([^:]+):(\d+)/
40
+ filename, line_number = $1, $2
41
+ puts "Running test at #{filename}:#{line_number}"
42
+ cmd "rspec", '-I', $config.probe.include_dirs_argument, '-l', line_number , filename
40
43
  else
41
- warn "no test found before line #{line_number}"
42
- exit 1
44
+ puts "Running ALL tests in #{filename}"
45
+ cmd "rspec", '-I', $config.probe.include_dirs_argument, filename
46
+ end
47
+ when :'test-unit'
48
+ if testname = $opt['n']
49
+ cmd "testrb", '-I', $config.probe.include_dirs_argument, '-n', testname , filename
50
+ elsif filename =~ /^\s*([^:]+):(\d+)/
51
+ filename, line_number = $1, $2
52
+ lf = Tins::LinesFile.for_filename filename, line_number.to_i
53
+ if testname = lf.match_backward(/def\s+(\S+?)(?:\(|\s*$)/).full?(:first)
54
+ puts "Running test #{testname.inspect} at #{filename}:#{lf.line_number}"
55
+ cmd "testrb", '-I', $config.probe.include_dirs_argument, '-n', testname , filename
56
+ else
57
+ warn "no test found before line #{line_number}"
58
+ exit 1
59
+ end
60
+ else
61
+ puts "Running ALL tests in #{filename}"
62
+ cmd "testrb", '-I', $config.probe.include_dirs_argument, filename
43
63
  end
44
- else
45
- puts "Running ALL tests in #{filename}"
46
- cmd "testrb", '-Ilib:test:ext', filename
47
64
  end
@@ -4,6 +4,8 @@ require 'tins/xt/string'
4
4
  class Utils::Config::ConfigFile
5
5
  include DSLKit::Interpreter
6
6
 
7
+ class ConfigFileError < StandardError; end
8
+
7
9
  def initialize
8
10
  end
9
11
 
@@ -53,6 +55,30 @@ class Utils::Config::ConfigFile
53
55
  end
54
56
  end
55
57
 
58
+ class Probe < BlockConfig
59
+ config :test_framework, :'test-unit'
60
+
61
+ config :include_dirs, %w[lib test tests ext spec]
62
+
63
+ def include_dirs_argument
64
+ Array(include_dirs) * ':'
65
+ end
66
+
67
+ def initialize(&block)
68
+ super
69
+ test_frameworks_allowed = [ :'test-unit', :rspec ]
70
+ test_frameworks_allowed.include?(test_framework) or raise ConfigFileError,
71
+ "test_framework has to be in #{test_frameworks_allowed.inspect}"
72
+ end
73
+ end
74
+
75
+ def probe(&block)
76
+ if block
77
+ @probe = Probe.new(&block)
78
+ end
79
+ @probe ||= Probe.new
80
+ end
81
+
56
82
  class FileFinder < BlockConfig
57
83
  def prune?(basename)
58
84
  Array(prune_dirs).any? { |pd| pd.match(basename) }
@@ -104,7 +130,7 @@ class Utils::Config::ConfigFile
104
130
 
105
131
  def to_ruby
106
132
  result = "# vim: set ft=ruby:\n"
107
- for bc in %w[search discover]
133
+ for bc in %w[search discover strip_spaces probe]
108
134
  result << "\n" << __send__(bc).to_ruby
109
135
  end
110
136
  result
@@ -450,17 +450,16 @@ def ls(*args)
450
450
  puts `ls #{args.map { |x| "'#{x}'" } * ' '}`
451
451
  end
452
452
 
453
- if defined?(ActiveRecord::Base)
454
- $logger = Logger.new(STDERR)
453
+ if RUBY_VERSION < '1.9' && defined?(ActiveRecord::Base)
454
+ require 'logger'
455
+ $real_logger = Logger.new(STDERR)
456
+ $logger = Tins::NULL
455
457
  def irb_toggle_logging
456
- require 'logger'
457
- if ActiveRecord::Base.logger != $logger
458
- $old_logger = ActiveRecord::Base.logger
459
- ActiveRecord::Base.logger = $logger
460
- true
461
- else
462
- ActiveRecord::Base.logger = $old_logger
463
- false
458
+ case $logger
459
+ when Tins::NULL
460
+ $logger = $real_logger
461
+ when Logger
462
+ $logger = Tins::NULL
464
463
  end
465
464
  end
466
465
  end
@@ -221,10 +221,10 @@ noremap <PageDown> <Nop>
221
221
  cnoremap <C-0> <Home>
222
222
  cnoremap <C-^> <Home>
223
223
  cnoremap <C-$> <End>
224
- cnoremap <C-H> <Left>
225
- cnoremap <C-L> <Right>
226
- cnoremap <C-K> <Up>
227
- cnoremap <C-J> <Down>
224
+ cnoremap <C-h> <Left>
225
+ cnoremap <C-l> <Right>
226
+ cnoremap <C-k> <Up>
227
+ cnoremap <C-j> <Down>
228
228
  vnoremap < <gv
229
229
  vnoremap > >gv
230
230
  " Marks
@@ -1,6 +1,6 @@
1
1
  module Utils
2
2
  # Utils version
3
- VERSION = '0.0.22'
3
+ VERSION = '0.0.23'
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:
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "utils"
5
- s.version = "0.0.22"
5
+ s.version = "0.0.23"
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 = "2011-09-25"
9
+ s.date = "2011-10-08"
10
10
  s.description = "This ruby gem provides some useful command line utilities"
11
11
  s.email = "flori@ping.de"
12
12
  s.executables = ["untest", "chroot-libs", "edit_wait", "chroot-exec", "number_files", "search", "strip_spaces", "path", "enum", "edit", "git-empty", "classify", "utils-install-config", "xmp", "discover", "sshscreen", "myex", "probe", "errf", "same_files", "unquarantine_apps", "vacuum_firefox_sqlite", "sedit"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
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: 2011-09-25 00:00:00.000000000Z
12
+ date: 2011-10-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gem_hadar
16
- requirement: &2156179340 !ruby/object:Gem::Requirement
16
+ requirement: &2156440800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.1.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2156179340
24
+ version_requirements: *2156440800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: tins
27
- requirement: &2156178520 !ruby/object:Gem::Requirement
27
+ requirement: &2156440360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2156178520
35
+ version_requirements: *2156440360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: term-ansicolor
38
- requirement: &2156177520 !ruby/object:Gem::Requirement
38
+ requirement: &2156439940 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2156177520
46
+ version_requirements: *2156439940
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: dslkit
49
- requirement: &2156176500 !ruby/object:Gem::Requirement
49
+ requirement: &2156439500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0.2'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2156176500
57
+ version_requirements: *2156439500
58
58
  description: This ruby gem provides some useful command line utilities
59
59
  email: flori@ping.de
60
60
  executables: