Permalink
Browse files

initial commit

  • Loading branch information...
ttscoff committed Aug 19, 2015
1 parent cce9114 commit dfa74f7b1fb3761d7ce4ec7dec89bba879604683
View
@@ -0,0 +1,2 @@
source 'https://rubygems.org'
gemspec
View
@@ -0,0 +1,47 @@
PATH
remote: .
specs:
mdless (0.0.1)
GEM
remote: https://rubygems.org/
specs:
aruba (0.6.2)
childprocess (>= 0.3.6)
cucumber (>= 1.1.1)
rspec-expectations (>= 2.7.0)
builder (3.2.2)
childprocess (0.5.6)
ffi (~> 1.0, >= 1.0.11)
cucumber (2.0.0)
builder (>= 2.1.2)
cucumber-core (~> 1.1.3)
diff-lcs (>= 1.1.3)
gherkin (~> 2.12)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
cucumber-core (1.1.3)
gherkin (~> 2.12.0)
diff-lcs (1.2.5)
ffi (1.9.8)
gherkin (2.12.2)
multi_json (~> 1.3)
json (1.8.2)
multi_json (1.11.0)
multi_test (0.1.2)
rake (10.4.2)
rdoc (4.1.1)
json (~> 1.4)
rspec-expectations (3.2.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.2)
PLATFORMS
ruby
DEPENDENCIES
aruba
mdless!
rake
rdoc
View
@@ -0,0 +1,6 @@
= mdless
Describe your project here
:include:mdless.rdoc
View
@@ -0,0 +1,44 @@
require 'rake/clean'
require 'rubygems'
require 'rubygems/package_task'
require 'rdoc/task'
require 'cucumber'
require 'cucumber/rake/task'
Rake::RDocTask.new do |rd|
rd.main = "README.rdoc"
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
rd.title = 'Your application title'
end
spec = eval(File.read('mdless.gemspec'))
Gem::PackageTask.new(spec) do |pkg|
end
CUKE_RESULTS = 'results.html'
CLEAN << CUKE_RESULTS
desc 'Run features'
Cucumber::Rake::Task.new(:features) do |t|
opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
t.cucumber_opts = opts
t.fork = false
end
desc 'Run features tagged as work-in-progress (@wip)'
Cucumber::Rake::Task.new('features:wip') do |t|
tag_opts = ' --tags ~@pending'
tag_opts = ' --tags @wip'
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
t.fork = false
end
task :cucumber => :features
task 'cucumber:wip' => 'features:wip'
task :wip => 'features:wip'
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/*_test.rb']
end
task :default => [:test,:features]
View
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# coding: utf-8
require 'mdless'
def class_exists?(class_name)
klass = Module.const_get(class_name)
return klass.is_a?(Class)
rescue NameError
return false
end
if class_exists? 'Encoding'
Encoding.default_external = Encoding::UTF_8 if Encoding.respond_to?('default_external')
Encoding.default_internal = Encoding::UTF_8 if Encoding.respond_to?('default_internal')
end
CLIMarkdown::Converter.new(ARGV)
# at_exit {
# if cli.helpers.size
# cli.log.info("Cleaning up")
# cli.helpers.each do |helper|
# if !helper[:file].nil? && File.exists?(helper[:file])
# cli.log.info("-> #{helper[:file]}")
# FileUtils.rm_f(helper[:file])
# end
# end
# end
# }
View
@@ -0,0 +1,8 @@
Feature: My bootstrapped app kinda works
In order to get going on coding my awesome app
I want to have aruba and cucumber setup
So I don't have to do it myself
Scenario: App just runs
When I get help for "mdless"
Then the exit status should be 0
@@ -0,0 +1,6 @@
When /^I get help for "([^"]*)"$/ do |app_name|
@app_name = app_name
step %(I run `#{app_name} help`)
end
# Add more step definitions here
View
@@ -0,0 +1,15 @@
require 'aruba/cucumber'
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
Before do
# Using "announce" causes massive warnings on 1.9.2
@puts = true
@original_rubylib = ENV['RUBYLIB']
ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
end
After do
ENV['RUBYLIB'] = @original_rubylib
end
View
@@ -0,0 +1,105 @@
#!/usr/bin/python
import sys
import re
def just(string, type, n):
"Justify a string to length n according to type."
if type == '::':
return string.center(n)
elif type == '-:':
return string.rjust(n)
elif type == ':-':
return string.ljust(n)
else:
return string
def normtable(text):
"Aligns the vertical bars in a text table."
# Start by turning the text into a list of lines.
lines = text.splitlines()
rows = len(lines)
# Figure out the cell formatting.
# First, find the separator line.
for i in range(rows):
if set(lines[i]).issubset('|:.-'):
formatline = lines[i]
formatrow = i
break
# Delete the separator line from the content.
del lines[formatrow]
# Determine how each column is to be justified.
formatline = formatline.strip(' ')
if formatline[0] == '|': formatline = formatline[1:]
if formatline[-1] == '|': formatline = formatline[:-1]
fstrings = formatline.split('|')
justify = []
for cell in fstrings:
ends = cell[0] + cell[-1]
if ends == '::':
justify.append('::')
elif ends == '-:':
justify.append('-:')
else:
justify.append(':-')
# Assume the number of columns in the separator line is the number
# for the entire table.
columns = len(justify)
# Extract the content into a matrix.
content = []
for line in lines:
line = line.strip(' ')
if line[0] == '|': line = line[1:]
if line[-1] == '|': line = line[:-1]
cells = line.split('|')
# Put exactly one space at each end as "bumpers."
linecontent = [ ' ' + x.strip() + ' ' for x in cells ]
content.append(linecontent)
# Append cells to rows that don't have enough.
rows = len(content)
for i in range(rows):
while len(content[i]) < columns:
content[i].append('')
# Get the width of the content in each column. The minimum width will
# be 2, because that's the shortest length of a formatting string and
# because that matches an empty column with "bumper" spaces.
widths = [2] * columns
for row in content:
for i in range(columns):
widths[i] = max(len(row[i]), widths[i])
# Add whitespace to make all the columns the same width and
formatted = []
for row in content:
formatted.append('|' + '|'.join([ just(s, t, n) for (s, t, n) in zip(row, justify, widths) ]) + '|')
# Recreate the format line with the appropriate column widths.
formatline = '|' + '|'.join([ s[0] + '-'*(n-2) + s[-1] for (s, n) in zip(justify, widths) ]) + '|'
# Insert the formatline back into the table.
formatted.insert(formatrow, formatline)
# Return the formatted table.
return '\n'.join(formatted)
space_cleaner = r'''(?s)[ \t]*(?P<value>[\|:])[ \t]*'''
def whitespaceProcess(group_object):
return group_object.group('value')
# Read the input, process, and print.
unformatted = sys.stdin.read()
unformatted = re.sub(space_cleaner, whitespaceProcess, unformatted, flags=re.DOTALL)
print normtable(unformatted)
View
@@ -0,0 +1,14 @@
dir = File.dirname(__FILE__)
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
require 'optparse'
require 'shellwords'
require 'open3'
require 'fileutils'
require 'logger'
require 'mdless/version.rb'
require 'mdless/colors'
require 'mdless/converter'
# Add requires for other files you add to your project here, so
# you just need to require this one file in your bin file
Oops, something went wrong.

0 comments on commit dfa74f7

Please sign in to comment.