pygments.rb 0.6.2 → 0.6.3
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/lib/pygments/popen.rb +21 -9
- data/lib/pygments/version.rb +1 -1
- metadata +2 -2
data/lib/pygments/popen.rb
CHANGED
@@ -36,19 +36,31 @@ module Pygments
|
|
36
36
|
|
37
37
|
# A pipe to the mentos python process. #popen4 gives us
|
38
38
|
# the pid and three IO objects to write and read.
|
39
|
-
|
39
|
+
python_path = python_binary(is_windows)
|
40
|
+
script = "#{python_path} #{File.expand_path('../mentos.py', __FILE__)}"
|
40
41
|
@pid, @in, @out, @err = popen4(script)
|
41
42
|
@log.info "[#{Time.now.iso8601}] Starting pid #{@pid.to_s} with fd #{@out.to_i.to_s}."
|
42
43
|
end
|
43
44
|
|
44
|
-
# Detect a suitable Python binary to use.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@python_binary ||= begin
|
49
|
-
`which python2`
|
50
|
-
$?.success? ? "python2" : "python"
|
45
|
+
# Detect a suitable Python binary to use.
|
46
|
+
def python_binary(is_windows)
|
47
|
+
if is_windows && which('py')
|
48
|
+
return 'py -2'
|
51
49
|
end
|
50
|
+
return which('python2') || 'python'
|
51
|
+
end
|
52
|
+
|
53
|
+
# Cross platform which command
|
54
|
+
# from http://stackoverflow.com/a/5471032/284795
|
55
|
+
def which(command)
|
56
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
57
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |dir|
|
58
|
+
exts.each { |ext|
|
59
|
+
path = File.join(dir, "#{command}#{ext}")
|
60
|
+
return path if File.executable?(path) && !File.directory?(path)
|
61
|
+
}
|
62
|
+
end
|
63
|
+
return nil
|
52
64
|
end
|
53
65
|
|
54
66
|
# Stop the child process by issuing a kill -9.
|
@@ -119,7 +131,7 @@ module Pygments
|
|
119
131
|
def lexers
|
120
132
|
begin
|
121
133
|
lexer_file = File.expand_path('../../../lexers', __FILE__)
|
122
|
-
raw = File.open(lexer_file, "
|
134
|
+
raw = File.open(lexer_file, "rb").read
|
123
135
|
Marshal.load(raw)
|
124
136
|
rescue Errno::ENOENT
|
125
137
|
raise MentosError, "Error loading lexer file. Was it created and vendored?"
|
data/lib/pygments/version.rb
CHANGED
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.6.
|
4
|
+
version: 0.6.3
|
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: 2015-
|
13
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: yajl-ruby
|