limerick_rake 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +140 -0
- data/limerick_rake.gemspec +20 -0
- data/tasks/backup.rake +39 -0
- data/tasks/db/bootstrap.rake +15 -0
- data/tasks/db/indexes.rake +22 -0
- data/tasks/db/shell.rake +23 -0
- data/tasks/db/validate_models.rake +27 -0
- data/tasks/git.rake +109 -0
- data/tasks/haml_sass.rake +78 -0
- data/tasks/svn.rake +21 -0
- metadata +65 -0
data/README.textile
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
Limerick Rake
|
2
|
+
=============
|
3
|
+
|
4
|
+
A collection of useful rake tasks.
|
5
|
+
|
6
|
+
To use in a Rails app:
|
7
|
+
|
8
|
+
script/plugin install git://github.com/thoughtbot/limerick_rake.git
|
9
|
+
|
10
|
+
h2. Database
|
11
|
+
|
12
|
+
Read tasks/database.rake for details for configuration.
|
13
|
+
|
14
|
+
* 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
|
15
|
+
* rake db:indexes:missing - Prints a list of unindexed foreign keys so you can index them.
|
16
|
+
* rake db:shell - Launches the database shell using the values defined in config/database.yml.
|
17
|
+
* rake db:validate_models - Run model validations on all model records in database.
|
18
|
+
|
19
|
+
h2. Git
|
20
|
+
|
21
|
+
* rake git:push:staging - Merge a branch into the origin/staging branch.
|
22
|
+
* rake git:push:production - Merge the staging branch into origin/production for launch.
|
23
|
+
* rake git:diff:staging - Show the difference between current branch and origin/staging.
|
24
|
+
* rake git:diff:production - Show the difference between origin/staging and origin/production.
|
25
|
+
* rake git:pull:suspenders - Pull updates from suspenders, the thoughtbot rails template.
|
26
|
+
* rake git:branch:production - Branch origin/production into BRANCH locally.
|
27
|
+
|
28
|
+
h2. Backup
|
29
|
+
|
30
|
+
* rake backup:db - Backup the current database. Timestamped file is created as :rails_root/../db-name-timestamp.sql
|
31
|
+
* rake backup:assets - Backup all assets under public/system. File is created as :rails_root/../system.tgz
|
32
|
+
|
33
|
+
h2. Haml & Sass
|
34
|
+
|
35
|
+
* rake sass:all_css2sass - Convert all CSS files in public/stylesheets to Sass.
|
36
|
+
* rake sass:all_sass2css - Convert all Sass files to CSS.
|
37
|
+
* rake haml:all_html2haml - Convert all HTML files to Haml.
|
38
|
+
|
39
|
+
h2. Rails 2+
|
40
|
+
|
41
|
+
* 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.
|
42
|
+
|
43
|
+
h2. Subversion
|
44
|
+
|
45
|
+
* rake svn:add - Adds all files with an svn status flag of '?'
|
46
|
+
* rake svn:delete - Deletes all files with an svn status flag of '!'
|
47
|
+
* rake svn:log - Writes the log file to doc/svn_log.txt
|
48
|
+
* rake svn:update\_svn\_ignore - Updates svn:ignore from .svnignore
|
49
|
+
|
50
|
+
h2. Test Coverage
|
51
|
+
|
52
|
+
Install rcov from http://github.com/mergulhao/rcov
|
53
|
+
|
54
|
+
* rake test:coverage - Uses rcov to provide reports about test coverage of your application.
|
55
|
+
|
56
|
+
h2. Mass Assignment
|
57
|
+
|
58
|
+
From "mhartl":http://github.com/mhartl/find_mass_assignment
|
59
|
+
|
60
|
+
* rake find_mass_assignment
|
61
|
+
|
62
|
+
The Limerick Rake
|
63
|
+
=================
|
64
|
+
|
65
|
+
Traditional Irish song. "YouTube":http://www.youtube.com/v/e8moLHIW8xw
|
66
|
+
|
67
|
+
I am a young fellow that's easy and bold,
|
68
|
+
In Castletown conners I'm very well known.
|
69
|
+
In Newcastle West I spent many a note,
|
70
|
+
With Kitty and Judy and Mary.
|
71
|
+
|
72
|
+
My father rebuked me for being such a rake,
|
73
|
+
And spending me time in such frolicsome ways,
|
74
|
+
But I ne'er could forget the good nature of Jane,
|
75
|
+
Agus fágaimíd siúd mar atá sé.
|
76
|
+
|
77
|
+
My parents had reared me to shake and to mow,
|
78
|
+
To plough and to harrow, to reap and to sow.
|
79
|
+
But my heart being airy to drop it so low,
|
80
|
+
I set out on high speculation.
|
81
|
+
|
82
|
+
On paper and parchment they taught me to write,
|
83
|
+
In Euclid and grammar they opened my eyes,
|
84
|
+
And in multiplication in truth I was bright,
|
85
|
+
Agus fágaimíd siúd mar atá sé.
|
86
|
+
|
87
|
+
If I chance for to go to the town of Rathkeale,
|
88
|
+
The girls all round me do flock on the square.
|
89
|
+
Some give me a bottle and others sweet cakes,
|
90
|
+
To treat me unknown to their parents.
|
91
|
+
|
92
|
+
There is one from Askeaton and one from the Pike,
|
93
|
+
Another from Arda, my heart was beguiled,
|
94
|
+
Tho' being from the mountains her stockings are white,
|
95
|
+
Agus fágaimíd siúd mar atá sé.
|
96
|
+
|
97
|
+
To quarrel for riches I ne'er was inclined,
|
98
|
+
For the greatest of misers that must leave all behind.
|
99
|
+
I'll purchase a cow that will never run dry,
|
100
|
+
And I'll milk her by twisting her horn.
|
101
|
+
|
102
|
+
John Damer of Shronel had plenty of gold,
|
103
|
+
And Lord Devonshire's treasures are twenty times more,
|
104
|
+
But he's laid on his back among nettles and stones,
|
105
|
+
Agus fágaimíd siúd mar atá sé.
|
106
|
+
|
107
|
+
The old cow could be milked without clover or grass,
|
108
|
+
She'd be pampered with corn, good barley and hops.
|
109
|
+
She's warm and stout, and she's free in the paps,
|
110
|
+
And she'll milk without spancil or halter.
|
111
|
+
|
112
|
+
The man that will drink it will cock his caubeen,
|
113
|
+
And if anyone laughs there'd be wigs on the green,
|
114
|
+
And the feeble old hag will get supple and free,
|
115
|
+
Agus fágaimíd siúd mar atá sé.
|
116
|
+
|
117
|
+
There's some say I'm foolish and more say I'm wise,
|
118
|
+
But being fond of the women I think is no crime,
|
119
|
+
For the son of King David had ten hundred wives,
|
120
|
+
And his wisdom was highly regarded.
|
121
|
+
|
122
|
+
I'll take a good garden and live at my ease,
|
123
|
+
And each woman and child can partake of the same,
|
124
|
+
If there'd be war in the cabin, themselves they'd be to blame,
|
125
|
+
Agus fágaimíd siúd mar atá sé.
|
126
|
+
|
127
|
+
And now for the future I mean to be wise,
|
128
|
+
And I'll send for the women that acted so kind,
|
129
|
+
I'd marry them all on the morrow by and by,
|
130
|
+
If the clergy agree to the bargain.
|
131
|
+
|
132
|
+
And when I'd be old and my soul is at peace,
|
133
|
+
These women will crowd for to cry at my wake,
|
134
|
+
And their sons and their daughters will offer their prayer,
|
135
|
+
To the Lord for the soul of their father.
|
136
|
+
|
137
|
+
License
|
138
|
+
-------
|
139
|
+
|
140
|
+
MIT License, under the same terms as Ruby.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "limerick_rake"
|
3
|
+
s.version = "0.0.2"
|
4
|
+
s.date = "2008-10-07"
|
5
|
+
s.summary = "A collection of useful rake tasks."
|
6
|
+
s.email = "support@thoughtbot.com"
|
7
|
+
s.homepage = "http://github.com/thoughtbot/limerick_rake"
|
8
|
+
s.description = "A collection of useful rake tasks."
|
9
|
+
s.authors = ["the Ruby community", "thoughtbot, inc."]
|
10
|
+
s.files = ["README.textile",
|
11
|
+
"limerick_rake.gemspec",
|
12
|
+
"tasks/backup.rake",
|
13
|
+
"tasks/db/bootstrap.rake",
|
14
|
+
"tasks/db/indexes.rake",
|
15
|
+
"tasks/db/shell.rake",
|
16
|
+
"tasks/db/validate_models.rake",
|
17
|
+
"tasks/git.rake",
|
18
|
+
"tasks/haml_sass.rake",
|
19
|
+
"tasks/svn.rake"]
|
20
|
+
end
|
data/tasks/backup.rake
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
namespace :backup do
|
5
|
+
desc "Backup the current database. Timestamped file is created as :rails_root/../db-name-timestamp.sql"
|
6
|
+
task :db => :environment do
|
7
|
+
config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
|
8
|
+
filename = "#{config['database'].gsub(/_/, '-')}-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.sql"
|
9
|
+
backupdir = File.expand_path(File.join(RAILS_ROOT, '..'))
|
10
|
+
filepath = File.join(backupdir, filename)
|
11
|
+
mysqldump = `which mysqldump`.strip
|
12
|
+
options = "-e -u #{config['username']}"
|
13
|
+
options += " -p#{config['password']}" if config['password']
|
14
|
+
options += " -h #{config['host']}" if config['host']
|
15
|
+
|
16
|
+
raise RuntimeError, "I only work with mysql." unless config['adapter'] == 'mysql'
|
17
|
+
raise RuntimeError, "Cannot find mysqldump." if mysqldump.blank?
|
18
|
+
|
19
|
+
FileUtils.mkdir_p backupdir
|
20
|
+
`#{mysqldump} #{options} #{config['database']} > #{filepath}`
|
21
|
+
puts "#{config['database']} => #{filepath}"
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
desc "Backup all assets under public/system. File is created as :rails_root/../system.tgz"
|
26
|
+
task :assets do
|
27
|
+
path = (Pathname.new(RAILS_ROOT) + 'public' + 'system').realpath
|
28
|
+
base_dir = path.parent
|
29
|
+
system_dir = path.basename
|
30
|
+
outfile = (Pathname.new(RAILS_ROOT) + '..').realpath + 'system.tgz'
|
31
|
+
|
32
|
+
cd base_dir
|
33
|
+
`tar -czf #{outfile} #{system_dir}`
|
34
|
+
puts "Assets => #{outfile}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'Backup the database and all assets by running the backup:db and backup:assets tasks.'
|
39
|
+
task :backup => ["backup:db", "backup:assets"]
|
@@ -0,0 +1,15 @@
|
|
1
|
+
namespace :db do
|
2
|
+
desc "Loads a schema.rb file into the database and then loads the initial database fixtures."
|
3
|
+
task :bootstrap => ['db:schema:load', 'db:bootstrap:load']
|
4
|
+
|
5
|
+
namespace :bootstrap do
|
6
|
+
desc "Load initial database fixtures (in db/bootstrap/*.yml) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
7
|
+
task :load => :environment do
|
8
|
+
require 'active_record/fixtures'
|
9
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
10
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'db', 'bootstrap', '*.{yml,csv}'))).each do |fixture_file|
|
11
|
+
Fixtures.create_fixtures('db/bootstrap', File.basename(fixture_file, '.*'))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
namespace :db do
|
2
|
+
namespace :indexes do
|
3
|
+
desc "Prints a list of unindexed foreign keys so you can index them"
|
4
|
+
task :missing => :environment do
|
5
|
+
indexes = {}
|
6
|
+
conn = ActiveRecord::Base.connection
|
7
|
+
conn.tables.each do |table|
|
8
|
+
indexed_columns = conn.indexes(table).map { |i| i.columns }.flatten
|
9
|
+
conn.columns(table).each do |column|
|
10
|
+
if column.name.match(/_id/) && !indexed_columns.include?(column.name)
|
11
|
+
indexes[table] ||= []
|
12
|
+
indexes[table] << column.name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
puts "Foreign Keys:"
|
17
|
+
indexes.each do |table, columns|
|
18
|
+
puts columns.map { |c| "\s\sadd_index '#{table}', '#{c}'\n"}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/tasks/db/shell.rake
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
namespace :db do
|
2
|
+
desc 'Launches the database shell using the values defined in config/database.yml'
|
3
|
+
task :shell => :environment do
|
4
|
+
config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
|
5
|
+
command = ""
|
6
|
+
|
7
|
+
case config['adapter']
|
8
|
+
when 'mysql'
|
9
|
+
command << "mysql "
|
10
|
+
command << "--host=#{config['host'] || 'localhost'} "
|
11
|
+
command << "--port=#{config['port'] || 3306} "
|
12
|
+
command << "--user=#{config['username'] || 'root'} "
|
13
|
+
command << "--password=#{config['password'] || ''} "
|
14
|
+
command << config['database']
|
15
|
+
when 'postgresql'
|
16
|
+
puts 'You should consider switching to MySQL or get off your butt and submit a patch'
|
17
|
+
else
|
18
|
+
command << "echo Unsupported database adapter: #{config['adapter']}"
|
19
|
+
end
|
20
|
+
|
21
|
+
system command
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
namespace :db do
|
2
|
+
# From http://blog.hasmanythrough.com/2006/8/27/validate-all-your-records
|
3
|
+
desc "Run model validations on all model records in database"
|
4
|
+
task :validate_models => :environment do
|
5
|
+
# because rails loads stuff on demand...
|
6
|
+
Dir.glob(RAILS_ROOT + '/app/models/**/*.rb').each do |file|
|
7
|
+
silence_warnings do
|
8
|
+
require file
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Object.subclasses_of(ActiveRecord::Base).select { |c| c.base_class == c}.sort_by(&:name).each do |klass|
|
13
|
+
next if klass.name == "CGI::Session::ActiveRecordStore::Session"
|
14
|
+
invalid_count = 0
|
15
|
+
total = klass.count
|
16
|
+
chunk_size = 1000
|
17
|
+
(total / chunk_size + 1).times do |i|
|
18
|
+
chunk = klass.find(:all, :offset => (i * chunk_size), :limit => chunk_size)
|
19
|
+
chunk.reject(&:valid?).each do |record|
|
20
|
+
invalid_count += 1
|
21
|
+
puts "#{klass} #{record.id}: #{record.errors.full_messages.to_sentence}"
|
22
|
+
end rescue nil
|
23
|
+
end
|
24
|
+
puts "#{invalid_count} of #{total} #{klass.name.pluralize} are invalid." if invalid_count > 0
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/tasks/git.rake
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
module GitCommands
|
2
|
+
class ShellError < RuntimeError; end
|
3
|
+
|
4
|
+
@logging = ENV['LOGGING'] != "false"
|
5
|
+
|
6
|
+
def self.run cmd, *expected_exitstatuses
|
7
|
+
puts "+ #{cmd}" if @logging
|
8
|
+
output = `#{cmd} 2>&1`
|
9
|
+
puts output.gsub(/^/, "- ") if @logging
|
10
|
+
expected_exitstatuses << 0 if expected_exitstatuses.empty?
|
11
|
+
raise ShellError.new("ERROR: '#{cmd}' failed with exit status #{$?.exitstatus}") unless
|
12
|
+
[expected_exitstatuses].flatten.include?( $?.exitstatus )
|
13
|
+
output
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.current_branch
|
17
|
+
run("git branch --no-color | grep '*' | cut -d ' ' -f 2").chomp
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.remote_branch_exists?(branch)
|
21
|
+
! run("git branch -r --no-color | grep '#{branch}'").blank?
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.ensure_clean_working_directory!
|
25
|
+
return if run("git status", 0, 1).match(/working directory clean/)
|
26
|
+
raise "Must have clean working directory"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.diff_staging
|
30
|
+
puts run("git diff HEAD origin/staging")
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.diff_production
|
34
|
+
puts run("git diff origin/staging origin/production")
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.push(src_branch, dst_branch)
|
38
|
+
raise "origin/#{dst_branch} branch does not exist" unless remote_branch_exists?("origin/#{dst_branch}")
|
39
|
+
ensure_clean_working_directory!
|
40
|
+
begin
|
41
|
+
run "git fetch"
|
42
|
+
run "git push -f origin #{src_branch}:#{dst_branch}"
|
43
|
+
rescue
|
44
|
+
puts "Pushing #{src_branch} to origin/#{dst_branch} failed."
|
45
|
+
raise
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.push_staging
|
50
|
+
push(current_branch, "staging")
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.push_production
|
54
|
+
push("origin/staging", "production")
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.branch_production(branch)
|
58
|
+
raise "You must specify a branch name." if branch.blank?
|
59
|
+
ensure_clean_working_directory!
|
60
|
+
run "git fetch"
|
61
|
+
run "git branch -f #{branch} origin/production"
|
62
|
+
run "git checkout #{branch}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.pull_template
|
66
|
+
ensure_clean_working_directory!
|
67
|
+
run "git pull git://github.com/thoughtbot/suspenders.git master"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
namespace :git do
|
72
|
+
namespace :push do
|
73
|
+
desc "Reset origin's staging branch to be the current branch."
|
74
|
+
task :staging do
|
75
|
+
GitCommands.push_staging
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "Reset origin's production branch to origin's staging branch."
|
79
|
+
task :production do
|
80
|
+
GitCommands.push_production
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
namespace :diff do
|
85
|
+
desc "Show the difference between current branch and origin/staging."
|
86
|
+
task :staging do
|
87
|
+
GitCommands.diff_staging
|
88
|
+
end
|
89
|
+
|
90
|
+
desc "Show the difference between origin/staging and origin/production."
|
91
|
+
task :production do
|
92
|
+
GitCommands.diff_production
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
namespace :pull do
|
97
|
+
desc "Pull updates from suspenders, the thoughtbot rails template."
|
98
|
+
task :suspenders do
|
99
|
+
GitCommands.pull_template
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
namespace :branch do
|
104
|
+
desc "Branch origin/production into BRANCH locally."
|
105
|
+
task :production do
|
106
|
+
GitCommands.branch_production(branch)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# Dan Croak, February 2008
|
2
|
+
|
3
|
+
@css_dir = "#{RAILS_ROOT}/public/stylesheets"
|
4
|
+
@sass_dir = "#{@css_dir}/sass"
|
5
|
+
@views_dir = "#{RAILS_ROOT}/app/views"
|
6
|
+
|
7
|
+
def convert_css_to_sass(basename)
|
8
|
+
system "css2sass #{@css_dir}/#{basename}.css > #{@sass_dir}/#{basename}.sass"
|
9
|
+
end
|
10
|
+
|
11
|
+
def convert_sass_to_css(basename)
|
12
|
+
system "sass #{@sass_dir}/#{basename}.sass > #{@css_dir}/#{basename}.css"
|
13
|
+
end
|
14
|
+
|
15
|
+
def convert_html_to_haml(controller, basename)
|
16
|
+
extname = basename.include?("erb") ? ".html.erb" : ".rhtml"
|
17
|
+
basename = basename.split(".").first
|
18
|
+
system "html2haml #{@views_dir}/#{controller}/#{basename}#{extname} > #{@views_dir}/#{controller}/#{basename}.html.haml"
|
19
|
+
system "rm #{@views_dir}/#{controller}/#{basename}#{extname}"
|
20
|
+
end
|
21
|
+
|
22
|
+
namespace :sass do
|
23
|
+
desc "Convert all CSS files to Sass."
|
24
|
+
task :all_css2sass => :environment do
|
25
|
+
begin
|
26
|
+
Dir.mkdir(@sass_dir)
|
27
|
+
rescue Exception => e
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
files = Dir.entries(@css_dir).find_all do |f|
|
32
|
+
File.extname("#{@css_dir}/#{f}") == ".css" &&
|
33
|
+
File.basename("#{@css_dir}/#{f}") !~ /^[.]/
|
34
|
+
end
|
35
|
+
|
36
|
+
files.each do |filename|
|
37
|
+
basename = File.basename("#{@css_dir}/#{filename}", ".css")
|
38
|
+
convert_css_to_sass basename
|
39
|
+
convert_sass_to_css basename
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Convert all Sass files to CSS."
|
44
|
+
task :all_sass2css => :environment do
|
45
|
+
files = Dir.entries(@sass_dir).find_all do |f|
|
46
|
+
File.extname("#{@sass_dir}/#{f}") == ".sass" &&
|
47
|
+
File.basename("#{@sass_dir}/#{f}") !~ /^[.]/
|
48
|
+
end
|
49
|
+
|
50
|
+
files.each do |filename|
|
51
|
+
basename = File.basename("#{@sass_dir}/#{filename}", ".sass")
|
52
|
+
convert_sass_to_css basename
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
namespace :haml do
|
58
|
+
desc "Convert all HTML files to Haml."
|
59
|
+
task :all_html2haml => :environment do
|
60
|
+
controllers = Dir.entries(@views_dir).find_all do |c|
|
61
|
+
File.directory?("#{@views_dir}/#{c}") &&
|
62
|
+
File.basename("#{@views_dir}/#{c}") !~ /^[.]/
|
63
|
+
end
|
64
|
+
|
65
|
+
controllers.each do |controller|
|
66
|
+
files = Dir.entries("#{@views_dir}/#{controller}").find_all do |f|
|
67
|
+
(File.new("#{@views_dir}/#{controller}/#{f}").path.include?(".html.erb") ||
|
68
|
+
File.new("#{@views_dir}/#{controller}/#{f}").path.include?(".rhtml")) &&
|
69
|
+
File.basename("#{@views_dir}/#{controller}/#{f}") !~ /^[.]/
|
70
|
+
end
|
71
|
+
files.each do |filename|
|
72
|
+
basename = File.basename("#{@views_dir}/#{controller}/#{filename}")
|
73
|
+
convert_html_to_haml controller, basename
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
data/tasks/svn.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Pulled together from various mailing lists.
|
2
|
+
|
3
|
+
namespace :svn do
|
4
|
+
desc "Adds all files with an svn status flag of '?'"
|
5
|
+
task(:add) { system %q(svn status | awk '/\\?/ {print $2}' | xargs svn add) }
|
6
|
+
|
7
|
+
desc "Deletes all files with an svn status flag of '!'"
|
8
|
+
task(:delete) { system %q(svn status | awk '/\\!/ {print $2}' | xargs svn delete) }
|
9
|
+
|
10
|
+
desc "Writes the log file to doc/svn_log.txt"
|
11
|
+
task(:log) do
|
12
|
+
File.delete("#{RAILS_ROOT}/doc/svn_log.txt") if File::exists?("#{RAILS_ROOT}/doc/svn_log.txt")
|
13
|
+
File.new("#{RAILS_ROOT}/doc/svn_log.txt", "w+")
|
14
|
+
system("svn log >> doc/svn_log.txt")
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Updates svn:ignore from .svnignore'
|
18
|
+
task(:update_svn_ignore) do
|
19
|
+
system %q(svn propset svn:ignore -F .svnignore .)
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: limerick_rake
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- the Ruby community
|
8
|
+
- thoughtbot, inc.
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2008-10-07 00:00:00 +04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: A collection of useful rake tasks.
|
18
|
+
email: support@thoughtbot.com
|
19
|
+
executables: []
|
20
|
+
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files: []
|
24
|
+
|
25
|
+
files:
|
26
|
+
- README.textile
|
27
|
+
- limerick_rake.gemspec
|
28
|
+
- tasks/backup.rake
|
29
|
+
- tasks/db/bootstrap.rake
|
30
|
+
- tasks/db/indexes.rake
|
31
|
+
- tasks/db/shell.rake
|
32
|
+
- tasks/db/validate_models.rake
|
33
|
+
- tasks/git.rake
|
34
|
+
- tasks/haml_sass.rake
|
35
|
+
- tasks/svn.rake
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: http://github.com/thoughtbot/limerick_rake
|
38
|
+
licenses: []
|
39
|
+
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
requirements: []
|
58
|
+
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.3.5
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: A collection of useful rake tasks.
|
64
|
+
test_files: []
|
65
|
+
|