jakewendt-documents 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +72 -0
- data/app/controllers/documents_controller.rb +97 -0
- data/app/models/document.rb +28 -0
- data/app/views/documents/_document.html.erb +15 -0
- data/app/views/documents/_form.html.erb +19 -0
- data/app/views/documents/edit.html.erb +4 -0
- data/app/views/documents/index.html.erb +11 -0
- data/app/views/documents/new.html.erb +3 -0
- data/app/views/documents/preview.html.erb +15 -0
- data/config/document.yml +54 -0
- data/config/routes.rb +5 -0
- data/generators/documents/USAGE +0 -0
- data/generators/documents/documents_generator.rb +69 -0
- data/generators/documents/templates/functional/documents_controller_test.rb +219 -0
- data/generators/documents/templates/javascripts/documents.js +0 -0
- data/generators/documents/templates/migrations/add_attachments_document_to_document.rb +19 -0
- data/generators/documents/templates/migrations/create_documents.rb +19 -0
- data/generators/documents/templates/migrations/polymorphicize_document_owner.rb +13 -0
- data/generators/documents/templates/stylesheets/documents.css +0 -0
- data/generators/documents/templates/unit/document_test.rb +115 -0
- data/lib/documents.rb +54 -0
- data/lib/documents/factories.rb +4 -0
- data/lib/documents/file_utils_extension.rb +18 -0
- data/lib/documents/owner.rb +12 -0
- data/lib/documents/pending.rb +72 -0
- data/lib/documents/tasks.rb +1 -0
- data/lib/tasks/application.rake +40 -0
- data/lib/tasks/database.rake +52 -0
- data/lib/tasks/documentation.rake +68 -0
- data/lib/tasks/rcov.rake +41 -0
- data/lib/tasks/ucb_ccls_engine_tasks.rake +50 -0
- metadata +364 -0
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class AddAttachmentsDocumentToDocument < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_column :documents, :document_file_name, :string
|
4
|
+
add_column :documents, :document_content_type, :string
|
5
|
+
add_column :documents, :document_file_size, :integer
|
6
|
+
add_column :documents, :document_updated_at, :datetime
|
7
|
+
|
8
|
+
add_index :documents, :document_file_name, :unique => true
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
remove_index :documents, :document_file_name
|
13
|
+
|
14
|
+
remove_column :documents, :document_file_name
|
15
|
+
remove_column :documents, :document_content_type
|
16
|
+
remove_column :documents, :document_file_size
|
17
|
+
remove_column :documents, :document_updated_at
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateDocuments < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :documents do |t|
|
4
|
+
t.references :owner
|
5
|
+
t.string :title, :null => false
|
6
|
+
t.text :abstract
|
7
|
+
t.boolean :shared_with_all,
|
8
|
+
:default => false, :null => false
|
9
|
+
t.boolean :shared_with_select,
|
10
|
+
:default => false, :null => false
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
add_index :documents, :owner_id
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.down
|
17
|
+
drop_table :documents
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class PolymorphicizeDocumentOwner < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_column :documents, :owner_type, :string
|
4
|
+
remove_index :documents, :owner_id
|
5
|
+
add_index :documents, [:owner_id,:owner_type]
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.down
|
9
|
+
remove_index :documents, [:owner_id,:owner_type]
|
10
|
+
add_index :documents, :owner_id
|
11
|
+
remove_column :documents, :owner_type_string
|
12
|
+
end
|
13
|
+
end
|
File without changes
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
|
3
|
+
class Documents::DocumentTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
assert_should_require(:title,
|
6
|
+
:model => 'Document')
|
7
|
+
assert_should_belong_to(:owner,:class_name => 'User',
|
8
|
+
:model => 'Document')
|
9
|
+
|
10
|
+
test "should create document" do
|
11
|
+
assert_difference 'Document.count' do
|
12
|
+
object = create_object
|
13
|
+
assert !object.new_record?,
|
14
|
+
"#{object.errors.full_messages.to_sentence}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# test "should return class s3_access_key_id" do
|
19
|
+
# s3_access_key_id = Document.s3_access_key_id
|
20
|
+
# assert_equal "test_access_key_id", s3_access_key_id
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# test "should return class s3_secret_access_key" do
|
24
|
+
# s3_secret_access_key = Document.s3_secret_access_key
|
25
|
+
# assert_equal "test_secret_access_key", s3_secret_access_key
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# test "should return class s3_protocol" do
|
29
|
+
# s3_protocol = Document.s3_protocol
|
30
|
+
# assert_equal "https://", s3_protocol
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# test "should return class s3_host" do
|
34
|
+
# s3_host = Document.s3_host
|
35
|
+
# assert_equal "s3.amazonaws.com", s3_host
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# test "should return s3_access_key_id" do
|
39
|
+
# object = create_object
|
40
|
+
# s3_access_key_id = object.s3_access_key_id
|
41
|
+
# assert_equal "test_access_key_id", s3_access_key_id
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# test "should return s3_secret_access_key" do
|
45
|
+
# object = create_object
|
46
|
+
# s3_secret_access_key = object.s3_secret_access_key
|
47
|
+
# assert_equal "test_secret_access_key", s3_secret_access_key
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# test "should return s3_expires_on within the hour" do
|
51
|
+
# object = create_object
|
52
|
+
# s3_expires_on = object.s3_expires_on
|
53
|
+
# assert_not_nil s3_expires_on
|
54
|
+
# printf "Pausing for 3 seconds"
|
55
|
+
# sleep 5
|
56
|
+
# assert_equal s3_expires_on, object.s3_expires_on
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# test "should return s3_string_to_sign" do
|
60
|
+
# object = create_object(:document_file_name => "BogusFileName")
|
61
|
+
# assert_equal object.document.url,
|
62
|
+
# "/system/documents/#{object.id}/original/BogusFileName."
|
63
|
+
# assert_match /\AGET\n\n\n\d+\n\/system\/documents\/\d+\/original\/BogusFileName.\z/,
|
64
|
+
# object.s3_string_to_sign
|
65
|
+
# #puts object.document.url
|
66
|
+
# # => /system/documents/1/original/BogusFileName.
|
67
|
+
# #puts object.document.path
|
68
|
+
# # => /Users/jake/github_repo/jakewendt/ucb_ccls_engine/test/documents/1/BogusFileName.
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# test "should return s3_signature" do
|
72
|
+
# Document.any_instance.stubs(:s3_string_to_sign).returns(
|
73
|
+
# "GET\n\n\n1281066749\n/system/documents/1/original/BogusFileName.")
|
74
|
+
# object = create_object(:document_file_name => "BogusFileName")
|
75
|
+
# assert_not_nil object.s3_signature
|
76
|
+
# assert_equal "sZveTMHwpLQk0tA7amx2JNqN7NY%3D", object.s3_signature
|
77
|
+
# # => sZveTMHwpLQk0tA7amx2JNqN7NY%3D
|
78
|
+
# end
|
79
|
+
#
|
80
|
+
# test "should return s3_path" do
|
81
|
+
# Document.any_instance.stubs(:s3_expires_on).returns(
|
82
|
+
# "1281066749")
|
83
|
+
# Document.any_instance.stubs(:s3_string_to_sign).returns(
|
84
|
+
# "GET\n\n\n1281066749\n/system/documents/1/original/BogusFileName.")
|
85
|
+
# object = create_object(:document_file_name => "BogusFileName")
|
86
|
+
# assert_not_nil object.s3_path
|
87
|
+
# assert_equal "/system/documents/#{object.id}/original/BogusFileName.?" +
|
88
|
+
# "AWSAccessKeyId=test_access_key_id&" +
|
89
|
+
# "Signature=sZveTMHwpLQk0tA7amx2JNqN7NY%3D&Expires=1281066749",
|
90
|
+
# object.s3_path
|
91
|
+
# end
|
92
|
+
#
|
93
|
+
# test "should return s3_url" do
|
94
|
+
# Document.any_instance.stubs(:s3_expires_on).returns(
|
95
|
+
# "1281066749")
|
96
|
+
# Document.any_instance.stubs(:s3_string_to_sign).returns(
|
97
|
+
# "GET\n\n\n1281066749\n/system/documents/1/original/BogusFileName.")
|
98
|
+
# object = create_object(:document_file_name => "BogusFileName")
|
99
|
+
# assert_not_nil object.s3_url
|
100
|
+
# assert_equal "https://s3.amazonaws.com" +
|
101
|
+
# "/system/documents/#{object.id}/original/BogusFileName.?" +
|
102
|
+
# "AWSAccessKeyId=test_access_key_id&" +
|
103
|
+
# "Signature=sZveTMHwpLQk0tA7amx2JNqN7NY%3D&Expires=1281066749",
|
104
|
+
# object.s3_url
|
105
|
+
# end
|
106
|
+
|
107
|
+
protected
|
108
|
+
|
109
|
+
def create_object(options = {})
|
110
|
+
record = Factory.build(:document,options)
|
111
|
+
record.save
|
112
|
+
record
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
data/lib/documents.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'active_support'
|
3
|
+
require 'ruby_extension'
|
4
|
+
require 'rails_helpers'
|
5
|
+
require 'authorized'
|
6
|
+
require 'gravatar'
|
7
|
+
require 'calnet_authenticated'
|
8
|
+
require 'acts_as_list'
|
9
|
+
module Documents
|
10
|
+
# predefine namespace
|
11
|
+
end
|
12
|
+
require 'documents/owner'
|
13
|
+
|
14
|
+
# This doesn't seem necessary
|
15
|
+
%w{models controllers}.each do |dir|
|
16
|
+
path = File.expand_path(File.join(File.dirname(__FILE__), '../app', dir))
|
17
|
+
ActiveSupport::Dependencies.autoload_paths << path
|
18
|
+
ActiveSupport::Dependencies.autoload_once_paths << path
|
19
|
+
end
|
20
|
+
|
21
|
+
HTML::WhiteListSanitizer.allowed_attributes.merge(%w(
|
22
|
+
id class style
|
23
|
+
))
|
24
|
+
|
25
|
+
if !defined?(RAILS_ENV) || RAILS_ENV == 'test'
|
26
|
+
require 'active_support'
|
27
|
+
require 'active_support/test_case'
|
28
|
+
require 'factory_girl'
|
29
|
+
require 'assert_this_and_that'
|
30
|
+
require 'documents/factories'
|
31
|
+
require 'documents/pending'
|
32
|
+
end
|
33
|
+
|
34
|
+
if RUBY_PLATFORM =~ /java/i
|
35
|
+
require 'documents/file_utils_extension'
|
36
|
+
end
|
37
|
+
|
38
|
+
require 'paperclip'
|
39
|
+
if defined? ::Paperclip::Glue
|
40
|
+
ActiveRecord::Base.send(:include, ::Paperclip::Glue)
|
41
|
+
else
|
42
|
+
ActiveRecord::Base.send(:include, ::Paperclip)
|
43
|
+
end
|
44
|
+
|
45
|
+
ActionController::Routing::Routes.add_configuration_file(
|
46
|
+
File.expand_path(
|
47
|
+
File.join(
|
48
|
+
File.dirname(__FILE__), '../config/routes.rb')))
|
49
|
+
|
50
|
+
ActionController::Base.view_paths <<
|
51
|
+
File.expand_path(
|
52
|
+
File.join(
|
53
|
+
File.dirname(__FILE__), '../app/views'))
|
54
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Needed for Paperclip gem 2.3.3
|
2
|
+
# http://jira.codehaus.org/browse/JRUBY-3381
|
3
|
+
# http://github.com/thoughtbot/paperclip/issues/issue/193
|
4
|
+
# Errno::EACCES: Permission denied - /var/folders/kV/kV5XVPtqE9uZBCjn3z6vmk+++TM/-Tmp-/stream,19661,34729.pdf or /Users/jakewendt/github_repo/jakewendt/ucb_ccls_buffler/development/documents/2/edit_save_wireframe.pdf
|
5
|
+
FileUtils.module_eval do
|
6
|
+
class << self
|
7
|
+
alias_method :built_in_mv, :mv
|
8
|
+
|
9
|
+
def mv(src, dest, options = {})
|
10
|
+
begin
|
11
|
+
built_in_mv(src, dest, options)
|
12
|
+
rescue Errno::EACCES
|
13
|
+
cp(src, dest)
|
14
|
+
rm(src)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end unless FileUtils.methods.include?('built_in_mv')
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Documents::Owner
|
2
|
+
def self.included(base)
|
3
|
+
base.extend(PrepMethod)
|
4
|
+
end
|
5
|
+
module PrepMethod
|
6
|
+
def document_owner(*args)
|
7
|
+
options = args.extract_options!
|
8
|
+
has_many :documents, :as => :owner
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
ActiveRecord::Base.send(:include,Documents::Owner)
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# Some code from jeremymcanally's "pending"
|
2
|
+
# http://github.com/jeremymcanally/pending/tree/master
|
3
|
+
|
4
|
+
module ActiveSupport
|
5
|
+
module Testing
|
6
|
+
module Pending
|
7
|
+
|
8
|
+
unless defined?(Spec)
|
9
|
+
|
10
|
+
@@pending_cases = []
|
11
|
+
@@at_exit = false
|
12
|
+
|
13
|
+
def pending(description = "", &block)
|
14
|
+
if description.is_a?(Symbol)
|
15
|
+
is_pending = $tags[description]
|
16
|
+
return block.call unless is_pending
|
17
|
+
end
|
18
|
+
|
19
|
+
if block_given?
|
20
|
+
failed = false
|
21
|
+
|
22
|
+
begin
|
23
|
+
block.call
|
24
|
+
rescue Exception
|
25
|
+
failed = true
|
26
|
+
end
|
27
|
+
|
28
|
+
flunk("<#{description}> did not fail.") unless failed
|
29
|
+
end
|
30
|
+
|
31
|
+
caller[0] =~ (/(.*):(.*):in `(.*)'/)
|
32
|
+
#puts caller.inspect
|
33
|
+
|
34
|
+
# looks like we lose the name of the 'method' in 1.9.1
|
35
|
+
#"/Users/jakewendt/github_repo/jakewendt/ucb_ccls_homex/test/unit/subject_test.rb:145:in `block in <class:SubjectTest>'",
|
36
|
+
|
37
|
+
# @@pending_cases << "#{$3} at #{$1}, line #{$2}"
|
38
|
+
# Gotta remember these as the next Regex will overwrite them.
|
39
|
+
filename = $1
|
40
|
+
linenumber = $2
|
41
|
+
# ruby 1.8.7
|
42
|
+
# Hx/Addresses Controller should NOT create new address with employee login and invalid address:
|
43
|
+
# ruby 1.9.1
|
44
|
+
#Hx/Addresses Controller block (2 levels) in <class:AddressesControllerTest>:
|
45
|
+
testmethod = $3
|
46
|
+
|
47
|
+
model = self.class.to_s.gsub(/Test$/,'').titleize
|
48
|
+
method = testmethod.gsub(/_/,' ').gsub(/^test /,'')
|
49
|
+
@@pending_cases << "#{model} #{method}:\n.\t#{filename} line #{linenumber}"
|
50
|
+
# @@pending_cases << "#{testmethod} at #{filename}, line #{linenumber}"
|
51
|
+
print "P"
|
52
|
+
|
53
|
+
@@at_exit ||= begin
|
54
|
+
at_exit do
|
55
|
+
# For some reason, special characters don't always
|
56
|
+
# print the way you would expect. Leading white space (tabs)
|
57
|
+
# and some carriage returns just weren't happening?
|
58
|
+
# Is this at_exit doing some parsing??
|
59
|
+
puts "\nPending Cases:"
|
60
|
+
@@pending_cases.each do |test_case|
|
61
|
+
puts test_case
|
62
|
+
end
|
63
|
+
puts " \n"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
ActiveSupport::TestCase.send(:include, ActiveSupport::Testing::Pending)
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir["#{File.dirname(__FILE__)}/../tasks/**/*.rake"].sort.each { |ext| load ext }
|
@@ -0,0 +1,40 @@
|
|
1
|
+
namespace :app do
|
2
|
+
|
3
|
+
# task :args_as_array do
|
4
|
+
# args = $*.dup.slice(1..-1)
|
5
|
+
# puts args.collect {|arg| "X:" << arg }.join("\n")
|
6
|
+
# exit
|
7
|
+
# end
|
8
|
+
|
9
|
+
desc "Add some expected users."
|
10
|
+
task :add_users => :environment do
|
11
|
+
puts "Adding users"
|
12
|
+
%w( 859908 228181 855747 214766 180918 66458 808 768475
|
13
|
+
10883 86094 754783 769067 854720 16647 ).each do |uid|
|
14
|
+
puts " - Adding user with uid:#{uid}:"
|
15
|
+
User.find_create_and_update_by_uid(uid)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Deputize user by UID"
|
20
|
+
task :deputize => :environment do
|
21
|
+
puts
|
22
|
+
if ENV['uid'].blank?
|
23
|
+
puts "User's CalNet UID required."
|
24
|
+
puts "Usage: rake #{$*} uid=INTEGER"
|
25
|
+
puts
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
if !User.exists?(:uid => ENV['uid'])
|
29
|
+
puts "No user found with uid=#{ENV['uid']}."
|
30
|
+
puts
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
user = User.find(:first, :conditions => { :uid => ENV['uid'] })
|
34
|
+
puts "Found user #{user.displayname}. Deputizing..."
|
35
|
+
user.deputize
|
36
|
+
puts "User deputized: #{user.is_administrator?}"
|
37
|
+
puts
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
namespace :db do
|
2
|
+
|
3
|
+
desc "Create yml fixtures for given model in database\n" <<
|
4
|
+
"rake db:extract_fixtures_from pages"
|
5
|
+
task :extract_fixtures_from => :environment do
|
6
|
+
me = $*.shift
|
7
|
+
while( table_name = $*.shift )
|
8
|
+
File.open("#{RAILS_ROOT}/db/#{table_name}.yml", 'w') do |file|
|
9
|
+
data = table_name.singularize.capitalize.constantize.find(
|
10
|
+
:all).collect(&:attributes)
|
11
|
+
file.write data.inject({}) { |hash, record|
|
12
|
+
record.delete('created_at')
|
13
|
+
record.delete('updated_at')
|
14
|
+
hash["#{table_name}_#{record['id']}"] = record
|
15
|
+
hash
|
16
|
+
}.to_yaml
|
17
|
+
end
|
18
|
+
end
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Dump MYSQL table descriptions."
|
23
|
+
task :describe => :environment do
|
24
|
+
puts
|
25
|
+
puts "FYI: This task ONLY works on MYSQL databases."
|
26
|
+
puts
|
27
|
+
config = ActiveRecord::Base.connection.instance_variable_get(:@config)
|
28
|
+
#=> {:adapter=>"mysql", :host=>"localhost", :password=>nil, :username=>"root", :database=>"my_development", :encoding=>"utf8"}
|
29
|
+
|
30
|
+
tables = ActiveRecord::Base.connection.execute('show tables;')
|
31
|
+
while( table = tables.fetch_row ) do
|
32
|
+
puts "Table: #{table}"
|
33
|
+
|
34
|
+
# may have to include host and port
|
35
|
+
system("mysql --table=true " <<
|
36
|
+
"--user=#{config[:username]} " <<
|
37
|
+
"--password='#{config[:password]}' " <<
|
38
|
+
"--execute='describe #{table}' " <<
|
39
|
+
config[:database]);
|
40
|
+
|
41
|
+
#
|
42
|
+
# mysql formats the table well so doing it by hand is something that
|
43
|
+
# will have to wait until I feel like wasting my time
|
44
|
+
#
|
45
|
+
# columns = ActiveRecord::Base.connection.execute("describe #{table};")
|
46
|
+
# while( column = columns.fetch_hash ) do
|
47
|
+
# puts column.keys Extra Default Null Type Field Key
|
48
|
+
# end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
# This file has been copied from rails
|
3
|
+
# .../rails-2.3.5/lib/tasks/documentation.rake
|
4
|
+
# so that parts of it could be modified.
|
5
|
+
|
6
|
+
namespace :doc do |doc|
|
7
|
+
|
8
|
+
# Rake::RDocTask.new("app") { |rdoc|
|
9
|
+
#
|
10
|
+
# We cannot overwrite or override an RDoc rake task.
|
11
|
+
# Redefining it here actually creates another
|
12
|
+
# of the same name and both are run when
|
13
|
+
# `rake doc:app` is called. The Rakefile
|
14
|
+
# is modified to handle the modifications.
|
15
|
+
#
|
16
|
+
# Actually, that's not entirely true. This would
|
17
|
+
# add another task, but you can remove and override
|
18
|
+
# a task. The rdoc_rails plugin was overriding my
|
19
|
+
# override, which caused all the frustration!!!
|
20
|
+
#
|
21
|
+
# }
|
22
|
+
|
23
|
+
plugins = FileList['vendor/plugins/**'].collect { |plugin|
|
24
|
+
File.basename(plugin) }
|
25
|
+
|
26
|
+
namespace :plugins do
|
27
|
+
# Define doc tasks for each plugin
|
28
|
+
plugins.each do |plugin|
|
29
|
+
|
30
|
+
# clear rails' Rake::Task of the same name
|
31
|
+
Rake::Task[plugin].clear_actions
|
32
|
+
Rake::Task[plugin].clear_prerequisites
|
33
|
+
|
34
|
+
Rake::RDocTask.new(plugin) { |rdoc|
|
35
|
+
plugin_base = "vendor/plugins/#{plugin}"
|
36
|
+
ENV['format'] ||= 'railsfish'
|
37
|
+
rdoc.rdoc_dir = "doc/plugins/#{plugin}"
|
38
|
+
rdoc.template = ENV['template'] if ENV['template']
|
39
|
+
rdoc.title = "#{plugin.titlecase} Plugin Documentation"
|
40
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
41
|
+
rdoc.options << '--charset' << 'utf-8'
|
42
|
+
rdoc.options << '--format' << ENV['format']
|
43
|
+
rdoc.rdoc_files.include("#{plugin_base}/lib/**/*.rb")
|
44
|
+
rdoc.rdoc_files.include("#{plugin_base}/app/**/*.rb")
|
45
|
+
|
46
|
+
%w( README README.rdoc ).each do |readme|
|
47
|
+
if File.exist?("#{plugin_base}/#{readme}")
|
48
|
+
rdoc.main = "#{plugin_base}/#{readme}"
|
49
|
+
break
|
50
|
+
end
|
51
|
+
end
|
52
|
+
%w( TODO.org MIT-LICENSE LICENSE CHANGELOG README README.rdoc ).each do |possible_file|
|
53
|
+
if File.exist?("#{plugin_base}/#{possible_file}")
|
54
|
+
rdoc.rdoc_files.include("#{plugin_base}/#{possible_file}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
}
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
task :parse_readme => :environment do
|
63
|
+
require 'rdoc/markup/to_html'
|
64
|
+
h = RDoc::Markup::ToHtml.new
|
65
|
+
puts h.convert( File.read('README.rdoc') )
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|