Browse files

Rename Pygments to Pygmentize and add bin/pygmentize.

  • Loading branch information...
1 parent 0a35a59 commit 108875142e61857e2309e7557fcd2deb00faf069 @soveran soveran committed Nov 30, 2010
Showing with 32 additions and 12 deletions.
  1. +6 −2 README.md
  2. +7 −0 Rakefile
  3. +5 −0 bin/pygmentize
  4. +2 −2 lib/{pygments.rb → pygmentize.rb}
  5. +4 −2 pygmentize.gemspec
  6. +5 −3 pygmentize.gemspec.erb
  7. +3 −3 test/{pygments.rb → pygmentize.rb}
View
8 README.md
@@ -3,11 +3,15 @@ Pygmentize
A standalone Pygments for Ruby.
- require "pygments"
+ require "pygmentize"
source = "function foo() { return 'bar'; }"
- Pygments.pygmentize(source, :javascript)
+ Pygmentize.process(source, :javascript)
+
+You can also use the binary from the command line:
+
+ $ pygmentize -l javascript somefile.js
You need to have Python installed.
View
7 Rakefile
@@ -0,0 +1,7 @@
+task :test do
+ require "cutest"
+
+ Cutest.run(Dir["test/pygmentize.rb"])
+end
+
+task :default => :test
View
5 bin/pygmentize
@@ -0,0 +1,5 @@
+#! /usr/bin/env ruby
+
+require "pygmentize"
+
+exec("#{Pygmentize.bin} #{Shellwords.shelljoin(ARGV)}")
View
4 lib/pygments.rb → lib/pygmentize.rb
@@ -1,13 +1,13 @@
require "shellwords"
-class Pygments
+class Pygmentize
VERSION = "0.0.1"
def self.bin
"/usr/bin/env python #{File.expand_path("../vendor/pygmentize.py", File.dirname(__FILE__))}"
end
- def self.pygmentize(source, lexer)
+ def self.process(source, lexer)
args = [
"-l", lexer.to_s,
"-f", "html",
View
6 pygmentize.gemspec
@@ -6,6 +6,8 @@ Gem::Specification.new do |s|
s.description = "A Ruby gem that vendors Pygments"
s.authors = ["Damian Janowski", "Michel Martens"]
s.email = ["djanowski@dimaion.com", "michel@soveran.com"]
- s.homepage = "http://github.com/djanowski/pygments"
- s.files = ["pygmentize.gemspec", "LICENSE", "lib/pygments.rb", "test/pygments.rb", "vendor/pygmentize.py", "vendor/pygments", "vendor/pygments/__init__.py", "vendor/pygments/__init__.pyc", "vendor/pygments/AUTHORS", "vendor/pygments/cmdline.py", "vendor/pygments/cmdline.pyc", "vendor/pygments/console.py", "vendor/pygments/console.pyc", "vendor/pygments/filter.py", "vendor/pygments/filter.pyc", "vendor/pygments/filters", "vendor/pygments/filters/__init__.py", "vendor/pygments/filters/__init__.pyc", "vendor/pygments/formatter.py", "vendor/pygments/formatter.pyc", "vendor/pygments/formatters", "vendor/pygments/formatters/__init__.py", "vendor/pygments/formatters/__init__.pyc", "vendor/pygments/formatters/_mapping.py", "vendor/pygments/formatters/_mapping.pyc", "vendor/pygments/formatters/bbcode.py", "vendor/pygments/formatters/bbcode.pyc", "vendor/pygments/formatters/html.py", "vendor/pygments/formatters/html.pyc", "vendor/pygments/formatters/img.py", "vendor/pygments/formatters/img.pyc", "vendor/pygments/formatters/latex.py", "vendor/pygments/formatters/latex.pyc", "vendor/pygments/formatters/other.py", "vendor/pygments/formatters/other.pyc", "vendor/pygments/formatters/rtf.py", "vendor/pygments/formatters/rtf.pyc", "vendor/pygments/formatters/svg.py", "vendor/pygments/formatters/svg.pyc", "vendor/pygments/formatters/terminal.py", "vendor/pygments/formatters/terminal.pyc", "vendor/pygments/formatters/terminal256.py", "vendor/pygments/formatters/terminal256.pyc", "vendor/pygments/lexer.py", "vendor/pygments/lexer.pyc", "vendor/pygments/lexers", "vendor/pygments/lexers/__init__.py", "vendor/pygments/lexers/__init__.pyc", "vendor/pygments/lexers/_asybuiltins.py", "vendor/pygments/lexers/_clbuiltins.py", "vendor/pygments/lexers/_luabuiltins.py", "vendor/pygments/lexers/_mapping.py", "vendor/pygments/lexers/_mapping.pyc", "vendor/pygments/lexers/_phpbuiltins.py", "vendor/pygments/lexers/_vimbuiltins.py", "vendor/pygments/lexers/agile.py", "vendor/pygments/lexers/agile.pyc", "vendor/pygments/lexers/asm.py", "vendor/pygments/lexers/compiled.py", "vendor/pygments/lexers/dotnet.py", "vendor/pygments/lexers/functional.py", "vendor/pygments/lexers/functional.pyc", "vendor/pygments/lexers/math.py", "vendor/pygments/lexers/other.py", "vendor/pygments/lexers/parsers.py", "vendor/pygments/lexers/special.py", "vendor/pygments/lexers/special.pyc", "vendor/pygments/lexers/templates.py", "vendor/pygments/lexers/text.py", "vendor/pygments/lexers/web.py", "vendor/pygments/lexers/web.pyc", "vendor/pygments/LICENSE", "vendor/pygments/plugin.py", "vendor/pygments/plugin.pyc", "vendor/pygments/scanner.py", "vendor/pygments/style.py", "vendor/pygments/style.pyc", "vendor/pygments/styles", "vendor/pygments/styles/__init__.py", "vendor/pygments/styles/__init__.pyc", "vendor/pygments/styles/autumn.py", "vendor/pygments/styles/borland.py", "vendor/pygments/styles/bw.py", "vendor/pygments/styles/colorful.py", "vendor/pygments/styles/default.py", "vendor/pygments/styles/default.pyc", "vendor/pygments/styles/emacs.py", "vendor/pygments/styles/friendly.py", "vendor/pygments/styles/fruity.py", "vendor/pygments/styles/manni.py", "vendor/pygments/styles/monokai.py", "vendor/pygments/styles/murphy.py", "vendor/pygments/styles/native.py", "vendor/pygments/styles/pastie.py", "vendor/pygments/styles/perldoc.py", "vendor/pygments/styles/tango.py", "vendor/pygments/styles/trac.py", "vendor/pygments/styles/vim.py", "vendor/pygments/styles/vs.py", "vendor/pygments/token.py", "vendor/pygments/token.pyc", "vendor/pygments/unistring.py", "vendor/pygments/unistring.pyc", "vendor/pygments/util.py", "vendor/pygments/util.pyc"]
+ s.homepage = "http://github.com/djanowski/pygmentize"
+ s.files = ["pygmentize.gemspec", "LICENSE", "Rakefile", "lib/pygmentize.rb", "test/pygmentize.rb", "vendor/pygmentize.py", "vendor/pygments", "vendor/pygments/__init__.py", "vendor/pygments/__init__.pyc", "vendor/pygments/AUTHORS", "vendor/pygments/cmdline.py", "vendor/pygments/cmdline.pyc", "vendor/pygments/console.py", "vendor/pygments/console.pyc", "vendor/pygments/filter.py", "vendor/pygments/filter.pyc", "vendor/pygments/filters", "vendor/pygments/filters/__init__.py", "vendor/pygments/filters/__init__.pyc", "vendor/pygments/formatter.py", "vendor/pygments/formatter.pyc", "vendor/pygments/formatters", "vendor/pygments/formatters/__init__.py", "vendor/pygments/formatters/__init__.pyc", "vendor/pygments/formatters/_mapping.py", "vendor/pygments/formatters/_mapping.pyc", "vendor/pygments/formatters/bbcode.py", "vendor/pygments/formatters/bbcode.pyc", "vendor/pygments/formatters/html.py", "vendor/pygments/formatters/html.pyc", "vendor/pygments/formatters/img.py", "vendor/pygments/formatters/img.pyc", "vendor/pygments/formatters/latex.py", "vendor/pygments/formatters/latex.pyc", "vendor/pygments/formatters/other.py", "vendor/pygments/formatters/other.pyc", "vendor/pygments/formatters/rtf.py", "vendor/pygments/formatters/rtf.pyc", "vendor/pygments/formatters/svg.py", "vendor/pygments/formatters/svg.pyc", "vendor/pygments/formatters/terminal.py", "vendor/pygments/formatters/terminal.pyc", "vendor/pygments/formatters/terminal256.py", "vendor/pygments/formatters/terminal256.pyc", "vendor/pygments/lexer.py", "vendor/pygments/lexer.pyc", "vendor/pygments/lexers", "vendor/pygments/lexers/__init__.py", "vendor/pygments/lexers/__init__.pyc", "vendor/pygments/lexers/_asybuiltins.py", "vendor/pygments/lexers/_clbuiltins.py", "vendor/pygments/lexers/_luabuiltins.py", "vendor/pygments/lexers/_mapping.py", "vendor/pygments/lexers/_mapping.pyc", "vendor/pygments/lexers/_phpbuiltins.py", "vendor/pygments/lexers/_vimbuiltins.py", "vendor/pygments/lexers/agile.py", "vendor/pygments/lexers/agile.pyc", "vendor/pygments/lexers/asm.py", "vendor/pygments/lexers/compiled.py", "vendor/pygments/lexers/dotnet.py", "vendor/pygments/lexers/functional.py", "vendor/pygments/lexers/functional.pyc", "vendor/pygments/lexers/math.py", "vendor/pygments/lexers/other.py", "vendor/pygments/lexers/parsers.py", "vendor/pygments/lexers/special.py", "vendor/pygments/lexers/special.pyc", "vendor/pygments/lexers/templates.py", "vendor/pygments/lexers/text.py", "vendor/pygments/lexers/web.py", "vendor/pygments/lexers/web.pyc", "vendor/pygments/LICENSE", "vendor/pygments/plugin.py", "vendor/pygments/plugin.pyc", "vendor/pygments/scanner.py", "vendor/pygments/style.py", "vendor/pygments/style.pyc", "vendor/pygments/styles", "vendor/pygments/styles/__init__.py", "vendor/pygments/styles/__init__.pyc", "vendor/pygments/styles/autumn.py", "vendor/pygments/styles/borland.py", "vendor/pygments/styles/bw.py", "vendor/pygments/styles/colorful.py", "vendor/pygments/styles/default.py", "vendor/pygments/styles/default.pyc", "vendor/pygments/styles/emacs.py", "vendor/pygments/styles/friendly.py", "vendor/pygments/styles/fruity.py", "vendor/pygments/styles/manni.py", "vendor/pygments/styles/monokai.py", "vendor/pygments/styles/murphy.py", "vendor/pygments/styles/native.py", "vendor/pygments/styles/pastie.py", "vendor/pygments/styles/perldoc.py", "vendor/pygments/styles/tango.py", "vendor/pygments/styles/trac.py", "vendor/pygments/styles/vim.py", "vendor/pygments/styles/vs.py", "vendor/pygments/token.py", "vendor/pygments/token.pyc", "vendor/pygments/unistring.py", "vendor/pygments/unistring.pyc", "vendor/pygments/util.py", "vendor/pygments/util.pyc"]
+
+ s.executables.push("pygmentize")
end
View
8 pygmentize.gemspec.erb
@@ -1,13 +1,13 @@
-<% require "./lib/pygments" -%>
+<% require "./lib/pygmentize" -%>
Gem::Specification.new do |s|
s.name = "pygmentize"
- s.version = "<%= Pygments::VERSION %>"
+ s.version = "<%= Pygmentize::VERSION %>"
s.summary = "A Ruby gem that vendors Pygments"
s.description = "A Ruby gem that vendors Pygments"
s.authors = ["Damian Janowski", "Michel Martens"]
s.email = ["djanowski@dimaion.com", "michel@soveran.com"]
- s.homepage = "http://github.com/djanowski/pygments"
+ s.homepage = "http://github.com/djanowski/pygmentize"
s.files = <%= Dir[
"*.gemspec",
"LICENSE",
@@ -17,4 +17,6 @@ Gem::Specification.new do |s|
"test/*.*",
"vendor/**/*",
].inspect %>
+
+ s.executables.push("pygmentize")
end
View
6 test/pygments.rb → test/pygmentize.rb
@@ -1,10 +1,10 @@
# encoding: UTF-8
-require File.expand_path("../lib/pygments", File.dirname(__FILE__))
+require File.expand_path("../lib/pygmentize", File.dirname(__FILE__))
require "nokogiri"
test "colorizes output" do
- output = Pygments.pygmentize(%Q[{foo: "bar"}], :javascript)
+ output = Pygmentize.process(%Q[{foo: "bar"}], :javascript)
doc = Nokogiri::HTML(output)
@@ -13,7 +13,7 @@
end
test "handles encodings" do
- output = Pygments.pygmentize(%Q[{foo: "bar", baz: "qüx"}], :javascript)
+ output = Pygmentize.process(%Q[{foo: "bar", baz: "qüx"}], :javascript)
assert output.encoding == Encoding::UTF_8
end

0 comments on commit 1088751

Please sign in to comment.