gigantron 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/test/test_generator_helper.rb +29 -29
  2. data/test/test_gigantron_generator.rb +118 -114
  3. data/test/test_helper.rb +4 -4
  4. data/test/test_mapreduce_task_generator.rb +50 -50
  5. data/test/test_migration_generator.rb +49 -49
  6. data/test/test_model_generator.rb +53 -53
  7. data/test/test_task_generator.rb +48 -48
  8. metadata +48 -109
  9. data/History.txt +0 -15
  10. data/License.txt +0 -20
  11. data/Manifest.txt +0 -62
  12. data/PostInstall.txt +0 -4
  13. data/README.txt +0 -77
  14. data/Rakefile +0 -4
  15. data/app_generators/gigantron/USAGE +0 -7
  16. data/app_generators/gigantron/gigantron_generator.rb +0 -81
  17. data/app_generators/gigantron/templates/Rakefile +0 -12
  18. data/app_generators/gigantron/templates/database.yml +0 -8
  19. data/app_generators/gigantron/templates/initialize.rb +0 -34
  20. data/app_generators/gigantron/templates/tasks/import.rake +0 -10
  21. data/app_generators/gigantron/templates/test/tasks/test_import.rb +0 -23
  22. data/app_generators/gigantron/templates/test/test_helper.rb +0 -7
  23. data/bin/gigantron +0 -15
  24. data/config/hoe.rb +0 -82
  25. data/config/requirements.rb +0 -15
  26. data/gigantron_generators/mapreduce_task/USAGE +0 -5
  27. data/gigantron_generators/mapreduce_task/mapreduce_task_generator.rb +0 -54
  28. data/gigantron_generators/mapreduce_task/templates/mapreduce/mr_task.rb +0 -22
  29. data/gigantron_generators/mapreduce_task/templates/tasks/task.rake +0 -5
  30. data/gigantron_generators/mapreduce_task/templates/test/tasks/test_task.rb +0 -22
  31. data/gigantron_generators/migration/USAGE +0 -5
  32. data/gigantron_generators/migration/migration_generator.rb +0 -61
  33. data/gigantron_generators/migration/templates/db/migrate/migration.rb +0 -7
  34. data/gigantron_generators/model/USAGE +0 -11
  35. data/gigantron_generators/model/model_generator.rb +0 -54
  36. data/gigantron_generators/model/templates/models/model.rb +0 -3
  37. data/gigantron_generators/model/templates/test/models/test_model.rb +0 -13
  38. data/gigantron_generators/task/USAGE +0 -10
  39. data/gigantron_generators/task/task_generator.rb +0 -51
  40. data/gigantron_generators/task/templates/tasks/task.rake +0 -4
  41. data/gigantron_generators/task/templates/test/tasks/test_task.rb +0 -22
  42. data/lib/gigantron/migrator.rb +0 -10
  43. data/lib/gigantron/tasks/db.rb +0 -11
  44. data/lib/gigantron/tasks/test.rb +0 -30
  45. data/lib/gigantron/version.rb +0 -9
  46. data/lib/gigantron.rb +0 -0
  47. data/script/console +0 -10
  48. data/script/destroy +0 -14
  49. data/script/generate +0 -14
  50. data/script/txt2html +0 -82
  51. data/setup.rb +0 -1585
  52. data/tasks/deployment.rake +0 -34
  53. data/tasks/environment.rake +0 -7
  54. data/tasks/website.rake +0 -17
  55. data/test/template_database.yml +0 -9
  56. data/test/template_database.yml.example +0 -9
  57. data/test/template_migration.rb +0 -16
  58. data/website/index.html +0 -213
  59. data/website/index.txt +0 -145
  60. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  61. data/website/stylesheets/screen.css +0 -138
  62. data/website/template.html.erb +0 -48
data/config/hoe.rb DELETED
@@ -1,82 +0,0 @@
1
- require 'gigantron/version'
2
-
3
- AUTHOR = 'Ben Hughes' # can also be an array of Authors
4
- EMAIL = "ben@pixelmachine.org"
5
- DESCRIPTION = "description of gem"
6
- GEM_NAME = 'gigantron' # what ppl will type to install your gem
7
- RUBYFORGE_PROJECT = 'gigantron' # The unix name for your project
8
- HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
- DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
- EXTRA_DEPENDENCIES = [
11
- ['activesupport', '>= 2.0.2'],
12
- ['rubigen', '>= 1.3.2'],
13
- ['rake', '>= 0.8.1'],
14
- ['Shoulda', '>= 1.1.1'],
15
- ['activerecord', '>= 2.0.2'],
16
- ] # An array of rubygem dependencies [name, version]
17
-
18
- @config_file = "~/.rubyforge/user-config.yml"
19
- @config = nil
20
- RUBYFORGE_USERNAME = "unknown"
21
- def rubyforge_username
22
- unless @config
23
- begin
24
- @config = YAML.load(File.read(File.expand_path(@config_file)))
25
- rescue
26
- puts <<-EOS
27
- ERROR: No rubyforge config file found: #{@config_file}
28
- Run 'rubyforge setup' to prepare your env for access to Rubyforge
29
- - See http://newgem.rubyforge.org/rubyforge.html for more details
30
- EOS
31
- exit
32
- end
33
- end
34
- RUBYFORGE_USERNAME.replace @config["username"]
35
- end
36
-
37
-
38
- REV = nil
39
- # UNCOMMENT IF REQUIRED:
40
- # REV = YAML.load(`svn info`)['Revision']
41
- VERS = Gigantron::VERSION::STRING + (REV ? ".#{REV}" : "")
42
- RDOC_OPTS = ['--quiet', '--title', 'gigantron documentation',
43
- "--opname", "index.html",
44
- "--line-numbers",
45
- "--main", "README",
46
- "--inline-source"]
47
-
48
-
49
- class Hoe
50
- silence_warnings do
51
- RUBY_FLAGS = "-I#{%w(lib ext bin test).join(File::PATH_SEPARATOR)}" +
52
- (ENV['RUBY_DEBUG'] ? " #{ENV['RUBY_DEBUG']}" : '')
53
- end
54
- def extra_deps
55
- @extra_deps.reject! { |x| Array(x).first == 'hoe' }
56
- @extra_deps
57
- end
58
- end
59
-
60
- # Generate all the Rake tasks
61
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
62
- $hoe = Hoe.new(GEM_NAME, VERS) do |p|
63
- p.developer(AUTHOR, EMAIL)
64
- p.description = DESCRIPTION
65
- p.summary = DESCRIPTION
66
- p.url = HOMEPATH
67
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
68
- p.test_globs = ["test/**/test_*.rb"]
69
- p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
70
-
71
- # == Optional
72
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
73
- #p.extra_deps = EXTRA_DEPENDENCIES
74
-
75
- #p.spec_extras = {} # A hash of extra values to set in the gemspec.
76
- end
77
-
78
- CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
79
- PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
80
- $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
81
- $hoe.rsync_args = '-av --delete --ignore-errors'
82
- $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
@@ -1,15 +0,0 @@
1
- require 'fileutils'
2
- include FileUtils
3
-
4
- require 'rubygems'
5
- %w[rake hoe newgem rubigen activerecord activesupport shoulda].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]))
@@ -1,5 +0,0 @@
1
- Description:
2
-
3
-
4
- Usage:
5
-
@@ -1,54 +0,0 @@
1
- class MapreduceTaskGenerator < RubiGen::Base
2
-
3
- default_options :author => nil
4
-
5
- attr_reader :name
6
-
7
- def initialize(runtime_args, runtime_options = {})
8
- super
9
- usage if args.empty?
10
- @name = args.shift
11
- extract_options
12
- end
13
-
14
- def manifest
15
- record do |m|
16
- # Ensure appropriate folder(s) exists
17
- m.directory 'test/'
18
- m.directory 'test/tasks/'
19
- m.template "test/tasks/test_task.rb", "test/tasks/test_#{@name}.rb"
20
- m.directory 'tasks/'
21
- m.template "tasks/task.rake", "tasks/#{@name}.rake"
22
- m.directory 'mapreduce/'
23
- m.template "mapreduce/mr_task.rb", "mapreduce/mr_#{@name}.rb"
24
-
25
- end
26
- end
27
-
28
- protected
29
- def banner
30
- <<-EOS
31
- Creates a ...
32
-
33
- USAGE: #{$0} #{spec.name} name
34
- EOS
35
- end
36
-
37
- def add_options!(opts)
38
- # opts.separator ''
39
- # opts.separator 'Options:'
40
- # For each option below, place the default
41
- # at the top of the file next to "default_options"
42
- # opts.on("-a", "--author=\"Your Name\"", String,
43
- # "Some comment about this option",
44
- # "Default: none") { |options[:author]| }
45
- # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
46
- end
47
-
48
- def extract_options
49
- # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
50
- # Templates can access these value via the attr_reader-generated methods, but not the
51
- # raw instance variable value.
52
- # @author = options[:author]
53
- end
54
- end
@@ -1,22 +0,0 @@
1
- class MapReduce<%= name.camelcase %>
2
- include SkynetDebugger
3
-
4
- def self.run
5
- job = Skynet::Job.new(
6
- :mappers => 2, #change to whatever is a good number
7
- :reducers => 1, #same
8
- :map_reduce_class => self,
9
- :map_data => [] #acquire your data!
10
- )
11
- job.run
12
- end
13
-
14
- def self.map(profiles)
15
- #map code
16
- end
17
-
18
- def self.reduce(pairs)
19
- #reduce code
20
- end
21
- end
22
-
@@ -1,5 +0,0 @@
1
- desc "Describe your MapReduce task"
2
- task :<%= name %> do
3
- load 'mapreduce/mr_<%= name %>'
4
- MapReduce<%= name.camelcase %>.run
5
- end
@@ -1,22 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper.rb'
2
-
3
- class Test<%= name.camelcase %> < Test::Unit::TestCase
4
- def setup
5
- get_db_conn(GTRON_ENV)
6
- @rake = Rake::Application.new
7
- Rake.application = @rake
8
- load File.dirname(__FILE__) + '/../../tasks/<%= name %>.rake'
9
- end
10
-
11
- should "be true" do
12
- # Testing rake is a bit different
13
- # http://blog.nicksieger.com/articles/2007/06/11/test-your-rake-tasks
14
- # Example:
15
- # @rake["task_name"].invoke
16
- assert true
17
- end
18
-
19
- def teardown
20
- Rake.application = nil
21
- end
22
- end
@@ -1,5 +0,0 @@
1
- Description:
2
-
3
-
4
- Usage:
5
-
@@ -1,61 +0,0 @@
1
- class MigrationGenerator < RubiGen::Base
2
-
3
- default_options :author => nil
4
-
5
- attr_reader :name
6
-
7
- def initialize(runtime_args, runtime_options = {})
8
- super
9
- usage if args.empty?
10
- @name = args.shift
11
- extract_options
12
- end
13
-
14
- def manifest
15
- record do |m|
16
- # Ensure appropriate folder(s) exists
17
- m.directory "db/"
18
- m.directory "db/migrate/"
19
- m.template "db/migrate/migration.rb",
20
- "db/migrate/#{next_migration_num}_#{name.underscore}.rb"
21
-
22
- end
23
- end
24
-
25
- protected
26
- def banner
27
- <<-EOS
28
- Creates a ...
29
-
30
- USAGE: #{$0} #{spec.name} name
31
- EOS
32
- end
33
-
34
- def add_options!(opts)
35
- # opts.separator ''
36
- # opts.separator 'Options:'
37
- # For each option below, place the default
38
- # at the top of the file next to "default_options"
39
- # opts.on("-a", "--author=\"Your Name\"", String,
40
- # "Some comment about this option",
41
- # "Default: none") { |options[:author]| }
42
- # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
43
- end
44
-
45
- def extract_options
46
- # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
47
- # Templates can access these value via the attr_reader-generated methods, but not the
48
- # raw instance variable value.
49
- # @author = options[:author]
50
- end
51
-
52
- def next_migration_num
53
- #blegh, catalog existing migrations, find next
54
- current = Dir.glob(
55
- "#{@destination_root}/db/migrate/[0-9][0-9][0-9]_*.rb").map{|x|
56
- /(\d{3})_.*\.rb/.match(x)[1].to_i
57
- }.max
58
- current ||= 0
59
- "%03d" % current.succ
60
- end
61
- end
@@ -1,7 +0,0 @@
1
- class <%= name.camelcase %> < ActiveRecord::Migration
2
- def self.up
3
- end
4
-
5
- def self.down
6
- end
7
- end
@@ -1,11 +0,0 @@
1
- Description:
2
- Generate a DataMapper model for your Gigantron project.
3
-
4
-
5
- Usage:
6
- shell> $ script/generate model modelname
7
-
8
- 1. edit models/modelname.rb to create the table schema
9
- 2. write tests in test/models/test_modelname.rb
10
- 3. run 'rake db:automigrate' to have changes updated
11
-
@@ -1,54 +0,0 @@
1
- class ModelGenerator < RubiGen::Base
2
-
3
- default_options :author => nil
4
-
5
- attr_reader :name
6
-
7
- def initialize(runtime_args, runtime_options = {})
8
- super
9
- usage if args.empty?
10
- @name = args.shift
11
- extract_options
12
- end
13
-
14
- def manifest
15
- record do |m|
16
- m.directory "models/"
17
- m.template "models/model.rb", "models/#{@name.underscore}.rb"
18
-
19
- m.directory "test/"
20
- m.directory "test/models/"
21
- m.template "test/models/test_model.rb",
22
- "test/models/test_#{name.underscore}.rb"
23
-
24
- m.dependency "migration", ["Create#{@name.pluralize.camelcase}"]
25
- end
26
- end
27
-
28
- protected
29
- def banner
30
- <<-EOS
31
- Creates a ...
32
-
33
- USAGE: #{$0} #{spec.name} name
34
- EOS
35
- end
36
-
37
- def add_options!(opts)
38
- # opts.separator ''
39
- # opts.separator 'Options:'
40
- # For each option below, place the default
41
- # at the top of the file next to "default_options"
42
- # opts.on("-a", "--author=\"Your Name\"", String,
43
- # "Some comment about this option",
44
- # "Default: none") { |options[:author]| }
45
- # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
46
- end
47
-
48
- def extract_options
49
- # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
50
- # Templates can access these value via the attr_reader-generated methods, but not the
51
- # raw instance variable value.
52
- # @author = options[:author]
53
- end
54
- end
@@ -1,3 +0,0 @@
1
- class <%= name.camelcase %> < ActiveRecord::Base
2
-
3
- end
@@ -1,13 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper.rb'
2
-
3
- class Test<%= name.camelcase %> < Test::Unit::TestCase
4
- def setup
5
- get_db_conn(GTRON_ENV)
6
- Gigantron.migrate_dbs
7
- end
8
-
9
- #replace with real tests
10
- should "be true" do
11
- assert true
12
- end
13
- end
@@ -1,10 +0,0 @@
1
- Description:
2
- Generate task for your Gigantron project
3
-
4
-
5
- Usage:
6
- shell> $ script/generate task taskname
7
-
8
- 1. edit tasks/taskname.rake to add functionality
9
- 2. write tests in test/tasks/test_taskname.rb
10
- 3. run 'rake taskname' to run task
@@ -1,51 +0,0 @@
1
- class TaskGenerator < RubiGen::Base
2
-
3
- default_options :author => nil
4
-
5
- attr_reader :name
6
-
7
- def initialize(runtime_args, runtime_options = {})
8
- super
9
- usage if args.empty?
10
- @name = args.shift
11
- extract_options
12
- end
13
-
14
- def manifest
15
- record do |m|
16
- m.directory "tasks/"
17
- m.template "tasks/task.rake", "tasks/#{@name.underscore}.rake"
18
- m.directory "test/"
19
- m.directory "test/tasks/"
20
- m.template "test/tasks/test_task.rb",
21
- "test/tasks/test_#{@name.underscore}.rb"
22
- end
23
- end
24
-
25
- protected
26
- def banner
27
- <<-EOS
28
- Creates a ...
29
-
30
- USAGE: #{$0} #{spec.name} name
31
- EOS
32
- end
33
-
34
- def add_options!(opts)
35
- # opts.separator ''
36
- # opts.separator 'Options:'
37
- # For each option below, place the default
38
- # at the top of the file next to "default_options"
39
- # opts.on("-a", "--author=\"Your Name\"", String,
40
- # "Some comment about this option",
41
- # "Default: none") { |options[:author]| }
42
- # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
43
- end
44
-
45
- def extract_options
46
- # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
47
- # Templates can access these value via the attr_reader-generated methods, but not the
48
- # raw instance variable value.
49
- # @author = options[:author]
50
- end
51
- end
@@ -1,4 +0,0 @@
1
- desc "Write a task description and write it good!"
2
- task :<%= name %> do
3
- get_db_conn(GTRON_ENV)
4
- end
@@ -1,22 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper.rb'
2
-
3
- class Test<%= name.camelcase %> < Test::Unit::TestCase
4
- def setup
5
- get_db_conn(GTRON_ENV)
6
- @rake = Rake::Application.new
7
- Rake.application = @rake
8
- load File.dirname(__FILE__) + '/../../tasks/<%= name %>.rake'
9
- end
10
-
11
- should "be true" do
12
- # Testing rake is a bit different
13
- # http://blog.nicksieger.com/articles/2007/06/11/test-your-rake-tasks
14
- # Example:
15
- # @rake["task_name"].invoke
16
- assert true
17
- end
18
-
19
- def teardown
20
- Rake.application = nil
21
- end
22
- end
@@ -1,10 +0,0 @@
1
-
2
- # simple function to handle migrating Gigantron databases
3
- module Gigantron
4
- def self.migrate_dbs
5
- ActiveRecord::Migration.verbose =
6
- ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
7
- ActiveRecord::Migrator.migrate("#{GTRON_ROOT}/db/migrate/",
8
- ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
9
- end
10
- end
@@ -1,11 +0,0 @@
1
- require 'gigantron/migrator'
2
-
3
- namespace :db do
4
- desc "Migrate databases according to models"
5
- task :migrate do
6
- puts "Migrating your database"
7
- get_db_conn(GTRON_ENV)
8
-
9
- Gigantron.migrate_dbs
10
- end
11
- end
@@ -1,30 +0,0 @@
1
- require 'rake/testtask'
2
-
3
- desc "Test all models and tasks"
4
- task :test do
5
- errors = %w(test:models test:tasks).collect do |task|
6
- begin
7
- Rake::Task[task].invoke
8
- nil
9
- rescue => e
10
- task
11
- end
12
- end.compact
13
- abort "Errors running #{errors.to_sentence}!" if errors.any?
14
- end
15
-
16
- namespace :test do
17
- Rake::TestTask.new(:models) do |t|
18
- t.libs << "test"
19
- t.pattern = 'test/models/test_*.rb'
20
- t.verbose = true
21
- end
22
- Rake::Task['test:models'].comment = "Run model tests"
23
-
24
- Rake::TestTask.new(:tasks) do |t|
25
- t.libs << "test"
26
- t.pattern = 'test/tasks/test_*.rb'
27
- t.verbose = true
28
- end
29
- Rake::Task['test:tasks'].comment = "Run task tests"
30
- end
@@ -1,9 +0,0 @@
1
- module Gigantron #:nodoc:
2
- module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 1
5
- TINY = 1
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
9
- end
data/lib/gigantron.rb DELETED
File without changes
data/script/console DELETED
@@ -1,10 +0,0 @@
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/gigantron.rb'}"
9
- puts "Loading gigantron gem"
10
- exec "#{irb} #{libs} --simple-prompt"
data/script/destroy DELETED
@@ -1,14 +0,0 @@
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 DELETED
@@ -1,14 +0,0 @@
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 DELETED
@@ -1,82 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- GEM_NAME = 'gigantron' # what ppl will type to install your gem
4
- RUBYFORGE_PROJECT = 'gigantron'
5
-
6
- require 'rubygems'
7
- begin
8
- require 'newgem'
9
- require 'rubyforge'
10
- rescue LoadError
11
- puts "\n\nGenerating the website requires the newgem RubyGem"
12
- puts "Install: gem install newgem\n\n"
13
- exit(1)
14
- end
15
- require 'redcloth'
16
- require 'syntax/convertors/html'
17
- require 'erb'
18
- require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
19
-
20
- version = Gigantron::VERSION::STRING
21
- download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
22
-
23
- def rubyforge_project_id
24
- RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT]
25
- end
26
-
27
- class Fixnum
28
- def ordinal
29
- # teens
30
- return 'th' if (10..19).include?(self % 100)
31
- # others
32
- case self % 10
33
- when 1: return 'st'
34
- when 2: return 'nd'
35
- when 3: return 'rd'
36
- else return 'th'
37
- end
38
- end
39
- end
40
-
41
- class Time
42
- def pretty
43
- return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
44
- end
45
- end
46
-
47
- def convert_syntax(syntax, source)
48
- return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
49
- end
50
-
51
- if ARGV.length >= 1
52
- src, template = ARGV
53
- template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
54
- else
55
- puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
56
- exit!
57
- end
58
-
59
- template = ERB.new(File.open(template).read)
60
-
61
- title = nil
62
- body = nil
63
- File.open(src) do |fsrc|
64
- title_text = fsrc.readline
65
- body_text_template = fsrc.read
66
- body_text = ERB.new(body_text_template).result(binding)
67
- syntax_items = []
68
- body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
69
- ident = syntax_items.length
70
- element, syntax, source = $1, $2, $3
71
- syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
72
- "syntax-temp-#{ident}"
73
- }
74
- title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
75
- body = RedCloth.new(body_text).to_html
76
- body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
77
- end
78
- stat = File.stat(src)
79
- created = stat.ctime
80
- modified = stat.mtime
81
-
82
- $stdout << template.result(binding)