Commit 15750f4817f2d869eef04370a459bf3d02a3a15c
1 parent
ce74c679
Exists in
master
and in
1 other branch
Upgrading thoughtbot/limerick_rake plugin.
So we get rid of Rake's deprecations warnings: DEPRECATION WARNING: Rake tasks in vendor/plugins/limerick_rake/tasks, ... The gem itself is deprecated, so we might be better of removing it completely.
Showing
32 changed files
with
600 additions
and
548 deletions
Show diff stats
vendor/plugins/limerick_rake/MIT-LICENSE
... | ... | @@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
17 | 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
18 | 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
19 | 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
20 | -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
21 | 20 | \ No newline at end of file |
21 | +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ... | ... |
... | ... | @@ -0,0 +1,166 @@ |
1 | +Limerick Rake | |
2 | +============= | |
3 | + | |
4 | +A collection of useful rake tasks. | |
5 | + | |
6 | +To use in a Rails app, in your Gemfile: | |
7 | + | |
8 | + gem 'limerick_rake' | |
9 | + | |
10 | +DEPRECATED | |
11 | +---------- | |
12 | + | |
13 | +We no longer use `limerick_rake`, and as such no longer maintain it. If you | |
14 | +wish to take over the project please email <support@thoughtbot.com>. | |
15 | + | |
16 | +Database | |
17 | +-------- | |
18 | + | |
19 | +Read tasks/database.rake for details for configuration. | |
20 | + | |
21 | + 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 | |
22 | + rake db:indexes:missing # Prints a list of unindexed foreign keys so you can index them. | |
23 | + rake db:shell # Launches the database shell using the values defined in config/database.yml. | |
24 | + rake db:validate_models # Run model validations on all model records in database. | |
25 | + rake db:recreate # Recreate database with seeds (drop, create, migrate and seed) | |
26 | + | |
27 | +Git | |
28 | +--- | |
29 | + | |
30 | + rake git:push:staging # Merge a branch into the origin/staging branch. | |
31 | + rake git:push:production # Merge the staging branch into origin/production for launch. | |
32 | + rake git:diff:staging # Show the difference between current branch and origin/staging. | |
33 | + rake git:diff:production # Show the difference between origin/staging and origin/production. | |
34 | + rake git:pull:suspenders # Pull updates from suspenders, the thoughtbot rails template. | |
35 | + rake git:branch:production #Branch origin/production into BRANCH locally. | |
36 | + | |
37 | +Backup | |
38 | +------ | |
39 | + | |
40 | + rake backup:db # Backup the current database. Timestamped file is created as :rails_root/../db-name-timestamp.sql | |
41 | + rake backup:assets # Backup all assets under public/system. File is created as :rails_root/../system.tgz | |
42 | + | |
43 | +Haml & Sass | |
44 | +----------- | |
45 | + | |
46 | + rake sass:all_css2sass # Convert all CSS files in public/stylesheets to Sass. | |
47 | + rake sass:all_sass2css # Convert all Sass files to CSS. | |
48 | + rake haml:all_html2haml # Convert all HTML files to Haml. | |
49 | + | |
50 | +Rails 2+ | |
51 | +-------- | |
52 | + | |
53 | + 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. | |
54 | + | |
55 | +Subversion | |
56 | +---------- | |
57 | + | |
58 | + rake svn:add # Adds all files with an svn status flag of '?' | |
59 | + rake svn:delete # Deletes all files with an svn status flag of '!' | |
60 | + rake svn:log # Writes the log file to doc/svn_log.txt | |
61 | + rake svn:update\_svn\_ignore # Updates svn:ignore from .svnignore | |
62 | + | |
63 | +Test Coverage | |
64 | +------------- | |
65 | + | |
66 | +Install rcov from http://github.com/mergulhao/rcov | |
67 | + | |
68 | + rake test:coverage # Uses rcov to provide reports about test coverage of your application. | |
69 | + | |
70 | +Mass Assignment | |
71 | +--------------- | |
72 | + | |
73 | +From "mhartl":http://github.com/mhartl/find_mass_assignment | |
74 | + | |
75 | + rake find_mass_assignment | |
76 | + | |
77 | +The Limerick Rake | |
78 | +================= | |
79 | + | |
80 | +Traditional Irish song. [YouTube](http://www.youtube.com/v/e8moLHIW8xw) | |
81 | + | |
82 | + I am a young fellow that's easy and bold, | |
83 | + In Castletown conners I'm very well known. | |
84 | + In Newcastle West I spent many a note, | |
85 | + With Kitty and Judy and Mary. | |
86 | + | |
87 | + My father rebuked me for being such a rake, | |
88 | + And spending me time in such frolicsome ways, | |
89 | + But I ne'er could forget the good nature of Jane, | |
90 | + Agus fágaimíd siúd mar atá sé. | |
91 | + | |
92 | + My parents had reared me to shake and to mow, | |
93 | + To plough and to harrow, to reap and to sow. | |
94 | + But my heart being airy to drop it so low, | |
95 | + I set out on high speculation. | |
96 | + | |
97 | + On paper and parchment they taught me to write, | |
98 | + In Euclid and grammar they opened my eyes, | |
99 | + And in multiplication in truth I was bright, | |
100 | + Agus fágaimíd siúd mar atá sé. | |
101 | + | |
102 | + If I chance for to go to the town of Rathkeale, | |
103 | + The girls all round me do flock on the square. | |
104 | + Some give me a bottle and others sweet cakes, | |
105 | + To treat me unknown to their parents. | |
106 | + | |
107 | + There is one from Askeaton and one from the Pike, | |
108 | + Another from Arda, my heart was beguiled, | |
109 | + Tho' being from the mountains her stockings are white, | |
110 | + Agus fágaimíd siúd mar atá sé. | |
111 | + | |
112 | + To quarrel for riches I ne'er was inclined, | |
113 | + For the greatest of misers that must leave all behind. | |
114 | + I'll purchase a cow that will never run dry, | |
115 | + And I'll milk her by twisting her horn. | |
116 | + | |
117 | + John Damer of Shronel had plenty of gold, | |
118 | + And Lord Devonshire's treasures are twenty times more, | |
119 | + But he's laid on his back among nettles and stones, | |
120 | + Agus fágaimíd siúd mar atá sé. | |
121 | + | |
122 | + The old cow could be milked without clover or grass, | |
123 | + She'd be pampered with corn, good barley and hops. | |
124 | + She's warm and stout, and she's free in the paps, | |
125 | + And she'll milk without spancil or halter. | |
126 | + | |
127 | + The man that will drink it will cock his caubeen, | |
128 | + And if anyone laughs there'd be wigs on the green, | |
129 | + And the feeble old hag will get supple and free, | |
130 | + Agus fágaimíd siúd mar atá sé. | |
131 | + | |
132 | + There's some say I'm foolish and more say I'm wise, | |
133 | + But being fond of the women I think is no crime, | |
134 | + For the son of King David had ten hundred wives, | |
135 | + And his wisdom was highly regarded. | |
136 | + | |
137 | + I'll take a good garden and live at my ease, | |
138 | + And each woman and child can partake of the same, | |
139 | + If there'd be war in the cabin, themselves they'd be to blame, | |
140 | + Agus fágaimíd siúd mar atá sé. | |
141 | + | |
142 | + And now for the future I mean to be wise, | |
143 | + And I'll send for the women that acted so kind, | |
144 | + I'd marry them all on the morrow by and by, | |
145 | + If the clergy agree to the bargain. | |
146 | + | |
147 | + And when I'd be old and my soul is at peace, | |
148 | + These women will crowd for to cry at my wake, | |
149 | + And their sons and their daughters will offer their prayer, | |
150 | + To the Lord for the soul of their father. | |
151 | + | |
152 | +Credits | |
153 | +------- | |
154 | + | |
155 | + | |
156 | + | |
157 | +Limerick Rake is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community) | |
158 | + | |
159 | +Thank you to all [the contributors](https://github.com/thoughtbot/limerick_rake/contributors)! | |
160 | + | |
161 | +The names and logos for thoughtbot are trademarks of thoughtbot, inc. | |
162 | + | |
163 | +License | |
164 | +------- | |
165 | + | |
166 | +Limerick Rake is Copyright © 2008-2011 thoughtbot. It is free software, and may be redistributed under the terms specified in the LICENSE file. | ... | ... |
vendor/plugins/limerick_rake/README.textile
... | ... | @@ -1,140 +0,0 @@ |
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. |
vendor/plugins/limerick_rake/Rakefile
vendor/plugins/limerick_rake/lib/find_mass_assignment.rb
... | ... | @@ -2,22 +2,22 @@ |
2 | 2 | # http://github.com/mhartl/find_mass_assignment |
3 | 3 | |
4 | 4 | require 'active_support' |
5 | - | |
5 | + | |
6 | 6 | # Find potential mass assignment problems. |
7 | 7 | # The method is to scan the controllers for likely mass assignment, |
8 | 8 | # and then find the corresponding models that *don't* have |
9 | 9 | # attr_accessible defined. Any time that happens, it's a potential problem. |
10 | - | |
10 | + | |
11 | 11 | class String |
12 | - | |
12 | + | |
13 | 13 | @@cache = {} |
14 | - | |
14 | + | |
15 | 15 | # A regex to match likely cases of mass assignment |
16 | 16 | # Examples of matching strings: |
17 | 17 | # "Foo.new( { :bar => 'baz' } )" |
18 | 18 | # "Foo.update_attributes!(params[:foo])" |
19 | 19 | MASS_ASSIGNMENT = /(\w+)\.(new|create|update_attributes|build)!*\(/ |
20 | - | |
20 | + | |
21 | 21 | # Return the strings that represent potential mass assignment problems. |
22 | 22 | # The MASS_ASSIGNMENT regex returns, e.g., ['Post', 'new'] because of |
23 | 23 | # the grouping methods; we want the first of the two for each match. |
... | ... | @@ -28,17 +28,17 @@ class String |
28 | 28 | def mass_assignment_models |
29 | 29 | scan(MASS_ASSIGNMENT).map { |problem| problem.first.classify } |
30 | 30 | end |
31 | - | |
31 | + | |
32 | 32 | # Return true if the string has potential mass assignment code. |
33 | 33 | def mass_assignment? |
34 | 34 | self =~ MASS_ASSIGNMENT |
35 | 35 | end |
36 | - | |
36 | + | |
37 | 37 | # Return true if the model defines attr_accessible. |
38 | 38 | # Note that 'attr_accessible' must be preceded by nothing other than |
39 | 39 | # whitespace; this catches cases where attr_accessible is commented out. |
40 | 40 | def attr_accessible? |
41 | - model = "#{RAILS_ROOT}/app/models/#{self.classify}.rb" | |
41 | + model = "#{Rails.root.to_s}/app/models/#{self.classify}.rb" | |
42 | 42 | if File.exist?(model) |
43 | 43 | return @@cache[model] unless @@cache[model].nil? |
44 | 44 | @@cache[model] = File.open(model).read =~ /^\s*attr_accessible/ |
... | ... | @@ -48,17 +48,17 @@ class String |
48 | 48 | true |
49 | 49 | end |
50 | 50 | end |
51 | - | |
51 | + | |
52 | 52 | # Returnt true if a model does not define attr_accessible. |
53 | 53 | def problem? |
54 | 54 | not attr_accessible? |
55 | 55 | end |
56 | - | |
56 | + | |
57 | 57 | # Return true if a line has a problem model (no attr_accessible). |
58 | 58 | def problem_model? |
59 | 59 | mass_assignment_models.find { |model| model.problem? } |
60 | 60 | end |
61 | - | |
61 | + | |
62 | 62 | # Return true if a controller string has a (likely) mass assignment problem. |
63 | 63 | # This is true if at least one of the controller's lines |
64 | 64 | # (1) Has a likely mass assignment |
... | ... | @@ -67,9 +67,9 @@ class String |
67 | 67 | File.open(self).find { |l| l.mass_assignment? and l.problem_model? } |
68 | 68 | end |
69 | 69 | end |
70 | - | |
70 | + | |
71 | 71 | module MassAssignment |
72 | - | |
72 | + | |
73 | 73 | def self.print_mass_assignment_problems(controller) |
74 | 74 | lines = File.open(controller) |
75 | 75 | lines.each_with_index do |line, number| |
... | ... | @@ -78,9 +78,9 @@ module MassAssignment |
78 | 78 | end |
79 | 79 | end |
80 | 80 | end |
81 | - | |
81 | + | |
82 | 82 | def self.find |
83 | - controllers = Dir.glob("#{RAILS_ROOT}/app/controllers/*_controller.rb") | |
83 | + controllers = Dir.glob("#{Rails.root.to_s}/app/controllers/*_controller.rb") | |
84 | 84 | controllers.each do |controller| |
85 | 85 | if controller.mass_assignment_problem? |
86 | 86 | puts "\n#{controller}" |
... | ... | @@ -88,4 +88,4 @@ module MassAssignment |
88 | 88 | end |
89 | 89 | end |
90 | 90 | end |
91 | -end | |
92 | 91 | \ No newline at end of file |
92 | +end | ... | ... |
vendor/plugins/limerick_rake/lib/limerick_rake/engine.rb
0 → 100644
vendor/plugins/limerick_rake/lib/limerick_rake/version.rb
0 → 100644
... | ... | @@ -0,0 +1,40 @@ |
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.to_s, '..')) | |
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 | + options += " -S #{config['socket']}" if config['socket'] | |
16 | + | |
17 | + raise RuntimeError, "I only work with mysql." unless config['adapter'] == 'mysql' | |
18 | + raise RuntimeError, "Cannot find mysqldump." if mysqldump.blank? | |
19 | + | |
20 | + FileUtils.mkdir_p backupdir | |
21 | + `#{mysqldump} #{options} #{config['database']} > #{filepath}` | |
22 | + puts "#{config['database']} => #{filepath}" | |
23 | + end | |
24 | + | |
25 | + | |
26 | + desc "Backup all assets under public/system. File is created as :rails_root/../system.tgz" | |
27 | + task :assets do | |
28 | + path = (Pathname.new(Rails.root.to_s) + 'public' + 'system').realpath | |
29 | + base_dir = path.parent | |
30 | + system_dir = path.basename | |
31 | + outfile = (Pathname.new(Rails.root.to_s) + '..').realpath + 'system.tgz' | |
32 | + | |
33 | + cd base_dir | |
34 | + `tar -czf #{outfile} #{system_dir}` | |
35 | + puts "Assets => #{outfile}" | |
36 | + end | |
37 | +end | |
38 | + | |
39 | +desc 'Backup the database and all assets by running the backup:db and backup:assets tasks.' | |
40 | +task :backup => ["backup:db", "backup:assets"] | ... | ... |
... | ... | @@ -0,0 +1,14 @@ |
1 | +namespace :test do | |
2 | + | |
3 | + desc 'Measures test coverage' | |
4 | + task :coverage do | |
5 | + rm_f "coverage" | |
6 | + rm_f "coverage.data" | |
7 | + rcov = "rcov -Itest --rails --aggregate coverage.data -T -x \" rubygems/*,/Library/Ruby/Site/*,gems/*,rcov*\"" | |
8 | + system("#{rcov} --no-html test/unit/*_test.rb test/unit/helpers/*_test.rb") | |
9 | + system("#{rcov} --no-html test/functional/*_test.rb") | |
10 | + system("#{rcov} --html test/integration/*_test.rb") | |
11 | + system("open coverage/index.html") if PLATFORM['darwin'] | |
12 | + end | |
13 | + | |
14 | +end | ... | ... |
vendor/plugins/limerick_rake/lib/tasks/db/bootstrap.rake
0 → 100644
... | ... | @@ -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.to_s, '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.sort.each do |table, columns| | |
18 | + puts columns.map { |c| "\s\sadd_index '#{table}', '#{c}'\n"} | |
19 | + end | |
20 | + end | |
21 | + end | |
22 | +end | ... | ... |
... | ... | @@ -0,0 +1,26 @@ |
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 | + command << "psql " | |
17 | + command << "-h #{config['host'] || 'localhost'} " | |
18 | + command << "-p #{config['port'] || 5432} " | |
19 | + command << "-U #{config['username'] || 'postgres'} " | |
20 | + command << "\"dbname=#{config['database']} password=#{config['password']}\"" | |
21 | + else | |
22 | + command << "echo Unsupported database adapter: #{config['adapter']}" | |
23 | + end | |
24 | + system command | |
25 | + end | |
26 | +end | ... | ... |
vendor/plugins/limerick_rake/lib/tasks/db/validate_models.rake
0 → 100644
... | ... | @@ -0,0 +1,31 @@ |
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.to_s + '/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 | + unless klass.table_exists? | |
15 | + puts "WARNING: Could not find table for #{klass} (skipping)" | |
16 | + next | |
17 | + end | |
18 | + invalid_count = 0 | |
19 | + total = klass.count | |
20 | + chunk_size = 1000 | |
21 | + (total / chunk_size + 1).times do |i| | |
22 | + chunk = klass.find(:all, :offset => (i * chunk_size), :limit => chunk_size) | |
23 | + chunk.reject(&:valid?).each do |record| | |
24 | + invalid_count += 1 | |
25 | + puts "#{klass} #{record.id}: #{record.errors.full_messages.to_sentence}" | |
26 | + end rescue nil | |
27 | + end | |
28 | + puts "#{invalid_count} of #{total} #{klass.name.pluralize} are invalid." if invalid_count > 0 | |
29 | + end | |
30 | + end | |
31 | +end | ... | ... |
vendor/plugins/limerick_rake/lib/tasks/find_mass_assignment_tasks.rake
0 → 100644
... | ... | @@ -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}'").empty? | |
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,77 @@ |
1 | +# Dan Croak, February 2008 | |
2 | + | |
3 | +@css_dir = "#{Rails.root.to_s}/public/stylesheets" | |
4 | +@sass_dir = "#{@css_dir}/sass" | |
5 | +@views_dir = "#{Rails.root.to_s}/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 | ... | ... |
... | ... | @@ -0,0 +1,20 @@ |
1 | +desc 'Renames all .rhtml views to .html.erb, .rjs to .js.rjs, .rxml to .xml.builder and .haml to .html.haml' | |
2 | +namespace :rails_two do | |
3 | + task :rename_views do | |
4 | + Dir.glob('app/views/**/[^_]*.rhtml').each do |file| | |
5 | + puts `git mv #{file} #{file.gsub(/\.rhtml$/, '.html.erb')}` | |
6 | + end | |
7 | + | |
8 | + Dir.glob('app/views/**/[^_]*.rjs').each do |file| | |
9 | + puts `git mv #{file} #{file.gsub(/\.rjs$/, '.js.rjs')}` | |
10 | + end | |
11 | + | |
12 | + Dir.glob('app/views/**/[^_]*.rxml').each do |file| | |
13 | + puts `git mv #{file} #{file.gsub(/\.rxml$/, '.xml.builder')}` | |
14 | + end | |
15 | + | |
16 | + Dir.glob('app/views/**/[^_]*.haml').each do |file| | |
17 | + puts `git mv #{file} #{file.gsub(/\.haml$/, '.html.haml')}` | |
18 | + end | |
19 | + end | |
20 | +end | ... | ... |
... | ... | @@ -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.to_s}/doc/svn_log.txt") if File::exists?("#{Rails.root.to_s}/doc/svn_log.txt") | |
13 | + File.new("#{Rails.root.to_s}/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 | ... | ... |
vendor/plugins/limerick_rake/limerick_rake.gemspec
1 | +# -*- encoding: utf-8 -*- | |
2 | +$:.push File.expand_path("../lib", __FILE__) | |
3 | +require "limerick_rake/version" | |
4 | + | |
1 | 5 | 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" | |
6 | + s.name = "limerick_rake" | |
7 | + s.version = LimerickRake::VERSION.dup | |
8 | + s.platform = Gem::Platform::RUBY | |
9 | + s.authors = ["the Ruby community", "thoughtbot, inc."] | |
10 | + s.email = "support@thoughtbot.com" | |
11 | + s.homepage = "http://github.com/thoughtbot/limerick_rake" | |
12 | + s.summary = "A collection of useful rake tasks." | |
8 | 13 | 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 | |
21 | 14 | \ No newline at end of file |
15 | + | |
16 | + s.files = `git ls-files`.split("\n") | |
17 | + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | |
18 | + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | |
19 | + s.require_paths = ["lib"] | |
20 | +end | ... | ... |
vendor/plugins/limerick_rake/tasks/backup.rake
... | ... | @@ -1,39 +0,0 @@ |
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"] |
vendor/plugins/limerick_rake/tasks/coverage.rake
... | ... | @@ -1,14 +0,0 @@ |
1 | -namespace :test do | |
2 | - | |
3 | - desc 'Measures test coverage' | |
4 | - task :coverage do | |
5 | - rm_f "coverage" | |
6 | - rm_f "coverage.data" | |
7 | - rcov = "rcov -Itest --rails --aggregate coverage.data -T -x \" rubygems/*,/Library/Ruby/Site/*,gems/*,rcov*\"" | |
8 | - system("#{rcov} --no-html test/unit/*_test.rb test/unit/helpers/*_test.rb") | |
9 | - system("#{rcov} --no-html test/functional/*_test.rb") | |
10 | - system("#{rcov} --html test/integration/*_test.rb") | |
11 | - system("open coverage/index.html") if PLATFORM['darwin'] | |
12 | - end | |
13 | - | |
14 | -end |
vendor/plugins/limerick_rake/tasks/db/bootstrap.rake
... | ... | @@ -1,15 +0,0 @@ |
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 |
vendor/plugins/limerick_rake/tasks/db/indexes.rake
... | ... | @@ -1,22 +0,0 @@ |
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 | |
23 | 0 | \ No newline at end of file |
vendor/plugins/limerick_rake/tasks/db/shell.rake
... | ... | @@ -1,23 +0,0 @@ |
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 | |
24 | 0 | \ No newline at end of file |
vendor/plugins/limerick_rake/tasks/db/validate_models.rake
... | ... | @@ -1,27 +0,0 @@ |
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 |
vendor/plugins/limerick_rake/tasks/find_mass_assignment_tasks.rake
vendor/plugins/limerick_rake/tasks/git.rake
... | ... | @@ -1,109 +0,0 @@ |
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 |
vendor/plugins/limerick_rake/tasks/haml_sass.rake
... | ... | @@ -1,78 +0,0 @@ |
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 | - |
vendor/plugins/limerick_rake/tasks/rails_two.rake
... | ... | @@ -1,20 +0,0 @@ |
1 | -desc 'Renames all .rhtml views to .html.erb, .rjs to .js.rjs, .rxml to .xml.builder and .haml to .html.haml' | |
2 | -namespace :rails_two do | |
3 | - task :rename_views do | |
4 | - Dir.glob('app/views/**/[^_]*.rhtml').each do |file| | |
5 | - puts `git mv #{file} #{file.gsub(/\.rhtml$/, '.html.erb')}` | |
6 | - end | |
7 | - | |
8 | - Dir.glob('app/views/**/[^_]*.rjs').each do |file| | |
9 | - puts `git mv #{file} #{file.gsub(/\.rjs$/, '.js.rjs')}` | |
10 | - end | |
11 | - | |
12 | - Dir.glob('app/views/**/[^_]*.rxml').each do |file| | |
13 | - puts `git mv #{file} #{file.gsub(/\.rxml$/, '.xml.builder')}` | |
14 | - end | |
15 | - | |
16 | - Dir.glob('app/views/**/[^_]*.haml').each do |file| | |
17 | - puts `git mv #{file} #{file.gsub(/\.haml$/, '.html.haml')}` | |
18 | - end | |
19 | - end | |
20 | -end | |
21 | 0 | \ No newline at end of file |
vendor/plugins/limerick_rake/tasks/svn.rake
... | ... | @@ -1,21 +0,0 @@ |
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 |