Sha256: d9a696187eb5a67a56712a93a8deffa70f679e6902f5b88cadc52e87b088f81e

Contents?: true

Size: 1.4 KB

Versions: 82

Compression:

Stored size: 1.4 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'redcloth'
require 'syntax/convertors/html'
require 'erb'
require 'active_support'

version_path = File.join(File.dirname(__FILE__), '..', 'lib', 'composite_primary_keys', 'version.rb')
require File.expand_path(version_path)

version  = CompositePrimaryKeys::VERSION::STRING
download = 'http://rubygems.org/gems/composite_primary_keys'

class Fixnum
  def ordinal
    # teens
    return 'th' if (10..19).include?(self % 100)
    # others
    case self % 10
    when 1
      return 'st'
    when 2
      return 'nd'
    when 3
      return 'rd'
    else
      return 'th'
    end
  end
end

class Time
  def pretty
    return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
  end
end

def convert_syntax(syntax, source)
  return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
end

if ARGV.length >= 1
  src, template = ARGV
  template ||= File.dirname(__FILE__) + '/../website/template.js'
else
  puts("Usage: #{File.split($0).last} source.txt [template.js] > output.html")
  exit!
end

template = ERB.new(File.open(template).read)

title = nil
body = nil
File.open(src) do |fsrc|
  title_text = fsrc.readline
  body_text = fsrc.read
  title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
  body = RedCloth.new(body_text)
end
stat = File.stat(src)
created = stat.ctime
modified = stat.mtime

$stdout << template.result(binding)

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
composite_primary_keys-8.1.2 scripts/txt2js
composite_primary_keys-7.0.16 scripts/txt2js
composite_primary_keys-7.0.15 scripts/txt2js
composite_primary_keys-8.1.1 scripts/txt2js
composite_primary_keys-7.0.14 scripts/txt2js
composite_primary_keys-8.1.0 scripts/txt2js
composite_primary_keys-7.0.13 scripts/txt2js
composite_primary_keys-6.0.8 scripts/txt2js
composite_primary_keys-8.0.0 scripts/txt2js
composite_primary_keys-7.0.12 scripts/txt2js
composite_primary_keys-7.0.11 scripts/txt2js
composite_primary_keys-6.0.7 scripts/txt2js
composite_primary_keys-7.0.10 scripts/txt2js
composite_primary_keys-7.0.9 scripts/txt2js
composite_primary_keys-7.0.8 scripts/txt2js
composite_primary_keys-7.0.7 scripts/txt2js
composite_primary_keys-7.0.6 scripts/txt2js
composite_primary_keys-7.0.5 scripts/txt2js
composite_primary_keys-7.0.4 scripts/txt2js
composite_primary_keys-7.0.3 scripts/txt2js