Skip to content

Commit

Permalink
Partial gemification of CodeRippa
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Tan Wei Hao committed Mar 25, 2012
1 parent 26a8117 commit 94462d9
Show file tree
Hide file tree
Showing 15 changed files with 899 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source 'https://rubygems.org'

# Specify your gem's dependencies in code_rippa.gemspec
gemspec
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2012 Benjamin Tan Wei Hao

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# CodeRippa

CodeRippa takes your source code and turns it into a beautiful PDF file.

## Installation

Add this line to your application's Gemfile:

gem 'code_rippa'

And then execute:

$ bundle

Or install it yourself as:

$ gem install code_rippa

## Usage

$ Usage: code_rippa [options] file_or_directory
$ -l, --list-themes List all available themes
$ -t, --theme THEME Selected theme
$ -n, --list-syntax List all available syntax
$ -s, --syntax SYNTAX Selected syntax
$ -x, --excluded-exts E1,E2,EN Exclude these extensions when processing
$ -h, --help Display this screen

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
74 changes: 74 additions & 0 deletions bin/code_rippa
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#! /usr/bin/env ruby
begin
require 'optparse'
require 'code_rippa'
rescue LoadError
$:.unshift File.join( File.dirname(__FILE__), '..', 'lib' )
require 'code_rippa'
end

options = {}
option_parser = OptionParser.new do |opts|

opts.banner = CodeRippa.usage

opts.on('-l', '--list-themes', 'List all available themes') do
puts Uv.themes.join("\n")
exit
end

opts.on('-t', '--theme THEME', 'Selected theme') do |theme|
if Uv.themes.include? theme
options[:theme] = theme
else
raise ArgumentError, "#{theme} theme not found. Use -l to see the list of available themes."
end
end

opts.on('-n', '--list-syntax', 'List all available syntax') do
puts CodeRippa.supported_syntax.join("\n")
exit
end

opts.on('-s', '--syntax SYNTAX', 'Selected syntax') do |syntax|
if CodeRippa.supported_syntax.include? syntax
options[:syntax] = syntax
else
raise ArgumentError, "syntax for #{syntax} not found. Use -s to see the list of available syntax."
end
end


options[:excluded_exts] = []
opts.on('-x', '--excluded-exts E1,E2,EN', Array, 'Exclude these extensions when processing') do |exts|

options[:excluded_exts] = exts.sort!
valid_exts = exts & CodeRippa.supported_exts

if valid_exts != exts
invalid_exts = exts - valid_exts
raise ArgumentError, "These extensions are not supported: #{invalid_exts.join(" ")}. Aborting."
else
options[:ex_extensions] = valid_exts
end
end

opts.on('-h', '--help', 'Display this screen') do
puts opts
exit
end
end

begin
option_parser.parse!

if options[:theme] and options[:syntax] and ARGV.size == 1
CodeRippa.rip_file(ARGV[0], options[:theme], options[:syntax], options[:excluded_exts])
else
raise ArgumentError, "Missing arguments. Aborting.\n" + CodeRippa.usage
end

rescue ArgumentError => e
puts e
exit
end
19 changes: 19 additions & 0 deletions bin/out.aux
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
\relax
\providecommand\HyperFirstAtBeginDocument{\AtBeginDocument}
\HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined
\global\let\oldcontentsline\contentsline
\gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}}
\global\let\oldnewlabel\newlabel
\gdef\newlabel#1#2{\newlabelxx{#1}#2}
\gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}}
\AtEndDocument{\ifx\hyper@anchor\@undefined
\let\contentsline\oldcontentsline
\let\newlabel\oldnewlabel
\fi}
\fi}
\global\let\hyper@last\relax
\gdef\HyperFirstAtBeginDocument#1{#1}
\providecommand\HyField@AuxAddToFields[1]{}
\gdef \LT@i {\LT@entry
{5}{33.67181pt}\LT@entry
{3}{646.72685pt}}
Loading

0 comments on commit 94462d9

Please sign in to comment.