Empact-rails-plugin-package-task 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +17 -0
- data/README.rdoc +43 -0
- data/Rakefile +15 -0
- data/lib/rails_plugin_package_task.rb +150 -0
- data/rails-plugin-package-task.gemspec +21 -0
- metadata +63 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Copyright (c) 2006 by Zak Mandhro
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
4
|
+
and associated documentation files (the "Software"), to deal in the Software without restriction,
|
5
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
6
|
+
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
7
|
+
subject to the following conditions:
|
8
|
+
|
9
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
10
|
+
portions of the Software.
|
11
|
+
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
13
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
14
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
15
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
16
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
17
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
= Rails Plug-in Package Task
|
2
|
+
|
3
|
+
RailsPluginPackageTask is a rake task designed to automate the publishing of
|
4
|
+
Ruby on Rails plug-ins. The Rails plug-in installer _RecursiveHTTPFetcher_ makes
|
5
|
+
certain assumptions about the web servers that does not hold through from
|
6
|
+
server to server, for example:
|
7
|
+
|
8
|
+
* Server generates an index page with links
|
9
|
+
* All links to plug-in files are relative links
|
10
|
+
* Folder links end with a forward slash (used to recurse)
|
11
|
+
|
12
|
+
RubyForge web server is an example of where these assupmtions don't hold
|
13
|
+
true. As a result, you can not simply copy your files to a web server
|
14
|
+
and expect Rails HTTP plugin installer to just work.
|
15
|
+
|
16
|
+
This Rake task helps fill the gap by complying to the plug-in scripts assumptions.
|
17
|
+
Following the Rake package task conventions, it defines the "rails_plugin" task
|
18
|
+
that recurses through your _package_files_, generates compliant index.html for
|
19
|
+
each folder (that contains a file), and creates a directory structure that you
|
20
|
+
can publish as a set for your plugin.
|
21
|
+
|
22
|
+
== Example
|
23
|
+
|
24
|
+
The following example uses the Rake::RailsPluginPackageTask to create
|
25
|
+
the package. It then uses the Rake::SshDirPublisher to publish the plugin
|
26
|
+
directory to RubyForge.
|
27
|
+
|
28
|
+
Rake::RailsPluginPackageTask.new(ProjectInfo[:name], ProjectInfo[:version]) do |p|
|
29
|
+
p.package_files = PluginPackageFiles
|
30
|
+
p.plugin_files = FileList["rails_plugin/**/*"]
|
31
|
+
p.extra_links = {"Project page"=>ProjectInfo[:homepage],
|
32
|
+
"Author: #{ProjectInfo[:author_name]}"=>ProjectInfo[:author_link]}
|
33
|
+
p.verbose = true
|
34
|
+
end
|
35
|
+
task :rails_plugin=>:clobber
|
36
|
+
|
37
|
+
desc "Publish Ruby on Rails plug-in on RubyForge"
|
38
|
+
task :release_plugin=>:rails_plugin do |task|
|
39
|
+
pub = Rake::SshDirPublisher.new("#{RubyForgeConfig[:user_name]}@rubyforge.org",
|
40
|
+
"/var/www/gforge-projects/#{RubyForgeConfig[:unix_name]}",
|
41
|
+
"pkg/rails_plugin")
|
42
|
+
pub.upload()
|
43
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rake/gempackagetask'
|
2
|
+
require "rake/rdoctask"
|
3
|
+
|
4
|
+
spec = eval(IO.read("rails-plugin-package-task.gemspec"))
|
5
|
+
|
6
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
7
|
+
pkg.gem_spec = spec
|
8
|
+
end
|
9
|
+
|
10
|
+
Rake::RDocTask.new do |rd|
|
11
|
+
rd.rdoc_dir = "doc"
|
12
|
+
rd.rdoc_files.include("lib/**/*.rb")
|
13
|
+
rd.rdoc_files.include(spec.extra_rdoc_files)
|
14
|
+
rd.options = spec.rdoc_options
|
15
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/tasklib'
|
5
|
+
|
6
|
+
module Rake
|
7
|
+
# RailsPluginPackageTask defines the "rails_plugin" task
|
8
|
+
# that recurses through your _package_files_, generates compliant index.html for
|
9
|
+
# each folder (that contains a file), and creates a directory structure that you
|
10
|
+
# can publish as a set for your plugin.
|
11
|
+
#
|
12
|
+
# Noteworthy attributes:
|
13
|
+
#
|
14
|
+
# [package_dir] Directory to store the package. Default 'pkg/rails_plugin'
|
15
|
+
#
|
16
|
+
# [package_dir] Files to include in the plugin.
|
17
|
+
#
|
18
|
+
# [extra_links] Links to put on every generated index page. Can be a hash, e.g.
|
19
|
+
# {"Home"=>"http://roxml.rubyforge.org"}, an array of strings or
|
20
|
+
# a single string.
|
21
|
+
#
|
22
|
+
# [plugin_files] Files to be placed in the root folder of the plug-in, e.g.
|
23
|
+
# init.rb. All files that are in the root of _package_dir_
|
24
|
+
# will also be placed in the root of the plug-in.
|
25
|
+
#
|
26
|
+
class RailsPluginPackageTask < TaskLib
|
27
|
+
# Name of plug-in or application
|
28
|
+
attr_accessor :name
|
29
|
+
# Version of plugin - distribution folder will be name_version
|
30
|
+
attr_accessor :version
|
31
|
+
# Directory used to store the package files (default is 'pkg/rails_plugin').
|
32
|
+
attr_accessor :package_dir
|
33
|
+
# Files to be stored in the package
|
34
|
+
attr_accessor :package_files
|
35
|
+
# Files to go into the root of the plug-in folder (e.g. init.rb)
|
36
|
+
attr_accessor :plugin_files
|
37
|
+
# Homepage for more information
|
38
|
+
attr_accessor :extra_links
|
39
|
+
# Verbose [true | false]
|
40
|
+
attr_accessor :verbose
|
41
|
+
|
42
|
+
# Create the "rails_plugin" task
|
43
|
+
def initialize(name=nil, version=nil)
|
44
|
+
init(name, version)
|
45
|
+
yield self if block_given?
|
46
|
+
define unless name.nil?
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initialize with defaults
|
50
|
+
def init(name, version)
|
51
|
+
@name = name
|
52
|
+
@version = version
|
53
|
+
@extra_links = nil
|
54
|
+
@package_files = Rake::FileList.new
|
55
|
+
@plugin_files = Rake::FileList.new
|
56
|
+
@package_dir = 'pkg/rails_plugin'
|
57
|
+
@folders = {}
|
58
|
+
@verbose = false
|
59
|
+
end
|
60
|
+
|
61
|
+
# Define the rails_plugin task
|
62
|
+
def define
|
63
|
+
desc "Create Ruby on Rails plug-in package"
|
64
|
+
task :rails_plugin do
|
65
|
+
@dest = "#@package_dir/#{@name}_#{@version}"
|
66
|
+
makedirs(@dest,:verbose=>false)
|
67
|
+
@plugin_files.each do |fn|
|
68
|
+
cp(fn, @dest,:verbose=>false)
|
69
|
+
add_file(File.basename(fn))
|
70
|
+
end
|
71
|
+
|
72
|
+
@package_files.each do |fn|
|
73
|
+
puts ". #{fn}" if verbose
|
74
|
+
f = File.join(@dest, fn)
|
75
|
+
fdir = File.dirname(f)
|
76
|
+
unless File.exist?(fdir)
|
77
|
+
mkdir_p(fdir,:verbose=>false)
|
78
|
+
add_folder("#{fdir}/")
|
79
|
+
end
|
80
|
+
if File.directory?(fn)
|
81
|
+
mkdir_p(f,:verbose=>false)
|
82
|
+
add_folder("#{fn}/")
|
83
|
+
else
|
84
|
+
cp(fn, f, :verbose=>false)
|
85
|
+
add_file(fn)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
generate_index_files()
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Generate the index.html files
|
94
|
+
def generate_index_files
|
95
|
+
@folders.each do |folder, files|
|
96
|
+
puts " + Creating #{@dest}/#{folder}/index.html" if @verbose
|
97
|
+
File.open("#{@dest}/#{folder}/index.html", "w") do |index|
|
98
|
+
title = "Rails Plug-in for #@name #@version"
|
99
|
+
index.write("<html><head><title>#{title}</title></head>\n")
|
100
|
+
index.write("<body>\n")
|
101
|
+
index.write("<h2>#{title}</h2>\n")
|
102
|
+
extra_links = create_extra_links()
|
103
|
+
index.write("<p>#{extra_links}</p>\n") if extra_links
|
104
|
+
files.each { |fn|
|
105
|
+
puts(" - Adding #{fn}") if @verbose
|
106
|
+
index.write(" <a href=\"#{fn}\">#{fn}</a><br/>\n")
|
107
|
+
}
|
108
|
+
index.write("<hr size=\"1\"/><p style=\"font-size: x-small\">Generated with RailsPluginPackageTask<p>")
|
109
|
+
index.write("</body>\n")
|
110
|
+
index.write("</html>\n")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
private
|
116
|
+
# Add a file to the folders hash
|
117
|
+
def add_file(filename)
|
118
|
+
dir = File.dirname(filename).gsub("#{@dest}",".")
|
119
|
+
fn = File.basename(filename)
|
120
|
+
folder = @folders[dir] || @folders[dir]=[]
|
121
|
+
folder << fn
|
122
|
+
end
|
123
|
+
|
124
|
+
# Add a folder to the folders hash
|
125
|
+
def add_folder(folder_name)
|
126
|
+
dir = File.dirname(folder_name).gsub("#{@dest}",".").gsub("./","")
|
127
|
+
fn = File.basename(folder_name) + "/"
|
128
|
+
folder = @folders[dir] || @folders[dir]=[]
|
129
|
+
folder << fn
|
130
|
+
end
|
131
|
+
|
132
|
+
# Create the anchor tag for extra links
|
133
|
+
def create_extra_links
|
134
|
+
return nil unless @extra_links
|
135
|
+
x_links = ""
|
136
|
+
if (@extra_links.class==Hash)
|
137
|
+
@extra_links.each do |k,v|
|
138
|
+
x_links << "<a href=\"#{v}\">#{k}</a> "
|
139
|
+
end
|
140
|
+
elsif (@extra_links.class==Array)
|
141
|
+
@extra_links.each do |link|
|
142
|
+
x_links << "<a href=\"#{link}\">#{link}</a> "
|
143
|
+
end
|
144
|
+
else
|
145
|
+
x_links = "<a href=\"#{@extra_links.to_s}\">#{@extra_links.to_s}</a>"
|
146
|
+
end
|
147
|
+
return x_links
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "rails-plugin-package-task"
|
3
|
+
s.version = "0.1"
|
4
|
+
s.date = "2008-08-27"
|
5
|
+
s.summary = "Automates the publishing of Rail plug-ins"
|
6
|
+
s.email = "mandhro@yahoo.com"
|
7
|
+
s.homepage = "http://roxml.rubyforge.org/"
|
8
|
+
s.description = "Designed to automate the publishing of Rail plug-ins. Extracted from ROXML CVS."
|
9
|
+
s.has_rdoc = true
|
10
|
+
s.author = "Zak Mandhro"
|
11
|
+
s.files = ["MIT-LICENSE",
|
12
|
+
"Rakefile",
|
13
|
+
"README.rdoc",
|
14
|
+
"rails-plugin-package-task.gemspec",
|
15
|
+
"lib/rails_plugin_package_task.rb"]
|
16
|
+
s.require_path = 'lib'
|
17
|
+
s.extra_rdoc_files = ["README.rdoc", 'MIT-LICENSE']
|
18
|
+
s.rdoc_options << '--line-numbers' << '--inline-source' <<
|
19
|
+
'--title' << 'Rails Plug-in Package Task' <<
|
20
|
+
'--main' << 'README.rdoc'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Empact-rails-plugin-package-task
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zak Mandhro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-08-27 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Designed to automate the publishing of Rail plug-ins. Extracted from ROXML CVS.
|
17
|
+
email: mandhro@yahoo.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
- MIT-LICENSE
|
25
|
+
files:
|
26
|
+
- MIT-LICENSE
|
27
|
+
- Rakefile
|
28
|
+
- README.rdoc
|
29
|
+
- rails-plugin-package-task.gemspec
|
30
|
+
- lib/rails_plugin_package_task.rb
|
31
|
+
has_rdoc: true
|
32
|
+
homepage: http://roxml.rubyforge.org/
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options:
|
35
|
+
- --line-numbers
|
36
|
+
- --inline-source
|
37
|
+
- --title
|
38
|
+
- Rails Plug-in Package Task
|
39
|
+
- --main
|
40
|
+
- README.rdoc
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
requirements: []
|
56
|
+
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 1.2.0
|
59
|
+
signing_key:
|
60
|
+
specification_version: 2
|
61
|
+
summary: Automates the publishing of Rail plug-ins
|
62
|
+
test_files: []
|
63
|
+
|