Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'mergulhao/master'

Conflicts:
	.gitignore
	tasks/integrate.rake
  • Loading branch information...
commit a421717e9d5b9b47b0b4d670ffdb1d496017e2ec 2 parents e6eb2a5 + 1a87c12
@tapajos authored
View
1  .gitignore
@@ -1 +1,2 @@
nbproject
+.rvmrc
View
340 BLUECLOTH-LICENSE
@@ -1,340 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
View
361 README.mkdn
@@ -6,7 +6,11 @@ Integration is a [Ruby on Rails][ror] plugin that provides a set of tasks to aut
## Installing
- ruby script/plugin install git://github.com/tapajos/integration.git
+Add it to your Gemfile:
+
+ group :test, :development do
+ gem 'integration', :git => 'git://github.com/mergulhao/integration.git'
+ end
After installing the plugin is ready to be used and you will need to execute only one task in order to integrate your code safely:
@@ -14,19 +18,30 @@ After installing the plugin is ready to be used and you will need to execute onl
## Dependencies
-* A scm(currently supported are [Subversion][s], [git][] and [git-svn][git]
-* [Hpricot][h] (optional)
-* [Rcov][rc] (optional)
-* [Selenium on Rails][sor] (optional)
-* [Rspec][rs] (optional)
+* Git
+* [Hpricot][h] to verify coverage
+* [Rcov][rc](Ruby 1.8) or [Simplecov][sc](Ruby 1.9) (optional)
+
+## [ProTip] Using Simplecov
+
+Using simplecov on your test suite will make your tests to run slower. You can fix it using an environment variable called "coverage" on test_helper.rb/spec_helper.rb to turn on/off the simplecov. See below:
+
+spec_helper.rb or test_helper.rb
+
+ if ENV['coverage'] == 'on'
+ require 'simplecov'
+ SimpleCov.start 'rails'
+ end
+
+The "coverage" variable is set to "on" by the integration process. When running tests/specs while you're developing, simplecov doesn't run, unless you set "coverage" environment variable by hand.
## Integration Steps
The integration process is composed of several steps that are explained ahead. It's possible to skip one or more steps and add other steps of your own. This will be demonstrated shortly. The complete set of steps are:
-1. task scm:status:check
+1. task git:status_check
- Check if all local files are under control of your scm. If your scm is subversion, it also checks if no local files have been removed using only rm (file removal should always use svn remove instead).
+ Check if all local files are under control of your scm.
* task log:clear
@@ -41,7 +56,7 @@ The integration process is composed of several steps that are explained ahead. I
Backup files locally. This is done before scm update to create a recovery point if you have problems during scm update. If a file merge creates undesirable effects on the software, you can recover from the backup file.
Backup file names have a timestamp. By default, the last 30 backups are kept. You may change this number as you'll see shortly. This task won't work on Windows because it uses [tar][]. So, if you're using Windows you'll have to write your own version of this task or just stop using Windows. We highly recommend the later.
-* task scm:update
+* task git:pull
Update local files from your remote scm repository.
@@ -49,276 +64,31 @@ The integration process is composed of several steps that are explained ahead. I
Execute any new database migration created by other team members since the last integration.
-* test:units
-
- Run all unit tests.
-
-* test:functionals
-
- Run all functional tests.
-
-* test:integration
-
- Run all integration tests.
-
-* spec:lib
-
- Run all lib specs.
-
-* spec:models
-
- Run all model specs.
-
-* spec:helpers
-
- Run all helper specs.
-
-* spec:controllers
-
- Run all controller specs.
-
-* spec:views
-
- Run all view specs.
-
-* test:rcov:units
-
- Run coverage analysis of the unit tests.
-
-* test:rcov:units:verify
-
- Check if unit tests cover 100% of the application code.
-
-* test:rcov:functionals
-
- Run coverage analysis of the functional tests.
-
-* test:rcov:functionals:verify
-
- Check if functional tests cover 100% of the application code.
-
-* spec:rcov
-
- Run coverage analysis of the specs.
-
-* spec:rcov:verify
-
- Check if specs cover 100% of the application code.
+* Your test/spec suite
-* test:plugins:selected
+ Set the rake task your test/spec suite needs to run. Use a command that generate the coverage files.
- Run tests on selected plugins. You might want to always run the tests of plugins you created, for example, while ignoring the tests of third party plugins. We'll show below how you can specify the plugins you want to test.
+* coverage_verify
-* spec:plugins:selected
+ Check if tests/specs cover 100% of the application code.
- Same as previous step, but with specs, instead of tests.
+* git:push
-* test:selenium:server:start
-
- If you use [Selenium][sor] to test your application, as you certainly should, you'll need to make sure the webserver is up and running before running [Selenium][sor] tests. That's what this task does.
-
-* test_acceptance
-
- Run all [Selenium][sor] tests.
-
-* test:selenium:server:stop
-
- Stop the webserver.
-
-* scm:commit
-
- Commit your changes. If any of the previous tasks break, because one test failed, for instance, the script won't commit. Actually this task runs only if every checking done before work well.
+ Push your changes. If any of the previous tasks break, because one test failed, for instance, the script won't push. Actually this task runs only if every checking done before work well.
Using this almost paranoid sequence of steps it will be hard to check in bad code in your repository, which is good, very good. The idea is that you should treat your repository as a sacred place, where only good code should ever enter.
-## Customize the integration process
-
-To customize the integration process you need to create a task file in your project, like:
-
- lib/tasks/integration.rake
-
-### Changing scm
-
-By default the integration process uses subversion, but you can customize it to use git(your remote repository is git) or git-svn(your remote repository is svn, but you uses git locally):
-
-* git
-
- ENV['SCM'] = 'git'
-
-* git-svn
-
- ENV['SCM'] = 'git_with_svn'
-
-### Skipping tasks
-
-In your custom integration rake file you may define a comma separated list of tasks that you don't want to execute. Let's see some examples:
-
-* Don't execute migrations
-
- ENV['SKIP_TASKS'] = 'db:migrate'
-
-* Don't execute spec coverage, nor spec coverage verification
-
- ENV['SKIP_TASKS'] = 'spec:rcov, spec:rcov:verify'
-
-* Don't execute any tests nor specs at all
-
- ENV['SKIP_TASKS'] = %w(
- test:units
- test:functionals
- test:integration
- spec:lib
- spec:models
- spec:helpers
- spec:controllers
- spec:views
- test:rcov:units
- test:rcov:units:verify
- test:rcov:functionals
- test:rcov:functionals:verify
- spec:rcov
- spec:rcov:verify
- test:selenium:server:start
- test_acceptance
- test:selenium:server:stop
- ).join(",")
-
-You can also define SKIP_TASKS when you run the integration process like this:
-
- rake integrate SKIP_TASKS=spec:rcov,spec:rcov:verify
-
-### Adding other tasks
-
-Integration plugin also defines callback tasks that you can use to customize it with your own tasks. You can add other tasks before or after any of the plugin tasks. Let's see an example. Say you want to sweep HTML cache pages after running [Selenium][sor]. To do that, you've just created a task cache:sweep. Let's configure Integration to run it just after Selenium:
-
- namespace :test_acceptance do
- desc 'Runs cache sweeper'
- task :after do
- Rake::Task["cache:sweep"].invoke
- end
- end
-
-A callback task is one that has the same name of a plugin task followed by :before or :after. In this case, the plugin defines a task called test\_acceptance. So, you may create test\_acceptance:before that will be executed before test\_acceptance and test\_acceptance:after to execute as soon as test\_acceptance finishes. To do that, you will need to use namespaces, like we did in the previous example. Now, let's see a real example from one of our projects:
-
- def integration_sweeper
- sh "script/integration_sweeper"
- end
-
- namespace :scm do
- namespace :status do
- namespace :check do
- task :before do
- integration_sweeper
- end
- end
- end
- end
-
- desc 'Generates error 500 page'
- task :error500 do
- `curl http://localhost:4000/server_error -o #{RAILS_ROOT}/public/500.html`
- end
-
- namespace :cache do
- namespace :sweeper do
- desc 'Runs cache_sweeper before executing Selenium'
- task :start do
- integration_sweeper
- end
-
- desc 'Runs cache_sweeper after executing Selenium'
- task :stop do
- integration_sweeper
- end
- end
- end
-
- namespace :test_acceptance do
- desc 'Runs cache sweeper and generate static 500 error page'
- task :before do
- Rake::Task["error500"].invoke
- end
-
- desc 'Runs cache sweeper'
- task :after do
- Rake::Task["cache:sweeper:stop"].invoke
- end
- end
-
-### Defining the list of plugins for which you want to run tests or specs
-
-In your integration process, you may want to run tests or specs for certain plugins. All you need to do is name them, like this:
-
- ENV['PLUGINS_TO_TEST'] = "packr, email"
- ENV['PLUGINS_TO_SPEC'] = "brazilian_rails"
-
-You can also inform these when you run rake integrate:
-
- rake integrate PLUGINS_TO_TEST=packr,email PLUGINS_TO_SPEC=brazilian_rails
-
-### Defining the environment in which to run the integration process
-
-Integration will run against the development environment by default. If you need it to run using another environment, you can do this:
-
- ENV['RAILS_ENV'] = 'development_cache'
-
-Once again, you can also inform this while running rake integrate:
-
- rake integrate RAILS_ENV=test
-
-### Selenium port
-
-When running Selenium, you might need to specify another port other them the default port 4000. That's how you do it:
-
- ENV['SELENIUM_PORT'] = 3000
-
-### Number of backups to keep
-
-If you want to change the number of backups that will be kept, use this:
-
- ENV['NUMBER_OF_BACKUPS_TO_KEEP'] = 50
-
-Backups are store in a sibling directory with the prefix 'backup-'. For instance, suppose you have a project 'amazing' in the projects directory. After the first backup, you will end up with something like this:
-
- projects/amazing
- projects/backup-amazing
- projects/backup-amazing/amazing-20080304-104812.tar.gz
-
-### Commit messages
-
-If you don't care to write commit messages, you can skip them:
-
- ENV['SKIP_COMMIT_MESSAGES'] = 'true'
-
### More examples
* Reckless programmer
- So you don't have tests, nor specs but you still want to use the plugin. Besides, you want to keep the log files and prefer not to run migrations. You might get away with this customized lib/tasks/integration.rake:
+ So you don't have tests, nor specs but you still want to use the integration. You might get away with this customized lib/tasks/integration.rake:
- ENV['SKIP_TASKS'] = %w(
- log:clear
- db:migrate
- test:units
- test:functionals
- test:integration
- spec:lib
- spec:models
- spec:helpers
- spec:controllers
- spec:views
- test:rcov:units
- test:rcov:units:verify
- test:rcov:functionals
- test:rcov:functionals:verify
- spec:rcov
- spec:rcov:verify
- test:plugins:selected
- spec:plugins:selected
- test:selenium:server:start
- test_acceptance
- test:selenium:server:stop
- ).join(",")
+ INTEGRATION_TASKS = %w(
+ integration:start
+ db:migrate
+ integration:finish
+ )
The fact that you can get away with this doesn't mean you should. Don't you think it's already time to grow up and become more professional about software development? I know you believe you have a great excuse to avoid writing those tests or specs. Still it's just an excuse. Write tests or write specs and make a better world!
@@ -326,53 +96,34 @@ If you don't care to write commit messages, you can skip them:
You haven't jumped on the [BDD][] bandwagon yet. Instead, you write tests, which is good, but they don't cover all of your code yet, which is bad. We believe you will [improve it][ii] and make sure your tests cover 100% of your code. In the meantime you might need to skip coverage checkings. Oh, you also don't use [Selenium][sor]. Shame on you! Try this:
- ENV['SKIP_TASKS'] = %w(
- spec:lib
- spec:models
- spec:helpers
- spec:controllers
- spec:views
- test:rcov:units
- test:rcov:units:verify
- test:rcov:functionals
- test:rcov:functionals:verify
- spec:rcov
- spec:rcov:verify
- test:selenium:server:start
- test_acceptance
- test:selenium:server:stop
- ).join(',')
-
+ INTEGRATION_TASKS = %w(
+ integration:start
+ db:migrate
+ test
+ integration:finish
+ )
+
As a matter of fact, since this case might be very common, **we decided to create a lib/tasks/integration.rake for you once the plugin has been installed. It has this very configuration and you can use it as a starting point to customize your integration process**.
* Spec infected programmer
So you used to [TDD][] all around but then someone told you that this is for gramma. The new wave has a name on it: [BDD][]. So, of course, you now have specs covering 100% of your code and doesn't have any more tests. Great! Just do it:
- ENV['SKIP_TASKS'] = %w(
- test:units
- test:functionals
- test:integration
- test:rcov:units
- test:rcov:units:verify
- test:rcov:functionals
- test:rcov:functionals:verify
- ).join(",")
-
-You can see more examples in the samples directory.
-
-## Forum
-
-Discussion about the Integration Plugin are welcome on the forum below:
-
-http://rubyforge.org/forum/?group_id=4662
+ INTEGRATION_TASKS = %w(
+ integration:start
+ db:migrate
+ spec
+ integration:coverage_verify
+ integration:finish
+ )
## Version
-Integration version 0.2.4
+Integration version 0.3.0
## Release Notes
+* Version 0.3.0 - Remove old svn support. Add support for Simplecov on Ruby 1.9.
* Version 0.2.4 - Added support for git and git-svn. Thanks to [Sylvestre Mergulhão][sm] and [Eduardo Fiorezi][edu].
* Version 0.2.3 - BUG FIX: Rake db:migrate fails when default RAILS\_ENV is used. Thanks to Celestino Gomes for fix this bug.
* Version 0.2.2 - Removed vendor/plugins/* commit. This commit is necessary when use plugins with externals but it is not a good practice. Piston is the correct way to use externals plugins. If you want to use externals commit in your integration process you can create a svn:commit:after task.
@@ -385,11 +136,12 @@ This code is free to be used under the terms of the [MIT license][mit].
## Contact
-Comments are welcome. Send your feedback through the [forum][f] or to [this page][co]
+Comments are welcome.
## Authors
[Marcos Tapajós][mt]
+[Sylvestre Mergulhão][sm]
[Vinícius Teles][vt]
## Shameless advertisement
@@ -401,13 +153,15 @@ This plugin is brought to you by [Improve It][ii].
[logo]: http://www.improveit.com.br/images/logo/logo_improve_it_screen.gif "Improve It"
[piston]: http://piston.rubyforge.org/
-[mt]: http://www.improveit.com.br/en/company/tapajos
+[mt]: https://github.com/tapajos
+[sm]: https://github.com/mergulhao
[vt]: http://www.improveit.com.br/vinicius
[f]: http://rubyforge.org/forum/?group_id=4662
[s]: http://subversion.tigris.org
[git]: http://git.or.cz/
[h]: http://code.whytheluckystiff.net/hpricot
[rc]: http://eigenclass.org/hiki.rb?rcov
+[sc]: https://github.com/colszowka/simplecov
[sor]: http://selenium-on-rails.openqa.org
[rs]: http://rspec.info
[rz]: http://rubyzip.sourceforge.net/
@@ -421,5 +175,4 @@ This plugin is brought to you by [Improve It][ii].
[tar]: http://en.wikipedia.org/wiki/Tar_%28file_format%29
[BDD]: http://en.wikipedia.org/wiki/Behavior_driven_development
[TDD]: http://en.wikipedia.org/wiki/Test-driven_development
-[sm]: http://mergulhao.info/
[edu]: http://tudoquequerosaber.com/
View
1,226 bin/bluecloth
@@ -1,1226 +0,0 @@
-#!/usr/bin/ruby
-#
-# = bluecloth
-#
-# Format one or more text files with the markdown formatter.
-#
-# = Synopsis
-#
-# bluecloth [OPTIONS] [FILES]
-#
-#
-#
-
-#!/usr/bin/ruby
-#
-# Bluecloth is a Ruby implementation of Markdown, a text-to-HTML conversion
-# tool.
-#
-# == Synopsis
-#
-# doc = BlueCloth::new "
-# ## Test document ##
-#
-# Just a simple test.
-# "
-#
-# puts doc.to_html
-#
-# == Authors
-#
-# * Michael Granger <ged@FaerieMUD.org>
-#
-# == Contributors
-#
-# * Martin Chase <stillflame@FaerieMUD.org> - Peer review, helpful suggestions
-# * Florian Gross <flgr@ccan.de> - Filter options, suggestions
-#
-# == Copyright
-#
-# Original version:
-# Copyright (c) 2003-2004 John Gruber
-# <http://daringfireball.net/>
-# All rights reserved.
-#
-# Ruby port:
-# Copyright (c) 2004 The FaerieMUD Consortium.
-#
-# BlueCloth is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# BlueCloth is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# == To-do
-#
-# * Refactor some of the larger uglier methods that have to do their own
-# brute-force scanning because of lack of Perl features in Ruby's Regexp
-# class. Alternately, could add a dependency on 'pcre' and use most Perl
-# regexps.
-#
-# * Put the StringScanner in the render state for thread-safety.
-#
-# == Version
-#
-# $Id: bluecloth.rb 69 2004-08-25 05:27:15Z ged $
-#
-
-require 'digest/md5'
-require 'logger'
-require 'strscan'
-
-
-### BlueCloth is a Ruby implementation of Markdown, a text-to-HTML conversion
-### tool.
-class BlueCloth < String
-
- ### Exception class for formatting errors.
- class FormatError < RuntimeError
-
- ### Create a new FormatError with the given source +str+ and an optional
- ### message about the +specific+ error.
- def initialize( str, specific=nil )
- if specific
- msg = "Bad markdown format near %p: %s" % [ str, specific ]
- else
- msg = "Bad markdown format near %p" % str
- end
-
- super( msg )
- end
- end
-
-
- # Release Version
- Version = '0.0.3'
-
- # SVN Revision
- SvnRev = %q$Rev: 69 $
-
- # SVN Id tag
- SvnId = %q$Id: bluecloth.rb 69 2004-08-25 05:27:15Z ged $
-
- # SVN URL
- SvnUrl = %q$URL: svn+ssh://svn.faeriemud.org/usr/local/svn/BlueCloth/trunk/lib/bluecloth.rb $
-
-
- # Rendering state struct. Keeps track of URLs, titles, and HTML blocks
- # midway through a render. I prefer this to the globals of the Perl version
- # because globals make me break out in hives. Or something.
- RenderState = Struct::new( "RenderState", :urls, :titles, :html_blocks, :log )
-
- # Tab width for #detab! if none is specified
- TabWidth = 4
-
- # The tag-closing string -- set to '>' for HTML
- EmptyElementSuffix = "/>";
-
- # Table of MD5 sums for escaped characters
- EscapeTable = {}
- '\\`*_{}[]()#.!'.split(//).each {|char|
- hash = Digest::MD5::hexdigest( char )
-
- EscapeTable[ char ] = {
- :md5 => hash,
- :md5re => Regexp::new( hash ),
- :re => Regexp::new( '\\\\' + Regexp::escape(char) ),
- }
- }
-
-
- #################################################################
- ### I N S T A N C E M E T H O D S
- #################################################################
-
- ### Create a new BlueCloth string.
- def initialize( content="", *restrictions )
- @log = Logger::new( $deferr )
- @log.level = $DEBUG ?
- Logger::DEBUG :
- ($VERBOSE ? Logger::INFO : Logger::WARN)
- @scanner = nil
-
- # Add any restrictions, and set the line-folding attribute to reflect
- # what happens by default.
- @filter_html = nil
- @filter_styles = nil
- restrictions.flatten.each {|r| __send__("#{r}=", true) }
- @fold_lines = true
-
- super( content )
-
- @log.debug "String is: %p" % self
- end
-
-
- ######
- public
- ######
-
- # Filters for controlling what gets output for untrusted input. (But really,
- # you're filtering bad stuff out of untrusted input at submission-time via
- # untainting, aren't you?)
- attr_accessor :filter_html, :filter_styles
-
- # RedCloth-compatibility accessor. Line-folding is part of Markdown syntax,
- # so this isn't used by anything.
- attr_accessor :fold_lines
-
-
- ### Render Markdown-formatted text in this string object as HTML and return
- ### it. The parameter is for compatibility with RedCloth, and is currently
- ### unused, though that may change in the future.
- def to_html( lite=false )
-
- # Create a StringScanner we can reuse for various lexing tasks
- @scanner = StringScanner::new( '' )
-
- # Make a structure to carry around stuff that gets placeholdered out of
- # the source.
- rs = RenderState::new( {}, {}, {} )
-
- # Make a copy of the string with normalized line endings, tabs turned to
- # spaces, and a couple of guaranteed newlines at the end
- text = self.gsub( /\r\n?/, "\n" ).detab
- text += "\n\n"
- @log.debug "Normalized line-endings: %p" % text
-
- # Filter HTML if we're asked to do so
- if self.filter_html
- text.gsub!( "<", "&lt;" )
- text.gsub!( ">", "&gt;" )
- @log.debug "Filtered HTML: %p" % text
- end
-
- # Simplify blank lines
- text.gsub!( /^ +$/, '' )
- @log.debug "Tabs -> spaces/blank lines stripped: %p" % text
-
- # Replace HTML blocks with placeholders
- text = hide_html_blocks( text, rs )
- @log.debug "Hid HTML blocks: %p" % text
- @log.debug "Render state: %p" % rs
-
- # Strip link definitions, store in render state
- text = strip_link_definitions( text, rs )
- @log.debug "Stripped link definitions: %p" % text
- @log.debug "Render state: %p" % rs
-
- # Escape meta-characters
- text = escape_special_chars( text )
- @log.debug "Escaped special characters: %p" % text
-
- # Transform block-level constructs
- text = apply_block_transforms( text, rs )
- @log.debug "After block-level transforms: %p" % text
-
- # Now swap back in all the escaped characters
- text = unescape_special_chars( text )
- @log.debug "After unescaping special characters: %p" % text
-
- return text
- end
-
-
- ### Convert tabs in +str+ to spaces.
- def detab( tabwidth=TabWidth )
- copy = self.dup
- copy.detab!( tabwidth )
- return copy
- end
-
-
- ### Convert tabs to spaces in place and return self if any were converted.
- def detab!( tabwidth=TabWidth )
- newstr = self.split( /\n/ ).collect {|line|
- line.gsub( /(.*?)\t/ ) do
- $1 + ' ' * (tabwidth - $1.length % tabwidth)
- end
- }.join("\n")
- self.replace( newstr )
- end
-
-
- #######
- #private
- #######
-
- ### Do block-level transforms on a copy of +str+ using the specified render
- ### state +rs+ and return the results.
- def apply_block_transforms( str, rs )
- # Port: This was called '_runBlockGamut' in the original
-
- @log.debug "Applying block transforms to:\n %p" % str
- text = transform_headers( str, rs )
- text = transform_hrules( text, rs )
- text = transform_lists( text, rs )
- text = transform_code_blocks( text, rs )
- text = transform_block_quotes( text, rs )
- text = transform_auto_links( text, rs )
- text = hide_html_blocks( text, rs )
-
- text = form_paragraphs( text, rs )
-
- @log.debug "Done with block transforms:\n %p" % text
- return text
- end
-
-
- ### Apply Markdown span transforms to a copy of the specified +str+ with the
- ### given render state +rs+ and return it.
- def apply_span_transforms( str, rs )
- @log.debug "Applying span transforms to:\n %p" % str
-
- str = transform_code_spans( str, rs )
- str = encode_html( str )
- str = transform_images( str, rs )
- str = transform_anchors( str, rs )
- str = transform_italic_and_bold( str, rs )
-
- # Hard breaks
- str.gsub!( / {2,}\n/, "<br#{EmptyElementSuffix}\n" )
-
- @log.debug "Done with span transforms:\n %p" % str
- return str
- end
-
-
- # The list of tags which are considered block-level constructs and an
- # alternation pattern suitable for use in regexps made from the list
- StrictBlockTags = %w[ p div h[1-6] blockquote pre table dl ol ul script noscript
- form fieldset iframe math ins del ]
- StrictTagPattern = StrictBlockTags.join('|')
-
- LooseBlockTags = StrictBlockTags - %w[ins del]
- LooseTagPattern = LooseBlockTags.join('|')
-
- # Nested blocks:
- # <div>
- # <div>
- # tags for inner block must be indented.
- # </div>
- # </div>
- StrictBlockRegex = %r{
- ^ # Start of line
- <(#{StrictTagPattern}) # Start tag: \2
- \b # word break
- (.*\n)*? # Any number of lines, minimal match
- </\1> # Matching end tag
- [ ]* # trailing spaces
- $ # End of line or document
- }ix
-
- # More-liberal block-matching
- LooseBlockRegex = %r{
- ^ # Start of line
- <(#{LooseTagPattern}) # start tag: \2
- \b # word break
- (.*\n)*? # Any number of lines, minimal match
- .*</\1> # Anything + Matching end tag
- [ ]* # trailing spaces
- $ # End of line or document
- }ix
-
- # Special case for <hr />.
- HruleBlockRegex = %r{
- ( # $1
- \A\n? # Start of doc + optional \n
- | # or
- .*\n\n # anything + blank line
- )
- ( # save in $2
- [ ]* # Any spaces
- <hr # Tag open
- \b # Word break
- ([^<>])*? # Attributes
- /?> # Tag close
- $ # followed by a blank line or end of document
- )
- }ix
-
- ### Replace all blocks of HTML in +str+ that start in the left margin with
- ### tokens.
- def hide_html_blocks( str, rs )
- @log.debug "Hiding HTML blocks in %p" % str
-
- # Tokenizer proc to pass to gsub
- tokenize = lambda {|match|
- key = Digest::MD5::hexdigest( match )
- rs.html_blocks[ key ] = match
- @log.debug "Replacing %p with %p" % [ match, key ]
- "\n\n#{key}\n\n"
- }
-
- rval = str.dup
-
- @log.debug "Finding blocks with the strict regex..."
- rval.gsub!( StrictBlockRegex, &tokenize )
-
- @log.debug "Finding blocks with the loose regex..."
- rval.gsub!( LooseBlockRegex, &tokenize )
-
- @log.debug "Finding hrules..."
- rval.gsub!( HruleBlockRegex ) {|match| $1 + tokenize[$2] }
-
- return rval
- end
-
-
- # Link defs are in the form: ^[id]: url "optional title"
- LinkRegex = %r{
- ^[ ]*\[(.+)\]: # id = $1
- [ ]*
- \n? # maybe *one* newline
- [ ]*
- <?(\S+?)>? # url = $2
- [ ]*
- \n? # maybe one newline
- [ ]*
- (?:
- # Titles are delimited by "quotes" or (parens).
- ["(]
- (.+?) # title = $3
- [")] # Matching ) or "
- [ ]*
- )? # title is optional
- (?:\n+|\Z)
- }x
-
- ### Strip link definitions from +str+, storing them in the given RenderState
- ### +rs+.
- def strip_link_definitions( str, rs )
- str.gsub( LinkRegex ) {|match|
- id, url, title = $1, $2, $3
-
- rs.urls[ id.downcase ] = encode_html( url )
- unless title.nil?
- rs.titles[ id.downcase ] = title.gsub( /"/, "&quot;" )
- end
- ""
- }
- end
-
-
- ### Escape special characters in the given +str+
- def escape_special_chars( str )
- @log.debug " Escaping special characters"
- text = ''
-
- # The original Markdown source has something called '$tags_to_skip'
- # declared here, but it's never used, so I don't define it.
-
- tokenize_html( str ) {|token, str|
- @log.debug " Adding %p token %p" % [ token, str ]
- case token
-
- # Within tags, encode * and _
- when :tag
- text += str.
- gsub( /\*/, EscapeTable['*'][:md5] ).
- gsub( /_/, EscapeTable['_'][:md5] )
-
- # Encode backslashed stuff in regular text
- when :text
- text += encode_backslash_escapes( str )
- else
- raise TypeError, "Unknown token type %p" % token
- end
- }
-
- @log.debug " Text with escapes is now: %p" % text
- return text
- end
-
-
- ### Swap escaped special characters in a copy of the given +str+ and return
- ### it.
- def unescape_special_chars( str )
- EscapeTable.each {|char, hash|
- @log.debug "Unescaping escaped %p with %p" % [ char, hash[:md5re] ]
- str.gsub!( hash[:md5re], char )
- }
-
- return str
- end
-
-
- ### Return a copy of the given +str+ with any backslashed special character
- ### in it replaced with MD5 placeholders.
- def encode_backslash_escapes( str )
- # Make a copy with any double-escaped backslashes encoded
- text = str.gsub( /\\\\/, EscapeTable['\\'][:md5] )
-
- EscapeTable.each_pair {|char, esc|
- next if char == '\\'
- text.gsub!( esc[:re], esc[:md5] )
- }
-
- return text
- end
-
-
- ### Transform any Markdown-style horizontal rules in a copy of the specified
- ### +str+ and return it.
- def transform_hrules( str, rs )
- @log.debug " Transforming horizontal rules"
- str.gsub( /^( ?[\-\*_] ?){3,}$/, "\n<hr#{EmptyElementSuffix}\n" )
- end
-
-
-
- # Patterns to match and transform lists
- ListMarkerOl = %r{\d+\.}
- ListMarkerUl = %r{[*+-]}
- ListMarkerAny = Regexp::union( ListMarkerOl, ListMarkerUl )
-
- ListRegexp = %r{
- (?:
- ^[ ]{0,#{TabWidth - 1}} # Indent < tab width
- (#{ListMarkerAny}) # unordered or ordered ($1)
- [ ]+ # At least one space
- )
- (?m:.+?) # item content (include newlines)
- (?:
- \z # Either EOF
- | # or
- \n{2,} # Blank line...
- (?=\S) # ...followed by non-space
- (?![ ]* # ...but not another item
- (#{ListMarkerAny})
- [ ]+)
- )
- }x
-
- ### Transform Markdown-style lists in a copy of the specified +str+ and
- ### return it.
- def transform_lists( str, rs )
- @log.debug " Transforming lists at %p" % (str[0,100] + '...')
-
- str.gsub( ListRegexp ) {|list|
- @log.debug " Found list %p" % list
- bullet = $1
- list_type = (ListMarkerUl.match(bullet) ? "ul" : "ol")
- list.gsub!( /\n{2,}/, "\n\n\n" )
-
- %{<%s>\n%s</%s>\n} % [
- list_type,
- transform_list_items( list, rs ),
- list_type,
- ]
- }
- end
-
-
- # Pattern for transforming list items
- ListItemRegexp = %r{
- (\n)? # leading line = $1
- (^[ ]*) # leading whitespace = $2
- (#{ListMarkerAny}) [ ]+ # list marker = $3
- ((?m:.+?) # list item text = $4
- (\n{1,2}))
- (?= \n* (\z | \2 (#{ListMarkerAny}) [ ]+))
- }x
-
- ### Transform list items in a copy of the given +str+ and return it.
- def transform_list_items( str, rs )
- @log.debug " Transforming list items"
-
- # Trim trailing blank lines
- str = str.sub( /\n{2,}\z/, "\n" )
-
- str.gsub( ListItemRegexp ) {|line|
- @log.debug " Found item line %p" % line
- leading_line, item = $1, $4
-
- if leading_line or /\n{2,}/.match( item )
- @log.debug " Found leading line or item has a blank"
- item = apply_block_transforms( outdent(item), rs )
- else
- # Recursion for sub-lists
- @log.debug " Recursing for sublist"
- item = transform_lists( outdent(item), rs ).chomp
- item = apply_span_transforms( item, rs )
- end
-
- %{<li>%s</li>\n} % item
- }
- end
-
-
- # Pattern for matching codeblocks
- CodeBlockRegexp = %r{
- (?:\n\n|\A)
- ( # $1 = the code block
- (?:
- (?:[ ]{#{TabWidth}} | \t) # a tab or tab-width of spaces
- .*\n+
- )+
- )
- (^[ ]{0,#{TabWidth - 1}}\S|\Z) # Lookahead for non-space at
- # line-start, or end of doc
- }x
-
- ### Transform Markdown-style codeblocks in a copy of the specified +str+ and
- ### return it.
- def transform_code_blocks( str, rs )
- @log.debug " Transforming code blocks"
-
- str.gsub( CodeBlockRegexp ) {|block|
- codeblock = $1
- remainder = $2
-
- # Generate the codeblock
- %{\n\n<pre><code>%s\n</code></pre>\n\n%s} %
- [ encode_code( outdent(codeblock), rs ).rstrip, remainder ]
- }
- end
-
-
- # Pattern for matching Markdown blockquote blocks
- BlockQuoteRegexp = %r{
- (?:
- ^[ ]*>[ ]? # '>' at the start of a line
- .+\n # rest of the first line
- (?:.+\n)* # subsequent consecutive lines
- \n* # blanks
- )+
- }x
- PreChunk = %r{ ( ^ \s* <pre> .+? </pre> ) }xm
-
- ### Transform Markdown-style blockquotes in a copy of the specified +str+
- ### and return it.
- def transform_block_quotes( str, rs )
- @log.debug " Transforming block quotes"
-
- str.gsub( BlockQuoteRegexp ) {|quote|
- @log.debug "Making blockquote from %p" % quote
-
- quote.gsub!( /^ *> ?/, '' ) # Trim one level of quoting
- quote.gsub!( /^ +$/, '' ) # Trim whitespace-only lines
-
- indent = " " * TabWidth
- quoted = %{<blockquote>\n%s\n</blockquote>\n\n} %
- apply_block_transforms( quote, rs ).
- gsub( /^/, indent ).
- gsub( PreChunk ) {|m| m.gsub(/^#{indent}/o, '') }
- @log.debug "Blockquoted chunk is: %p" % quoted
- quoted
- }
- end
-
-
- AutoAnchorURLRegexp = /<((https?|ftp):[^'">\s]+)>/
- AutoAnchorEmailRegexp = %r{
- <
- (
- [-.\w]+
- \@
- [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
- )
- >
- }xi
-
- ### Transform URLs in a copy of the specified +str+ into links and return
- ### it.
- def transform_auto_links( str, rs )
- @log.debug " Transforming auto-links"
- str.gsub( AutoAnchorURLRegexp, %{<a href="\\1">\\1</a>}).
- gsub( AutoAnchorEmailRegexp ) {|addr|
- encode_email_address( unescape_special_chars($1) )
- }
- end
-
-
- # Encoder functions to turn characters of an email address into encoded
- # entities.
- Encoders = [
- lambda {|char| "&#%03d;" % char},
- lambda {|char| "&#x%X;" % char},
- lambda {|char| char.chr },
- ]
-
- ### Transform a copy of the given email +addr+ into an escaped version safer
- ### for posting publicly.
- def encode_email_address( addr )
-
- rval = ''
- ("mailto:" + addr).each_byte {|b|
- case b
- when ?:
- rval += ":"
- when ?@
- rval += Encoders[ rand(2) ][ b ]
- else
- r = rand(100)
- rval += (
- r > 90 ? Encoders[2][ b ] :
- r < 45 ? Encoders[1][ b ] :
- Encoders[0][ b ]
- )
- end
- }
-
- return %{<a href="%s">%s</a>} % [ rval, rval.sub(/.+?:/, '') ]
- end
-
-
- # Regex for matching Setext-style headers
- SetextHeaderRegexp = %r{
- (.+) # The title text ($1)
- \n
- ([\-=])+ # Match a line of = or -. Save only one in $2.
- [ ]*\n+
- }x
-
- # Regexp for matching ATX-style headers
- AtxHeaderRegexp = %r{
- ^(\#{1,6}) # $1 = string of #'s
- [ ]*
- (.+?) # $2 = Header text
- [ ]*
- \#* # optional closing #'s (not counted)
- \n+
- }x
-
- ### Apply Markdown header transforms to a copy of the given +str+ amd render
- ### state +rs+ and return the result.
- def transform_headers( str, rs )
- @log.debug " Transforming headers"
-
- # Setext-style headers:
- # Header 1
- # ========
- #
- # Header 2
- # --------
- #
- str.
- gsub( SetextHeaderRegexp ) {|m|
- @log.debug "Found setext-style header"
- title, hdrchar = $1, $2
- title = apply_span_transforms( title, rs )
-
- case hdrchar
- when '='
- %[<h1>#{title}</h1>\n\n]
- when '-'
- %[<h2>#{title}</h2>\n\n]
- else
- title
- end
- }.
-
- gsub( AtxHeaderRegexp ) {|m|
- @log.debug "Found ATX-style header"
- hdrchars, title = $1, $2
- title = apply_span_transforms( title, rs )
-
- level = hdrchars.length
- %{<h%d>%s</h%d>\n\n} % [ level, title, level ]
- }
- end
-
-
- ### Wrap all remaining paragraph-looking text in a copy of +str+ inside <p>
- ### tags and return it.
- def form_paragraphs( str, rs )
- @log.debug " Forming paragraphs"
- grafs = str.
- sub( /\A\n+/, '' ).
- sub( /\n+\z/, '' ).
- split( /\n{2,}/ )
-
- rval = grafs.collect {|graf|
-
- # Unhashify HTML blocks if this is a placeholder
- if rs.html_blocks.key?( graf )
- rs.html_blocks[ graf ]
-
- # Otherwise, wrap in <p> tags
- else
- apply_span_transforms(graf, rs).
- sub( /^[ ]*/, '<p>' ) + '</p>'
- end
- }.join( "\n\n" )
-
- @log.debug " Formed paragraphs: %p" % rval
- return rval
- end
-
-
- # Pattern to match the linkid part of an anchor tag for reference-style
- # links.
- RefLinkIdRegex = %r{
- [ ]? # Optional leading space
- (?:\n[ ]*)? # Optional newline + spaces
- \[
- (.*?) # Id = $1
- \]
- }x
-
- InlineLinkRegex = %r{
- \( # Literal paren
- [ ]* # Zero or more spaces
- <?(.+?)>? # URI = $1
- [ ]* # Zero or more spaces
- (?: #
- ([\"\']) # Opening quote char = $2
- (.*?) # Title = $3
- \2 # Matching quote char
- )? # Title is optional
- \)
- }x
-
- ### Apply Markdown anchor transforms to a copy of the specified +str+ with
- ### the given render state +rs+ and return it.
- def transform_anchors( str, rs )
- @log.debug " Transforming anchors"
- @scanner.string = str.dup
- text = ''
-
- # Scan the whole string
- until @scanner.empty?
-
- if @scanner.scan( /\[/ )
- link = ''; linkid = ''
- depth = 1
- startpos = @scanner.pos
- @log.debug " Found a bracket-open at %d" % startpos
-
- # Scan the rest of the tag, allowing unlimited nested []s. If
- # the scanner runs out of text before the opening bracket is
- # closed, append the text and return (wasn't a valid anchor).
- while depth.nonzero?
- linktext = @scanner.scan_until( /\]|\[/ )
-
- if linktext
- @log.debug " Found a bracket at depth %d: %p" % [ depth, linktext ]
- link += linktext
-
- # Decrement depth for each closing bracket
- depth += ( linktext[-1, 1] == ']' ? -1 : 1 )
- @log.debug " Depth is now #{depth}"
-
- # If there's no more brackets, it must not be an anchor, so
- # just abort.
- else
- @log.debug " Missing closing brace, assuming non-link."
- link += @scanner.rest
- @scanner.terminate
- return text + '[' + link
- end
- end
- link.slice!( -1 ) # Trim final ']'
- @log.debug " Found leading link %p" % link
-
- # Look for a reference-style second part
- if @scanner.scan( RefLinkIdRegex )
- linkid = @scanner[1]
- linkid = link.dup if linkid.empty?
- linkid.downcase!
- @log.debug " Found a linkid: %p" % linkid
-
- # If there's a matching link in the link table, build an
- # anchor tag for it.
- if rs.urls.key?( linkid )
- @log.debug " Found link key in the link table: %p" % rs.urls[linkid]
- url = escape_md( rs.urls[linkid] )
-
- text += %{<a href="#{url}"}
- if rs.titles.key?(linkid)
- text += %{ title="%s"} % escape_md( rs.titles[linkid] )
- end
- text += %{>#{link}</a>}
-
- # If the link referred to doesn't exist, just append the raw
- # source to the result
- else
- @log.debug " Linkid %p not found in link table" % linkid
- @log.debug " Appending original string instead: "
- @log.debug "%p" % @scanner.string[ startpos-1 .. @scanner.pos-1 ]
- text += @scanner.string[ startpos-1 .. @scanner.pos-1 ]
- end
-
- # ...or for an inline style second part
- elsif @scanner.scan( InlineLinkRegex )
- url = @scanner[1]
- title = @scanner[3]
- @log.debug " Found an inline link to %p" % url
-
- text += %{<a href="%s"} % escape_md( url )
- if title
- title.gsub!( /"/, "&quot;" )
- text += %{ title="%s"} % escape_md( title )
- end
- text += %{>#{link}</a>}
-
- # No linkid part: just append the first part as-is.
- else
- @log.debug "No linkid, so no anchor. Appending literal text."
- text += @scanner.string[ startpos-1 .. @scanner.pos-1 ]
- end # if linkid
-
- # Plain text
- else
- @log.debug " Scanning to the next link from %p" % @scanner.rest
- text += @scanner.scan( /[^\[]+/ )
- end
-
- end # until @scanner.empty?
-
- return text
- end
-
-
- # Pattern to match strong emphasis in Markdown text
- BoldRegexp = %r{ (\*\*|__) (\S|\S.+?\S) \1 }x
-
- # Pattern to match normal emphasis in Markdown text
- ItalicRegexp = %r{ (\*|_) (\S|\S.+?\S) \1 }x
-
- ### Transform italic- and bold-encoded text in a copy of the specified +str+
- ### and return it.
- def transform_italic_and_bold( str, rs )
- @log.debug " Transforming italic and bold"
-
- str.
- gsub( BoldRegexp, %{<strong>\\2</strong>} ).
- gsub( ItalicRegexp, %{<em>\\2</em>} )
- end
-
-
- ### Transform backticked spans into <code> spans.
- def transform_code_spans( str, rs )
- @log.debug " Transforming code spans"
-
- # Set up the string scanner and just return the string unless there's at
- # least one backtick.
- @scanner.string = str.dup
- unless @scanner.exist?( /`/ )
- @scanner.terminate
- @log.debug "No backticks found for code span in %p" % str
- return str
- end
-
- @log.debug "Transforming code spans in %p" % str
-
- # Build the transformed text anew
- text = ''
-
- # Scan to the end of the string
- until @scanner.empty?
-
- # Scan up to an opening backtick
- if pre = @scanner.scan_until( /.?(?=`)/m )
- text += pre
- @log.debug "Found backtick at %d after '...%s'" % [ @scanner.pos, text[-10, 10] ]
-
- # Make a pattern to find the end of the span
- opener = @scanner.scan( /`+/ )
- len = opener.length
- closer = Regexp::new( opener )
- @log.debug "Scanning for end of code span with %p" % closer
-
- # Scan until the end of the closing backtick sequence. Chop the
- # backticks off the resultant string, strip leading and trailing
- # whitespace, and encode any enitites contained in it.
- codespan = @scanner.scan_until( closer ) or
- raise FormatError::new( @scanner.rest[0,20],
- "No %p found before end" % opener )
-
- @log.debug "Found close of code span at %d: %p" % [ @scanner.pos - len, codespan ]
- codespan.slice!( -len, len )
- text += "<code>%s</code>" %
- encode_code( codespan.strip, rs )
-
- # If there's no more backticks, just append the rest of the string
- # and move the scan pointer to the end
- else
- text += @scanner.rest
- @scanner.terminate
- end
- end
-
- return text
- end
-
-
- # Next, handle inline images: ![alt text](url "optional title")
- # Don't forget: encode * and _
- InlineImageRegexp = %r{
- ( # Whole match = $1
- !\[ (.*?) \] # alt text = $2
- \([ ]*
- <?(\S+?)>? # source url = $3
- [ ]*
- (?: #
- (["']) # quote char = $4
- (.*?) # title = $5
- \4 # matching quote
- [ ]*
- )? # title is optional
- \)
- )
- }xs #"
-
-
- # Reference-style images
- ReferenceImageRegexp = %r{
- ( # Whole match = $1
- !\[ (.*?) \] # Alt text = $2
- [ ]? # Optional space
- (?:\n[ ]*)? # One optional newline + spaces
- \[ (.*?) \] # id = $3
- )
- }xs
-
- ### Turn image markup into image tags.
- def transform_images( str, rs )
- @log.debug " Transforming images" % str
-
- # Handle reference-style labeled images: ![alt text][id]
- str.
- gsub( ReferenceImageRegexp ) {|match|
- whole, alt, linkid = $1, $2, $3.downcase
- @log.debug "Matched %p" % match
- res = nil
- alt.gsub!( /"/, '&quot;' )
-
- # for shortcut links like ![this][].
- linkid = alt.downcase if linkid.empty?
-
- if rs.urls.key?( linkid )
- url = escape_md( rs.urls[linkid] )
- @log.debug "Found url '%s' for linkid '%s' " % [ url, linkid ]
-
- # Build the tag
- result = %{<img src="%s" alt="%s"} % [ url, alt ]
- if rs.titles.key?( linkid )
- result += %{ title="%s"} % escape_md( rs.titles[linkid] )
- end
- result += EmptyElementSuffix
-
- else
- result = whole
- end
-
- @log.debug "Replacing %p with %p" % [ match, result ]
- result
- }.
-
- # Inline image style
- gsub( InlineImageRegexp ) {|match|
- @log.debug "Found inline image %p" % match
- whole, alt, title = $1, $2, $5
- url = escape_md( $3 )
- alt.gsub!( /"/, '&quot;' )
-
- # Build the tag
- result = %{<img src="%s" alt="%s"} % [ url, alt ]
- unless title.nil?
- title.gsub!( /"/, '&quot;' )
- result += %{ title="%s"} % escape_md( title )
- end
- result += EmptyElementSuffix
-
- @log.debug "Replacing %p with %p" % [ match, result ]
- result
- }
- end
-
-
- # Regexp to match special characters in a code block
- CodeEscapeRegexp = %r{( \* | _ | \{ | \} | \[ | \] | \\ )}x
-
- ### Escape any characters special to HTML and encode any characters special
- ### to Markdown in a copy of the given +str+ and return it.
- def encode_code( str, rs )
- str.gsub( %r{&}, '&amp;' ).
- gsub( %r{<}, '&lt;' ).
- gsub( %r{>}, '&gt;' ).
- gsub( CodeEscapeRegexp ) {|match| EscapeTable[match][:md5]}
- end
-
-
-
- #################################################################
- ### U T I L I T Y F U N C T I O N S
- #################################################################
-
- ### Escape any markdown characters in a copy of the given +str+ and return
- ### it.
- def escape_md( str )
- str.
- gsub( /\*/, EscapeTable['*'][:md5] ).
- gsub( /_/, EscapeTable['_'][:md5] )
- end
-
-
- # Matching constructs for tokenizing X/HTML
- HTMLCommentRegexp = %r{ <! ( -- .*? -- \s* )+ > }mx
- XMLProcInstRegexp = %r{ <\? .*? \?> }mx
- MetaTag = Regexp::union( HTMLCommentRegexp, XMLProcInstRegexp )
-
- HTMLTagOpenRegexp = %r{ < [a-z/!$] [^<>]* }imx
- HTMLTagCloseRegexp = %r{ > }x
- HTMLTagPart = Regexp::union( HTMLTagOpenRegexp, HTMLTagCloseRegexp )
-
- ### Break the HTML source in +str+ into a series of tokens and return
- ### them. The tokens are just 2-element Array tuples with a type and the
- ### actual content. If this function is called with a block, the type and
- ### text parts of each token will be yielded to it one at a time as they are
- ### extracted.
- def tokenize_html( str )
- depth = 0
- tokens = []
- @scanner.string = str.dup
- type, token = nil, nil
-
- until @scanner.empty?
- @log.debug "Scanning from %p" % @scanner.rest
-
- # Match comments and PIs without nesting
- if (( token = @scanner.scan(MetaTag) ))
- type = :tag
-
- # Do nested matching for HTML tags
- elsif (( token = @scanner.scan(HTMLTagOpenRegexp) ))
- tagstart = @scanner.pos
- @log.debug " Found the start of a plain tag at %d" % tagstart
-
- # Start the token with the opening angle
- depth = 1
- type = :tag
-
- # Scan the rest of the tag, allowing unlimited nested <>s. If
- # the scanner runs out of text before the tag is closed, raise
- # an error.
- while depth.nonzero?
-
- # Scan either an opener or a closer
- chunk = @scanner.scan( HTMLTagPart ) or
- raise "Malformed tag at character %d: %p" %
- [ tagstart, token + @scanner.rest ]
-
- @log.debug " Found another part of the tag at depth %d: %p" % [ depth, chunk ]
-
- token += chunk
-
- # If the last character of the token so far is a closing
- # angle bracket, decrement the depth. Otherwise increment
- # it for a nested tag.
- depth += ( token[-1, 1] == '>' ? -1 : 1 )
- @log.debug " Depth is now #{depth}"
- end
-
- # Match text segments
- else
- @log.debug " Looking for a chunk of text"
- type = :text
-
- # Scan forward, always matching at least one character to move
- # the pointer beyond any non-tag '<'.
- token = @scanner.scan_until( /[^<]+/m )
- end
-
- @log.debug " type: %p, token: %p" % [ type, token ]
-
- # If a block is given, feed it one token at a time. Add the token to
- # the token list to be returned regardless.
- if block_given?
- yield( type, token )
- end
- tokens << [ type, token ]
- end
-
- return tokens
- end
-
-
- ### Return a copy of +str+ with angle brackets and ampersands HTML-encoded.
- def encode_html( str )
- str.gsub( /&(?!#?[x]?(?:[0-9a-f]+|\w+);)/i, "&amp;" ).
- gsub( %r{<(?![a-z/?\$!])}i, "&lt;" )
- end
-
-
- ### Return one level of line-leading tabs or spaces from a copy of +str+ and
- ### return it.
- def outdent( str )
- str.gsub( /^(\t|[ ]{1,#{TabWidth}})/, '')
- end
-
-end # class BlueCloth
-
-BEGIN {
- require 'optparse'
-}
-
-DocumentWrapper = %{
-<html>
- <head><title>%s</title></head>
- <body>
-%s
- </body>
-</html>
-}
-
-def main
- fragment = false
- destination = '.'
-
- ARGV.options do |oparser|
-
- oparser.banner = "Usage: #$0 [OPTIONS] FILES"
-
- # Debug mode
- oparser.on( "--debug", "-d", TrueClass, "Turn debugging output on" ) {
- $DEBUG = true
- }
-
- # 'Fragment' mode
- oparser.on( "--fragment", "-f", TrueClass,
- "Output HTML fragments instead of whole documents" ) {
- fragment = true
- }
-
- # Output destination
- #oparser.on( "--output=DESTINATION", "-o DESTINATION", String,
- # "Write output to DESTINATION instead of the current directory" ) {|arg|
- # destination = arg
- #}
-
- oparser.parse!
- end
-
- # Filter mode if no arguments
- ARGV.push( "-" ) if ARGV.empty?
-
- ARGV.each {|file|
- if file == '-'
- contents = $stdin.readlines(nil)
- else
- contents = File::readlines( file, nil )
- end
-
- bc = BlueCloth::new( contents.join )
-
- if fragment
- $stdout.puts bc.to_html
- else
- $stdout.puts DocumentWrapper % [ file, bc.to_html ]
- end
- }
-
-rescue => err
- $stderr.puts "Aborting: Fatal error: %s" % err.message
- exit 255
-end
-
-
-
-main
-
View
BIN  doc/images/continuous_integration.jpg
Deleted file not rendered
View
BIN  doc/images/improveit.gif
Deleted file not rendered
View
427 doc/index.html
@@ -1,427 +0,0 @@
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
-
- <head>
- <title>Integration</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
- </head>
-
- <body>
-<h1>Integration</h1>
-
-<h2>What</h2>
-
-<p>Integration is a <a href="http://www.rubyonrails.org">Ruby on Rails</a> plugin that provides a set of tasks to automate all steps of a <a href="http://jamesshore.com/Blog/Why%20I%20Dont%20Like%20CruiseControl.html">synchronous continuous integration</a> process, that is, <a href="http://martinfowler.com/articles/continuousIntegration.html">continuous integration</a> without a server such as <a href="http://cruisecontrol.sourceforge.net">CruiseControl</a>. Why? Because that's the way we like it!</p>
-
-<h2>Installing</h2>
-
-<pre><code>ruby script/plugin install git://github.com/tapajos/integration.git
-</code></pre>
-
-<p>After installing the plugin is ready to be used and you will need to execute only one task in order to integrate your code safely:</p>
-
-<pre><code>rake integrate
-</code></pre>
-
-<h2>Dependencies</h2>
-
-<ul>
-<li>A scm(currently supported are <a href="http://subversion.tigris.org">Subversion</a>, <a href="http://git.or.cz/">git</a> and <a href="http://git.or.cz/">git-svn</a></li>
-<li><a href="http://code.whytheluckystiff.net/hpricot">Hpricot</a> (optional)</li>
-<li><a href="http://eigenclass.org/hiki.rb?rcov">Rcov</a> (optional) </li>
-<li><a href="http://selenium-on-rails.openqa.org">Selenium on Rails</a> (optional)</li>
-<li><a href="http://rspec.info">Rspec</a> (optional)</li>
-</ul>
-
-<h2>Integration Steps</h2>
-
-<p>The integration process is composed of several steps that are explained ahead. It's possible to skip one or more steps and add other steps of your own. This will be demonstrated shortly. The complete set of steps are:</p>
-
-<ol>
-<li><p>task scm:status:check </p>
-
-<p>Check if all local files are under control of your scm. If your scm is subversion, it also checks if no local files have been removed using only rm (file removal should always use svn remove instead).</p></li>
-<li><p>task log:clear </p>
-
-<p>Remove log files.</p></li>
-<li><p>task tmp:clear </p>
-
-<p>Remove temporary files.</p></li>
-<li><p>task backup:local </p>
-
-<p>Backup files locally. This is done before scm update to create a recovery point if you have problems during scm update. If a file merge creates undesirable effects on the software, you can recover from the backup file.
-Backup file names have a timestamp. By default, the last 30 backups are kept. You may change this number as you'll see shortly. This task won't work on Windows because it uses <a href="http://en.wikipedia.org/wiki/Tar_%28file_format%29">tar</a>. So, if you're using Windows you'll have to write your own version of this task or just stop using Windows. We highly recommend the later.</p></li>
-<li><p>task scm:update </p>
-
-<p>Update local files from your remote scm repository.</p></li>
-<li><p>task db:migrate</p>
-
-<p>Execute any new database migration created by other team members since the last integration.</p></li>
-<li><p>test:units </p>
-
-<p>Run all unit tests.</p></li>
-<li><p>test:functionals </p>
-
-<p>Run all functional tests.</p></li>
-<li><p>test:integration </p>
-
-<p>Run all integration tests.</p></li>
-<li><p>spec:lib </p>
-
-<p>Run all lib specs.</p></li>
-<li><p>spec:models </p>
-
-<p>Run all model specs.</p></li>
-<li><p>spec:helpers </p>
-
-<p>Run all helper specs.</p></li>
-<li><p>spec:controllers </p>
-
-<p>Run all controller specs.</p></li>
-<li><p>spec:views </p>
-
-<p>Run all view specs.</p></li>
-<li><p>test:rcov:units </p>
-
-<p>Run coverage analysis of the unit tests.</p></li>
-<li><p>test:rcov:units:verify </p>
-
-<p>Check if unit tests cover 100% of the application code.</p></li>
-<li><p>test:rcov:functionals </p>
-
-<p>Run coverage analysis of the functional tests.</p></li>
-<li><p>test:rcov:functionals:verify </p>
-
-<p>Check if functional tests cover 100% of the application code.</p></li>
-<li><p>spec:rcov </p>
-
-<p>Run coverage analysis of the specs.</p></li>
-<li><p>spec:rcov:verify </p>
-
-<p>Check if specs cover 100% of the application code.</p></li>
-<li><p>test:plugins:selected </p>
-
-<p>Run tests on selected plugins. You might want to always run the tests of plugins you created, for example, while ignoring the tests of third party plugins. We'll show below how you can specify the plugins you want to test.</p></li>
-<li><p>spec:plugins:selected </p>
-
-<p>Same as previous step, but with specs, instead of tests.</p></li>
-<li><p>test:selenium:server:start </p>
-
-<p>If you use <a href="http://selenium-on-rails.openqa.org">Selenium</a> to test your application, as you certainly should, you'll need to make sure the webserver is up and running before running <a href="http://selenium-on-rails.openqa.org">Selenium</a> tests. That's what this task does.</p></li>
-<li><p>test_acceptance</p>
-
-<p>Run all <a href="http://selenium-on-rails.openqa.org">Selenium</a> tests.</p></li>
-<li><p>test:selenium:server:stop</p>
-
-<p>Stop the webserver.</p></li>
-<li><p>scm:commit</p>
-
-<p>Commit your changes. If any of the previous tasks break, because one test failed, for instance, the script won't commit. Actually this task runs only if every checking done before work well.</p></li>
-</ol>
-
-<p>Using this almost paranoid sequence of steps it will be hard to check in bad code in your repository, which is good, very good. The idea is that you should treat your repository as a sacred place, where only good code should ever enter. </p>
-
-<h2>Customize the integration process</h2>
-
-<p>To customize the integration process you need to create a task file in your project, like:</p>
-
-<pre><code>lib/tasks/integration.rake
-</code></pre>
-
-<h3>Changing scm</h3>
-
-<p>By default the integration process uses subversion, but you can customize it to use git(your remote repository is git) or git-svn(your remote repository is svn, but you uses git locally):</p>
-
-<ul>
-<li><p>git</p>
-
-<pre><code>ENV['SCM'] = 'git'
-</code></pre></li>
-<li><p>git-svn</p>
-
-<pre><code>ENV['SCM'] = 'git_with_svn'
-</code></pre></li>
-</ul>
-
-<h3>Skipping tasks</h3>
-
-<p>In your custom integration rake file you may define a comma separated list of tasks that you don't want to execute. Let's see some examples:</p>
-
-<ul>
-<li><p>Don't execute migrations </p>
-
-<pre><code>ENV['SKIP_TASKS'] = 'db:migrate'
-</code></pre></li>
-<li><p>Don't execute spec coverage, nor spec coverage verification </p>
-
-<pre><code>ENV['SKIP_TASKS'] = 'spec:rcov, spec:rcov:verify'
-</code></pre></li>
-<li><p>Don't execute any tests nor specs at all</p>
-
-<pre><code>ENV['SKIP_TASKS'] = %w(
- test:units
- test:functionals
- test:integration
- spec:lib
- spec:models
- spec:helpers
- spec:controllers
- spec:views
- test:rcov:units
- test:rcov:units:verify
- test:rcov:functionals
- test:rcov:functionals:verify
- spec:rcov
- spec:rcov:verify
- test:selenium:server:start
- test_acceptance
- test:selenium:server:stop
- ).join(",")
-</code></pre></li>
-</ul>
-
-<p>You can also define SKIP_TASKS when you run the integration process like this:</p>
-
-<pre><code>rake integrate SKIP_TASKS=spec:rcov,spec:rcov:verify
-</code></pre>
-
-<h3>Adding other tasks</h3>
-
-<p>Integration plugin also defines callback tasks that you can use to customize it with your own tasks. You can add other tasks before or after any of the plugin tasks. Let's see an example. Say you want to sweep HTML cache pages after running <a href="http://selenium-on-rails.openqa.org">Selenium</a>. To do that, you've just created a task cache:sweep. Let's configure Integration to run it just after Selenium:</p>
-
-<pre><code> namespace :test_acceptance do
- desc 'Runs cache sweeper'
- task :after do
- Rake::Task["cache:sweep"].invoke
- end
- end
-</code></pre>
-
-<p>A callback task is one that has the same name of a plugin task followed by :before or :after. In this case, the plugin defines a task called test_acceptance. So, you may create test_acceptance:before that will be executed before test_acceptance and test_acceptance:after to execute as soon as test_acceptance finishes. To do that, you will need to use namespaces, like we did in the previous example. Now, let's see a real example from one of our projects:</p>
-
-<pre><code>def integration_sweeper
- sh "script/integration_sweeper"
-end
-
-namespace :scm do
- namespace :status do
- namespace :check do
- task :before do
- integration_sweeper
- end
- end
- end
-end
-
-desc 'Generates error 500 page'
-task :error500 do
- `curl http://localhost:4000/server_error -o #{RAILS_ROOT}/public/500.html`
-end
-
-namespace :cache do
- namespace :sweeper do
- desc 'Runs cache_sweeper before executing Selenium'
- task :start do
- integration_sweeper
- end
-
- desc 'Runs cache_sweeper after executing Selenium'
- task :stop do
- integration_sweeper
- end
- end
-end
-
-namespace :test_acceptance do
- desc 'Runs cache sweeper and generate static 500 error page'
- task :before do
- Rake::Task["error500"].invoke
- end
-
- desc 'Runs cache sweeper'
- task :after do
- Rake::Task["cache:sweeper:stop"].invoke
- end
-end
-</code></pre>
-
-<h3>Defining the list of plugins for which you want to run tests or specs</h3>
-
-<p>In your integration process, you may want to run tests or specs for certain plugins. All you need to do is name them, like this:</p>
-
-<pre><code>ENV['PLUGINS_TO_TEST'] = "packr, email"
-ENV['PLUGINS_TO_SPEC'] = "brazilian_rails"
-</code></pre>
-
-<p>You can also inform these when you run rake integrate:</p>
-
-<pre><code>rake integrate PLUGINS_TO_TEST=packr,email PLUGINS_TO_SPEC=brazilian_rails
-</code></pre>
-
-<h3>Defining the environment in which to run the integration process</h3>
-
-<p>Integration will run against the development environment by default. If you need it to run using another environment, you can do this:</p>
-
-<pre><code>ENV['RAILS_ENV'] = 'development_cache'
-</code></pre>
-
-<p>Once again, you can also inform this while running rake integrate:</p>
-
-<pre><code>rake integrate RAILS_ENV=test
-</code></pre>
-
-<h3>Selenium port</h3>
-
-<p>When running Selenium, you might need to specify another port other them the default port 4000. That's how you do it:</p>
-
-<pre><code>ENV['SELENIUM_PORT'] = 3000
-</code></pre>
-
-<h3>Number of backups to keep</h3>
-
-<p>If you want to change the number of backups that will be kept, use this:</p>
-
-<pre><code>ENV['NUMBER_OF_BACKUPS_TO_KEEP'] = 50
-</code></pre>
-
-<p>Backups are store in a sibling directory with the prefix 'backup-'. For instance, suppose you have a project 'amazing' in the projects directory. After the first backup, you will end up with something like this:</p>
-
-<pre><code>projects/amazing
-projects/backup-amazing
-projects/backup-amazing/amazing-20080304-104812.tar.gz
-</code></pre>
-
-<h3>Commit messages</h3>
-
-<p>If you don't care to write commit messages, you can skip them:</p>
-
-<pre><code>ENV['SKIP_COMMIT_MESSAGES'] = 'true'
-</code></pre>
-
-<h3>More examples</h3>
-
-<ul>
-<li><p>Reckless programmer</p>
-
-<p>So you don't have tests, nor specs but you still want to use the plugin. Besides, you want to keep the log files and prefer not to run migrations. You might get away with this customized lib/tasks/integration.rake:</p>
-
-<pre><code>ENV['SKIP_TASKS'] = %w(
- log:clear
- db:migrate
- test:units
- test:functionals
- test:integration
- spec:lib
- spec:models
- spec:helpers
- spec:controllers
- spec:views
- test:rcov:units
- test:rcov:units:verify
- test:rcov:functionals
- test:rcov:functionals:verify
- spec:rcov
- spec:rcov:verify
- test:plugins:selected
- spec:plugins:selected
- test:selenium:server:start
- test_acceptance
- test:selenium:server:stop
- ).join(",")
-</code></pre>
-
-<p>The fact that you can get away with this doesn't mean you should. Don't you think it's already time to grow up and become more professional about software development? I know you believe you have a great excuse to avoid writing those tests or specs. Still it's just an excuse. Write tests or write specs and make a better world!</p></li>
-<li><p>Test conscious programmer</p>
-
-<p>You haven't jumped on the <a href="http://en.wikipedia.org/wiki/Behavior_driven_development">BDD</a> bandwagon yet. Instead, you write tests, which is good, but they don't cover all of your code yet, which is bad. We believe you will <a href="http://www.improveit.com.br/en">improve it</a> and make sure your tests cover 100% of your code. In the meantime you might need to skip coverage checkings. Oh, you also don't use <a href="http://selenium-on-rails.openqa.org">Selenium</a>. Shame on you! Try this:</p>
-
-<pre><code>ENV['SKIP_TASKS'] = %w(
- spec:lib
- spec:models
- spec:helpers
- spec:controllers
- spec:views
- test:rcov:units
- test:rcov:units:verify
- test:rcov:functionals
- test:rcov:functionals:verify
- spec:rcov
- spec:rcov:verify
- test:selenium:server:start
- test_acceptance
- test:selenium:server:stop
- ).join(',')
-</code></pre>
-
-<p>As a matter of fact, since this case might be very common, <strong>we decided to create a lib/tasks/integration.rake for you once the plugin has been installed. It has this very configuration and you can use it as a starting point to customize your integration process</strong>.</p></li>
-<li><p>Spec infected programmer</p>
-
-<p>So you used to <a href="http://en.wikipedia.org/wiki/Test-driven_development">TDD</a> all around but then someone told you that this is for gramma. The new wave has a name on it: <a href="http://en.wikipedia.org/wiki/Behavior_driven_development">BDD</a>. So, of course, you now have specs covering 100% of your code and doesn't have any more tests. Great! Just do it:</p>
-
-<pre><code>ENV['SKIP_TASKS'] = %w(
- test:units
- test:functionals
- test:integration
- test:rcov:units
- test:rcov:units:verify
- test:rcov:functionals
- test:rcov:functionals:verify
- ).join(",")
-</code></pre></li>
-</ul>
-
-<p>You can see more examples in the samples directory.</p>
-
-<h2>Forum</h2>
-
-<p>Discussion about the Integration Plugin are welcome on the forum below:</p>
-
-<p><a href="http://rubyforge.org/forum/?group_id=4662">http://rubyforge.org/forum/?group_id=4662</a></p>
-
-<h2>Version</h2>
-
-<p>Integration version 0.2.4</p>
-
-<h2>Release Notes</h2>
-
-<ul>
-<li>Version 0.2.4 - Added support for git and git-svn. Thanks to <a href="http://mergulhao.info/">Sylvestre Mergulhão</a> and <a href="http://tudoquequerosaber.com/">Eduardo Fiorezi</a>.</li>
-<li>Version 0.2.3 - BUG FIX: Rake db:migrate fails when default ENV['RAILS_ENV'] is used. Thanks to Celestino Gomes for fix this bug.</li>
-<li>Version 0.2.2 - Removed vendor/plugins/* commit. This commit is necessary when use plugins with externals but it isn`t a good practice. <a href="http://piston.rubyforge.org/">Piston</a> is the correct way to use externals plugins. If you want to use externals commit in your integration process you can create a svn:commit:after task.</li>
-<li>Version 0.2.1 - BUG FIX: Setting ENV['RAILS_ENV'] wasn't affecting migrations. This bug fix changes this behavior and makes sure that ENV['RAILS_ENV'] set by the user will always be respected, for all tasks. Thanks to Sylvestre Mergulhão for point this out.</li>
-<li>Version 0.2 - Added support for ENV['SKIP_COMMIT_MESSAGES'].</li>
-</ul>
-
-<h2>License</h2>
-
-<p>This code is free to be used under the terms of the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.</p>
-
-<h2>Contact</h2>
-
-<p>Comments are welcome. Send your feedback through the <a href="http://rubyforge.org/forum/?group_id=4662">forum</a> or to <a href="http://www.improveit.com.br/en/contact">this page</a></p>
-
-<h2>Authors</h2>
-
-<p><a href="http://www.improveit.com.br/en/company/tapajos">Marcos Tapajós</a><br/>
-<a href="http://www.improveit.com.br/vinicius">Vinícius Teles</a></p>
-
-<h2>Shameless advertisement</h2>
-
-<p>This plugin is brought to you by <a href="http://www.improveit.com.br/en">Improve It</a>.</p>
-
-<p><a href="http://www.improveit.com.br/en"><img src="http://www.improveit.com.br/images/logo/logo_improve_it_screen.gif" alt="Improve It" title="Improve It"/></a></p>
-
- <script type="text/javascript">
- var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
- document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
- </script>
- <script type="text/javascript">
- var pageTracker = _gat._getTracker("UA-2309104-4");
- pageTracker._initData();
- pageTracker._trackPageview();
- </script>
- </body>
-
-</html>
View
107 doc/stylesheets/screen.css
@@ -1,107 +0,0 @@
-html * {
- color: #222;
- font: normal normal normal 1em/1em "Trebuchet MS", "Lucida Grande", Helvetica, Arial, sans-serif;
- padding: 0;
- background: none;
- border: none;
- margin: 0;
-}
-
-html {
- background: #CCCCFF;
-}
-
-body {
- width: 42.5em;
- padding: 0 3em 5em 3em;
- background: #FFF;
- margin: 0 auto;
- position: relative;
-}
-
-h1, h2, h3 {
- text-transform: uppercase;
- margin: 2em 0 1em 0;
-}
-
-h1 {
- color: #D74768;
- font: normal normal bold 280% "Eurostile", "Trebuchet MS", "Lucida Grande", Helvetica, Arial, sans-serif;
- padding-top: 130px;
- background: #FFF url("../images/continuous_integration.jpg") no-repeat;
- margin: 0;
-}
-
-h2 {
- color: #660066;
- font: normal normal bold 130% Georgia, Times, "Times New Roman", serif;
- border-bottom: 1px solid #686868;
-}
-
-h3 {
- color: #CC6666;
-}
-
-a {
- color: #660066;
-}
-
-p {
- font-size: 95%;
- line-height: 1.3em;
- text-align: justify;
- padding: 0 1.3em;
- margin: .5em 0 1em 0;
-}
-
-pre {
- padding: 1.25em;
- background-color: #E3DEFF;
- margin: .5em 0 1em 0;
- overflow: auto;
-}
-
-code {
- color: #533D2A;
- font: normal normal normal 85%/1.2em "Lucida Console", "Monaco", serif;
-}
-
-ul {
- list-style-type: square;
-}
-
-ul, ol {
- padding: 0 3.1em .5em 3.1em;
-}
-
-ul li, ol li {
- margin-bottom: 1em;
-}
-
-ul p, ol p {
- padding: 0;
- margin: 0 0 .3em 0;
-}
-
-ol p {
- color: #533D2A;
- font: normal normal normal 90%/1.2em "Lucida Console", "Monaco", serif;
- padding: .2em;
- background-color: #E3DEFF;
-}
-
-ol p + p {
- color: #222;
- font: normal normal normal 85%/1em "Trebuchet MS", "Lucida Grande", Helvetica, Arial, sans-serif;
- background: none;
-}
-
-img {
- position: absolute;
- bottom: 4.3em;
- right: 4.3em;
-}
-
-strong {
- font-weight: bold;
-}
View
1  init.rb
@@ -1 +0,0 @@
-# Include hook code here
View
5 install.rb
@@ -1,5 +0,0 @@
-require 'fileutils'
-sample = File.expand_path(File.dirname(__FILE__) + "/samples/skip_selenium_and_coverage.rake")
-integration = File.expand_path(RAILS_ROOT + "/lib/tasks/integration.rake")
-
-FileUtils.cp sample, integration
View
12 integration.gemspec
@@ -0,0 +1,12 @@
+# -*- encoding : utf-8 -*-
+Gem::Specification.new do |s|
+ s.name = "integration"
+ s.version = "0.0.1"
+ s.description = "A synchronous continuous integration gem."
+ s.summary = "Integration gem help people that want to do synchronous continuous integration on their ruby projects."
+ s.authors = ["Marcos Tapajós", "Sylvestre Mergulhão","Vinícius Teles"]
+ s.homepage = "http://github.com/mergulhao/integration"
+ s.files = Dir["{lib/**/*.rb, lib/**/*.rake, test/**/*.rb,README.mkdn,Rakefile,MIT-LICENSE,*.gemspec}"]
+ s.required_rubygems_version = "1.8.0"
+ s.add_runtime_dependency('hpricot')
+end
View
1  lib/integration.rb
@@ -0,0 +1 @@
+Dir["#{Gem::Specification.find_by_name('integration').full_gem_path}/lib/tasks/*.rake"].each { |ext| load ext } if defined?(Rake)
View
103 lib/tasks/integrate.rake
@@ -0,0 +1,103 @@
+require 'find'
+
+namespace :integration do
+ def project_name
+ File.expand_path(Rails.root).split("/").last
+ end
+
+ def p80(message)
+ puts "-"*80
+ puts message if message
+ yield if block_given?
+ end
+
+ def remove_old_backups(backup_dir)
+ backups_to_keep = ENV['NUMBER_OF_BACKUPS_TO_KEEP'] || 30
+ backups = []
+ Find.find(backup_dir) { |file_name| backups << file_name if !File.directory?(file_name) && file_name =~ /.*\.tar.gz$/ }
+ backups.sort!
+ (backups - backups.last(backups_to_keep - 1)).each do |file_name|
+ puts "Removing #{file_name}..."
+ FileUtils.rm(file_name)
+ end