rtrac-utils 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +28 -0
- data/README.txt +51 -0
- data/Rakefile +4 -0
- data/bin/rtrac-cards +62 -0
- data/config/hoe.rb +74 -0
- data/config/requirements.rb +15 -0
- data/lib/rtrac-utils.rb +13 -0
- data/lib/rtrac-utils/rtrac_cards.rb +44 -0
- data/lib/rtrac-utils/version.rb +9 -0
- data/log/debug.log +0 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/spec/rtrac-utils/rtrac_cards_spec.rb +82 -0
- data/spec/rtrac-utils_spec.rb +2 -0
- data/spec/spec_helper.rb +48 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/website/index.html +93 -0
- data/website/index.txt +39 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +96 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 ELC Technologies
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
bin/rtrac-cards
|
7
|
+
config/hoe.rb
|
8
|
+
config/requirements.rb
|
9
|
+
lib/rtrac-utils.rb
|
10
|
+
lib/rtrac-utils/version.rb
|
11
|
+
lib/rtrac-utils/rtrac_cards.rb
|
12
|
+
log/debug.log
|
13
|
+
script/console
|
14
|
+
script/destroy
|
15
|
+
script/generate
|
16
|
+
script/txt2html
|
17
|
+
setup.rb
|
18
|
+
tasks/deployment.rake
|
19
|
+
tasks/environment.rake
|
20
|
+
tasks/website.rake
|
21
|
+
spec/spec_helper.rb
|
22
|
+
spec/rtrac-utils_spec.rb
|
23
|
+
spec/rtrac-utils/rtrac_cards_spec.rb
|
24
|
+
website/index.html
|
25
|
+
website/index.txt
|
26
|
+
website/javascripts/rounded_corners_lite.inc.js
|
27
|
+
website/stylesheets/screen.css
|
28
|
+
website/template.html.erb
|
data/README.txt
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
= rtrac-utils
|
2
|
+
|
3
|
+
* http://rubyforge.org/projects/rtrac-utils
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
rtrac-utils is a suite of power-user Trac ticket utilities to make your Trac project run more smoothly.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* rtrac-cards: export your Trac tickets to index-card-size PDF's
|
12
|
+
* supports 3x5 and 4x6 sizes
|
13
|
+
* print only one milestone or all tickets
|
14
|
+
|
15
|
+
== SYNOPSIS:
|
16
|
+
|
17
|
+
rtrac-cards --milestone="Some Milestone"
|
18
|
+
|
19
|
+
== REQUIREMENTS:
|
20
|
+
|
21
|
+
* rtrac
|
22
|
+
* pdf-writer
|
23
|
+
|
24
|
+
== INSTALL:
|
25
|
+
|
26
|
+
sudo gem install -y rtrac-utils
|
27
|
+
|
28
|
+
== LICENSE:
|
29
|
+
|
30
|
+
(The MIT License)
|
31
|
+
|
32
|
+
Copyright (c) 2008 FIX
|
33
|
+
|
34
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
35
|
+
a copy of this software and associated documentation files (the
|
36
|
+
'Software'), to deal in the Software without restriction, including
|
37
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
38
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
39
|
+
permit persons to whom the Software is furnished to do so, subject to
|
40
|
+
the following conditions:
|
41
|
+
|
42
|
+
The above copyright notice and this permission notice shall be
|
43
|
+
included in all copies or substantial portions of the Software.
|
44
|
+
|
45
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
46
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
47
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
48
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
49
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
50
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
51
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/rtrac-cards
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Created on 2008-4-15.
|
4
|
+
# Copyright (c) 2008. All rights reserved.
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'rubygems'
|
8
|
+
require File.dirname(__FILE__) + '/../lib/rtrac-utils'
|
9
|
+
rescue LoadError
|
10
|
+
puts "Error loading dependencies."
|
11
|
+
end
|
12
|
+
|
13
|
+
include RtracUtils
|
14
|
+
|
15
|
+
require 'optparse'
|
16
|
+
|
17
|
+
# NOTE: the option -p/--path= is given as an example, and should probably be replaced in your application.
|
18
|
+
|
19
|
+
OPTIONS = {
|
20
|
+
:path => '~',
|
21
|
+
:file => 'trac.pdf',
|
22
|
+
:size => '4x6'
|
23
|
+
}
|
24
|
+
MANDATORY_OPTIONS = %w( )
|
25
|
+
|
26
|
+
parser = OptionParser.new do |opts|
|
27
|
+
opts.banner = <<BANNER
|
28
|
+
Export a PDF of your Trac tickets for printing to index cards.
|
29
|
+
Be sure to set up your Rtrac configuration file before executing. This is usually kept at ~/.rtrac.yml.
|
30
|
+
|
31
|
+
Usage: #{File.basename($0)} [options]
|
32
|
+
|
33
|
+
Options are:
|
34
|
+
BANNER
|
35
|
+
opts.separator ""
|
36
|
+
opts.on("-p", "--path=PATH", String,
|
37
|
+
"The root path for selecting files",
|
38
|
+
"Default: ~") { |OPTIONS[:path]| }
|
39
|
+
opts.on("-h", "--help",
|
40
|
+
"Show this help message.") { puts opts; exit }
|
41
|
+
opts.on("-m", "--milestone=MILESTONE", String,
|
42
|
+
"Milestone to print",
|
43
|
+
"Default: ALL") { |OPTIONS[:milestone]| }
|
44
|
+
opts.on("-s", "--size=SIZE", String,
|
45
|
+
"Paper size (one of 3x5 or 4x6)",
|
46
|
+
"Default: 4x6") { |OPTIONS[:paper]| }
|
47
|
+
opts.on("-o", "--output=FILE", String,
|
48
|
+
"Output file",
|
49
|
+
"Default: trac.pdf") { |OPTIONS[:file]| }
|
50
|
+
|
51
|
+
opts.parse!(ARGV)
|
52
|
+
|
53
|
+
if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
|
54
|
+
puts opts; exit
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
path = OPTIONS[:path]
|
59
|
+
|
60
|
+
OPTIONS[:paper] = OPTIONS[:paper]=='3x5' ? :is_3x5 : :is_4x6
|
61
|
+
|
62
|
+
RtracUtils::RtracCards.write!(OPTIONS[:file], OPTIONS)
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rtrac-utils/version'
|
2
|
+
|
3
|
+
AUTHOR = 'T.J. VanSlyke' # can also be an array of Authors
|
4
|
+
EMAIL = "tj@elctech.com"
|
5
|
+
DESCRIPTION = "a suite of utilities for use with Josh Stephenson's Rtrac gem"
|
6
|
+
GEM_NAME = 'rtrac-utils' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'rtrac-utils' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
|
11
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
12
|
+
@config = nil
|
13
|
+
RUBYFORGE_USERNAME = "unknown"
|
14
|
+
def rubyforge_username
|
15
|
+
unless @config
|
16
|
+
begin
|
17
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
18
|
+
rescue
|
19
|
+
puts <<-EOS
|
20
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
21
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
22
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
23
|
+
EOS
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
REV = nil
|
32
|
+
# UNCOMMENT IF REQUIRED:
|
33
|
+
# REV = YAML.load(`svn info`)['Revision']
|
34
|
+
VERS = RtracUtils::VERSION::STRING + (REV ? ".#{REV}" : "")
|
35
|
+
RDOC_OPTS = ['--quiet', '--title', 'rtrac-utils documentation',
|
36
|
+
"--opname", "index.html",
|
37
|
+
"--line-numbers",
|
38
|
+
"--main", "README",
|
39
|
+
"--inline-source"]
|
40
|
+
|
41
|
+
class Hoe
|
42
|
+
def extra_deps
|
43
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
44
|
+
@extra_deps
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Generate all the Rake tasks
|
49
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
50
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
51
|
+
p.developer(AUTHOR, EMAIL)
|
52
|
+
p.description = DESCRIPTION
|
53
|
+
p.summary = DESCRIPTION
|
54
|
+
p.url = HOMEPATH
|
55
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
56
|
+
p.test_globs = ["test/**/test_*.rb"]
|
57
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
58
|
+
|
59
|
+
# == Optional
|
60
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
61
|
+
p.extra_deps =
|
62
|
+
[
|
63
|
+
['rtrac', '1.0.2'],
|
64
|
+
['pdf-writer', '1.1.8']
|
65
|
+
]
|
66
|
+
|
67
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
72
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
73
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
74
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
data/lib/rtrac-utils.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
gem 'rtrac'
|
6
|
+
gem 'pdf-writer'
|
7
|
+
require 'rtrac'
|
8
|
+
require 'pdf/writer'
|
9
|
+
require File.dirname(__FILE__) + '/rtrac-utils/rtrac_cards'
|
10
|
+
|
11
|
+
module RtracUtils
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module RtracUtils
|
2
|
+
class RtracCards
|
3
|
+
|
4
|
+
def self.message(text)
|
5
|
+
puts "rtrac-cards: #{text}"
|
6
|
+
end
|
7
|
+
|
8
|
+
# Needed because Rtrac currently only allows pulling a
|
9
|
+
# given number of tickets.
|
10
|
+
MAX_FIXNUM = 999
|
11
|
+
|
12
|
+
def self.write!(file, options={})
|
13
|
+
file = File.new(file, "w") if file.is_a? String
|
14
|
+
|
15
|
+
message 'Retreiving tickets...'
|
16
|
+
if !options[:milestone] || options[:milestone] == :all
|
17
|
+
tickets = Rtrac::Base.get_tickets(MAX_FIXNUM)
|
18
|
+
else
|
19
|
+
milestone = options[:milestone]
|
20
|
+
tickets = Rtrac::Base.get_by_milestone(milestone)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
if options[:paper] == :is_3x5
|
25
|
+
paper = [ 12.7, 7.62 ]
|
26
|
+
else
|
27
|
+
paper = [ 15.24, 10.16 ]
|
28
|
+
end
|
29
|
+
pdf = PDF::Writer.new(:paper => paper)
|
30
|
+
|
31
|
+
message 'Exporting pages...'
|
32
|
+
tickets.each do |id|
|
33
|
+
ticket = Rtrac::Ticket.new(id)
|
34
|
+
puts ">> #{ticket.summary}"
|
35
|
+
pdf.text "##{id}", :font_size => 12, :justification => :right
|
36
|
+
pdf.text ticket.summary, :font_size => 14, :justification => :left
|
37
|
+
pdf.start_new_page
|
38
|
+
end
|
39
|
+
|
40
|
+
pdf.save_as(file.path)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
data/log/debug.log
ADDED
File without changes
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/rtrac-utils.rb'}"
|
9
|
+
puts "Loading rtrac-utils gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/script/txt2html
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
begin
|
5
|
+
require 'newgem'
|
6
|
+
rescue LoadError
|
7
|
+
puts "\n\nGenerating the website requires the newgem RubyGem"
|
8
|
+
puts "Install: gem install newgem\n\n"
|
9
|
+
exit(1)
|
10
|
+
end
|
11
|
+
require 'redcloth'
|
12
|
+
require 'syntax/convertors/html'
|
13
|
+
require 'erb'
|
14
|
+
require File.dirname(__FILE__) + '/../lib/rtrac-utils/version.rb'
|
15
|
+
|
16
|
+
version = RtracUtils::VERSION::STRING
|
17
|
+
download = 'http://rubyforge.org/projects/rtrac-utils'
|
18
|
+
|
19
|
+
class Fixnum
|
20
|
+
def ordinal
|
21
|
+
# teens
|
22
|
+
return 'th' if (10..19).include?(self % 100)
|
23
|
+
# others
|
24
|
+
case self % 10
|
25
|
+
when 1: return 'st'
|
26
|
+
when 2: return 'nd'
|
27
|
+
when 3: return 'rd'
|
28
|
+
else return 'th'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Time
|
34
|
+
def pretty
|
35
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def convert_syntax(syntax, source)
|
40
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
41
|
+
end
|
42
|
+
|
43
|
+
if ARGV.length >= 1
|
44
|
+
src, template = ARGV
|
45
|
+
template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
|
46
|
+
|
47
|
+
else
|
48
|
+
puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
|
49
|
+
exit!
|
50
|
+
end
|
51
|
+
|
52
|
+
template = ERB.new(File.open(template).read)
|
53
|
+
|
54
|
+
title = nil
|
55
|
+
body = nil
|
56
|
+
File.open(src) do |fsrc|
|
57
|
+
title_text = fsrc.readline
|
58
|
+
body_text = fsrc.read
|
59
|
+
syntax_items = []
|
60
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
61
|
+
ident = syntax_items.length
|
62
|
+
element, syntax, source = $1, $2, $3
|
63
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
64
|
+
"syntax-temp-#{ident}"
|
65
|
+
}
|
66
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
67
|
+
body = RedCloth.new(body_text).to_html
|
68
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
69
|
+
end
|
70
|
+
stat = File.stat(src)
|
71
|
+
created = stat.ctime
|
72
|
+
modified = stat.mtime
|
73
|
+
|
74
|
+
$stdout << template.result(binding)
|