From 15750f4817f2d869eef04370a459bf3d02a3a15c Mon Sep 17 00:00:00 2001 From: Vitor Baptista Date: Mon, 6 Aug 2012 23:07:14 -0300 Subject: [PATCH] Upgrading thoughtbot/limerick_rake plugin. --- vendor/plugins/limerick_rake/MIT-LICENSE | 2 +- vendor/plugins/limerick_rake/README.md | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ vendor/plugins/limerick_rake/README.textile | 140 -------------------------------------------------------------------------------------------------------------------------------------------- vendor/plugins/limerick_rake/Rakefile | 2 ++ vendor/plugins/limerick_rake/lib/find_mass_assignment.rb | 32 ++++++++++++++++---------------- vendor/plugins/limerick_rake/lib/limerick_rake.rb | 5 +++++ vendor/plugins/limerick_rake/lib/limerick_rake/engine.rb | 6 ++++++ vendor/plugins/limerick_rake/lib/limerick_rake/version.rb | 3 +++ vendor/plugins/limerick_rake/lib/tasks/backup.rake | 40 ++++++++++++++++++++++++++++++++++++++++ vendor/plugins/limerick_rake/lib/tasks/coverage.rake | 14 ++++++++++++++ vendor/plugins/limerick_rake/lib/tasks/db/bootstrap.rake | 15 +++++++++++++++ vendor/plugins/limerick_rake/lib/tasks/db/indexes.rake | 22 ++++++++++++++++++++++ vendor/plugins/limerick_rake/lib/tasks/db/recreate.rake | 4 ++++ vendor/plugins/limerick_rake/lib/tasks/db/shell.rake | 26 ++++++++++++++++++++++++++ vendor/plugins/limerick_rake/lib/tasks/db/validate_models.rake | 31 +++++++++++++++++++++++++++++++ vendor/plugins/limerick_rake/lib/tasks/find_mass_assignment_tasks.rake | 5 +++++ vendor/plugins/limerick_rake/lib/tasks/git.rake | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ vendor/plugins/limerick_rake/lib/tasks/haml_sass.rake | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ vendor/plugins/limerick_rake/lib/tasks/rails_two.rake | 20 ++++++++++++++++++++ vendor/plugins/limerick_rake/lib/tasks/svn.rake | 21 +++++++++++++++++++++ vendor/plugins/limerick_rake/limerick_rake.gemspec | 35 +++++++++++++++++------------------ vendor/plugins/limerick_rake/tasks/backup.rake | 39 --------------------------------------- vendor/plugins/limerick_rake/tasks/coverage.rake | 14 -------------- vendor/plugins/limerick_rake/tasks/db/bootstrap.rake | 15 --------------- vendor/plugins/limerick_rake/tasks/db/indexes.rake | 22 ---------------------- vendor/plugins/limerick_rake/tasks/db/shell.rake | 23 ----------------------- vendor/plugins/limerick_rake/tasks/db/validate_models.rake | 27 --------------------------- vendor/plugins/limerick_rake/tasks/find_mass_assignment_tasks.rake | 5 ----- vendor/plugins/limerick_rake/tasks/git.rake | 109 ------------------------------------------------------------------------------------------------------------- vendor/plugins/limerick_rake/tasks/haml_sass.rake | 78 ------------------------------------------------------------------------------ vendor/plugins/limerick_rake/tasks/rails_two.rake | 20 -------------------- vendor/plugins/limerick_rake/tasks/svn.rake | 21 --------------------- 32 files changed, 600 insertions(+), 548 deletions(-) create mode 100644 vendor/plugins/limerick_rake/README.md delete mode 100644 vendor/plugins/limerick_rake/README.textile create mode 100644 vendor/plugins/limerick_rake/lib/limerick_rake.rb create mode 100644 vendor/plugins/limerick_rake/lib/limerick_rake/engine.rb create mode 100644 vendor/plugins/limerick_rake/lib/limerick_rake/version.rb create mode 100644 vendor/plugins/limerick_rake/lib/tasks/backup.rake create mode 100644 vendor/plugins/limerick_rake/lib/tasks/coverage.rake create mode 100644 vendor/plugins/limerick_rake/lib/tasks/db/bootstrap.rake create mode 100644 vendor/plugins/limerick_rake/lib/tasks/db/indexes.rake create mode 100644 vendor/plugins/limerick_rake/lib/tasks/db/recreate.rake create mode 100644 vendor/plugins/limerick_rake/lib/tasks/db/shell.rake create mode 100644 vendor/plugins/limerick_rake/lib/tasks/db/validate_models.rake create mode 100644 vendor/plugins/limerick_rake/lib/tasks/find_mass_assignment_tasks.rake create mode 100644 vendor/plugins/limerick_rake/lib/tasks/git.rake create mode 100644 vendor/plugins/limerick_rake/lib/tasks/haml_sass.rake create mode 100644 vendor/plugins/limerick_rake/lib/tasks/rails_two.rake create mode 100644 vendor/plugins/limerick_rake/lib/tasks/svn.rake delete mode 100644 vendor/plugins/limerick_rake/tasks/backup.rake delete mode 100644 vendor/plugins/limerick_rake/tasks/coverage.rake delete mode 100644 vendor/plugins/limerick_rake/tasks/db/bootstrap.rake delete mode 100644 vendor/plugins/limerick_rake/tasks/db/indexes.rake delete mode 100644 vendor/plugins/limerick_rake/tasks/db/shell.rake delete mode 100644 vendor/plugins/limerick_rake/tasks/db/validate_models.rake delete mode 100644 vendor/plugins/limerick_rake/tasks/find_mass_assignment_tasks.rake delete mode 100644 vendor/plugins/limerick_rake/tasks/git.rake delete mode 100644 vendor/plugins/limerick_rake/tasks/haml_sass.rake delete mode 100644 vendor/plugins/limerick_rake/tasks/rails_two.rake delete mode 100644 vendor/plugins/limerick_rake/tasks/svn.rake diff --git a/vendor/plugins/limerick_rake/MIT-LICENSE b/vendor/plugins/limerick_rake/MIT-LICENSE index dbacb62..d7381cf 100644 --- a/vendor/plugins/limerick_rake/MIT-LICENSE +++ b/vendor/plugins/limerick_rake/MIT-LICENSE @@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/limerick_rake/README.md b/vendor/plugins/limerick_rake/README.md new file mode 100644 index 0000000..1b96187 --- /dev/null +++ b/vendor/plugins/limerick_rake/README.md @@ -0,0 +1,166 @@ +Limerick Rake +============= + +A collection of useful rake tasks. + +To use in a Rails app, in your Gemfile: + + gem 'limerick_rake' + +DEPRECATED +---------- + +We no longer use `limerick_rake`, and as such no longer maintain it. If you +wish to take over the project please email . + +Database +-------- + +Read tasks/database.rake for details for configuration. + + rake db:bootstrap:load # Load initial database fixtures (in db/bootstrap/*.yml) into the current environment's database. Load specific fixtures using FIXTURES=x,y + rake db:indexes:missing # Prints a list of unindexed foreign keys so you can index them. + rake db:shell # Launches the database shell using the values defined in config/database.yml. + rake db:validate_models # Run model validations on all model records in database. + rake db:recreate # Recreate database with seeds (drop, create, migrate and seed) + +Git +--- + + rake git:push:staging # Merge a branch into the origin/staging branch. + rake git:push:production # Merge the staging branch into origin/production for launch. + rake git:diff:staging # Show the difference between current branch and origin/staging. + rake git:diff:production # Show the difference between origin/staging and origin/production. + rake git:pull:suspenders # Pull updates from suspenders, the thoughtbot rails template. + rake git:branch:production #Branch origin/production into BRANCH locally. + +Backup +------ + + rake backup:db # Backup the current database. Timestamped file is created as :rails_root/../db-name-timestamp.sql + rake backup:assets # Backup all assets under public/system. File is created as :rails_root/../system.tgz + +Haml & Sass +----------- + + rake sass:all_css2sass # Convert all CSS files in public/stylesheets to Sass. + rake sass:all_sass2css # Convert all Sass files to CSS. + rake haml:all_html2haml # Convert all HTML files to Haml. + +Rails 2+ +-------- + + rake rails_two:rename_views # Renames all .rhtml views to .html.erb, .rjs to .js.rjs, .rxml to .xml.builder and .haml to .html.haml. + +Subversion +---------- + + rake svn:add # Adds all files with an svn status flag of '?' + rake svn:delete # Deletes all files with an svn status flag of '!' + rake svn:log # Writes the log file to doc/svn_log.txt + rake svn:update\_svn\_ignore # Updates svn:ignore from .svnignore + +Test Coverage +------------- + +Install rcov from http://github.com/mergulhao/rcov + + rake test:coverage # Uses rcov to provide reports about test coverage of your application. + +Mass Assignment +--------------- + +From "mhartl":http://github.com/mhartl/find_mass_assignment + + rake find_mass_assignment + +The Limerick Rake +================= + +Traditional Irish song. [YouTube](http://www.youtube.com/v/e8moLHIW8xw) + + I am a young fellow that's easy and bold, + In Castletown conners I'm very well known. + In Newcastle West I spent many a note, + With Kitty and Judy and Mary. + + My father rebuked me for being such a rake, + And spending me time in such frolicsome ways, + But I ne'er could forget the good nature of Jane, + Agus fágaimíd siúd mar atá sé. + + My parents had reared me to shake and to mow, + To plough and to harrow, to reap and to sow. + But my heart being airy to drop it so low, + I set out on high speculation. + + On paper and parchment they taught me to write, + In Euclid and grammar they opened my eyes, + And in multiplication in truth I was bright, + Agus fágaimíd siúd mar atá sé. + + If I chance for to go to the town of Rathkeale, + The girls all round me do flock on the square. + Some give me a bottle and others sweet cakes, + To treat me unknown to their parents. + + There is one from Askeaton and one from the Pike, + Another from Arda, my heart was beguiled, + Tho' being from the mountains her stockings are white, + Agus fágaimíd siúd mar atá sé. + + To quarrel for riches I ne'er was inclined, + For the greatest of misers that must leave all behind. + I'll purchase a cow that will never run dry, + And I'll milk her by twisting her horn. + + John Damer of Shronel had plenty of gold, + And Lord Devonshire's treasures are twenty times more, + But he's laid on his back among nettles and stones, + Agus fágaimíd siúd mar atá sé. + + The old cow could be milked without clover or grass, + She'd be pampered with corn, good barley and hops. + She's warm and stout, and she's free in the paps, + And she'll milk without spancil or halter. + + The man that will drink it will cock his caubeen, + And if anyone laughs there'd be wigs on the green, + And the feeble old hag will get supple and free, + Agus fágaimíd siúd mar atá sé. + + There's some say I'm foolish and more say I'm wise, + But being fond of the women I think is no crime, + For the son of King David had ten hundred wives, + And his wisdom was highly regarded. + + I'll take a good garden and live at my ease, + And each woman and child can partake of the same, + If there'd be war in the cabin, themselves they'd be to blame, + Agus fágaimíd siúd mar atá sé. + + And now for the future I mean to be wise, + And I'll send for the women that acted so kind, + I'd marry them all on the morrow by and by, + If the clergy agree to the bargain. + + And when I'd be old and my soul is at peace, + These women will crowd for to cry at my wake, + And their sons and their daughters will offer their prayer, + To the Lord for the soul of their father. + +Credits +------- + +![thoughtbot](http://thoughtbot.com/images/tm/logo.png) + +Limerick Rake is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community) + +Thank you to all [the contributors](https://github.com/thoughtbot/limerick_rake/contributors)! + +The names and logos for thoughtbot are trademarks of thoughtbot, inc. + +License +------- + +Limerick Rake is Copyright © 2008-2011 thoughtbot. It is free software, and may be redistributed under the terms specified in the LICENSE file. diff --git a/vendor/plugins/limerick_rake/README.textile b/vendor/plugins/limerick_rake/README.textile deleted file mode 100644 index 59d2295..0000000 --- a/vendor/plugins/limerick_rake/README.textile +++ /dev/null @@ -1,140 +0,0 @@ -Limerick Rake -============= - -A collection of useful rake tasks. - -To use in a Rails app: - - script/plugin install git://github.com/thoughtbot/limerick_rake.git - -h2. Database - -Read tasks/database.rake for details for configuration. - -* rake db:bootstrap:load - Load initial database fixtures (in db/bootstrap/*.yml) into the current environment's database. Load specific fixtures using FIXTURES=x,y -* rake db:indexes:missing - Prints a list of unindexed foreign keys so you can index them. -* rake db:shell - Launches the database shell using the values defined in config/database.yml. -* rake db:validate_models - Run model validations on all model records in database. - -h2. Git - -* rake git:push:staging - Merge a branch into the origin/staging branch. -* rake git:push:production - Merge the staging branch into origin/production for launch. -* rake git:diff:staging - Show the difference between current branch and origin/staging. -* rake git:diff:production - Show the difference between origin/staging and origin/production. -* rake git:pull:suspenders - Pull updates from suspenders, the thoughtbot rails template. -* rake git:branch:production - Branch origin/production into BRANCH locally. - -h2. Backup - -* rake backup:db - Backup the current database. Timestamped file is created as :rails_root/../db-name-timestamp.sql -* rake backup:assets - Backup all assets under public/system. File is created as :rails_root/../system.tgz - -h2. Haml & Sass - -* rake sass:all_css2sass - Convert all CSS files in public/stylesheets to Sass. -* rake sass:all_sass2css - Convert all Sass files to CSS. -* rake haml:all_html2haml - Convert all HTML files to Haml. - -h2. Rails 2+ - -* rake rails_two:rename_views - Renames all .rhtml views to .html.erb, .rjs to .js.rjs, .rxml to .xml.builder and .haml to .html.haml. - -h2. Subversion - -* rake svn:add - Adds all files with an svn status flag of '?' -* rake svn:delete - Deletes all files with an svn status flag of '!' -* rake svn:log - Writes the log file to doc/svn_log.txt -* rake svn:update\_svn\_ignore - Updates svn:ignore from .svnignore - -h2. Test Coverage - -Install rcov from http://github.com/mergulhao/rcov - -* rake test:coverage - Uses rcov to provide reports about test coverage of your application. - -h2. Mass Assignment - -From "mhartl":http://github.com/mhartl/find_mass_assignment - -* rake find_mass_assignment - -The Limerick Rake -================= - -Traditional Irish song. "YouTube":http://www.youtube.com/v/e8moLHIW8xw - - I am a young fellow that's easy and bold, - In Castletown conners I'm very well known. - In Newcastle West I spent many a note, - With Kitty and Judy and Mary. - - My father rebuked me for being such a rake, - And spending me time in such frolicsome ways, - But I ne'er could forget the good nature of Jane, - Agus fágaimíd siúd mar atá sé. - - My parents had reared me to shake and to mow, - To plough and to harrow, to reap and to sow. - But my heart being airy to drop it so low, - I set out on high speculation. - - On paper and parchment they taught me to write, - In Euclid and grammar they opened my eyes, - And in multiplication in truth I was bright, - Agus fágaimíd siúd mar atá sé. - - If I chance for to go to the town of Rathkeale, - The girls all round me do flock on the square. - Some give me a bottle and others sweet cakes, - To treat me unknown to their parents. - - There is one from Askeaton and one from the Pike, - Another from Arda, my heart was beguiled, - Tho' being from the mountains her stockings are white, - Agus fágaimíd siúd mar atá sé. - - To quarrel for riches I ne'er was inclined, - For the greatest of misers that must leave all behind. - I'll purchase a cow that will never run dry, - And I'll milk her by twisting her horn. - - John Damer of Shronel had plenty of gold, - And Lord Devonshire's treasures are twenty times more, - But he's laid on his back among nettles and stones, - Agus fágaimíd siúd mar atá sé. - - The old cow could be milked without clover or grass, - She'd be pampered with corn, good barley and hops. - She's warm and stout, and she's free in the paps, - And she'll milk without spancil or halter. - - The man that will drink it will cock his caubeen, - And if anyone laughs there'd be wigs on the green, - And the feeble old hag will get supple and free, - Agus fágaimíd siúd mar atá sé. - - There's some say I'm foolish and more say I'm wise, - But being fond of the women I think is no crime, - For the son of King David had ten hundred wives, - And his wisdom was highly regarded. - - I'll take a good garden and live at my ease, - And each woman and child can partake of the same, - If there'd be war in the cabin, themselves they'd be to blame, - Agus fágaimíd siúd mar atá sé. - - And now for the future I mean to be wise, - And I'll send for the women that acted so kind, - I'd marry them all on the morrow by and by, - If the clergy agree to the bargain. - - And when I'd be old and my soul is at peace, - These women will crowd for to cry at my wake, - And their sons and their daughters will offer their prayer, - To the Lord for the soul of their father. - -License -------- - -MIT License, under the same terms as Ruby. diff --git a/vendor/plugins/limerick_rake/Rakefile b/vendor/plugins/limerick_rake/Rakefile index 50ea354..7fd127e 100644 --- a/vendor/plugins/limerick_rake/Rakefile +++ b/vendor/plugins/limerick_rake/Rakefile @@ -1,2 +1,4 @@ +require 'bundler/gem_tasks' + task :default do end diff --git a/vendor/plugins/limerick_rake/lib/find_mass_assignment.rb b/vendor/plugins/limerick_rake/lib/find_mass_assignment.rb index e5ce772..34f1e61 100644 --- a/vendor/plugins/limerick_rake/lib/find_mass_assignment.rb +++ b/vendor/plugins/limerick_rake/lib/find_mass_assignment.rb @@ -2,22 +2,22 @@ # http://github.com/mhartl/find_mass_assignment require 'active_support' - + # Find potential mass assignment problems. # The method is to scan the controllers for likely mass assignment, # and then find the corresponding models that *don't* have # attr_accessible defined. Any time that happens, it's a potential problem. - + class String - + @@cache = {} - + # A regex to match likely cases of mass assignment # Examples of matching strings: # "Foo.new( { :bar => 'baz' } )" # "Foo.update_attributes!(params[:foo])" MASS_ASSIGNMENT = /(\w+)\.(new|create|update_attributes|build)!*\(/ - + # Return the strings that represent potential mass assignment problems. # The MASS_ASSIGNMENT regex returns, e.g., ['Post', 'new'] because of # the grouping methods; we want the first of the two for each match. @@ -28,17 +28,17 @@ class String def mass_assignment_models scan(MASS_ASSIGNMENT).map { |problem| problem.first.classify } end - + # Return true if the string has potential mass assignment code. def mass_assignment? self =~ MASS_ASSIGNMENT end - + # Return true if the model defines attr_accessible. # Note that 'attr_accessible' must be preceded by nothing other than # whitespace; this catches cases where attr_accessible is commented out. def attr_accessible? - model = "#{RAILS_ROOT}/app/models/#{self.classify}.rb" + model = "#{Rails.root.to_s}/app/models/#{self.classify}.rb" if File.exist?(model) return @@cache[model] unless @@cache[model].nil? @@cache[model] = File.open(model).read =~ /^\s*attr_accessible/ @@ -48,17 +48,17 @@ class String true end end - + # Returnt true if a model does not define attr_accessible. def problem? not attr_accessible? end - + # Return true if a line has a problem model (no attr_accessible). def problem_model? mass_assignment_models.find { |model| model.problem? } end - + # Return true if a controller string has a (likely) mass assignment problem. # This is true if at least one of the controller's lines # (1) Has a likely mass assignment @@ -67,9 +67,9 @@ class String File.open(self).find { |l| l.mass_assignment? and l.problem_model? } end end - + module MassAssignment - + def self.print_mass_assignment_problems(controller) lines = File.open(controller) lines.each_with_index do |line, number| @@ -78,9 +78,9 @@ module MassAssignment end end end - + def self.find - controllers = Dir.glob("#{RAILS_ROOT}/app/controllers/*_controller.rb") + controllers = Dir.glob("#{Rails.root.to_s}/app/controllers/*_controller.rb") controllers.each do |controller| if controller.mass_assignment_problem? puts "\n#{controller}" @@ -88,4 +88,4 @@ module MassAssignment end end end -end \ No newline at end of file +end diff --git a/vendor/plugins/limerick_rake/lib/limerick_rake.rb b/vendor/plugins/limerick_rake/lib/limerick_rake.rb new file mode 100644 index 0000000..38c8f15 --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/limerick_rake.rb @@ -0,0 +1,5 @@ +require 'limerick_rake/version' + +module LimerickRake + require 'limerick_rake/engine' if defined?(Rails) +end diff --git a/vendor/plugins/limerick_rake/lib/limerick_rake/engine.rb b/vendor/plugins/limerick_rake/lib/limerick_rake/engine.rb new file mode 100644 index 0000000..d5a3426 --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/limerick_rake/engine.rb @@ -0,0 +1,6 @@ +module LimerickRake + + class Engine < Rails::Engine + end + +end diff --git a/vendor/plugins/limerick_rake/lib/limerick_rake/version.rb b/vendor/plugins/limerick_rake/lib/limerick_rake/version.rb new file mode 100644 index 0000000..60dedeb --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/limerick_rake/version.rb @@ -0,0 +1,3 @@ +module LimerickRake + VERSION = '0.0.2'.freeze +end diff --git a/vendor/plugins/limerick_rake/lib/tasks/backup.rake b/vendor/plugins/limerick_rake/lib/tasks/backup.rake new file mode 100644 index 0000000..4fad4d8 --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/tasks/backup.rake @@ -0,0 +1,40 @@ +require 'fileutils' +require 'pathname' + +namespace :backup do + desc "Backup the current database. Timestamped file is created as :rails_root/../db-name-timestamp.sql" + task :db => :environment do + config = ActiveRecord::Base.configurations[Rails.env || 'development'] + filename = "#{config['database'].gsub(/_/, '-')}-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.sql" + backupdir = File.expand_path(File.join(Rails.root.to_s, '..')) + filepath = File.join(backupdir, filename) + mysqldump = `which mysqldump`.strip + options = "-e -u #{config['username']}" + options += " -p'#{config['password']}'" if config['password'] + options += " -h #{config['host']}" if config['host'] + options += " -S #{config['socket']}" if config['socket'] + + raise RuntimeError, "I only work with mysql." unless config['adapter'] == 'mysql' + raise RuntimeError, "Cannot find mysqldump." if mysqldump.blank? + + FileUtils.mkdir_p backupdir + `#{mysqldump} #{options} #{config['database']} > #{filepath}` + puts "#{config['database']} => #{filepath}" + end + + + desc "Backup all assets under public/system. File is created as :rails_root/../system.tgz" + task :assets do + path = (Pathname.new(Rails.root.to_s) + 'public' + 'system').realpath + base_dir = path.parent + system_dir = path.basename + outfile = (Pathname.new(Rails.root.to_s) + '..').realpath + 'system.tgz' + + cd base_dir + `tar -czf #{outfile} #{system_dir}` + puts "Assets => #{outfile}" + end +end + +desc 'Backup the database and all assets by running the backup:db and backup:assets tasks.' +task :backup => ["backup:db", "backup:assets"] diff --git a/vendor/plugins/limerick_rake/lib/tasks/coverage.rake b/vendor/plugins/limerick_rake/lib/tasks/coverage.rake new file mode 100644 index 0000000..0158eb7 --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/tasks/coverage.rake @@ -0,0 +1,14 @@ +namespace :test do + + desc 'Measures test coverage' + task :coverage do + rm_f "coverage" + rm_f "coverage.data" + rcov = "rcov -Itest --rails --aggregate coverage.data -T -x \" rubygems/*,/Library/Ruby/Site/*,gems/*,rcov*\"" + system("#{rcov} --no-html test/unit/*_test.rb test/unit/helpers/*_test.rb") + system("#{rcov} --no-html test/functional/*_test.rb") + system("#{rcov} --html test/integration/*_test.rb") + system("open coverage/index.html") if PLATFORM['darwin'] + end + +end diff --git a/vendor/plugins/limerick_rake/lib/tasks/db/bootstrap.rake b/vendor/plugins/limerick_rake/lib/tasks/db/bootstrap.rake new file mode 100644 index 0000000..665d178 --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/tasks/db/bootstrap.rake @@ -0,0 +1,15 @@ +namespace :db do + desc "Loads a schema.rb file into the database and then loads the initial database fixtures." + task :bootstrap => ['db:schema:load', 'db:bootstrap:load'] + + namespace :bootstrap do + desc "Load initial database fixtures (in db/bootstrap/*.yml) into the current environment's database. Load specific fixtures using FIXTURES=x,y" + task :load => :environment do + require 'active_record/fixtures' + ActiveRecord::Base.establish_connection(Rails.env.to_sym) + (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Rails.root.to_s, 'db', 'bootstrap', '*.{yml,csv}'))).each do |fixture_file| + Fixtures.create_fixtures('db/bootstrap', File.basename(fixture_file, '.*')) + end + end + end +end diff --git a/vendor/plugins/limerick_rake/lib/tasks/db/indexes.rake b/vendor/plugins/limerick_rake/lib/tasks/db/indexes.rake new file mode 100644 index 0000000..499ebe7 --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/tasks/db/indexes.rake @@ -0,0 +1,22 @@ +namespace :db do + namespace :indexes do + desc "Prints a list of unindexed foreign keys so you can index them" + task :missing => :environment do + indexes = {} + conn = ActiveRecord::Base.connection + conn.tables.each do |table| + indexed_columns = conn.indexes(table).map { |i| i.columns }.flatten + conn.columns(table).each do |column| + if column.name.match(/_id$/) && !indexed_columns.include?(column.name) + indexes[table] ||= [] + indexes[table] << column.name + end + end + end + puts "Foreign Keys:" + indexes.sort.each do |table, columns| + puts columns.map { |c| "\s\sadd_index '#{table}', '#{c}'\n"} + end + end + end +end diff --git a/vendor/plugins/limerick_rake/lib/tasks/db/recreate.rake b/vendor/plugins/limerick_rake/lib/tasks/db/recreate.rake new file mode 100644 index 0000000..e4a2bbc --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/tasks/db/recreate.rake @@ -0,0 +1,4 @@ + namespace :db do + desc "Recreate database. Drop, create, migrate and seed it." + task :recreate => [:drop, :create, :migrate, :seed] + end diff --git a/vendor/plugins/limerick_rake/lib/tasks/db/shell.rake b/vendor/plugins/limerick_rake/lib/tasks/db/shell.rake new file mode 100644 index 0000000..3b5c867 --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/tasks/db/shell.rake @@ -0,0 +1,26 @@ +namespace :db do + desc 'Launches the database shell using the values defined in config/database.yml' + task :shell => :environment do + config = ActiveRecord::Base.configurations[Rails.env || 'development'] + command = "" + + case config['adapter'] + when 'mysql' + command << "mysql " + command << "--host=#{config['host'] || 'localhost'} " + command << "--port=#{config['port'] || 3306} " + command << "--user=#{config['username'] || 'root'} " + command << "--password=#{config['password'] || ''} " + command << config['database'] + when 'postgresql' + command << "psql " + command << "-h #{config['host'] || 'localhost'} " + command << "-p #{config['port'] || 5432} " + command << "-U #{config['username'] || 'postgres'} " + command << "\"dbname=#{config['database']} password=#{config['password']}\"" + else + command << "echo Unsupported database adapter: #{config['adapter']}" + end + system command + end +end diff --git a/vendor/plugins/limerick_rake/lib/tasks/db/validate_models.rake b/vendor/plugins/limerick_rake/lib/tasks/db/validate_models.rake new file mode 100644 index 0000000..173f4f5 --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/tasks/db/validate_models.rake @@ -0,0 +1,31 @@ +namespace :db do + # From http://blog.hasmanythrough.com/2006/8/27/validate-all-your-records + desc "Run model validations on all model records in database" + task :validate_models => :environment do + # because rails loads stuff on demand... + Dir.glob(Rails.root.to_s + '/app/models/**/*.rb').each do |file| + silence_warnings do + require file + end + end + + Object.subclasses_of(ActiveRecord::Base).select { |c| c.base_class == c}.sort_by(&:name).each do |klass| + next if klass.name == "CGI::Session::ActiveRecordStore::Session" + unless klass.table_exists? + puts "WARNING: Could not find table for #{klass} (skipping)" + next + end + invalid_count = 0 + total = klass.count + chunk_size = 1000 + (total / chunk_size + 1).times do |i| + chunk = klass.find(:all, :offset => (i * chunk_size), :limit => chunk_size) + chunk.reject(&:valid?).each do |record| + invalid_count += 1 + puts "#{klass} #{record.id}: #{record.errors.full_messages.to_sentence}" + end rescue nil + end + puts "#{invalid_count} of #{total} #{klass.name.pluralize} are invalid." if invalid_count > 0 + end + end +end diff --git a/vendor/plugins/limerick_rake/lib/tasks/find_mass_assignment_tasks.rake b/vendor/plugins/limerick_rake/lib/tasks/find_mass_assignment_tasks.rake new file mode 100644 index 0000000..750eb4d --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/tasks/find_mass_assignment_tasks.rake @@ -0,0 +1,5 @@ +desc "Find potential mass assignment vulnerabilities" +task :find_mass_assignment do + require File.join(File.dirname(__FILE__), '../../lib/find_mass_assignment.rb') + MassAssignment.find +end diff --git a/vendor/plugins/limerick_rake/lib/tasks/git.rake b/vendor/plugins/limerick_rake/lib/tasks/git.rake new file mode 100644 index 0000000..dddacc3 --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/tasks/git.rake @@ -0,0 +1,109 @@ +module GitCommands + class ShellError < RuntimeError; end + + @logging = ENV['LOGGING'] != "false" + + def self.run cmd, *expected_exitstatuses + puts "+ #{cmd}" if @logging + output = `#{cmd} 2>&1` + puts output.gsub(/^/, "- ") if @logging + expected_exitstatuses << 0 if expected_exitstatuses.empty? + raise ShellError.new("ERROR: '#{cmd}' failed with exit status #{$?.exitstatus}") unless + [expected_exitstatuses].flatten.include?( $?.exitstatus ) + output + end + + def self.current_branch + run("git branch --no-color | grep '*' | cut -d ' ' -f 2").chomp + end + + def self.remote_branch_exists?(branch) + ! run("git branch -r --no-color | grep '#{branch}'").empty? + end + + def self.ensure_clean_working_directory! + return if run("git status", 0, 1).match(/working directory clean/) + raise "Must have clean working directory" + end + + def self.diff_staging + puts run("git diff HEAD origin/staging") + end + + def self.diff_production + puts run("git diff origin/staging origin/production") + end + + def self.push(src_branch, dst_branch) + raise "origin/#{dst_branch} branch does not exist" unless remote_branch_exists?("origin/#{dst_branch}") + ensure_clean_working_directory! + begin + run "git fetch" + run "git push -f origin #{src_branch}:#{dst_branch}" + rescue + puts "Pushing #{src_branch} to origin/#{dst_branch} failed." + raise + end + end + + def self.push_staging + push(current_branch, "staging") + end + + def self.push_production + push("origin/staging", "production") + end + + def self.branch_production(branch) + raise "You must specify a branch name." if branch.blank? + ensure_clean_working_directory! + run "git fetch" + run "git branch -f #{branch} origin/production" + run "git checkout #{branch}" + end + + def self.pull_template + ensure_clean_working_directory! + run "git pull git://github.com/thoughtbot/suspenders.git master" + end +end + +namespace :git do + namespace :push do + desc "Reset origin's staging branch to be the current branch." + task :staging do + GitCommands.push_staging + end + + desc "Reset origin's production branch to origin's staging branch." + task :production do + GitCommands.push_production + end + end + + namespace :diff do + desc "Show the difference between current branch and origin/staging." + task :staging do + GitCommands.diff_staging + end + + desc "Show the difference between origin/staging and origin/production." + task :production do + GitCommands.diff_production + end + end + + namespace :pull do + desc "Pull updates from suspenders, the thoughtbot rails template." + task :suspenders do + GitCommands.pull_template + end + end + + namespace :branch do + desc "Branch origin/production into BRANCH locally." + task :production do + GitCommands.branch_production(branch) + end + end +end diff --git a/vendor/plugins/limerick_rake/lib/tasks/haml_sass.rake b/vendor/plugins/limerick_rake/lib/tasks/haml_sass.rake new file mode 100644 index 0000000..a11f973 --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/tasks/haml_sass.rake @@ -0,0 +1,77 @@ +# Dan Croak, February 2008 + +@css_dir = "#{Rails.root.to_s}/public/stylesheets" +@sass_dir = "#{@css_dir}/sass" +@views_dir = "#{Rails.root.to_s}/app/views" + +def convert_css_to_sass(basename) + system "css2sass #{@css_dir}/#{basename}.css > #{@sass_dir}/#{basename}.sass" +end + +def convert_sass_to_css(basename) + system "sass #{@sass_dir}/#{basename}.sass > #{@css_dir}/#{basename}.css" +end + +def convert_html_to_haml(controller, basename) + extname = basename.include?("erb") ? ".html.erb" : ".rhtml" + basename = basename.split(".").first + system "html2haml #{@views_dir}/#{controller}/#{basename}#{extname} > #{@views_dir}/#{controller}/#{basename}.html.haml" + system "rm #{@views_dir}/#{controller}/#{basename}#{extname}" +end + +namespace :sass do + desc "Convert all CSS files to Sass." + task :all_css2sass => :environment do + begin + Dir.mkdir(@sass_dir) + rescue Exception => e + nil + end + + files = Dir.entries(@css_dir).find_all do |f| + File.extname("#{@css_dir}/#{f}") == ".css" && + File.basename("#{@css_dir}/#{f}") !~ /^[.]/ + end + + files.each do |filename| + basename = File.basename("#{@css_dir}/#{filename}", ".css") + convert_css_to_sass basename + convert_sass_to_css basename + end + end + + desc "Convert all Sass files to CSS." + task :all_sass2css => :environment do + files = Dir.entries(@sass_dir).find_all do |f| + File.extname("#{@sass_dir}/#{f}") == ".sass" && + File.basename("#{@sass_dir}/#{f}") !~ /^[.]/ + end + + files.each do |filename| + basename = File.basename("#{@sass_dir}/#{filename}", ".sass") + convert_sass_to_css basename + end + end +end + +namespace :haml do + desc "Convert all HTML files to Haml." + task :all_html2haml => :environment do + controllers = Dir.entries(@views_dir).find_all do |c| + File.directory?("#{@views_dir}/#{c}") && + File.basename("#{@views_dir}/#{c}") !~ /^[.]/ + end + + controllers.each do |controller| + files = Dir.entries("#{@views_dir}/#{controller}").find_all do |f| + (File.new("#{@views_dir}/#{controller}/#{f}").path.include?(".html.erb") || + File.new("#{@views_dir}/#{controller}/#{f}").path.include?(".rhtml")) && + File.basename("#{@views_dir}/#{controller}/#{f}") !~ /^[.]/ + end + files.each do |filename| + basename = File.basename("#{@views_dir}/#{controller}/#{filename}") + convert_html_to_haml controller, basename + end + end + end +end diff --git a/vendor/plugins/limerick_rake/lib/tasks/rails_two.rake b/vendor/plugins/limerick_rake/lib/tasks/rails_two.rake new file mode 100644 index 0000000..5061366 --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/tasks/rails_two.rake @@ -0,0 +1,20 @@ +desc 'Renames all .rhtml views to .html.erb, .rjs to .js.rjs, .rxml to .xml.builder and .haml to .html.haml' +namespace :rails_two do + task :rename_views do + Dir.glob('app/views/**/[^_]*.rhtml').each do |file| + puts `git mv #{file} #{file.gsub(/\.rhtml$/, '.html.erb')}` + end + + Dir.glob('app/views/**/[^_]*.rjs').each do |file| + puts `git mv #{file} #{file.gsub(/\.rjs$/, '.js.rjs')}` + end + + Dir.glob('app/views/**/[^_]*.rxml').each do |file| + puts `git mv #{file} #{file.gsub(/\.rxml$/, '.xml.builder')}` + end + + Dir.glob('app/views/**/[^_]*.haml').each do |file| + puts `git mv #{file} #{file.gsub(/\.haml$/, '.html.haml')}` + end + end +end diff --git a/vendor/plugins/limerick_rake/lib/tasks/svn.rake b/vendor/plugins/limerick_rake/lib/tasks/svn.rake new file mode 100644 index 0000000..aab33cd --- /dev/null +++ b/vendor/plugins/limerick_rake/lib/tasks/svn.rake @@ -0,0 +1,21 @@ +# Pulled together from various mailing lists. + +namespace :svn do + desc "Adds all files with an svn status flag of '?'" + task(:add) { system %q(svn status | awk '/\\?/ {print $2}' | xargs svn add) } + + desc "Deletes all files with an svn status flag of '!'" + task(:delete) { system %q(svn status | awk '/\\!/ {print $2}' | xargs svn delete) } + + desc "Writes the log file to doc/svn_log.txt" + task(:log) do + File.delete("#{Rails.root.to_s}/doc/svn_log.txt") if File::exists?("#{Rails.root.to_s}/doc/svn_log.txt") + File.new("#{Rails.root.to_s}/doc/svn_log.txt", "w+") + system("svn log >> doc/svn_log.txt") + end + + desc 'Updates svn:ignore from .svnignore' + task(:update_svn_ignore) do + system %q(svn propset svn:ignore -F .svnignore .) + end +end diff --git a/vendor/plugins/limerick_rake/limerick_rake.gemspec b/vendor/plugins/limerick_rake/limerick_rake.gemspec index e388cf4..27ca976 100644 --- a/vendor/plugins/limerick_rake/limerick_rake.gemspec +++ b/vendor/plugins/limerick_rake/limerick_rake.gemspec @@ -1,20 +1,19 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) +require "limerick_rake/version" + Gem::Specification.new do |s| - s.name = "limerick_rake" - s.version = "0.0.2" - s.date = "2008-10-07" - s.summary = "A collection of useful rake tasks." - s.email = "support@thoughtbot.com" - s.homepage = "http://github.com/thoughtbot/limerick_rake" + s.name = "limerick_rake" + s.version = LimerickRake::VERSION.dup + s.platform = Gem::Platform::RUBY + s.authors = ["the Ruby community", "thoughtbot, inc."] + s.email = "support@thoughtbot.com" + s.homepage = "http://github.com/thoughtbot/limerick_rake" + s.summary = "A collection of useful rake tasks." s.description = "A collection of useful rake tasks." - s.authors = ["the Ruby community", "thoughtbot, inc."] - s.files = ["README.textile", - "limerick_rake.gemspec", - "tasks/backup.rake", - "tasks/db/bootstrap.rake", - "tasks/db/indexes.rake", - "tasks/db/shell.rake", - "tasks/db/validate_models.rake", - "tasks/git.rake", - "tasks/haml_sass.rake", - "tasks/svn.rake"] -end \ No newline at end of file + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.require_paths = ["lib"] +end diff --git a/vendor/plugins/limerick_rake/tasks/backup.rake b/vendor/plugins/limerick_rake/tasks/backup.rake deleted file mode 100644 index d476364..0000000 --- a/vendor/plugins/limerick_rake/tasks/backup.rake +++ /dev/null @@ -1,39 +0,0 @@ -require 'fileutils' -require 'pathname' - -namespace :backup do - desc "Backup the current database. Timestamped file is created as :rails_root/../db-name-timestamp.sql" - task :db => :environment do - config = ActiveRecord::Base.configurations[RAILS_ENV || 'development'] - filename = "#{config['database'].gsub(/_/, '-')}-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.sql" - backupdir = File.expand_path(File.join(RAILS_ROOT, '..')) - filepath = File.join(backupdir, filename) - mysqldump = `which mysqldump`.strip - options = "-e -u #{config['username']}" - options += " -p#{config['password']}" if config['password'] - options += " -h #{config['host']}" if config['host'] - - raise RuntimeError, "I only work with mysql." unless config['adapter'] == 'mysql' - raise RuntimeError, "Cannot find mysqldump." if mysqldump.blank? - - FileUtils.mkdir_p backupdir - `#{mysqldump} #{options} #{config['database']} > #{filepath}` - puts "#{config['database']} => #{filepath}" - end - - - desc "Backup all assets under public/system. File is created as :rails_root/../system.tgz" - task :assets do - path = (Pathname.new(RAILS_ROOT) + 'public' + 'system').realpath - base_dir = path.parent - system_dir = path.basename - outfile = (Pathname.new(RAILS_ROOT) + '..').realpath + 'system.tgz' - - cd base_dir - `tar -czf #{outfile} #{system_dir}` - puts "Assets => #{outfile}" - end -end - -desc 'Backup the database and all assets by running the backup:db and backup:assets tasks.' -task :backup => ["backup:db", "backup:assets"] diff --git a/vendor/plugins/limerick_rake/tasks/coverage.rake b/vendor/plugins/limerick_rake/tasks/coverage.rake deleted file mode 100644 index 0158eb7..0000000 --- a/vendor/plugins/limerick_rake/tasks/coverage.rake +++ /dev/null @@ -1,14 +0,0 @@ -namespace :test do - - desc 'Measures test coverage' - task :coverage do - rm_f "coverage" - rm_f "coverage.data" - rcov = "rcov -Itest --rails --aggregate coverage.data -T -x \" rubygems/*,/Library/Ruby/Site/*,gems/*,rcov*\"" - system("#{rcov} --no-html test/unit/*_test.rb test/unit/helpers/*_test.rb") - system("#{rcov} --no-html test/functional/*_test.rb") - system("#{rcov} --html test/integration/*_test.rb") - system("open coverage/index.html") if PLATFORM['darwin'] - end - -end diff --git a/vendor/plugins/limerick_rake/tasks/db/bootstrap.rake b/vendor/plugins/limerick_rake/tasks/db/bootstrap.rake deleted file mode 100644 index 44fc544..0000000 --- a/vendor/plugins/limerick_rake/tasks/db/bootstrap.rake +++ /dev/null @@ -1,15 +0,0 @@ -namespace :db do - desc "Loads a schema.rb file into the database and then loads the initial database fixtures." - task :bootstrap => ['db:schema:load', 'db:bootstrap:load'] - - namespace :bootstrap do - desc "Load initial database fixtures (in db/bootstrap/*.yml) into the current environment's database. Load specific fixtures using FIXTURES=x,y" - task :load => :environment do - require 'active_record/fixtures' - ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) - (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'db', 'bootstrap', '*.{yml,csv}'))).each do |fixture_file| - Fixtures.create_fixtures('db/bootstrap', File.basename(fixture_file, '.*')) - end - end - end -end diff --git a/vendor/plugins/limerick_rake/tasks/db/indexes.rake b/vendor/plugins/limerick_rake/tasks/db/indexes.rake deleted file mode 100644 index 76e2529..0000000 --- a/vendor/plugins/limerick_rake/tasks/db/indexes.rake +++ /dev/null @@ -1,22 +0,0 @@ -namespace :db do - namespace :indexes do - desc "Prints a list of unindexed foreign keys so you can index them" - task :missing => :environment do - indexes = {} - conn = ActiveRecord::Base.connection - conn.tables.each do |table| - indexed_columns = conn.indexes(table).map { |i| i.columns }.flatten - conn.columns(table).each do |column| - if column.name.match(/_id/) && !indexed_columns.include?(column.name) - indexes[table] ||= [] - indexes[table] << column.name - end - end - end - puts "Foreign Keys:" - indexes.each do |table, columns| - puts columns.map { |c| "\s\sadd_index '#{table}', '#{c}'\n"} - end - end - end -end \ No newline at end of file diff --git a/vendor/plugins/limerick_rake/tasks/db/shell.rake b/vendor/plugins/limerick_rake/tasks/db/shell.rake deleted file mode 100644 index d72e274..0000000 --- a/vendor/plugins/limerick_rake/tasks/db/shell.rake +++ /dev/null @@ -1,23 +0,0 @@ -namespace :db do - desc 'Launches the database shell using the values defined in config/database.yml' - task :shell => :environment do - config = ActiveRecord::Base.configurations[RAILS_ENV || 'development'] - command = "" - - case config['adapter'] - when 'mysql' - command << "mysql " - command << "--host=#{config['host'] || 'localhost'} " - command << "--port=#{config['port'] || 3306} " - command << "--user=#{config['username'] || 'root'} " - command << "--password=#{config['password'] || ''} " - command << config['database'] - when 'postgresql' - puts 'You should consider switching to MySQL or get off your butt and submit a patch' - else - command << "echo Unsupported database adapter: #{config['adapter']}" - end - - system command - end -end \ No newline at end of file diff --git a/vendor/plugins/limerick_rake/tasks/db/validate_models.rake b/vendor/plugins/limerick_rake/tasks/db/validate_models.rake deleted file mode 100644 index 5c21039..0000000 --- a/vendor/plugins/limerick_rake/tasks/db/validate_models.rake +++ /dev/null @@ -1,27 +0,0 @@ -namespace :db do - # From http://blog.hasmanythrough.com/2006/8/27/validate-all-your-records - desc "Run model validations on all model records in database" - task :validate_models => :environment do - # because rails loads stuff on demand... - Dir.glob(RAILS_ROOT + '/app/models/**/*.rb').each do |file| - silence_warnings do - require file - end - end - - Object.subclasses_of(ActiveRecord::Base).select { |c| c.base_class == c}.sort_by(&:name).each do |klass| - next if klass.name == "CGI::Session::ActiveRecordStore::Session" - invalid_count = 0 - total = klass.count - chunk_size = 1000 - (total / chunk_size + 1).times do |i| - chunk = klass.find(:all, :offset => (i * chunk_size), :limit => chunk_size) - chunk.reject(&:valid?).each do |record| - invalid_count += 1 - puts "#{klass} #{record.id}: #{record.errors.full_messages.to_sentence}" - end rescue nil - end - puts "#{invalid_count} of #{total} #{klass.name.pluralize} are invalid." if invalid_count > 0 - end - end -end diff --git a/vendor/plugins/limerick_rake/tasks/find_mass_assignment_tasks.rake b/vendor/plugins/limerick_rake/tasks/find_mass_assignment_tasks.rake deleted file mode 100644 index 2a30bcf..0000000 --- a/vendor/plugins/limerick_rake/tasks/find_mass_assignment_tasks.rake +++ /dev/null @@ -1,5 +0,0 @@ -desc "Find potential mass assignment vulnerabilities" -task :find_mass_assignment do - require File.join(File.dirname(__FILE__), "../lib/find_mass_assignment.rb") - MassAssignment.find -end \ No newline at end of file diff --git a/vendor/plugins/limerick_rake/tasks/git.rake b/vendor/plugins/limerick_rake/tasks/git.rake deleted file mode 100644 index 2c49ef4..0000000 --- a/vendor/plugins/limerick_rake/tasks/git.rake +++ /dev/null @@ -1,109 +0,0 @@ -module GitCommands - class ShellError < RuntimeError; end - - @logging = ENV['LOGGING'] != "false" - - def self.run cmd, *expected_exitstatuses - puts "+ #{cmd}" if @logging - output = `#{cmd} 2>&1` - puts output.gsub(/^/, "- ") if @logging - expected_exitstatuses << 0 if expected_exitstatuses.empty? - raise ShellError.new("ERROR: '#{cmd}' failed with exit status #{$?.exitstatus}") unless - [expected_exitstatuses].flatten.include?( $?.exitstatus ) - output - end - - def self.current_branch - run("git branch --no-color | grep '*' | cut -d ' ' -f 2").chomp - end - - def self.remote_branch_exists?(branch) - ! run("git branch -r --no-color | grep '#{branch}'").blank? - end - - def self.ensure_clean_working_directory! - return if run("git status", 0, 1).match(/working directory clean/) - raise "Must have clean working directory" - end - - def self.diff_staging - puts run("git diff HEAD origin/staging") - end - - def self.diff_production - puts run("git diff origin/staging origin/production") - end - - def self.push(src_branch, dst_branch) - raise "origin/#{dst_branch} branch does not exist" unless remote_branch_exists?("origin/#{dst_branch}") - ensure_clean_working_directory! - begin - run "git fetch" - run "git push -f origin #{src_branch}:#{dst_branch}" - rescue - puts "Pushing #{src_branch} to origin/#{dst_branch} failed." - raise - end - end - - def self.push_staging - push(current_branch, "staging") - end - - def self.push_production - push("origin/staging", "production") - end - - def self.branch_production(branch) - raise "You must specify a branch name." if branch.blank? - ensure_clean_working_directory! - run "git fetch" - run "git branch -f #{branch} origin/production" - run "git checkout #{branch}" - end - - def self.pull_template - ensure_clean_working_directory! - run "git pull git://github.com/thoughtbot/suspenders.git master" - end -end - -namespace :git do - namespace :push do - desc "Reset origin's staging branch to be the current branch." - task :staging do - GitCommands.push_staging - end - - desc "Reset origin's production branch to origin's staging branch." - task :production do - GitCommands.push_production - end - end - - namespace :diff do - desc "Show the difference between current branch and origin/staging." - task :staging do - GitCommands.diff_staging - end - - desc "Show the difference between origin/staging and origin/production." - task :production do - GitCommands.diff_production - end - end - - namespace :pull do - desc "Pull updates from suspenders, the thoughtbot rails template." - task :suspenders do - GitCommands.pull_template - end - end - - namespace :branch do - desc "Branch origin/production into BRANCH locally." - task :production do - GitCommands.branch_production(branch) - end - end -end diff --git a/vendor/plugins/limerick_rake/tasks/haml_sass.rake b/vendor/plugins/limerick_rake/tasks/haml_sass.rake deleted file mode 100644 index 839ac73..0000000 --- a/vendor/plugins/limerick_rake/tasks/haml_sass.rake +++ /dev/null @@ -1,78 +0,0 @@ -# Dan Croak, February 2008 - -@css_dir = "#{RAILS_ROOT}/public/stylesheets" -@sass_dir = "#{@css_dir}/sass" -@views_dir = "#{RAILS_ROOT}/app/views" - -def convert_css_to_sass(basename) - system "css2sass #{@css_dir}/#{basename}.css > #{@sass_dir}/#{basename}.sass" -end - -def convert_sass_to_css(basename) - system "sass #{@sass_dir}/#{basename}.sass > #{@css_dir}/#{basename}.css" -end - -def convert_html_to_haml(controller, basename) - extname = basename.include?("erb") ? ".html.erb" : ".rhtml" - basename = basename.split(".").first - system "html2haml #{@views_dir}/#{controller}/#{basename}#{extname} > #{@views_dir}/#{controller}/#{basename}.html.haml" - system "rm #{@views_dir}/#{controller}/#{basename}#{extname}" -end - -namespace :sass do - desc "Convert all CSS files to Sass." - task :all_css2sass => :environment do - begin - Dir.mkdir(@sass_dir) - rescue Exception => e - nil - end - - files = Dir.entries(@css_dir).find_all do |f| - File.extname("#{@css_dir}/#{f}") == ".css" && - File.basename("#{@css_dir}/#{f}") !~ /^[.]/ - end - - files.each do |filename| - basename = File.basename("#{@css_dir}/#{filename}", ".css") - convert_css_to_sass basename - convert_sass_to_css basename - end - end - - desc "Convert all Sass files to CSS." - task :all_sass2css => :environment do - files = Dir.entries(@sass_dir).find_all do |f| - File.extname("#{@sass_dir}/#{f}") == ".sass" && - File.basename("#{@sass_dir}/#{f}") !~ /^[.]/ - end - - files.each do |filename| - basename = File.basename("#{@sass_dir}/#{filename}", ".sass") - convert_sass_to_css basename - end - end -end - -namespace :haml do - desc "Convert all HTML files to Haml." - task :all_html2haml => :environment do - controllers = Dir.entries(@views_dir).find_all do |c| - File.directory?("#{@views_dir}/#{c}") && - File.basename("#{@views_dir}/#{c}") !~ /^[.]/ - end - - controllers.each do |controller| - files = Dir.entries("#{@views_dir}/#{controller}").find_all do |f| - (File.new("#{@views_dir}/#{controller}/#{f}").path.include?(".html.erb") || - File.new("#{@views_dir}/#{controller}/#{f}").path.include?(".rhtml")) && - File.basename("#{@views_dir}/#{controller}/#{f}") !~ /^[.]/ - end - files.each do |filename| - basename = File.basename("#{@views_dir}/#{controller}/#{filename}") - convert_html_to_haml controller, basename - end - end - end -end - diff --git a/vendor/plugins/limerick_rake/tasks/rails_two.rake b/vendor/plugins/limerick_rake/tasks/rails_two.rake deleted file mode 100644 index 2508cef..0000000 --- a/vendor/plugins/limerick_rake/tasks/rails_two.rake +++ /dev/null @@ -1,20 +0,0 @@ -desc 'Renames all .rhtml views to .html.erb, .rjs to .js.rjs, .rxml to .xml.builder and .haml to .html.haml' -namespace :rails_two do - task :rename_views do - Dir.glob('app/views/**/[^_]*.rhtml').each do |file| - puts `git mv #{file} #{file.gsub(/\.rhtml$/, '.html.erb')}` - end - - Dir.glob('app/views/**/[^_]*.rjs').each do |file| - puts `git mv #{file} #{file.gsub(/\.rjs$/, '.js.rjs')}` - end - - Dir.glob('app/views/**/[^_]*.rxml').each do |file| - puts `git mv #{file} #{file.gsub(/\.rxml$/, '.xml.builder')}` - end - - Dir.glob('app/views/**/[^_]*.haml').each do |file| - puts `git mv #{file} #{file.gsub(/\.haml$/, '.html.haml')}` - end - end -end \ No newline at end of file diff --git a/vendor/plugins/limerick_rake/tasks/svn.rake b/vendor/plugins/limerick_rake/tasks/svn.rake deleted file mode 100644 index cac7740..0000000 --- a/vendor/plugins/limerick_rake/tasks/svn.rake +++ /dev/null @@ -1,21 +0,0 @@ -# Pulled together from various mailing lists. - -namespace :svn do - desc "Adds all files with an svn status flag of '?'" - task(:add) { system %q(svn status | awk '/\\?/ {print $2}' | xargs svn add) } - - desc "Deletes all files with an svn status flag of '!'" - task(:delete) { system %q(svn status | awk '/\\!/ {print $2}' | xargs svn delete) } - - desc "Writes the log file to doc/svn_log.txt" - task(:log) do - File.delete("#{RAILS_ROOT}/doc/svn_log.txt") if File::exists?("#{RAILS_ROOT}/doc/svn_log.txt") - File.new("#{RAILS_ROOT}/doc/svn_log.txt", "w+") - system("svn log >> doc/svn_log.txt") - end - - desc 'Updates svn:ignore from .svnignore' - task(:update_svn_ignore) do - system %q(svn propset svn:ignore -F .svnignore .) - end -end -- libgit2 0.21.2