build-tool 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +28 -1
- data/Manifest.txt +91 -52
- data/README.txt +63 -0
- data/Rakefile +20 -23
- data/bin/build-tool +53 -0
- data/lib/build-tool.rb +7 -0
- data/lib/build-tool/GUI.rb +360 -0
- data/lib/build-tool/application.rb +84 -0
- data/lib/build-tool/build-system/autoconf.rb +60 -0
- data/lib/build-tool/build-system/base.rb +142 -0
- data/lib/build-tool/build-system/cmake.rb +119 -0
- data/lib/build-tool/build-system/custom.rb +115 -0
- data/lib/build-tool/build-system/qt.rb +113 -0
- data/lib/build-tool/cfg/lexer.rb +558 -0
- data/lib/build-tool/cfg/lexer.rex +248 -0
- data/lib/build-tool/cfg/lexer_base.rb +82 -0
- data/lib/build-tool/cfg/node.rb +94 -0
- data/lib/build-tool/cfg/parser.rb +871 -0
- data/lib/build-tool/cfg/parser.y +279 -0
- data/lib/build-tool/cfg/visitor.rb +471 -0
- data/lib/build-tool/commands.rb +639 -0
- data/lib/build-tool/commands/build.rb +120 -0
- data/lib/build-tool/commands/configure.rb +73 -0
- data/lib/build-tool/commands/ctags.rb +46 -0
- data/lib/build-tool/commands/environments.rb +29 -0
- data/lib/build-tool/commands/environments/list.rb +37 -0
- data/lib/build-tool/commands/environments/set.rb +33 -0
- data/lib/build-tool/commands/fetch.rb +50 -0
- data/lib/build-tool/commands/files.rb +73 -0
- data/lib/build-tool/commands/help.rb +22 -0
- data/lib/build-tool/commands/info.rb +48 -0
- data/lib/build-tool/commands/install.rb +56 -0
- data/lib/build-tool/commands/modules.rb +29 -0
- data/lib/build-tool/commands/modules/info.rb +75 -0
- data/lib/build-tool/commands/modules/list.rb +49 -0
- data/lib/build-tool/commands/modules/shell.rb +40 -0
- data/lib/build-tool/commands/rebase.rb +46 -0
- data/lib/build-tool/commands/recipes.rb +32 -0
- data/lib/build-tool/commands/recipes/info.rb +46 -0
- data/lib/build-tool/commands/recipes/install.rb +184 -0
- data/lib/build-tool/commands/recipes/list.rb +33 -0
- data/lib/build-tool/configuration.rb +115 -0
- data/lib/build-tool/environment.rb +119 -0
- data/lib/build-tool/errors.rb +9 -0
- data/lib/build-tool/module.rb +366 -0
- data/lib/build-tool/pluginbase.rb +43 -0
- data/lib/build-tool/recipe.rb +180 -0
- data/lib/build-tool/repository.rb +59 -0
- data/lib/build-tool/server.rb +43 -0
- data/lib/build-tool/singleton.rb +50 -0
- data/lib/build-tool/sshkey.rb +22 -0
- data/lib/build-tool/vcs/base.rb +105 -0
- data/lib/build-tool/vcs/git-svn.rb +154 -0
- data/lib/build-tool/vcs/git.rb +187 -0
- data/lib/build-tool/vcs/svn.rb +136 -0
- data/lib/mj/logging.rb +31 -0
- data/lib/mj/tools/ssh.rb +64 -0
- data/lib/{kde-build → mj/tools}/subprocess.rb +21 -16
- data/lib/mj/visitor.rb +21 -0
- data/recipes/kde/files/finish_installation.sh +16 -0
- data/recipes/kde/files/kde4.desktop +22 -0
- data/recipes/kde/files/xsession +89 -0
- data/recipes/kde/info.yaml +10 -0
- data/recipes/kde/recipe +585 -0
- data/recipes/kde/recipe-local +90 -0
- data/recipes/kde/settings.yaml +52 -0
- data/recipes/kde43/info.yaml +10 -0
- data/recipes/kde43/recipe +256 -0
- data/recipes/kde43/recipe-local +90 -0
- data/recipes/kde43/settings.yaml +32 -0
- data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/compile.sh +77 -0
- data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/configure.sh +70 -0
- data/recipes/kdeqt4.6/custom/qt/qtscriptgenerator/install.sh +39 -0
- data/recipes/kdeqt4.6/info.yaml +7 -0
- data/recipes/kdeqt4.6/recipe +155 -0
- data/recipes/kdeqt4.6/recipe-local +30 -0
- data/recipes/kdeqt4.6/settings.yaml +27 -0
- data/tags +745 -0
- data/tasks/genfiles.rake +28 -0
- data/tasks/rdoc.rake +34 -0
- data/tasks/rspec.rake +21 -0
- data/test.rb +28 -0
- data/test/commands/test_build.rb +29 -0
- data/test/test_build_system.rb +98 -0
- data/test/test_cli.rb +61 -0
- data/test/test_command.rb +175 -0
- data/test/test_configuration_parser.rb +542 -0
- data/test/test_environment.rb +82 -0
- data/test/test_helper.rb +39 -7
- data/test/test_module.rb +158 -0
- data/test/test_repository.rb +75 -0
- data/test/test_singleton.rb +51 -0
- data/test/test_ssh_key.rb +14 -0
- data/test/test_svn_parser.rb +28 -0
- data/test/test_vcs.rb +33 -0
- metadata +139 -90
- metadata.gz.sig +0 -0
- data/PostInstall.txt +0 -3
- data/TODO +0 -2
- data/bin/kde-build.rb +0 -21
- data/config/website.yml +0 -2
- data/config/website.yml.sample +0 -2
- data/lib/kde-build.rb +0 -18
- data/lib/kde-build/application.rb +0 -270
- data/lib/kde-build/build_system.rb +0 -28
- data/lib/kde-build/build_system/autoconf.rb +0 -108
- data/lib/kde-build/build_system/base.rb +0 -139
- data/lib/kde-build/build_system/cmake.rb +0 -94
- data/lib/kde-build/build_system/qtcopy.rb +0 -127
- data/lib/kde-build/command.rb +0 -42
- data/lib/kde-build/command/build.rb +0 -106
- data/lib/kde-build/command/compile.rb +0 -39
- data/lib/kde-build/command/configure.rb +0 -48
- data/lib/kde-build/command/ctags.rb +0 -41
- data/lib/kde-build/command/fetch.rb +0 -33
- data/lib/kde-build/command/help.rb +0 -71
- data/lib/kde-build/command/info.rb +0 -45
- data/lib/kde-build/command/install.rb +0 -39
- data/lib/kde-build/command/module_based.rb +0 -44
- data/lib/kde-build/command/rebase.rb +0 -50
- data/lib/kde-build/command/version.rb +0 -43
- data/lib/kde-build/configuration.rb +0 -209
- data/lib/kde-build/exception.rb +0 -6
- data/lib/kde-build/metaaid.rb +0 -18
- data/lib/kde-build/module.rb +0 -227
- data/lib/kde-build/module_configuration.rb +0 -107
- data/lib/kde-build/moduleregistry.rb +0 -85
- data/lib/kde-build/tools/ctags.rb +0 -59
- data/lib/kde-build/tools/logging.rb +0 -49
- data/lib/kde-build/tools/make.rb +0 -58
- data/lib/kde-build/tools/ssh.rb +0 -47
- data/lib/kde-build/vcs.rb +0 -28
- data/lib/kde-build/vcs/base.rb +0 -85
- data/lib/kde-build/vcs/git-svn.rb +0 -139
- data/lib/kde-build/vcs/git.rb +0 -121
- data/lib/kde-build/vcs/svn.rb +0 -102
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -71
- data/test.yaml.tmpl +0 -632
- data/test/test_kde-build.rb +0 -11
- data/test/test_vcs_svn.rb +0 -44
- data/website/index.html +0 -84
- data/website/index.txt +0 -59
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -159
- data/website/template.html.erb +0 -50
@@ -1,139 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
require 'kde-build/vcs/base'
|
4
|
-
|
5
|
-
module BuildTool; module VCS
|
6
|
-
|
7
|
-
|
8
|
-
class GitSvnConfiguration < BaseConfiguration
|
9
|
-
|
10
|
-
option( "externals", "List of externals to fetch" ).
|
11
|
-
on_write {
|
12
|
-
|val|
|
13
|
-
if val.instance_of?( Array )
|
14
|
-
a = val.inject([]) {
|
15
|
-
|arr, v|
|
16
|
-
v.each_pair {
|
17
|
-
|val, key|
|
18
|
-
arr << val << key
|
19
|
-
}
|
20
|
-
arr
|
21
|
-
}
|
22
|
-
val = Hash[*a]
|
23
|
-
else
|
24
|
-
throw :todo
|
25
|
-
raise Exception, "FIXME"
|
26
|
-
end
|
27
|
-
val
|
28
|
-
}
|
29
|
-
|
30
|
-
|
31
|
-
def initialize
|
32
|
-
super
|
33
|
-
self.name = "git-svn"
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
# Git-SVN Error
|
39
|
-
class GitSvnError < BuildToolError
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
# Implementation for the git-svn version control system
|
44
|
-
# (http://git-scm.org)
|
45
|
-
class GitSVN < Base
|
46
|
-
|
47
|
-
def initialize( repository, path )
|
48
|
-
super repository, path
|
49
|
-
end
|
50
|
-
|
51
|
-
# Check if the local checkout exists.
|
52
|
-
#
|
53
|
-
# calls VCS::Base::checkedout? and checks if there is a '.git'
|
54
|
-
# directory at +path+
|
55
|
-
def checkedout?
|
56
|
-
return false if !super
|
57
|
-
if !File.exists? "#{path}/.git"
|
58
|
-
$log.debug("Checkout path #{path} is not a git repo")
|
59
|
-
return false
|
60
|
-
end
|
61
|
-
return true
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.config
|
65
|
-
GitSvnConfiguration
|
66
|
-
end
|
67
|
-
|
68
|
-
# Execute a git command in the context of the local git repository
|
69
|
-
def git_svn( command, wd = path )
|
70
|
-
self.class.execute "git svn #{command}", wd
|
71
|
-
end
|
72
|
-
|
73
|
-
# Fetch from +repository+
|
74
|
-
#
|
75
|
-
# Initializes the local clone if it does not exist.
|
76
|
-
def fetch( revision = nil )
|
77
|
-
if !checkedout? and !$noop
|
78
|
-
init
|
79
|
-
end
|
80
|
-
if revision
|
81
|
-
cmd = "fetch -r#{revision}"
|
82
|
-
else
|
83
|
-
cmd = "fetch"
|
84
|
-
end
|
85
|
-
if ( rc = git_svn( cmd ) ) != 0
|
86
|
-
raise GitSvnError, "Error while fetching: #{rc}"
|
87
|
-
end
|
88
|
-
update_externals
|
89
|
-
end
|
90
|
-
|
91
|
-
# Initialize the local repository
|
92
|
-
def init( revision = nil )
|
93
|
-
# Check if path exists
|
94
|
-
if File.exists? path
|
95
|
-
raise GitSvnError, "Failed to create repository at '#{path}': Path exists"
|
96
|
-
end
|
97
|
-
# Make sure we have a revision
|
98
|
-
if !revision
|
99
|
-
revision = SVN.new( repository ).last_changed_rev
|
100
|
-
end
|
101
|
-
if !revision or revision == 0
|
102
|
-
raise GitSvnError, "Failed to retrieve revision to clone from '#{repository}'"
|
103
|
-
end
|
104
|
-
# Create the directory
|
105
|
-
FileUtils.mkdir_p( path ) if !$noop
|
106
|
-
# Init the repository
|
107
|
-
if !git_svn "init #{repository}"
|
108
|
-
raise GitSvnError, "Error while initializing the repo `git svn init '#{repository}'`: #{$?}"
|
109
|
-
end
|
110
|
-
fetch( revision )
|
111
|
-
update_externals
|
112
|
-
end
|
113
|
-
|
114
|
-
def info
|
115
|
-
super
|
116
|
-
puts " Externals: #{configuration.externals.inspect}" if configuration.externals
|
117
|
-
end
|
118
|
-
|
119
|
-
# Returns Git-SVN
|
120
|
-
def name
|
121
|
-
"Git-SVN"
|
122
|
-
end
|
123
|
-
|
124
|
-
def rebase
|
125
|
-
return git_svn "rebase -l master"
|
126
|
-
end
|
127
|
-
|
128
|
-
def update_externals
|
129
|
-
return if !configuration.externals
|
130
|
-
configuration.externals.each do |local, remote|
|
131
|
-
SVN::svn( "checkout #{remote}@HEAD #{local}", wd = path )
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
136
|
-
|
137
|
-
|
138
|
-
end; end
|
139
|
-
|
data/lib/kde-build/vcs/git.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# git-svn.rb - GIT-SVN VCS Implementation
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# == Overview
|
7
|
-
#
|
8
|
-
# bla bla
|
9
|
-
#
|
10
|
-
require 'kde-build/vcs/base'
|
11
|
-
|
12
|
-
module BuildTool; module VCS
|
13
|
-
|
14
|
-
class GitConfiguration < BaseConfiguration
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
super
|
18
|
-
self.name = "git"
|
19
|
-
end
|
20
|
-
|
21
|
-
option( "remote-branch", "The remote branch to checkout" ).
|
22
|
-
default = "master"
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
# Implementation for the git-svn version control system
|
28
|
-
# (http://git-scm.org)
|
29
|
-
class Git < Base
|
30
|
-
|
31
|
-
def initialize( repository, path )
|
32
|
-
super
|
33
|
-
end
|
34
|
-
|
35
|
-
def name
|
36
|
-
"GIT"
|
37
|
-
end
|
38
|
-
|
39
|
-
def git( command, wd = path )
|
40
|
-
self.class.execute "git #{command}", wd
|
41
|
-
end
|
42
|
-
|
43
|
-
def remote_branch
|
44
|
-
@configuration.remote_branch
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.config
|
48
|
-
GitConfiguration
|
49
|
-
end
|
50
|
-
|
51
|
-
# Check if the local checkout exists.
|
52
|
-
#
|
53
|
-
# calls VCS::Base::checkedout? and checks if there is a '.git'
|
54
|
-
# directory at +path+
|
55
|
-
def checkedout?
|
56
|
-
return false if !super
|
57
|
-
if !File.exists? "#{path}/.git"
|
58
|
-
$log.debug("Checkout path #{path} is not a git repo")
|
59
|
-
return false
|
60
|
-
end
|
61
|
-
return true
|
62
|
-
end
|
63
|
-
|
64
|
-
# Fetch from +repository+
|
65
|
-
#
|
66
|
-
# Initializes the local clone if it does not exist.
|
67
|
-
def fetch()
|
68
|
-
if !checkedout? and !$noop
|
69
|
-
init
|
70
|
-
end
|
71
|
-
cmd = "fetch"
|
72
|
-
if ( rc = git( cmd ) ) != 0
|
73
|
-
raise GitError, "Error while fetching: #{rc}"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
# Initialize the local repository
|
79
|
-
def init
|
80
|
-
# Check if path exists
|
81
|
-
if File.exists? path
|
82
|
-
raise GitSvnError, "Failed to create repository at '#{path}': Path exists"
|
83
|
-
end
|
84
|
-
|
85
|
-
# Create the directory
|
86
|
-
FileUtils.mkdir_p( File.split(path)[0] ) if !$noop
|
87
|
-
|
88
|
-
# Initialize the repository
|
89
|
-
if !git( "clone --no-checkout #{repository} #{path}", Pathname.new(path).dirname )
|
90
|
-
raise GitError, "Error while initializing the repo `git clone --no-checkout '#{repository} #{path}'`: #{$?}"
|
91
|
-
end
|
92
|
-
|
93
|
-
# Create the local checkout
|
94
|
-
if remote_branch != "master"
|
95
|
-
if !git( "checkout --track -b #{remote_branch} origin/#{remote_branch}", path )
|
96
|
-
raise GitError, "Error while initializing the repo `checkout --track -b '#{remote_branch} origin/#{remote_branch}'`: #{$?}"
|
97
|
-
end
|
98
|
-
else
|
99
|
-
if !git( "checkout #{remote_branch}", path )
|
100
|
-
raise GitError, "Error while initializing the repo `git checkout #{remote_branch}'`: #{$?}"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
fetch()
|
106
|
-
end
|
107
|
-
|
108
|
-
def info
|
109
|
-
super
|
110
|
-
puts " Remote Branch: #{remote_branch.inspect}"
|
111
|
-
end
|
112
|
-
|
113
|
-
def rebase
|
114
|
-
return git "rebase origin"
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
|
-
end
|
121
|
-
end
|
data/lib/kde-build/vcs/svn.rb
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'kde-build/vcs/base.rb'
|
4
|
-
|
5
|
-
module BuildTool; module VCS
|
6
|
-
|
7
|
-
class SvnConfiguration < BaseConfiguration
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
super
|
11
|
-
self.name = "svn"
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
# Implementation for the subversion version control system
|
18
|
-
# (http://subversion.tigris.org).
|
19
|
-
class SVN < Base
|
20
|
-
|
21
|
-
def initialize( repository, path = nil )
|
22
|
-
super
|
23
|
-
end
|
24
|
-
|
25
|
-
def name
|
26
|
-
"Subversion"
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.svn( command, wd, &block )
|
30
|
-
self.execute( "svn #{command}", wd, &block )
|
31
|
-
end
|
32
|
-
|
33
|
-
def svn( command, wd = path, &block )
|
34
|
-
self.class.svn command, wd, &block
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.config
|
38
|
-
SvnConfiguration
|
39
|
-
end
|
40
|
-
|
41
|
-
# Check if the local checkout exists.
|
42
|
-
#
|
43
|
-
# calls VCS::Base::checkedout? and checks if there is a '.git'
|
44
|
-
# directory at +path+
|
45
|
-
def checkedout?
|
46
|
-
return false if !super
|
47
|
-
if !File.exists? "#{path}/.svn"
|
48
|
-
$log.debug("Checkout path #{path} is not a svn repo")
|
49
|
-
return false
|
50
|
-
end
|
51
|
-
return true
|
52
|
-
end
|
53
|
-
|
54
|
-
# Returns the last changed revision on the remote repository.
|
55
|
-
# Return 0 if the last changed revision could not be determined.
|
56
|
-
def last_changed_rev
|
57
|
-
info = Hash.new
|
58
|
-
return 777777 if $noop
|
59
|
-
svn( "info #{repository}", nil ) {
|
60
|
-
|line|
|
61
|
-
key, value = line.chomp.split( ':', 2 )
|
62
|
-
info[key] = value
|
63
|
-
}
|
64
|
-
version = info["Last Changed Rev"];
|
65
|
-
return version
|
66
|
-
end
|
67
|
-
|
68
|
-
# Fetch from +repository+
|
69
|
-
#
|
70
|
-
# Initializes the local clone if it does not exist.
|
71
|
-
def fetch()
|
72
|
-
if !checkedout?
|
73
|
-
init
|
74
|
-
end
|
75
|
-
return true
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
# Initialize the local repository
|
80
|
-
def init
|
81
|
-
# Check if path exists
|
82
|
-
if File.exists? path
|
83
|
-
raise SvnError, "Failed to create repository at '#{path}': Path exists"
|
84
|
-
end
|
85
|
-
|
86
|
-
# Create the directories parent dir.
|
87
|
-
FileUtils.mkdir_p( File.dirname( path ) ) if !$noop
|
88
|
-
|
89
|
-
# Init the repository
|
90
|
-
if !svn "checkout --depth=infinity #{repository}", File.dirname(path)
|
91
|
-
raise SvnError, "Error during 'svn checkout #{repository}'`: #{$?}"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def rebase
|
96
|
-
return svn "update"
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
|
-
end; end
|
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/kde-build.rb'}"
|
9
|
-
puts "Loading kde-build 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,71 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
load File.dirname(__FILE__) + "/../Rakefile"
|
4
|
-
require 'rubyforge'
|
5
|
-
require 'redcloth'
|
6
|
-
require 'syntax/convertors/html'
|
7
|
-
require 'erb'
|
8
|
-
|
9
|
-
download = "http://rubyforge.org/projects/#{$hoe.rubyforge_name}"
|
10
|
-
version = $hoe.version
|
11
|
-
|
12
|
-
def rubyforge_project_id
|
13
|
-
RubyForge.new.configure.autoconfig["group_ids"][$hoe.rubyforge_name]
|
14
|
-
end
|
15
|
-
|
16
|
-
class Fixnum
|
17
|
-
def ordinal
|
18
|
-
# teens
|
19
|
-
return 'th' if (10..19).include?(self % 100)
|
20
|
-
# others
|
21
|
-
case self % 10
|
22
|
-
when 1: return 'st'
|
23
|
-
when 2: return 'nd'
|
24
|
-
when 3: return 'rd'
|
25
|
-
else return 'th'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class Time
|
31
|
-
def pretty
|
32
|
-
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def convert_syntax(syntax, source)
|
37
|
-
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
38
|
-
end
|
39
|
-
|
40
|
-
if ARGV.length >= 1
|
41
|
-
src, template = ARGV
|
42
|
-
template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
|
43
|
-
else
|
44
|
-
puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
|
45
|
-
exit!
|
46
|
-
end
|
47
|
-
|
48
|
-
template = ERB.new(File.open(template).read)
|
49
|
-
|
50
|
-
title = nil
|
51
|
-
body = nil
|
52
|
-
File.open(src) do |fsrc|
|
53
|
-
title_text = fsrc.readline
|
54
|
-
body_text_template = fsrc.read
|
55
|
-
body_text = ERB.new(body_text_template).result(binding)
|
56
|
-
syntax_items = []
|
57
|
-
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
58
|
-
ident = syntax_items.length
|
59
|
-
element, syntax, source = $1, $2, $3
|
60
|
-
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
61
|
-
"syntax-temp-#{ident}"
|
62
|
-
}
|
63
|
-
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
64
|
-
body = RedCloth.new(body_text).to_html
|
65
|
-
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
66
|
-
end
|
67
|
-
stat = File.stat(src)
|
68
|
-
created = stat.ctime
|
69
|
-
modified = stat.mtime
|
70
|
-
|
71
|
-
$stdout << template.result(binding)
|