pygments.rb 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ changelog
2
+ ===========
3
+
4
+ Version 0.3.4 (Dec 28, 2012)
5
+ -----------------------------
6
+
7
+ * Add support for Windows
8
+ * Add MIT license
9
+
10
+
data/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) Ted Nyman and Aman Gupta, 2012
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5
+ associated documentation files (the "Software"), to deal in the Software without restriction,
6
+ including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
+ and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial
11
+ portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
14
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
15
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
16
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
17
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -88,5 +88,23 @@ Pygments.start("/path/to/pygments")
88
88
  pygments popen (process already started) 0.010000 0.000000 0.010000 ( 0.676515)
89
89
  pygments popen (process already started 2) 0.000000 0.010000 0.010000 ( 0.674189)
90
90
 
91
+ ## license
91
92
 
93
+ The MIT License (MIT)
92
94
 
95
+ Copyright (c) Ted Nyman and Aman Gupta, 2012
96
+
97
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
98
+ associated documentation files (the "Software"), to deal in the Software without restriction,
99
+ including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
100
+ and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
101
+ subject to the following conditions:
102
+
103
+ The above copyright notice and this permission notice shall be included in all copies or substantial
104
+ portions of the Software.
105
+
106
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
107
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
108
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
109
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
110
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- import sys, re, os, signal, resource
4
+ import sys, re, os, signal
5
5
  import traceback
6
6
  if 'PYGMENTS_PATH' in os.environ:
7
7
  sys.path.insert(0, os.environ['PYGMENTS_PATH'])
@@ -320,20 +320,27 @@ def main():
320
320
  # Signal handlers to trap signals.
321
321
  signal.signal(signal.SIGINT, _signal_handler)
322
322
  signal.signal(signal.SIGTERM, _signal_handler)
323
- signal.signal(signal.SIGHUP, _signal_handler)
323
+ if sys.platform != "win32":
324
+ signal.signal(signal.SIGHUP, _signal_handler)
324
325
 
325
326
  mentos = Mentos()
326
327
 
327
- # close fd's inherited from the ruby parent
328
- maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
329
- if maxfd == resource.RLIM_INFINITY:
330
- maxfd = 65536
331
-
332
- for fd in range(3, maxfd):
333
- try:
334
- os.close(fd)
335
- except:
336
- pass
328
+ if sys.platform == "win32":
329
+ # disable CRLF
330
+ import msvcrt
331
+ msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
332
+ else:
333
+ # close fd's inherited from the ruby parent
334
+ import resource
335
+ maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
336
+ if maxfd == resource.RLIM_INFINITY:
337
+ maxfd = 65536
338
+
339
+ for fd in range(3, maxfd):
340
+ try:
341
+ os.close(fd)
342
+ except:
343
+ pass
337
344
 
338
345
  mentos.start()
339
346
 
@@ -20,12 +20,13 @@ module Pygments
20
20
  # Python process that talks to the Pygments library. We'll talk back and
21
21
  # forth across this pipe.
22
22
  def start(pygments_path = File.expand_path('../../../vendor/pygments-main/', __FILE__))
23
+ is_windows = RUBY_PLATFORM =~ /mswin|mingw/
23
24
  begin
24
- @log = Logger.new(ENV['MENTOS_LOG'] ||= '/dev/null')
25
+ @log = Logger.new(ENV['MENTOS_LOG'] ||= is_windows ? 'NUL:' : '/dev/null')
25
26
  @log.level = Logger::INFO
26
27
  @log.datetime_format = "%Y-%m-%d %H:%M "
27
28
  rescue
28
- @log = Logger.new('/dev/null')
29
+ @log = Logger.new(is_windows ? 'NUL:' : '/dev/null')
29
30
  end
30
31
 
31
32
  ENV['PYGMENTS_PATH'] = pygments_path
@@ -35,7 +36,9 @@ module Pygments
35
36
 
36
37
  # A pipe to the mentos python process. #popen4 gives us
37
38
  # the pid and three IO objects to write and read.
38
- @pid, @in, @out, @err = popen4(File.expand_path('../mentos.py', __FILE__))
39
+ script = File.expand_path('../mentos.py', __FILE__)
40
+ script = 'python ' + script if is_windows
41
+ @pid, @in, @out, @err = popen4(script)
39
42
  @log.info "[#{Time.now.iso8601}] Starting pid #{@pid.to_s} with fd #{@out.to_i.to_s}."
40
43
  end
41
44
 
@@ -1,3 +1,3 @@
1
1
  module Pygments
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pygments.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-12-17 00:00:00.000000000 Z
13
+ date: 2012-12-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: yajl-ruby
@@ -68,7 +68,9 @@ extensions: []
68
68
  extra_rdoc_files: []
69
69
  files:
70
70
  - .gitignore
71
+ - CHANGELOG.md
71
72
  - Gemfile
73
+ - LICENSE
72
74
  - README.md
73
75
  - Rakefile
74
76
  - bench.rb