sitefuel 0.0.0b → 0.1.0a
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 +81 -0
- data/{RELEASE_NOTES → RELEASE_NOTES.rdoc} +0 -0
- data/bin/sitefuel +64 -111
- data/lib/sitefuel/CommandLine.rb +142 -0
- data/lib/sitefuel/Configuration.rb +49 -13
- data/lib/sitefuel/License.rb +292 -0
- data/lib/sitefuel/SiteFuelLogger.rb +34 -5
- data/lib/sitefuel/SiteFuelRuntime.rb +217 -44
- data/lib/sitefuel/extensions/ArrayComparisons.rb +2 -2
- data/lib/sitefuel/extensions/ColumnPrinter.rb +276 -0
- data/lib/sitefuel/extensions/DynamicClassMethods.rb +2 -2
- data/lib/sitefuel/extensions/FileComparison.rb +2 -2
- data/lib/sitefuel/extensions/FileTree.rb +94 -0
- data/lib/sitefuel/extensions/Silently.rb +2 -2
- data/lib/sitefuel/extensions/StringFormatting.rb +52 -8
- data/lib/sitefuel/extensions/SymbolComparison.rb +4 -2
- data/lib/sitefuel/extensions/TerminalInfo.rb +53 -0
- data/lib/sitefuel/external/AbstractExternalProgram.rb +65 -11
- data/lib/sitefuel/external/ExternalProgramTestCase.rb +2 -2
- data/lib/sitefuel/external/GIT.rb +50 -3
- data/lib/sitefuel/external/JPEGTran.rb +2 -2
- data/lib/sitefuel/external/PNGCrush.rb +2 -2
- data/lib/sitefuel/external/SVN.rb +57 -0
- data/lib/sitefuel/processors/AbstractExternalProgramProcessor.rb +17 -4
- data/lib/sitefuel/processors/AbstractProcessor.rb +64 -47
- data/lib/sitefuel/processors/AbstractStringBasedProcessor.rb +20 -3
- data/lib/sitefuel/processors/CSSProcessor.rb +2 -2
- data/lib/sitefuel/processors/Configurable.rb +94 -0
- data/lib/sitefuel/processors/HAMLProcessor.rb +4 -4
- data/lib/sitefuel/processors/HTMLProcessor.rb +2 -2
- data/lib/sitefuel/processors/JavaScriptProcessor.rb +2 -2
- data/lib/sitefuel/processors/PHPProcessor.rb +2 -2
- data/lib/sitefuel/processors/PNGProcessor.rb +2 -2
- data/lib/sitefuel/processors/RHTMLProcessor.rb +2 -2
- data/lib/sitefuel/processors/SASSProcessor.rb +4 -4
- data/test/{test_images → images}/sample_jpg01.jpg +0 -0
- data/test/{test_images → images}/sample_png01.png +0 -0
- data/test/processor_listing.rb +2 -2
- data/test/{test_programs → programs}/versioning.rb +2 -2
- data/test/repositories/git/few_files/deployment.yml +0 -0
- data/test/repositories/git/few_files/index.html +10 -0
- data/test/repositories/git/few_files/style.css +2 -0
- data/test/repositories/svn/testrepo1/README.txt +5 -0
- data/test/repositories/svn/testrepo1/conf/authz +32 -0
- data/test/repositories/svn/testrepo1/conf/passwd +8 -0
- data/test/repositories/svn/testrepo1/conf/svnserve.conf +47 -0
- data/test/repositories/svn/testrepo1/db/current +1 -0
- data/test/repositories/svn/testrepo1/db/format +2 -0
- data/test/repositories/svn/testrepo1/db/fs-type +1 -0
- data/test/repositories/svn/testrepo1/db/fsfs.conf +37 -0
- data/test/repositories/svn/testrepo1/db/min-unpacked-rev +1 -0
- data/test/repositories/svn/testrepo1/db/rep-cache.db +0 -0
- data/test/repositories/svn/testrepo1/db/revprops/0/0 +5 -0
- data/test/repositories/svn/testrepo1/db/revprops/0/1 +13 -0
- data/test/repositories/svn/testrepo1/db/revs/0/0 +11 -0
- data/test/repositories/svn/testrepo1/db/revs/0/1 +0 -0
- data/test/repositories/svn/testrepo1/db/txn-current +1 -0
- data/test/repositories/svn/testrepo1/db/txn-current-lock +0 -0
- data/test/repositories/svn/testrepo1/db/uuid +1 -0
- data/test/repositories/svn/testrepo1/db/write-lock +0 -0
- data/test/repositories/svn/testrepo1/format +1 -0
- data/test/repositories/svn/testrepo1/hooks/post-commit.tmpl +50 -0
- data/test/repositories/svn/testrepo1/hooks/post-lock.tmpl +45 -0
- data/test/repositories/svn/testrepo1/hooks/post-revprop-change.tmpl +57 -0
- data/test/repositories/svn/testrepo1/hooks/post-unlock.tmpl +43 -0
- data/test/repositories/svn/testrepo1/hooks/pre-commit.tmpl +85 -0
- data/test/repositories/svn/testrepo1/hooks/pre-lock.tmpl +71 -0
- data/test/repositories/svn/testrepo1/hooks/pre-revprop-change.tmpl +66 -0
- data/test/repositories/svn/testrepo1/hooks/pre-unlock.tmpl +63 -0
- data/test/repositories/svn/testrepo1/hooks/start-commit.tmpl +68 -0
- data/test/repositories/svn/testrepo1/locks/db-logs.lock +3 -0
- data/test/repositories/svn/testrepo1/locks/db.lock +3 -0
- data/test/sites/simplehtml/deployment.yml +19 -0
- data/test/{test_sites → sites}/simplehtml/index.html +0 -0
- data/test/{test_sites → sites}/simplehtml/style.css +0 -0
- data/test/sites/sitefuelteaser/deployment.yml +13 -0
- data/test/sites/sitefuelteaser/img/hd.png +0 -0
- data/test/sites/sitefuelteaser/img/logo.png +0 -0
- data/test/sites/sitefuelteaser/img/uses-sitefuel.png +0 -0
- data/test/sites/sitefuelteaser/index.html +1 -1
- data/test/sites/sitefuelteaser/master.css +18 -0
- data/test/test_AbstractExternalProgram.rb +5 -5
- data/test/test_AbstractProcessor.rb +4 -4
- data/test/test_AbstractStringBasedProcessor.rb +2 -2
- data/test/test_AllProcessors.rb +4 -4
- data/test/test_ArrayComparisons.rb +4 -4
- data/test/test_CSSProcessor.rb +4 -4
- data/test/test_ColumnPrinter.rb +40 -0
- data/test/test_Configurable.rb +106 -0
- data/test/test_FileComparisons.rb +4 -4
- data/test/test_GIT.rb +41 -0
- data/test/{test_HAMLProcessor.rb.rb → test_HAMLProcessor.rb} +4 -4
- data/test/test_HTMLProcessor.rb +4 -4
- data/test/test_JPEGTran.rb +4 -4
- data/test/test_JavaScriptProcessor.rb +3 -2
- data/test/test_PHPProcessor.rb +4 -4
- data/test/test_PNGCrush.rb +8 -8
- data/test/test_PNGProcessor.rb +5 -5
- data/test/test_RHTMLProcessor.rb +4 -4
- data/test/test_SASSProcessor.rb +4 -4
- data/test/test_SVN.rb +44 -0
- data/test/test_SiteFuelLogging.rb +4 -4
- data/test/test_SiteFuelRuntime.rb +42 -4
- data/test/test_StringFormatting.rb +27 -4
- data/test/test_SymbolComparison.rb +4 -4
- data/test/ts_all.rb +2 -2
- metadata +94 -20
- data/README +0 -86
- data/test/test_sites/simplehtml/deployment.yml +0 -22
data/README.rdoc
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
|
|
2
|
+
= SiteFuel
|
|
3
|
+
==== http://sitefuel.org
|
|
4
|
+
==== v0.1.0 (alpha release)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
--------------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
A program and API for minifying websites and web applications and
|
|
10
|
+
deploying them from version control.
|
|
11
|
+
|
|
12
|
+
- Get started: http://sitefuel.org/getstarted
|
|
13
|
+
- Lists: http://sitefuel.org/mailinglists
|
|
14
|
+
- Report a bug: http://sitefuel.org/bug
|
|
15
|
+
|
|
16
|
+
- Contribute! http://sitefuel.org/contribute
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
== Table of Contents
|
|
20
|
+
|
|
21
|
+
- Introduction
|
|
22
|
+
- System Requirements
|
|
23
|
+
- Supported Formats
|
|
24
|
+
- Installation
|
|
25
|
+
- Getting Started
|
|
26
|
+
- Reporting a Bug
|
|
27
|
+
- A Note about the API
|
|
28
|
+
- Further Reading
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
== Introduction
|
|
32
|
+
SiteFuel is a Ruby program
|
|
33
|
+
|
|
34
|
+
Use SiteFuel to:
|
|
35
|
+
- deploy your website out of SVN or GIT
|
|
36
|
+
- minify your
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
== System Requirements
|
|
40
|
+
|
|
41
|
+
- Ruby 1.8.6 or greater.
|
|
42
|
+
- =pngcrush= for PNG compression
|
|
43
|
+
- =jpegtran= for JPEG compression
|
|
44
|
+
- =git= for deploying sites from Git repositories
|
|
45
|
+
- =svn= for deploying sites from SVN repositories
|
|
46
|
+
|
|
47
|
+
SiteFuel hasn't been tested on Windows machines.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
== Installation
|
|
51
|
+
|
|
52
|
+
SiteFuel is deployed as a RubyGem through http://gemcutter.org. You
|
|
53
|
+
should be able to install it directly using RubyGems:
|
|
54
|
+
|
|
55
|
+
$ gem install -t sitefuel
|
|
56
|
+
|
|
57
|
+
Note that for PNG and JPEG compression to be enabled you must install
|
|
58
|
+
the =pngcrush= and =jpegtran= programs.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
== Getting Started
|
|
63
|
+
|
|
64
|
+
SiteFuel
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
== Reporting a Bug
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
== A Note About the API
|
|
73
|
+
|
|
74
|
+
The general API in SiteFuel should be considered unstable while SiteFuel
|
|
75
|
+
is <1.0. For practical reasons we can't increment the major version
|
|
76
|
+
number each time there is a non-backwards compatible API change....
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
== Further Reading
|
|
80
|
+
- http://sitefuel.org: main sitefuel website
|
|
81
|
+
- http://sitefuel.org/help: pointers to various resources
|
|
File without changes
|
data/bin/sitefuel
CHANGED
|
@@ -2,46 +2,74 @@
|
|
|
2
2
|
|
|
3
3
|
# == Synopsis
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
5
|
+
# SiteFuel is a program and lightweight Ruby API for processing the
|
|
6
|
+
# source code behind your static and dynamic websites. SiteFuel can
|
|
7
|
+
# remove comments and unneeded whitespace from your CSS, HTML, and
|
|
8
|
+
# JavaScript files (as well as fragments in RHTML and PHP) files. It can
|
|
9
|
+
# also loss-lessly compress your PNG and JPEG images. SiteFuel can also
|
|
10
|
+
# deploy your website from SVN or GIT.
|
|
11
|
+
#
|
|
12
|
+
# Support for more file formats and repositories is planned for future
|
|
13
|
+
# versions.
|
|
14
|
+
#
|
|
7
15
|
#
|
|
8
16
|
# == Usage
|
|
9
17
|
#
|
|
10
|
-
# sitefuel
|
|
18
|
+
# sitefuel <command> [--driver=file|svn|git] <source> [<output>]
|
|
19
|
+
# [--debug] [--verbose] [--help] [--license]
|
|
11
20
|
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
# (and more!)
|
|
18
|
-
#
|
|
19
|
-
# TODO: add more details
|
|
21
|
+
# === <command>
|
|
22
|
+
# Possible commands are:
|
|
23
|
+
# stage:: Simulate a deployment of a site.
|
|
24
|
+
# deploy:: Deploy a site using SiteFuel.
|
|
25
|
+
# help:: Show this message.
|
|
20
26
|
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
#
|
|
27
|
+
# === <driver>
|
|
28
|
+
# SiteFuel can typically guess what driver to use, but you can explicitly
|
|
29
|
+
# specify:
|
|
30
|
+
#
|
|
31
|
+
# filesystem:: deploy a directory
|
|
32
|
+
# svn:: use with Subversion repositories
|
|
33
|
+
# git:: use with Git repositories
|
|
34
|
+
#
|
|
35
|
+
# === <source>
|
|
36
|
+
# Specify the source SiteFuel is deploying from. This should accept all
|
|
37
|
+
# protocols supported by enabled drivers. Eg.
|
|
38
|
+
#
|
|
39
|
+
# For svn:
|
|
40
|
+
# svn+ssh://user@sitefuel.org/svn/web/sitefuel-main
|
|
41
|
+
#
|
|
42
|
+
# For git:
|
|
43
|
+
# ssh://user@sitefuel.org/...
|
|
44
|
+
#
|
|
45
|
+
# === <output>
|
|
46
|
+
# Specify the directory into which SiteFuel is to deploy. Currently SiteFuel can
|
|
47
|
+
# only deploy into the file system.
|
|
24
48
|
#
|
|
25
|
-
#
|
|
49
|
+
# === --debug
|
|
50
|
+
# Enables all messages including debugging. This will give you a blow by blow
|
|
51
|
+
# account of what SiteFuel is doing.
|
|
52
|
+
#
|
|
53
|
+
# === --verbose
|
|
54
|
+
# Enables most messages. This will give you a relatively detailed account of
|
|
55
|
+
# how SiteFuel is deploying your site.
|
|
26
56
|
#
|
|
27
|
-
# deploy:: Deploy a site using sitefuel.
|
|
28
|
-
# process:: Modify an existing website inplace.
|
|
29
|
-
# stage:: Simulates a deployment without actually changing anything.
|
|
30
|
-
# help:: Show this message.
|
|
31
57
|
#
|
|
32
58
|
# == Examples
|
|
33
59
|
# Process an already deployed site:
|
|
34
|
-
# sitefuel
|
|
60
|
+
# sitefuel deploy /var/www/sitefuel /var/www/sitefuel-compacted
|
|
35
61
|
#
|
|
36
62
|
# Deploy a site from SVN:
|
|
37
63
|
# sitefuel deploy svn+ssh://sitefuel.org/svn/tags/21 /var/www/
|
|
38
64
|
#
|
|
39
|
-
#
|
|
40
|
-
# sitefuel process /var/www/ -c customdeployment.yml
|
|
65
|
+
# == Links
|
|
41
66
|
#
|
|
67
|
+
# * More information: http://sitefuel.org
|
|
68
|
+
# * Getting started: http://sitefuel.org/getstarted
|
|
69
|
+
# * Documentation: http://sitefuel.org/documentation
|
|
42
70
|
#
|
|
43
71
|
# == Author
|
|
44
|
-
#
|
|
72
|
+
# wkm, Zanoccio LLC.
|
|
45
73
|
#
|
|
46
74
|
# == Copyright
|
|
47
75
|
# Copyright (c) 2009 Zanoccio.
|
|
@@ -51,7 +79,7 @@
|
|
|
51
79
|
# modify it under the terms of the GNU General Public License
|
|
52
80
|
# as published by the Free Software Foundation; either version 2
|
|
53
81
|
# of the License, or (at your option) any later version.
|
|
54
|
-
#
|
|
82
|
+
# # stage::
|
|
55
83
|
# This program is distributed in the hope that it will be useful,
|
|
56
84
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
57
85
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
@@ -66,97 +94,22 @@
|
|
|
66
94
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
|
67
95
|
|
|
68
96
|
begin
|
|
69
|
-
require 'rubygems'
|
|
70
|
-
rescue LoadError
|
|
71
|
-
# attempt to continue running the program
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
require 'rdoc/usage'
|
|
76
|
-
require 'term/ansicolor'
|
|
77
|
-
|
|
78
|
-
require 'sitefuel/SiteFuelRuntime'
|
|
79
|
-
|
|
80
|
-
include Term::ANSIColor
|
|
81
|
-
|
|
82
|
-
def puts_and_exit(*args)
|
|
83
|
-
puts(*args)
|
|
84
|
-
exit
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
$HELP_HINT_LINE = "type \'#{$0} help\' for usage"
|
|
88
|
-
|
|
89
|
-
# parse command line arguments and configure a SiteFuelRuntime
|
|
90
|
-
def parse_command_line(runtime)
|
|
91
|
-
|
|
92
|
-
#### BUILD THE OPTIONS PARSER
|
|
93
|
-
opts = OptionParser.new
|
|
94
|
-
|
|
95
|
-
# the banner text comes from the header comment for this file
|
|
96
|
-
|
|
97
|
-
opts.on('-oARG', '-o=ARG', '-o PLACE', '--output=ARG', '--output PLACE', String,
|
|
98
|
-
'Where to put a deployed site') do |out|
|
|
99
|
-
runtime.deploy_to = out
|
|
100
|
-
end
|
|
101
|
-
opts.on('-v', '--version', 'Gives the version of sitefuel') do
|
|
102
|
-
puts 'SiteFuel ' + VERSION_TEXT
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
opts.on('--[no-]verbose', 'List actions as they are preformed') do
|
|
106
|
-
puts 'cause SiteFuel to be verbose listing actions as they are preformed'
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
opts.on('--only-list-recognized-files', 'Only list summaries for files which were changed') do
|
|
110
|
-
runtime.only_list_recognized_files = true
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
opts.on('-h', '--help', '-?', '--about', 'Gives help for a specific command.') do
|
|
114
|
-
RDoc::usage_no_exit('Synopsis', 'Usage', 'Introduction')
|
|
115
|
-
puts opts
|
|
116
|
-
RDoc::usage_no_exit('Examples', 'Author', 'Copyright', 'License')
|
|
117
|
-
exit
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
opts.separator ''
|
|
121
|
-
opts.separator 'Specific options for a command can be seen with: '
|
|
122
|
-
opts.separator ' COMMAND --help'
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
#### ATTEMPT TO PARSE THE COMMAND LINE
|
|
126
97
|
begin
|
|
127
|
-
|
|
128
|
-
rescue
|
|
129
|
-
|
|
130
|
-
puts_and_exit $HELP_HINT_LINE
|
|
131
|
-
rescue => exception
|
|
132
|
-
# TODO: add better handling for the various exceptions (unnecessary
|
|
133
|
-
# argument, missing argument, etc.)
|
|
134
|
-
puts_and_exit "couldn't parse command line: #{exception}", $HELP_HINT_LINE
|
|
98
|
+
require 'rubygems'
|
|
99
|
+
rescue LoadError
|
|
100
|
+
# attempt to continue running the program
|
|
135
101
|
end
|
|
136
102
|
|
|
103
|
+
require 'sitefuel/SiteFuelRuntime'
|
|
104
|
+
require 'sitefuel/CommandLine'
|
|
137
105
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
puts_and_exit opts if commands[0].downcase == 'help'
|
|
142
|
-
|
|
143
|
-
case commands[0].downcase
|
|
144
|
-
when 'deploy'
|
|
145
|
-
runtime.deploy_from = commands[1]
|
|
146
|
-
runtime.deploy
|
|
147
|
-
|
|
148
|
-
when 'stage'
|
|
149
|
-
runtime.deploy_from = commands[1]
|
|
150
|
-
runtime.stage
|
|
151
|
-
|
|
152
|
-
else
|
|
153
|
-
puts_and_exit "unknown command: '#{commands[0]}'", $HELP_HINT_LINE
|
|
106
|
+
def main
|
|
107
|
+
runtime = SiteFuel::SiteFuelRuntime.new
|
|
108
|
+
SiteFuel::CommandLine::parse_command_line(runtime)
|
|
154
109
|
end
|
|
155
|
-
end
|
|
156
110
|
|
|
157
|
-
|
|
158
|
-
runtime = SiteFuel::SiteFuelRuntime.new
|
|
159
|
-
parse_command_line(runtime)
|
|
160
|
-
end
|
|
111
|
+
main()
|
|
161
112
|
|
|
162
|
-
|
|
113
|
+
rescue Interrupt
|
|
114
|
+
puts 'Fatal: interrupted. Exiting.'
|
|
115
|
+
end
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#
|
|
2
|
+
# File:: CommandLine.rb
|
|
3
|
+
# Author:: wkm
|
|
4
|
+
# Copyright:: 2009, Zanoccio LLC.
|
|
5
|
+
# License:: GPL version 2.0 (see LICENSE.rb)
|
|
6
|
+
#
|
|
7
|
+
# Contains the command line parser for the sitefuel program
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
module SiteFuel
|
|
12
|
+
module CommandLine
|
|
13
|
+
|
|
14
|
+
require 'rdoc/usage'
|
|
15
|
+
require 'term/ansicolor'
|
|
16
|
+
|
|
17
|
+
require 'sitefuel/License'
|
|
18
|
+
|
|
19
|
+
include Term::ANSIColor
|
|
20
|
+
|
|
21
|
+
def self.puts_and_exit(*args)
|
|
22
|
+
puts(*args)
|
|
23
|
+
exit
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
$HELP_HINT_LINE = "type '#{$0} help' for usage"
|
|
27
|
+
|
|
28
|
+
@option_parser = nil
|
|
29
|
+
|
|
30
|
+
# parse command line arguments and configure a SiteFuelRuntime
|
|
31
|
+
def self.parse_command_line(runtime)
|
|
32
|
+
|
|
33
|
+
#### BUILD THE OPTIONS PARSER
|
|
34
|
+
@option_parser = OptionParser.new
|
|
35
|
+
|
|
36
|
+
# the banner text comes from the header comment for this file
|
|
37
|
+
|
|
38
|
+
@option_parser.on('-o PLACE', '--output=ARG', '--output PLACE', String,
|
|
39
|
+
'Where to put a deployed site') do |out|
|
|
40
|
+
runtime.deploy_to = out
|
|
41
|
+
end
|
|
42
|
+
@option_parser.on('-v', '--version', 'Gives the version of sitefuel') do
|
|
43
|
+
puts_and_exit 'SiteFuel ' + VERSION_TEXT
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
@option_parser.on('--scm=ARG', '--scm PLACE', String,
|
|
47
|
+
'What SCM to use (git, svn, or filesystem)') do |out|
|
|
48
|
+
runtime.scm_system = out
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
#
|
|
52
|
+
# Verbosity options
|
|
53
|
+
#
|
|
54
|
+
|
|
55
|
+
@option_parser.on('--[no-]verbose', 'List actions as they are preformed') do |be_verbose|
|
|
56
|
+
if be_verbose
|
|
57
|
+
# fatal, error, warnings, and info
|
|
58
|
+
runtime.verbosity(3)
|
|
59
|
+
else
|
|
60
|
+
# fatal, error, and warnings
|
|
61
|
+
runtime.verbosity(2)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
@option_parser.on('--debug', 'Gives verbose debugging information') do
|
|
66
|
+
runtime.verbosity(4)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
@option_parser.on('--abort-errors', '[default] Abort deployment if there are errors') do
|
|
70
|
+
runtime.abort_on_errors = true
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
@option_parser.on('--ignore-errors', 'Deploy even if there are errors') do
|
|
74
|
+
runtime.abort_on_errors = false
|
|
75
|
+
runtime.abort_on_warnings = false
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
@option_parser.on('--abort-warnings', 'Abort deployment if there are warnings') do
|
|
79
|
+
runtime.abort_on_warnings = true
|
|
80
|
+
runtime.abort_on_errors = true
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
@option_parser.on('--ignore-warnings', '[default] Deploy even if there are warnings') do
|
|
84
|
+
runtime.abort_on_warnings = true
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
@option_parser.on('--only-list-recognized-files', 'Only list summaries for files which were changed') do
|
|
88
|
+
runtime.only_list_recognized_files = true
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
@option_parser.on('-h', '--help', '-?', '--about', 'Gives help for a specific command.') do
|
|
92
|
+
RDoc::usage_no_exit('Synopsis', 'Usage', 'Introduction')
|
|
93
|
+
puts @option_parser
|
|
94
|
+
RDoc::usage_no_exit('Examples', 'Author', 'Copyright')
|
|
95
|
+
exit
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
@option_parser.on('--license', 'Gives the license for SiteFuel.') do
|
|
99
|
+
puts_and_exit SiteFuel::LICENSE
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
@option_parser.separator ''
|
|
103
|
+
@option_parser.separator 'Specific options for a command can be seen with: '
|
|
104
|
+
@option_parser.separator ' COMMAND --help'
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
#### ATTEMPT TO PARSE THE COMMAND LINE
|
|
108
|
+
begin
|
|
109
|
+
commands = @option_parser.parse(*ARGV)
|
|
110
|
+
rescue OptionParser::InvalidOption => invalid_option
|
|
111
|
+
puts invalid_option
|
|
112
|
+
puts_and_exit $HELP_HINT_LINE
|
|
113
|
+
rescue => exception
|
|
114
|
+
# TODO: add better handling for the various exceptions (unnecessary
|
|
115
|
+
# argument, missing argument, etc.)
|
|
116
|
+
|
|
117
|
+
puts_and_exit "couldn't parse command line: #{exception}", $HELP_HINT_LINE
|
|
118
|
+
# puts exception.backtrace.join("\n")
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# note that --help will have already been intercepted but 'help' still needs
|
|
123
|
+
# special treatment
|
|
124
|
+
puts_and_exit 'no command given', $HELP_HINT_LINE if commands.length < 1
|
|
125
|
+
puts_and_exit @option_parser if commands[0].downcase == 'help'
|
|
126
|
+
|
|
127
|
+
case commands[0].downcase
|
|
128
|
+
when 'deploy'
|
|
129
|
+
runtime.deploy_from = commands[1]
|
|
130
|
+
runtime.deploy_to = commands[2]
|
|
131
|
+
runtime.deploy
|
|
132
|
+
|
|
133
|
+
when 'stage'
|
|
134
|
+
runtime.deploy_from = commands[1]
|
|
135
|
+
runtime.stage
|
|
136
|
+
|
|
137
|
+
else
|
|
138
|
+
puts_and_exit "unknown command: '#{commands[0]}'", $HELP_HINT_LINE
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
@@ -1,35 +1,71 @@
|
|
|
1
1
|
#
|
|
2
2
|
# File:: configuration.rb
|
|
3
3
|
# Author:: wkm
|
|
4
|
-
# Copyright:: 2009
|
|
5
|
-
# License:: GPL
|
|
4
|
+
# Copyright:: 2009, Zanoccio LLC.
|
|
5
|
+
# License:: GPL version 2.0 (see LICENSE.rb)
|
|
6
6
|
#
|
|
7
7
|
# Load and process SiteFuel YAML configuration files
|
|
8
8
|
#
|
|
9
9
|
|
|
10
10
|
module SiteFuel
|
|
11
|
+
require 'sitefuel/SiteFuelLogger'
|
|
11
12
|
require 'yaml'
|
|
12
13
|
|
|
14
|
+
# exception which represents that a configuration could not be found
|
|
13
15
|
class Configuration
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
include SiteFuel::Logging
|
|
18
|
+
|
|
19
|
+
DEFAULT_CONFIGURATION_FILE = 'deployment.yml'
|
|
18
20
|
|
|
19
21
|
# given a directory path will attempt to location a configuration file
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
def self.find_configuration(path, filename = DEFAULT_CONFIGURATION_FILE)
|
|
23
|
+
files = Dir["**/"+filename]
|
|
24
|
+
|
|
25
|
+
if files.length < 0
|
|
26
|
+
return nil
|
|
27
|
+
elsif files.length > 1
|
|
28
|
+
warn("Multiple possible configuration files found: #{files.join(', ')}; using #{files.first}")
|
|
29
|
+
return files.first
|
|
30
|
+
else
|
|
31
|
+
return files.first
|
|
24
32
|
end
|
|
33
|
+
end
|
|
25
34
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
|
|
36
|
+
# given a directory path will attempt to find and load a
|
|
37
|
+
# configuration file
|
|
38
|
+
def self.load_configuration(runtime, path, filename = DEFAULT_CONFIGURATION_FILE)
|
|
39
|
+
configuration_file = find_configuration(path, filename)
|
|
40
|
+
|
|
41
|
+
if configuration_file == nil
|
|
42
|
+
warn('No deployment configuration file found. Using defaults.')
|
|
43
|
+
return Configuration.new(runtime, nil)
|
|
44
|
+
else
|
|
45
|
+
yaml = YAML::load_file(configuration_file)
|
|
46
|
+
return Configuration.new(runtime, yaml)
|
|
47
|
+
end
|
|
29
48
|
end
|
|
30
49
|
|
|
50
|
+
|
|
31
51
|
# builds a sitefuel configuration from a parsed YAML file
|
|
32
|
-
def initialize(
|
|
52
|
+
def initialize(runtime, yaml_config)
|
|
53
|
+
@processor_configurations = Hash.new([])
|
|
54
|
+
@runtime = runtime
|
|
55
|
+
|
|
56
|
+
load_yaml_config(yaml_config)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# loads a yaml configuration
|
|
61
|
+
def load_yaml_config(yaml_config)
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# gives an array of configuration options for the processor
|
|
67
|
+
def processor_configuration(processor)
|
|
68
|
+
@processor_configurations[processor]
|
|
33
69
|
end
|
|
34
70
|
end
|
|
35
71
|
end
|