command-t 1.6 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65e092a4101159c349fa3add3f4654a8ea0ce323
4
- data.tar.gz: 0da32ec23fd4db0d33aae16ae131201161872e16
3
+ metadata.gz: 64b588caab585d019ca8114678e3fa6f7f3642c5
4
+ data.tar.gz: 26625225d34e10161297f8722d282dfcd0f7541c
5
5
  SHA512:
6
- metadata.gz: 15aee07c8cbf2e2f6d1dbf5b2da4731adb9a5f359d8a0f4a783d2e9eb998eb56cc4ae2d72d3e4ac4a4bc87a1465f99c63b1dea1f131124869475403c599cf489
7
- data.tar.gz: 75ead8da5ba910874aa4172f4c7558e63e4cd95923a9db2daa37ea319a41d5dd8761994117ab81307d9c734085d2dbef49cbd89b1acb8fb2f1552d7a53ce9b3e
6
+ metadata.gz: 18c544603a39fd969fa1abcb81d8e42d9508fea862d32c5788b87a818aa45ae8194d4e07b5a7922d537e2bb3518024f27d409833faa724253f2cf203e74d5e22
7
+ data.tar.gz: bc5e0f40d2194b9d38c1971debd033ec1462cfe4381a6ce59e9645702bbd6b003827246233fe69c9632c8082f3298ff53fdadd30be80d5bdae45a0b69058c971
data/README.txt CHANGED
@@ -68,8 +68,11 @@ If your Vim lacks support you'll see an error message like this:
68
68
 
69
69
  E319: Sorry, the command is not available in this version
70
70
 
71
- The version of Vim distributed with Mac OS X does not include Ruby support,
72
- while MacVim does; it is available from:
71
+ The version of Vim distributed with OS X may not include Ruby support (for
72
+ exmaple, Snow Leopard, which was the current version of OS X when Command-T
73
+ was first released, did not support Ruby in the system Vim, but the current
74
+ version of OS X at the time of writing, Mavericks, does). All recent versions
75
+ of MacVim come with Ruby support; it is available from:
73
76
 
74
77
  http://github.com/b4winckler/macvim/downloads
75
78
 
@@ -85,8 +88,14 @@ compatible Ruby install. "Compatible" means the same version as Vim itself
85
88
  links against. If you use a different version then Command-T is unlikely
86
89
  to work (see TROUBLE-SHOOTING below).
87
90
 
88
- On Mac OS X Snow Leopard, the system comes with Ruby 1.8.7 and all recent
89
- versions of MacVim (the 7.2 snapshots and 7.3) are linked against it.
91
+ On OS X Snow Leopard, Lion and Mountain Lion, the system comes with Ruby 1.8.7
92
+ and all recent versions of MacVim (the 7.2 snapshots and 7.3) are linked
93
+ against it.
94
+
95
+ On OS X Mavericks, the default system ruby is 2.0, but MacVim continues to
96
+ link against 1.8.7, which is also present on the system at:
97
+
98
+ /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
90
99
 
91
100
  On Linux and similar platforms, the linked version of Ruby will depend on
92
101
  your distribution. You can usually find this out by examining the
@@ -112,8 +121,8 @@ it to work responsively even on directory hierarchies containing enormous
112
121
  numbers of files. As such, a C compiler is required in order to build the
113
122
  extension and complete the installation.
114
123
 
115
- On Mac OS X, this can be obtained by installing the Xcode Tools that come on
116
- the Mac OS X install disc.
124
+ On OS X, this can be obtained by installing the Xcode Tools from the App
125
+ Store.
117
126
 
118
127
  On Windows, the RubyInstaller Development Kit can be used to conveniently
119
128
  install the necessary tool chain:
@@ -129,8 +138,12 @@ folder.
129
138
 
130
139
  INSTALLATION *command-t-installation*
131
140
 
132
- Command-T is distributed as a "vimball" which means that it can be installed
133
- by opening it in Vim and then sourcing it:
141
+ You can install Command-T by obtaining the source files and building the C
142
+ extension. The recommended way to get the source is by using a plug-in
143
+ management system such as Pathogen (see |command-t-pathogen|).
144
+
145
+ Command-T is also distributed as a "vimball" which means that it can be
146
+ installed by opening it in Vim and then sourcing it:
134
147
 
135
148
  :e command-t.vba
136
149
  :so %
@@ -156,6 +169,14 @@ of the following commands:
156
169
  rvm use system
157
170
  rbenv local system
158
171
 
172
+ Note: If you are on OS X Mavericks and compiling against MacVim, the default
173
+ system Ruby is 2.0 but MacVim still links against the older 1.8.7 Ruby that is
174
+ also bundled with the system; in this case the build command becomes:
175
+
176
+ cd ~/.vim/ruby/command-t
177
+ /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
178
+ make
179
+
159
180
  Note: Make sure you compile targeting the same architecture Vim was built for.
160
181
  For instance, MacVim binaries are built for i386, but sometimes GCC compiles
161
182
  for x86_64. First you have to check the platform Vim was built for:
@@ -170,6 +191,10 @@ and make sure you use the correct ARCHFLAGS during compilation:
170
191
  export ARCHFLAGS="-arch i386"
171
192
  make
172
193
 
194
+ Note: If you are on Fedora 17+, you can install Command-T from the system
195
+ repository with:
196
+
197
+ su -c 'yum install vim-command-t'
173
198
 
174
199
  MANAGING USING PATHOGEN *command-t-pathogen*
175
200
 
@@ -224,7 +249,7 @@ linked against at compile time. For example, if one is 32-bit and the other is
224
249
  64-bit, or one is from the Ruby 1.9 series and the other is from the 1.8
225
250
  series, then the plug-in is not likely to work.
226
251
 
227
- As such, on Mac OS X, I recommend using the standard Ruby that comes with the
252
+ As such, on OS X, I recommend using the standard Ruby that comes with the
228
253
  system (currently 1.8.7) along with the latest version of MacVim (currently
229
254
  version 7.3). If you wish to use custom builds of Ruby or of MacVim (not
230
255
  recommmended) then you will have to take extra care to ensure that the exact
@@ -652,6 +677,7 @@ Command-T is written and maintained by Wincent Colaiuta <win@wincent.com>.
652
677
  Other contributors that have submitted patches include (in alphabetical
653
678
  order):
654
679
 
680
+ Andy Waite Matthew Todd Steven Moazami
655
681
  Anthony Panozzo Mike Lundy Sung Pae
656
682
  Daniel Hahler Nate Kane Thomas Pelletier
657
683
  Felix Tjandrawibawa Nicholas Alpi Victor Hugo Borja
@@ -661,7 +687,6 @@ order):
661
687
  Lucas de Vries Rainux Luo Zak Johnson
662
688
  Marcus Brito Scott Bronson
663
689
  Marian Schubert Seth Fowler
664
- Matthew Todd Steven Moazami
665
690
 
666
691
  As this was the first Vim plug-in I had ever written I was heavily influenced
667
692
  by the design of the LustyExplorer plug-in by Stephen Bach, which I understand
@@ -764,16 +789,24 @@ POSSIBILITY OF SUCH DAMAGE.
764
789
 
765
790
  HISTORY *command-t-history*
766
791
 
792
+ 1.6.1 (22 December 2013)
793
+
794
+ - defer processor count detection until runtime (makes it possible to sensibly
795
+ build Command-T on one machine and use it on another)
796
+
767
797
  1.6 (16 December 2013)
798
+
768
799
  - on systems with POSIX threads (such as OS X and Linux), Command-T will use
769
800
  threads to compute match results in parallel, resulting in a large speed
770
801
  boost that is especially noticeable when navigating large projects
771
802
 
772
803
  1.5.1 (23 September 2013)
804
+
773
805
  - exclude large benchmark fixture file from source exports (patch from Vít
774
806
  Ondruch)
775
807
 
776
808
  1.5 (18 September 2013)
809
+
777
810
  - don't scan "pathological" filesystem structures (ie. circular or
778
811
  self-referential symlinks; patch from Marcus Brito)
779
812
  - gracefully handle files starting with "+" (patch from Ivan Ukhov)
data/Rakefile CHANGED
@@ -171,10 +171,10 @@ task :prerelease => ['make:all', 'spec:all', :vimball, :check_tag]
171
171
  namespace :upload do
172
172
  desc 'Upload current vimball to Amazon S3'
173
173
  task :s3 => :vimball do
174
- sh 'aws put ' +
174
+ sh 'aws --curl-options=--insecure put ' +
175
175
  "s3.wincent.com/command-t/releases/command-t-#{version}.vba " +
176
176
  "command-t-#{version}.vba"
177
- sh 'aws put ' +
177
+ sh 'aws --curl-options=--insecure put ' +
178
178
  "s3.wincent.com/command-t/releases/command-t-#{version}.vba?acl " +
179
179
  '--public'
180
180
  end
data/doc/command-t.txt CHANGED
@@ -68,8 +68,11 @@ If your Vim lacks support you'll see an error message like this:
68
68
 
69
69
  E319: Sorry, the command is not available in this version
70
70
 
71
- The version of Vim distributed with Mac OS X does not include Ruby support,
72
- while MacVim does; it is available from:
71
+ The version of Vim distributed with OS X may not include Ruby support (for
72
+ exmaple, Snow Leopard, which was the current version of OS X when Command-T
73
+ was first released, did not support Ruby in the system Vim, but the current
74
+ version of OS X at the time of writing, Mavericks, does). All recent versions
75
+ of MacVim come with Ruby support; it is available from:
73
76
 
74
77
  http://github.com/b4winckler/macvim/downloads
75
78
 
@@ -85,8 +88,14 @@ compatible Ruby install. "Compatible" means the same version as Vim itself
85
88
  links against. If you use a different version then Command-T is unlikely
86
89
  to work (see TROUBLE-SHOOTING below).
87
90
 
88
- On Mac OS X Snow Leopard, the system comes with Ruby 1.8.7 and all recent
89
- versions of MacVim (the 7.2 snapshots and 7.3) are linked against it.
91
+ On OS X Snow Leopard, Lion and Mountain Lion, the system comes with Ruby 1.8.7
92
+ and all recent versions of MacVim (the 7.2 snapshots and 7.3) are linked
93
+ against it.
94
+
95
+ On OS X Mavericks, the default system ruby is 2.0, but MacVim continues to
96
+ link against 1.8.7, which is also present on the system at:
97
+
98
+ /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
90
99
 
91
100
  On Linux and similar platforms, the linked version of Ruby will depend on
92
101
  your distribution. You can usually find this out by examining the
@@ -112,8 +121,8 @@ it to work responsively even on directory hierarchies containing enormous
112
121
  numbers of files. As such, a C compiler is required in order to build the
113
122
  extension and complete the installation.
114
123
 
115
- On Mac OS X, this can be obtained by installing the Xcode Tools that come on
116
- the Mac OS X install disc.
124
+ On OS X, this can be obtained by installing the Xcode Tools from the App
125
+ Store.
117
126
 
118
127
  On Windows, the RubyInstaller Development Kit can be used to conveniently
119
128
  install the necessary tool chain:
@@ -129,8 +138,12 @@ folder.
129
138
 
130
139
  INSTALLATION *command-t-installation*
131
140
 
132
- Command-T is distributed as a "vimball" which means that it can be installed
133
- by opening it in Vim and then sourcing it:
141
+ You can install Command-T by obtaining the source files and building the C
142
+ extension. The recommended way to get the source is by using a plug-in
143
+ management system such as Pathogen (see |command-t-pathogen|).
144
+
145
+ Command-T is also distributed as a "vimball" which means that it can be
146
+ installed by opening it in Vim and then sourcing it:
134
147
 
135
148
  :e command-t.vba
136
149
  :so %
@@ -156,6 +169,14 @@ of the following commands:
156
169
  rvm use system
157
170
  rbenv local system
158
171
 
172
+ Note: If you are on OS X Mavericks and compiling against MacVim, the default
173
+ system Ruby is 2.0 but MacVim still links against the older 1.8.7 Ruby that is
174
+ also bundled with the system; in this case the build command becomes:
175
+
176
+ cd ~/.vim/ruby/command-t
177
+ /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
178
+ make
179
+
159
180
  Note: Make sure you compile targeting the same architecture Vim was built for.
160
181
  For instance, MacVim binaries are built for i386, but sometimes GCC compiles
161
182
  for x86_64. First you have to check the platform Vim was built for:
@@ -170,6 +191,10 @@ and make sure you use the correct ARCHFLAGS during compilation:
170
191
  export ARCHFLAGS="-arch i386"
171
192
  make
172
193
 
194
+ Note: If you are on Fedora 17+, you can install Command-T from the system
195
+ repository with:
196
+
197
+ su -c 'yum install vim-command-t'
173
198
 
174
199
  MANAGING USING PATHOGEN *command-t-pathogen*
175
200
 
@@ -224,7 +249,7 @@ linked against at compile time. For example, if one is 32-bit and the other is
224
249
  64-bit, or one is from the Ruby 1.9 series and the other is from the 1.8
225
250
  series, then the plug-in is not likely to work.
226
251
 
227
- As such, on Mac OS X, I recommend using the standard Ruby that comes with the
252
+ As such, on OS X, I recommend using the standard Ruby that comes with the
228
253
  system (currently 1.8.7) along with the latest version of MacVim (currently
229
254
  version 7.3). If you wish to use custom builds of Ruby or of MacVim (not
230
255
  recommmended) then you will have to take extra care to ensure that the exact
@@ -652,6 +677,7 @@ Command-T is written and maintained by Wincent Colaiuta <win@wincent.com>.
652
677
  Other contributors that have submitted patches include (in alphabetical
653
678
  order):
654
679
 
680
+ Andy Waite Matthew Todd Steven Moazami
655
681
  Anthony Panozzo Mike Lundy Sung Pae
656
682
  Daniel Hahler Nate Kane Thomas Pelletier
657
683
  Felix Tjandrawibawa Nicholas Alpi Victor Hugo Borja
@@ -661,7 +687,6 @@ order):
661
687
  Lucas de Vries Rainux Luo Zak Johnson
662
688
  Marcus Brito Scott Bronson
663
689
  Marian Schubert Seth Fowler
664
- Matthew Todd Steven Moazami
665
690
 
666
691
  As this was the first Vim plug-in I had ever written I was heavily influenced
667
692
  by the design of the LustyExplorer plug-in by Stephen Bach, which I understand
@@ -764,16 +789,24 @@ POSSIBILITY OF SUCH DAMAGE.
764
789
 
765
790
  HISTORY *command-t-history*
766
791
 
792
+ 1.6.1 (22 December 2013)
793
+
794
+ - defer processor count detection until runtime (makes it possible to sensibly
795
+ build Command-T on one machine and use it on another)
796
+
767
797
  1.6 (16 December 2013)
798
+
768
799
  - on systems with POSIX threads (such as OS X and Linux), Command-T will use
769
800
  threads to compute match results in parallel, resulting in a large speed
770
801
  boost that is especially noticeable when navigating large projects
771
802
 
772
803
  1.5.1 (23 September 2013)
804
+
773
805
  - exclude large benchmark fixture file from source exports (patch from Vít
774
806
  Ondruch)
775
807
 
776
808
  1.5 (18 September 2013)
809
+
777
810
  - don't scan "pathological" filesystem structures (ie. circular or
778
811
  self-referential symlinks; patch from Marcus Brito)
779
812
  - gracefully handle files starting with "+" (patch from Ivan Ukhov)
@@ -80,7 +80,7 @@ warnflags =
80
80
  CCDLFLAGS =
81
81
  CFLAGS = $(CCDLFLAGS) -g -Os -pipe $(ARCH_FLAG)
82
82
  INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
83
- DEFS = -DPROCESSOR_COUNT=4
83
+ DEFS =
84
84
  CPPFLAGS = -DHAVE_PTHREAD_H -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) $(cppflags)
85
85
  CXXFLAGS = $(CCDLFLAGS) -g -Os -pipe $(ARCH_FLAG)
86
86
  ldflags = -L. -L/usr/local/lib
@@ -28,6 +28,7 @@ require 'command-t/finder/tag_finder'
28
28
  require 'command-t/match_window'
29
29
  require 'command-t/prompt'
30
30
  require 'command-t/vim/path_utilities'
31
+ require 'command-t/util'
31
32
 
32
33
  module CommandT
33
34
  class Controller
@@ -342,7 +343,11 @@ module CommandT
342
343
  end
343
344
 
344
345
  def list_matches
345
- @matches = @active_finder.sorted_matches_for @prompt.abbrev, :limit => match_limit
346
+ @matches = @active_finder.sorted_matches_for(
347
+ @prompt.abbrev,
348
+ :limit => match_limit,
349
+ :threads => CommandT::Util.processor_count
350
+ )
346
351
  @match_window.matches = @matches
347
352
  end
348
353
 
Binary file
@@ -30,61 +30,6 @@ def header(item)
30
30
  end
31
31
  end
32
32
 
33
- # Stolen, with minor modifications, from:
34
- #
35
- # https://github.com/grosser/parallel/blob/d11e4a3c8c1a2091a0cc2896befa71a94a88d1e7/lib/parallel.rb
36
- #
37
- # Number of processors seen by the OS and used for process scheduling.
38
- #
39
- # * AIX: /usr/sbin/pmcycles (AIX 5+), /usr/sbin/lsdev
40
- # * BSD: /sbin/sysctl
41
- # * Cygwin: /proc/cpuinfo
42
- # * Darwin: /usr/bin/hwprefs, /usr/sbin/sysctl
43
- # * HP-UX: /usr/sbin/ioscan
44
- # * IRIX: /usr/sbin/sysconf
45
- # * Linux: /proc/cpuinfo
46
- # * Minix 3+: /proc/cpuinfo
47
- # * Solaris: /usr/sbin/psrinfo
48
- # * Tru64 UNIX: /usr/sbin/psrinfo
49
- # * UnixWare: /usr/sbin/psrinfo
50
- #
51
- def processor_count
52
- os_name = RbConfig::CONFIG['target_os']
53
- if os_name =~ /mingw|mswin/
54
- require 'win32ole'
55
- result = WIN32OLE.connect('winmgmts://').ExecQuery(
56
- 'select NumberOfLogicalProcessors from Win32_Processor')
57
- result.to_enum.collect(&:NumberOfLogicalProcessors).reduce(:+)
58
- elsif File.readable?('/proc/cpuinfo')
59
- IO.read('/proc/cpuinfo').scan(/^processor/).size
60
- elsif File.executable?('/usr/bin/hwprefs')
61
- IO.popen(%w[/usr/bin/hwprefs thread_count]).read.to_i
62
- elsif File.executable?('/usr/sbin/psrinfo')
63
- IO.popen('/usr/sbin/psrinfo').read.scan(/^.*on-*line/).size
64
- elsif File.executable?('/usr/sbin/ioscan')
65
- IO.popen(%w[/usr/sbin/ioscan -kC processor]) do |out|
66
- out.read.scan(/^.*processor/).size
67
- end
68
- elsif File.executable?('/usr/sbin/pmcycles')
69
- IO.popen(%w[/usr/sbin/pmcycles -m]).read.count("\n")
70
- elsif File.executable?('/usr/sbin/lsdev')
71
- IO.popen(%w[/usr/sbin/lsdev -Cc processor -S 1]).read.count("\n")
72
- elsif File.executable?('/usr/sbin/sysconf') and os_name =~ /irix/i
73
- IO.popen(%w[/usr/sbin/sysconf NPROC_ONLN]).read.to_i
74
- elsif File.executable?('/usr/sbin/sysctl')
75
- IO.popen(%w[/usr/sbin/sysctl -n hw.ncpu]).read.to_i
76
- elsif File.executable?('/sbin/sysctl')
77
- IO.popen(%w[/sbin/sysctl -n hw.ncpu]).read.to_i
78
- else
79
- puts 'Unknown platform: ' + RbConfig::CONFIG['target_os']
80
- puts 'Assuming 1 processor.'
81
- 1
82
- end
83
- rescue => e
84
- puts "#{e}: assuming 1 processor."
85
- 1
86
- end
87
-
88
33
  # mandatory headers
89
34
  header('float.h')
90
35
  header('ruby.h')
@@ -96,9 +41,4 @@ have_header('pthread.h') # sets HAVE_PTHREAD_H if found
96
41
 
97
42
  RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
98
43
 
99
- count = processor_count
100
- count = 1 if count < 0 # sanity check
101
- count = 32 if count > 32 # sanity check
102
- RbConfig::MAKEFILE_CONFIG['DEFS'] += "-DPROCESSOR_COUNT=#{count}"
103
-
104
44
  create_makefile('ext')
@@ -139,6 +139,7 @@ VALUE CommandTMatcher_sorted_matches_for(int argc, VALUE *argv, VALUE self)
139
139
 
140
140
  // check optional options has for overrides
141
141
  VALUE limit_option = CommandT_option_from_hash("limit", options);
142
+ VALUE threads_option = CommandT_option_from_hash("threads", options);
142
143
 
143
144
  // get unsorted matches
144
145
  VALUE scanner = rb_iv_get(self, "@scanner");
@@ -152,14 +153,12 @@ VALUE CommandTMatcher_sorted_matches_for(int argc, VALUE *argv, VALUE self)
152
153
  rb_raise(rb_eNoMemError, "memory allocation failed");
153
154
 
154
155
  int err;
155
- int thread_count = 1;
156
+ long thread_count = NIL_P(threads_option) ? 1 : NUM2LONG(threads_option);
156
157
 
157
158
  #ifdef HAVE_PTHREAD_H
158
159
  #define THREAD_THRESHOLD 1000 /* avoid the overhead of threading when search space is small */
159
160
  if (path_count < THREAD_THRESHOLD)
160
161
  thread_count = 1;
161
- else
162
- thread_count = PROCESSOR_COUNT; // passed in as preprocessor macro
163
162
  pthread_t *threads = malloc(sizeof(pthread_t) * thread_count);
164
163
  if (!threads)
165
164
  rb_raise(rb_eNoMemError, "memory allocation failed");
@@ -0,0 +1,112 @@
1
+ # Copyright 2013 Wincent Colaiuta. All rights reserved.
2
+ #
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions are met:
5
+ #
6
+ # 1. Redistributions of source code must retain the above copyright notice,
7
+ # this list of conditions and the following disclaimer.
8
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
9
+ # this list of conditions and the following disclaimer in the documentation
10
+ # and/or other materials provided with the distribution.
11
+ #
12
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
16
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22
+ # POSSIBILITY OF SUCH DAMAGE.
23
+
24
+ module CommandT
25
+ module Util
26
+ class << self
27
+ def processor_count
28
+ @processor_count ||= begin
29
+ count = processor_count!
30
+ count = 1 if count < 1 # sanity check
31
+ count = 32 if count > 32 # sanity check
32
+ count
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ # This method derived from:
39
+ #
40
+ # https://github.com/grosser/parallel/blob/d11e4a3c8c1a/lib/parallel.rb
41
+ #
42
+ # Number of processors seen by the OS and used for process scheduling.
43
+ #
44
+ # * AIX: /usr/sbin/pmcycles (AIX 5+), /usr/sbin/lsdev
45
+ # * BSD: /sbin/sysctl
46
+ # * Cygwin: /proc/cpuinfo
47
+ # * Darwin: /usr/bin/hwprefs, /usr/sbin/sysctl
48
+ # * HP-UX: /usr/sbin/ioscan
49
+ # * IRIX: /usr/sbin/sysconf
50
+ # * Linux: /proc/cpuinfo
51
+ # * Minix 3+: /proc/cpuinfo
52
+ # * Solaris: /usr/sbin/psrinfo
53
+ # * Tru64 UNIX: /usr/sbin/psrinfo
54
+ # * UnixWare: /usr/sbin/psrinfo
55
+ #
56
+ # Copyright (C) 2013 Michael Grosser <michael@grosser.it>
57
+ #
58
+ # Permission is hereby granted, free of charge, to any person obtaining
59
+ # a copy of this software and associated documentation files (the
60
+ # "Software"), to deal in the Software without restriction, including
61
+ # without limitation the rights to use, copy, modify, merge, publish,
62
+ # distribute, sublicense, and/or sell copies of the Software, and to
63
+ # permit persons to whom the Software is furnished to do so, subject to
64
+ # the following conditions:
65
+ #
66
+ # The above copyright notice and this permission notice shall be
67
+ # included in all copies or substantial portions of the Software.
68
+ #
69
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
70
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
71
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
72
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
73
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
74
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
75
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
76
+ #
77
+ def processor_count!
78
+ os_name = RbConfig::CONFIG['target_os']
79
+ if os_name =~ /mingw|mswin/
80
+ require 'win32ole'
81
+ result = WIN32OLE.connect('winmgmts://').ExecQuery(
82
+ 'select NumberOfLogicalProcessors from Win32_Processor')
83
+ result.to_enum.collect(&:NumberOfLogicalProcessors).reduce(:+)
84
+ elsif File.readable?('/proc/cpuinfo')
85
+ IO.read('/proc/cpuinfo').scan(/^processor/).size
86
+ elsif File.executable?('/usr/bin/hwprefs')
87
+ IO.popen(%w[/usr/bin/hwprefs thread_count]).read.to_i
88
+ elsif File.executable?('/usr/sbin/psrinfo')
89
+ IO.popen('/usr/sbin/psrinfo').read.scan(/^.*on-*line/).size
90
+ elsif File.executable?('/usr/sbin/ioscan')
91
+ IO.popen(%w[/usr/sbin/ioscan -kC processor]) do |out|
92
+ out.read.scan(/^.*processor/).size
93
+ end
94
+ elsif File.executable?('/usr/sbin/pmcycles')
95
+ IO.popen(%w[/usr/sbin/pmcycles -m]).read.count("\n")
96
+ elsif File.executable?('/usr/sbin/lsdev')
97
+ IO.popen(%w[/usr/sbin/lsdev -Cc processor -S 1]).read.count("\n")
98
+ elsif File.executable?('/usr/sbin/sysconf') and os_name =~ /irix/i
99
+ IO.popen(%w[/usr/sbin/sysconf NPROC_ONLN]).read.to_i
100
+ elsif File.executable?('/usr/sbin/sysctl')
101
+ IO.popen(%w[/usr/sbin/sysctl -n hw.ncpu]).read.to_i
102
+ elsif File.executable?('/sbin/sysctl')
103
+ IO.popen(%w[/sbin/sysctl -n hw.ncpu]).read.to_i
104
+ else # unknown platform
105
+ 1
106
+ end
107
+ rescue
108
+ 1
109
+ end
110
+ end
111
+ end # module Util
112
+ end # module commandT
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command-t
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.6'
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wincent Colaiuta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-16 00:00:00.000000000 Z
11
+ date: 2013-12-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Command-T provides a fast, intuitive mechanism for opening files with a
@@ -51,6 +51,7 @@ files:
51
51
  - ruby/command-t/scanner.rb
52
52
  - ruby/command-t/settings.rb
53
53
  - ruby/command-t/stub.rb
54
+ - ruby/command-t/util.rb
54
55
  - ruby/command-t/vim/path_utilities.rb
55
56
  - ruby/command-t/vim/screen.rb
56
57
  - ruby/command-t/vim/window.rb