public
Description: Collective Idea's Awesomeness. A collection of useful Rails bits and pieces.
Clone URL: git://github.com/collectiveidea/awesomeness.git
Search Repo:
Click here to lend your support to: awesomeness and make a donation at www.pledgie.com !
updated docs
brandon (author)
Sun Apr 27 14:16:47 -0700 2008
commit  8e538b37c014ae23187e5da67c1e9f966dbcc671
tree    547a95a3b3df116b75895df9c6da430c2ab3641b
parent  025ec9b8ce5eaead17f5db2e1ded1ec81803e1d9
0
...
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
...
5
6
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
0
@@ -5,18 +5,48 @@ A collection of stuff that we use often, but not generic enough to go in another
0
 
0
 If you've stumbled across this and love/hate it, let us know!
0
 
0
-Right now, it consists of:
0
-* A few core extensions, mostly to the collection classes
0
-** Object#tap (http://moonbase.rydia.net/mental/blog/programming/eavesdropping-on-expressions)
0
-** String#widont to make typography nicer (http://shauninman.com/archive/2006/08/22/widont_wordpress_plugin)
0
-* Unicode TextHelper Additions
0
-** Change the default truncate & excerpt string to … instead of ...
0
-** Add widont to textilize methods
0
-* Transparent removal of trailing slashes in URLs.
0
-* some capistrano tasks
0
-* a rake task to rename all .rhtml files to .erb
0
-* some test assertions
0
-
0
-TODO:
0
- * Phone cleanup/validations
0
-
0
\ No newline at end of file
0
+== Core Extensions
0
+
0
+* Object#tap (http://moonbase.rydia.net/mental/blog/programming/eavesdropping-on-expressions)
0
+
0
+* String#widont to make typography nicer (http://shauninman.com/archive/2006/08/22/widont_wordpress_plugin)
0
+
0
+* Array#uniq with a block
0
+
0
+ >> %w(the cow jumped over the moon).uniq {|s| s.length }
0
+ => ["the", "jumped", "over"]
0
+
0
+* Round floats to the nearest x
0
+
0
+ >> 5.38475.round(0.5)
0
+ => 5.5
0
+
0
+* Hash goodies
0
+
0
+ >> {:a => [1,3,4], :b => [2,5]}.without(:a => 1)
0
+ => {:a => [3,4], :b => [2,5]}
0
+
0
+ >> {:a => "", :b => nil, :c => 1}.compact
0
+ => {:c => 1}
0
+
0
+* And more…
0
+
0
+== Rails Helpers
0
+
0
+* Unicode TextHelper additions that change the default truncate & excerpt string to an elipsis (…) instead of just three periods (...)
0
+
0
+* Add widont to textilize methods
0
+
0
+* Transparent removal of trailing slashes in URLs
0
+
0
+== Rake Tasks
0
+
0
+== Capistrano Recipes
0
+
0
+* Use :remote_cache by default
0
+
0
+* Disable and enable web during restarts
0
+
0
+* Run deploy:cleanup after deploys
0
+
0
+* Backups
0
\ No newline at end of file
...
14
15
16
17
 
18
19
20
21
22
23
24
 
25
26
27
...
32
33
34
 
 
 
 
 
 
 
35
36
...
14
15
16
 
17
18
19
20
21
22
23
 
24
25
26
27
...
32
33
34
35
36
37
38
39
40
41
42
43
0
@@ -14,14 +14,14 @@ namespace :backup do
0
     capture("cd #{current_path}; rake -s backup:latest BACKUP_DIR=#{backup_path}").strip
0
   end
0
 
0
- # Create a backup on the server
0
+ desc "Create a backup on the server"
0
   task :create, :roles => :db, :only => {:primary => true} do
0
     rails_env = fetch(:rails_env, "production")
0
     skip_tables = Array(skip_backup_tables).join(',')
0
     run "cd #{current_path}; rake backup:create RAILS_ENV=#{rails_env} BACKUP_DIR=#{backup_path} SKIP_TABLES=#{skip_tables}"
0
   end
0
   
0
- # Retreive a backup from the server. Gets the latest by default, set :backup_version to specify which version to copy
0
+ desc "Retreive a backup from the server. Gets the latest by default, set :backup_version to specify which version to copy"
0
   task :get, :roles => :db, :only => {:primary => true} do
0
     version = fetch(:backup_version, latest)
0
     run "tar -C #{backup_path} -czf #{backup_path}/#{version}.tar.gz #{version}"
0
@@ -32,4 +32,11 @@ namespace :backup do
0
     `rm backups/#{version}.tar.gz`
0
   end
0
   
0
+ desc "Creates a new remote backup and clones it to the local database"
0
+ task :clone, :roles => :db, :only => {:primary => true} do
0
+ create
0
+ get
0
+ `rake db:backup:restore`
0
+ end
0
+
0
 end
0
\ No newline at end of file
...
21
22
23
 
24
25
 
26
27
...
21
22
23
24
25
26
27
28
29
0
@@ -21,7 +21,9 @@ namespace :backup do
0
     `cp db/schema.rb #{ENV['FIXTURES_DIR']}/`
0
   end
0
   
0
+ desc "Create a new backup of the database"
0
   task :create => [:environment, 'db:fixtures:dump', 'db:schema:dump']
0
   
0
+ desc "Restore a backup of the database. Use VERSION to specify a version other than the latest."
0
   task :restore => [:latest, :environment, 'db:schema:load', 'db:fixtures:load']
0
 end
...
 
 
 
1
2
3
...
1
2
3
4
5
6
0
@@ -1,3 +1,6 @@
0
+# These tasks replace the built-in Rails tasks for dumping and loading the schema,
0
+# allowing you to specify the FIXTURES_DIR to use for dumping and loading.
0
+
0
 # http://matthewbass.com/2007/03/07/overriding-existing-rake-tasks/
0
 Rake::TaskManager.class_eval do
0
   def remove_task(task_name)

Comments

    No one has commented yet.