Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

code_rippa

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code_rippa - rubygems Package Compare versions

Comparing version
0.0.7
to
1.0.0
+36
Gemfile.lock
PATH
remote: .
specs:
code_rippa (0.0.9)
ansi (~> 1.4)
color (~> 1.5)
language_sniffer (~> 1.0)
psych (~> 2.0)
ptools (~> 1.2)
rainbow (~> 2.0)
spox-ultraviolet (~> 0.10)
GEM
remote: https://rubygems.org/
specs:
ansi (1.4.3)
color (1.5.1)
language_sniffer (1.0.2)
minitest (5.2.2)
psych (2.0.2)
ptools (1.2.2)
rainbow (2.0.0)
rake (10.1.1)
spox-plist (3.0.1)
spox-textpow (0.10.3)
spox-plist
spox-ultraviolet (0.10.5)
spox-textpow
PLATFORMS
ruby
DEPENDENCIES
code_rippa!
minitest (~> 5.2)
rake (~> 10.1)
require 'yaml'
require 'syck'
require 'fileutils'
if ARGV.empty?
$stderr.puts "! Must pass one or more filenames to convert from Syck output to Psych output."
exit 1
end
bad_files = ARGV.select{ |f| ! File.exists?(f) }
if bad_files.any?
$stderr.puts "! Aborting because the following files do not exist:"
$stderr.puts bad_files
exit 1
end
def use_syck
YAML::ENGINE.yamler = 'syck'
raise "Oops! Something went horribly wrong." unless YAML == Syck
end
def use_psych
YAML::ENGINE.yamler = 'psych'
raise "Oops! Something went horribly wrong." unless YAML == Psych
end
ARGV.each do |filename|
$stdout.print "Converting #{filename} from Syck to Psych..."
use_syck
hash = YAML.load(File.read filename)
FileUtils.cp filename, "#{filename}.bak"
use_psych
File.open(filename, 'w'){ |file| file.write(YAML.dump(hash)) }
$stdout.puts " done."
end
+12
-10

@@ -6,3 +6,3 @@ # -*- encoding: utf-8 -*-

gem.authors = ["Benjamin Tan Wei Hao"]
gem.email = ["ben@witsvale.com"]
gem.email = ["benjamintanweihao@gmail.com"]
gem.platform = Gem::Platform::RUBY

@@ -19,11 +19,13 @@ gem.description = %q{Converts source code into a (bookmarked, themed, and syntax highlighted!) PDF.}

gem.version = CodeRippa::VERSION
gem.required_ruby_version = '>= 1.9.0'
gem.add_dependency "color"
gem.add_dependency "ansi"
gem.add_dependency "language_sniffer"
gem.add_dependency "ptools", "~> 1.2.1"
gem.add_dependency "rainbow"
gem.add_dependency "spox-ultraviolet", "~> 0.10.5"
gem.add_development_dependency "rake"
gem.add_development_dependency "minitest"
gem.required_ruby_version = ">= 1.9.0"
gem.add_dependency "psych", "~> 2.0"
gem.add_dependency "ansi", "~> 1.4"
gem.add_dependency "color", "~> 1.5"
gem.add_dependency "language_sniffer", "~> 1.0"
gem.add_dependency "ptools", "~> 1.2"
gem.add_dependency "rainbow", "~> 2.0"
gem.add_dependency "spox-ultraviolet", "~> 0.10"
gem.add_development_dependency "rake", "~> 10.1"
gem.add_development_dependency "minitest", "~> 5.2"
gem.licenses = ['MIT']
end
require 'find'
require 'code_rippa/uv_overrides'
require 'code_rippa/version'
require 'ansi'
require 'ansi/progressbar'

@@ -12,3 +13,3 @@ require 'language_sniffer'

YAML::ENGINE.yamler = 'syck'
YAML::ENGINE.yamler = 'psych'

@@ -20,55 +21,79 @@ module CodeRippa

@@supported_ext = nil
# main entry point:
# Parses the given directory/file, and writes the output file (out.tex)
# into the current directory.
#
# path - The directory path
# theme - The selected theme
#
# Examples
# main entry point for parsing using the module
#
# parse("~/code/ruby/some_folder_or_file", "space_cadet")
# takes in an array of the arguments (a list of valid file/dir paths), and a theme
#
# Returns nothing
def self.parse(path, theme)
# logfile = File.open('code_rippa.log', 'w')
output = ""
if FileTest.file?(path)
output = parse_file(path, theme)
else
pbar = Progressbar.new("Rippin'", Dir["**/*"].length)
counter = 0
# returns latex output as a string
# note that this output doesn't contain the preamble, or the closing tags. (ref:self.write_file)
def self.handle_parsing(arguments, theme)
paths = parse_paths(arguments)
output = parse(paths, theme)
return output
end
Find.find path do |p|
# logfile << "Parsing: #{p}\n"
depth = p.to_s.count('/')
if File.basename(p)[0] == ?.
Find.prune
else
output << bookmark(p, depth, counter) if bookmarkable?(p, source_syntax(p))
begin
output << parse_file(p, theme)
rescue Exception => e
# logfile << "* Failed: #{p}\n"
# Takes in an array of file/dir paths, and returns an array of file paths,
# having expanded the directories into their contents.
def self.parse_paths(args)
paths = []
args.each do |path|
if FileTest.file? path
paths << path
elsif File.directory?(path)
Find.find path do |file_path|
if File.basename(file_path)[0] == ?.
Find.prune
else
paths << file_path
end
end
counter += 1
pbar.inc
else
raise ArgumentError, "Invalid path: #{path}. Aborting.\n"
end
pbar.finish
end
return paths
end
# the main workhorse for parsing.
# takes in a list of file paths, and returns latex
def self.parse(files, theme)
output = ""
pbar = Progressbar.new("Rippin'", files.length)
counter = 0
files.each do | p |
depth = p.to_s.count('/')
output << bookmark(p, depth, counter) if bookmarkable?(p, source_syntax(p))
begin
output << parse_file(p, theme)
rescue Exception => e
# logfile << "* Failed: #{p}\n"
end
counter += 1
pbar.inc
end
pbar.finish
return output
end
# writes to the out.tex file.
# if passed true for the "compile" parameter, also compiles the tex file into pdf.
# therefore, if one were to desire ps output/*, they could generate it themselves
def self.write_file(output, theme, compile = false)
outfile = File.open('out.tex', 'w')
output = preamble(theme) << output << postscript
outfile.write output
outfile.close
if compile
compile_pdf(outfile)
end
end
def self.compile_pdf(outfile)
path = ""
# Run the 'pdflatex' command
puts "=================================================="
if pdflatex_installed?
puts "pdflatex found!. Converting TeX -> PDF".color(:green)
puts "pdflatex found!. Converting TeX -> PDF"
puts "Compiling [1/2]"

@@ -89,3 +114,2 @@ `pdflatex -interaction=batchmode #{File.expand_path(outfile)}`

puts "=================================================="
end

@@ -308,13 +332,11 @@

def self.completed_message(in_path, out_path)
msg = "Success!. ".color(:green)
msg << "Output file written to: "
msg << "#{out_path.gsub!('tex', 'pdf')}".color(:green)
"Success! Output file written to: #{out_path.gsub!('tex', 'pdf')}"
end
def self.install_pdflatex_message(out_path)
msg = "You do not have 'pdflatex' installed!\n".color(:red)
msg = "You do not have 'pdflatex' installed!\n"
msg << "Please install it at "
msg << "http://www.tug.org/texlive'\n".color(:yellow)
msg << "http://www.tug.org/texlive'\n"
msg << "Output TEX file written to: "
msg << "#{out_path}\n".color(:yellow)
msg << "#{out_path}\n"
end

@@ -336,5 +358,1 @@

end
# Sanity check
# CodeRippa.parse("/Users/rambo/code/ruby/code_rippa", "succulent")
# CodeRippa.parse("/Users/rambo/code/ruby/code_rippa/lib/code_rippa.rb", "amy")
module CodeRippa
VERSION = "0.0.7"
VERSION = "1.0.0"
end

@@ -1,2 +0,2 @@

Copyright (c) 2012 Benjamin Tan Wei Hao
Copyright (c) 2014 Benjamin Tan Wei Hao

@@ -22,2 +22,2 @@ MIT License

OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@@ -1,5 +0,9 @@

# CodeRippa
# CodeRippa!
![Code Rippa!](http://code-rippa.heroku.com/assets/ripit-fbef5b91ff0416d7cfb736d4fcff2b04.png)
[![Build Status](https://secure.travis-ci.org/benjamintanweihao/code_rippa.png)](http://travis-ci.org/benjamintanweihao/code_rippa)
[![endorse](http://api.coderwall.com/benjamintanweihao/endorsecount.png)](http://coderwall.com/benjamintanweihao)
_CodeRippa_ takes your source code and turns it into a beautiful PDF file. Currently, it supports 150 languages and 84 themes, all of which are available in TextMate.

@@ -78,2 +82,15 @@

### 1.0.0
- Compile pdf by default.
- Choose a more sane theme (Code) by default.
- Include LICENCE.
### 0.0.8 - 0.0.9
- Syntax files are finally compatible for `psych`
- Abandoned `syck` completely for `psych`
- Ruby 2.x compatibility! \o/
- Thanks @jasonyeo for the initial push towards Ruby 2.x compatibility.
### 0.0.7

@@ -80,0 +97,0 @@

@@ -9,5 +9,7 @@ require 'uv'

if defined? Syck
YAML::ENGINE.yamler = 'syck'
else
YAML::ENGINE.yamler = 'psych'
YAML::ENGINE.yamler = 'syck'
module CodeRippa

@@ -124,2 +126,2 @@

end
end

@@ -29,53 +29,53 @@ require 'minitest/autorun'

describe ".rippable?" do
# describe ".rippable?" do
it "should parse a file with an extension that is supported" do
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.rb", 'rubyblue', [])
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.c", 'rubyblue', [])
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.cpp", 'rubyblue', [])
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.m", 'rubyblue', [])
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.s", 'rubyblue', [])
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.txt", 'rubyblue', [])
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.haml", 'rubyblue', [])
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.json", 'rubyblue', [])
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.py", 'rubyblue', [])
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.sh", 'rubyblue', [])
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.groovy", 'rubyblue', [])
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.php", 'rubyblue', [])
end
# it "should parse a file with an extension that is supported" do
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.rb", 'rubyblue')
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.c", 'rubyblue')
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.cpp", 'rubyblue')
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.m", 'rubyblue')
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.s", 'rubyblue')
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.txt", 'rubyblue')
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.haml", 'rubyblue')
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.json", 'rubyblue')
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.py", 'rubyblue')
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.sh", 'rubyblue')
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.groovy", 'rubyblue')
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.php", 'rubyblue')
# end
it "should not parse a file with an extension that isn't supported" do
assert_equal false, CodeRippa.rippable?("#{fixtures_path}/hello.vark", 'rubyblue', [])
assert_equal false, CodeRippa.rippable?("#{fixtures_path}/hello.psd", 'rubyblue', [])
assert_equal false, CodeRippa.rippable?("#{fixtures_path}/hello.ai", 'rubyblue', [])
assert_equal false, CodeRippa.rippable?("#{fixtures_path}/hello.scala", 'rubyblue', [])
end
# it "should not parse a file with an extension that isn't supported" do
# assert_equal false, CodeRippa.rippable?("#{fixtures_path}/hello.vark", 'rubyblue')
# assert_equal false, CodeRippa.rippable?("#{fixtures_path}/hello.psd", 'rubyblue')
# assert_equal false, CodeRippa.rippable?("#{fixtures_path}/hello.ai", 'rubyblue')
# assert_equal false, CodeRippa.rippable?("#{fixtures_path}/hello.scala", 'rubyblue')
# end
it "should not parse a directory" do
assert_equal false, CodeRippa.rippable?("#{fixtures_path}/", 'rubyblue', [])
end
# it "should not parse a directory" do
# assert_equal false, CodeRippa.rippable?("#{fixtures_path}/", 'rubyblue')
# end
it "should not parse a file that has an excluded extension" do
assert_equal false, CodeRippa.rippable?("#{fixtures_path}/hello.rb", 'rubyblue', ['rb'])
assert_equal false, CodeRippa.rippable?("#{fixtures_path}/hello.c", 'rubyblue', ['c'])
assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.cpp", 'rubyblue', ['rb'])
end
# it "should not parse a file that has an excluded extension" do
# assert_equal false, CodeRippa.rippable?("#{fixtures_path}/hello.rb", 'rubyblue')
# assert_equal false, CodeRippa.rippable?("#{fixtures_path}/hello.c", 'rubyblue')
# assert_equal true, CodeRippa.rippable?("#{fixtures_path}/hello.cpp", 'rubyblue')
# end
end
# end
describe ".bookmarkable?" do
# describe ".bookmarkable?" do
it "should bookmark a directory" do
assert_equal true, CodeRippa.bookmarkable?("#{fixtures_path}/", 'rubyblue', [])
end
# it "should bookmark a directory" do
# assert_equal true, CodeRippa.bookmarkable?("#{fixtures_path}/", 'rubyblue')
# end
it "should not bookmark a file that has an excluded extension" do
assert_equal false, CodeRippa.bookmarkable?("#{fixtures_path}/hello.rb", 'rubyblue', ['rb'])
assert_equal false, CodeRippa.bookmarkable?("#{fixtures_path}/hello.c", 'rubyblue', ['c'])
assert_equal true, CodeRippa.bookmarkable?("#{fixtures_path}/hello.cpp", 'rubyblue', ['rb'])
end
# it "should not bookmark a file that has an excluded extension" do
# assert_equal false, CodeRippa.bookmarkable?("#{fixtures_path}/hello.rb", 'rubyblue', ['rb'])
# assert_equal false, CodeRippa.bookmarkable?("#{fixtures_path}/hello.c", 'rubyblue', ['c'])
# assert_equal true, CodeRippa.bookmarkable?("#{fixtures_path}/hello.cpp", 'rubyblue', ['rb'])
# end
end
# end
end

@@ -19,21 +19,12 @@ require 'minitest/autorun'

describe ".rip_file" do
it "should rip a file that is supported" do
puts File.expand_path(File.open("."))
CodeRippa.rip_file(File.join("#{File.expand_path(File.open("."))}", "hello.rb"), "rubyblue", "ruby")
f1 = File.open("out.tex")
f2 = File.open("rip_file.tex")
assert (f1.size - f2.size).abs < 300
end
end
# describe ".rip_file" do
# it "should rip a file that is supported" do
# puts File.expand_path(File.open("."))
# CodeRippa.rip_file(File.join("#{File.expand_path(File.open("."))}", "hello.rb"), "rubyblue", "ruby")
# f1 = File.open("out.tex")
# f2 = File.open("rip_file.tex")
# assert (f1.size - f2.size).abs < 300
# end
# end
describe ".rip_dir" do
it "should rip a directory that is supported" do
CodeRippa.rip_dir("ruby_proj/", "rubyblue", "ruby")
f1 = File.open("out.tex")
f2 = File.open("rip_dir.tex")
assert (f1.size - f2.size).abs < 300
end
end
end

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet