kematzy-tasks 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ ## OS STUFF
2
+ .DS_Store
3
+
4
+ ## TM SPECIFIC
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## PROJECT::GENERAL
9
+ *.sw?
10
+ coverage
11
+ rdoc
12
+ pkg
13
+ doc
14
+
15
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 kematzy
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
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.
data/README.rdoc ADDED
@@ -0,0 +1,306 @@
1
+ = Kematzy::Tasks
2
+
3
+ A helpful collection of Rake tasks for improved workflows.
4
+
5
+
6
+ == Installation
7
+
8
+ # Add Gemcutter to your RubyGems sources
9
+ $ gem sources -a http://gemcutter.com
10
+
11
+ $ (sudo)? gem install kematzy-tasks
12
+
13
+ == Dependencies
14
+
15
+ This Gem depends upon the following:
16
+
17
+ === Runtime:
18
+
19
+ * rake ( >= 0.8.7 )
20
+
21
+ === Development & Tests:
22
+
23
+ * rspec (>= 1.2.7 )
24
+
25
+
26
+ == Getting Started
27
+
28
+ These tasks are available:
29
+
30
+
31
+ === DB => Database Related Tasks
32
+
33
+ <b>NB! These tasks are only supporting SQLite3 databases with name ending in <tt>.db</tt> for now.</b>
34
+
35
+
36
+ To setup the <tt>../db/</tt> directories used by these Rake tasks.
37
+
38
+ rake db:setup => creates ../db/bootstraps & ../db/backups in the Rakefile directory.
39
+
40
+
41
+ ==== DB => BACKUPS
42
+
43
+
44
+ To backup a database <tt>[db]</tt> and compresses it as a <tt>YYYY-MM-DD-[db].tar.gz</tt> file.
45
+
46
+ rake db:backup:db db=/name-of-database.db =>
47
+
48
+ ../db/backups/YYYY-MM-DD-name-of-database.db.tar.gz
49
+
50
+
51
+ alias:
52
+
53
+ rake db:backup db=/name-of-database.db
54
+
55
+
56
+
57
+ To dump (backup) <b>ALL databases</b> into <tt>.sql</tt> files.
58
+
59
+ rake db:dump =>
60
+
61
+ # creates ../db/backups/YYYYMMDD-HHMMSS-development.db.sql
62
+ # with the following comments in the sql file
63
+ #
64
+ -- ++++
65
+ -- BACKUP OF DB [ development.db ]
66
+ -- IN APP [ /full/path/2/your/app ]
67
+ -- Created on [ YYYY-MM-DD at HH:MM:SS ]
68
+ --
69
+ -- /++++
70
+
71
+
72
+ alias:
73
+
74
+ rake db:backups
75
+
76
+ rake db:backup:sql
77
+
78
+
79
+
80
+ ==== DB => BOOTSTRAPS
81
+
82
+
83
+ To dump <b>all current databases</b> as bootstrap <tt>.sql</tt> files.
84
+
85
+ rake db:dump:bootstrap
86
+
87
+
88
+
89
+
90
+ To bootstrap an existing database with its <tt>..db/bootstraps/*.sql</tt> file.
91
+
92
+ rake db:bootstrap db=db/development.db =>
93
+
94
+ # is equivalent to this:
95
+ `sqlite3 db/development.db < db/bootstraps/development.db.sql`
96
+
97
+
98
+
99
+ To bootstrap a NEW database with a <tt>..db/bootstraps/*.sql</tt> file.
100
+
101
+ rake db:bootstrap:new db=db/new.db bf=db/bootstraps/somefile.sql
102
+
103
+ # creates the new DB ../db/new.db
104
+
105
+ # and loads the contents of ../db/bootstraps/somefile.sql into it
106
+
107
+
108
+ ==== DB => EXTRAS
109
+
110
+
111
+ To copy the <tt>../db/development.db</tt> into <tt>..db/production.db</tt>.
112
+
113
+ rake db:production:setup =>
114
+
115
+
116
+
117
+
118
+ === FS => File System Related Tasks
119
+
120
+
121
+ Commonly used file system related tasks.
122
+
123
+ <b>NB! Use these with care, as they might NOT be 100% solid at this stage.</b>
124
+
125
+
126
+ ==== FS => COPY
127
+
128
+
129
+ To copy files or directories from one location to another.
130
+
131
+ # copies the file to the directory
132
+ rake fs:copy from=path/from/filename.ext to=path/to/some/directory
133
+
134
+ # copies the contents of the from directory to the to directory
135
+ rake fs:copy from=path/from/directory/ to=path/to/some/directory
136
+
137
+ # copies the whole directory to the new path
138
+ rake fs:copy from=path/from/directory to=path/to/some/new/path
139
+
140
+
141
+ ==== FS => MOVE
142
+
143
+ To move files or directories from one location to another.
144
+
145
+ # moves the file to the directory
146
+ rake fs:move from=path/from/filename.ext to=path/to/some/directory
147
+
148
+ # moves the contents of the from directory to the to directory
149
+ rake fs:move from=path/from/directory/ to=path/to/some/directory
150
+
151
+ # moves the whole directory to the new path
152
+ rake fs:move from=path/from/directory to=path/to/some/new/path
153
+
154
+
155
+
156
+ ==== FS => CREATE
157
+
158
+
159
+ To create a NEW directory at the path given.
160
+
161
+ rake fs:create:dir:new path=path/2/new/dir
162
+
163
+
164
+ Other Create Tasks (more specific to my workflow perhaps)
165
+
166
+ To create a Classes directory at the path given.
167
+
168
+ rake fs:create:dir:classes path=path/2/dir =>
169
+
170
+ # results in ../path/2/dir/classes being created
171
+
172
+
173
+ To create a Helpers directory at the path given.
174
+
175
+ rake fs:create:dir:helpers path=path/2/dir =>
176
+
177
+ # results in ../path/2/dir/helpers being created
178
+
179
+
180
+ To create a Models directory at the path given.
181
+
182
+ rake fs:create:dir:models path=path/2/dir =>
183
+
184
+ # results in ../path/2/dir/models being created
185
+
186
+
187
+ To create a Routes directory at the path given.
188
+
189
+ rake fs:create:dir:routes path=path/2/dir =>
190
+
191
+ # results in ../path/2/dir/routes being created
192
+
193
+
194
+
195
+ === PASSENGER => Passenger / mod_rails Related Tasks
196
+
197
+
198
+ To restart the server, and create the ../tmp/restart.txt file (if missing)
199
+
200
+ rake passenger:init => touch tmp/restart.txt
201
+
202
+
203
+ alias:
204
+
205
+ rake passenger:restart
206
+
207
+ rake psr
208
+
209
+
210
+
211
+ To turn on "Always Restart Passenger" on each request.
212
+
213
+ rake passenger:always:on => touch tmp/always_restart.txt
214
+
215
+ alias:
216
+
217
+ rake pson
218
+
219
+
220
+ To turn <b>OFF</b> "Always Restart Passenger" on each request.
221
+
222
+ rake passenger:always:off => rm tmp/always_restart.txt
223
+
224
+ alias:
225
+
226
+ rake psoff
227
+
228
+
229
+
230
+ === SYMLINK => Symlink Related Tasks
231
+
232
+ When developing sites, I keep certain directories out of Git versioning, and instead
233
+ store them in a 'shared' directory one level up from my app.
234
+
235
+ I then symlink the directories into the <tt>../APP_ROOT/public/</tt> directory.
236
+
237
+
238
+ To symlink all shared directories to public/.
239
+
240
+ rake symlink:shared dirs=images, photos, downloads,.... =>
241
+
242
+ # equivalent of:
243
+ `ln -s ../APP_ROOT/shared/downloads ../APP_ROOT/public/downloads
244
+ and so on...
245
+
246
+
247
+
248
+ === SASS => Sass Related Tasks
249
+
250
+ This is a very personal workflow task, whereby I essentially have this Sinatra App structure.
251
+
252
+ APP_ROOT
253
+ |
254
+ |-> config.ru
255
+ |
256
+ |-> apps
257
+ | |
258
+ | |-> app1
259
+ | | |
260
+ | | |-> sass
261
+ | | | |
262
+ | | | |_> _pages.sass #
263
+ | | | |
264
+ | | | |-> pages
265
+ | | | | |
266
+ | | | | |-> home.sass
267
+ | | | | |-> login.sass
268
+ | | | | |-> ....
269
+ | | | | |
270
+ | | |
271
+ | |
272
+ | |-> app2
273
+ | |
274
+ | |-> ....
275
+
276
+
277
+ Create a NEW Sass page and include it in the _pages.sass file for loading.
278
+
279
+ rake sass:page:new page=app1:logout =>
280
+
281
+ # creates the ../apps/app1/sass/pages/logout.sass page and includes it in the _pages.sass file
282
+
283
+
284
+ == TODOs
285
+
286
+ * Make it less personal perhaps.
287
+
288
+ * Make the DB Tasks work with both MySQL and SQLite3 databases.
289
+
290
+ * Work out how to test all these tasks via RSpec tests, for more solid tasks.
291
+
292
+
293
+ == Note on Patches/Pull Requests
294
+
295
+ * Fork the project.
296
+ * Make your feature addition or bug fix.
297
+ * Add tests for it. This is important so I don't break it in a
298
+ future version unintentionally.
299
+ * Commit, do not mess with rakefile, version, or history.
300
+ (if you want to have your own version, that is fine but
301
+ bump version in a commit by itself I can ignore when I pull)
302
+ * Send me a pull request. Bonus points for topic branches.
303
+
304
+ == Copyright
305
+
306
+ Copyright (c) 2009 kematzy. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,71 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "kematzy-tasks"
8
+ gem.summary = %Q{A helpful collection of Rake tasks for improved workflows}
9
+ gem.description = %Q{All those helpful little Rake tasks in one single location for use in any site}
10
+ gem.email = "kematzy@gmail.com"
11
+ gem.homepage = "http://github.com/kematzy/kematzy-tasks"
12
+ gem.authors = ["kematzy"]
13
+ gem.add_dependency('rake', '>=0.8.7')
14
+ gem.add_development_dependency("rspec")
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
+ end
20
+
21
+ require 'spec/rake/spectask'
22
+ Spec::Rake::SpecTask.new(:spec) do |spec|
23
+ spec.libs << 'lib' << 'spec'
24
+ spec.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
25
+ spec.spec_files = FileList['spec/**/*_spec.rb']
26
+ end
27
+
28
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
31
+ spec.pattern = 'spec/**/*_spec.rb'
32
+ spec.rcov = true
33
+ end
34
+
35
+ task :spec => :check_dependencies
36
+
37
+ task :default => :spec
38
+
39
+ require 'rake/rdoctask'
40
+ Rake::RDocTask.new do |rdoc|
41
+ version = File.exist?('VERSION') ? IO.read('VERSION').chomp : "[Unknown]"
42
+
43
+ rdoc.rdoc_dir = 'rdoc'
44
+ rdoc.title = "kematzy-tasks v#{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
48
+
49
+ desc 'Build the rdoc HTML Files'
50
+ task :docs do
51
+ version = File.exist?('VERSION') ? IO.read('VERSION').chomp : "[Unknown]"
52
+
53
+ sh "sdoc -N --title 'kematzy-tasks v#{version}' lib/ README.rdoc"
54
+ end
55
+
56
+ namespace :docs do
57
+
58
+ desc 'Remove rdoc products'
59
+ task :remove => [:clobber_rdoc]
60
+
61
+ desc 'Force a rebuild of the RDOC files'
62
+ task :rebuild => [:rerdoc]
63
+
64
+ desc 'Build docs, and open in browser for viewing (specify BROWSER)'
65
+ task :open => [:docs] do
66
+ browser = ENV["BROWSER"] || "safari"
67
+ sh "open -a #{browser} doc/index.html"
68
+ end
69
+
70
+ end
71
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,63 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{kematzy-tasks}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["kematzy"]
12
+ s.date = %q{2010-02-22}
13
+ s.description = %q{All those helpful little Rake tasks in one single location for use in any site}
14
+ s.email = %q{kematzy@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "kematzy-tasks.gemspec",
27
+ "lib/kematzy/tasks.rb",
28
+ "lib/kematzy/tasks/rake/all.rb",
29
+ "lib/kematzy/tasks/rake/db.rb",
30
+ "lib/kematzy/tasks/rake/filesystem.rb",
31
+ "lib/kematzy/tasks/rake/passenger.rb",
32
+ "lib/kematzy/tasks/rake/sass.rb",
33
+ "lib/kematzy/tasks/rake/symlink.rb",
34
+ "spec/kematzy/tasks_spec.rb",
35
+ "spec/spec_helper.rb"
36
+ ]
37
+ s.homepage = %q{http://github.com/kematzy/kematzy-tasks}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.3.5}
41
+ s.summary = %q{A helpful collection of Rake tasks for improved workflows}
42
+ s.test_files = [
43
+ "spec/kematzy/tasks_spec.rb",
44
+ "spec/spec_helper.rb"
45
+ ]
46
+
47
+ if s.respond_to? :specification_version then
48
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
+ s.specification_version = 3
50
+
51
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
52
+ s.add_runtime_dependency(%q<rake>, [">= 0.8.7"])
53
+ s.add_development_dependency(%q<rspec>, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<rake>, [">= 0.8.7"])
56
+ s.add_dependency(%q<rspec>, [">= 0"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<rake>, [">= 0.8.7"])
60
+ s.add_dependency(%q<rspec>, [">= 0"])
61
+ end
62
+ end
63
+
@@ -0,0 +1,6 @@
1
+ ## Require all Rake tasks
2
+ require 'kematzy/tasks/rake/db'
3
+ require 'kematzy/tasks/rake/filesystem'
4
+ require 'kematzy/tasks/rake/passenger'
5
+ require 'kematzy/tasks/rake/symlink'
6
+ require 'kematzy/tasks/rake/sass'
@@ -0,0 +1,103 @@
1
+
2
+ namespace :db do
3
+
4
+ desc "Backup database to .tar.gz file (=> db:backup:db)"
5
+ task :backup => ['db:backup:db']
6
+
7
+ desc "Backups DBs into .sql files (=> db:backup:sql)"
8
+ task :backups => ['db:backup:sql']
9
+
10
+ namespace :backup do
11
+
12
+ desc "Backups DBs into .sql file"
13
+ task :sql => ['db:dump']
14
+
15
+ desc "Backups DB .db file and compresses it"
16
+ task :db, [:db] do |t, args|
17
+ unless args.db
18
+ puts %Q[\nERROR:\n\n You must define the DB variable like this:\n rake db:backup:db db=db/name-of-database.db\n\n]
19
+ else
20
+ db_name = args.db.sub(/^db\//,'')
21
+ `cd db/ && tar zcf ../db/backups/#{Time.now.strftime("%Y%m%d-%H%M%S")}-#{db_name}.tar.gz #{db_name} `
22
+ puts "\n-- created a compressed backup version of [ #{args.db} ]\n\n"
23
+ end
24
+ end
25
+
26
+ end #/namespace :backup
27
+
28
+
29
+ desc "Bootstrap database with .sql files (db=db/name.db)"
30
+ task :bootstrap, [:db] do |t, args|
31
+ # To put the data into a SQLite database from a sql file use:
32
+ # sqlite database < database.sql
33
+ unless args.db
34
+ msg = %Q[\nERROR:\n\n You must define the :db variable like this:\n]
35
+ msg << %Q[ rake db:bootstrap db=db/name-of-database.db\n\n]
36
+ puts msg
37
+ else
38
+ sh "sqlite3 #{args.db} < db/bootstraps/#{args.db.sub(/^db\//,'')}.sql"
39
+ puts "-- DB [ #{args.db}] bootstrapped with [ db/bootstraps/#{args.db.sub(/^db\//,'')}.sql ]l\n\n"
40
+ # if test(?d, '.git/config')
41
+ # sh "git add db/bootstraps/#{args.db.sub(/^db\//,'')}.sql"
42
+ # sh %Q{git commit -m "#{Time.now.strftime("%Y-%d-%m at %H:%M:%S")} : updated DB bootstraps for #{args.db}" }
43
+ # end
44
+ end
45
+
46
+ end
47
+
48
+ namespace :bootstrap do
49
+
50
+ desc "Bootstrap NEW DB (db=db/name.db, bf=db/bootstraps/name.sql)"
51
+ task :new, [:db, :bf] do |t, args|
52
+ unless args.db && args.bf
53
+ msg = %Q[\nERROR:\n\n You must define the DB variable like this:\n]
54
+ msg << %Q[ rake db:bootstrap:new db=db/name-of-database.db\n]
55
+ msg << %Q[ bf=db/bootstraps/name.sql \n\n]
56
+ puts msg
57
+ else
58
+ sh "sqlite3 #{args.db} < #{args.bf}"
59
+ puts "-- created new DB [ #{args.db} ]\n"
60
+ puts "-- - bootstrapped with [ #{args.bf} ]\n\n"
61
+ end
62
+ end
63
+
64
+ end #/namespace :bootstrap
65
+
66
+ desc "Dump database(s) to .sql file(s)"
67
+ task :dump do
68
+ # In order to dump a SQLite database you can use the following command:
69
+ # sqlite database .dump > database.sql
70
+ Kematzy::Tasks::Rake::DB.dump_all_dbs_and_wrap_dumps_with_comments(:backups)
71
+ puts "-- dumped all DBs into .sql files\n\n"
72
+ end
73
+
74
+ namespace :dump do
75
+
76
+ desc "Dump current database as a bootstrap .sql file"
77
+ task :bootstrap do
78
+ Kematzy::Tasks::Rake::DB.dump_all_dbs_and_wrap_dumps_with_comments(:bootstraps)
79
+ end
80
+
81
+ end #/ namespace :dump
82
+
83
+ namespace :production do
84
+
85
+ desc "Convert development.db into production.db"
86
+ task :setup do
87
+ # step 1: backup current production db
88
+ db_name = 'production.db'
89
+ `cd db/ && tar zcf ../db/backups/#{Time.now.strftime("%Y%m%d-%H%M%S")}-#{db_name}.tar.gz #{db_name} `
90
+ puts "\n-- created a compressed backup version of [ production.db ]\n"
91
+
92
+ sh "cp db/development.db db/production.db"
93
+ end
94
+ end #/ namespace production
95
+
96
+ desc "Init DB directory structure, for use by these Rake commands"
97
+ task :setup do
98
+ sh "mkdir -p db/bootstraps"
99
+ sh "mkdir -p db/backups"
100
+ end
101
+
102
+
103
+ end #/ namespace :db
@@ -0,0 +1,104 @@
1
+
2
+
3
+ namespace :fs do
4
+
5
+ desc "Copy file/dir(s) :from => :to (from=path/2/.., to=path/2/..)"
6
+ task :copy, [:from, :to] do |t, args|
7
+ unless args.from && args.to
8
+ msg = %Q[\nERROR:\n\n You must define the :from, :to variable like this:\n]
9
+ msg << %Q[ rake fs:copy from=path/2/something/ to=path/2/something \n\n]
10
+ msg << %Q[ NB! remember to add a trailing '/' to the end of :from \n]
11
+ msg << %Q[ when you want to copy the contents only \n\n]
12
+ puts msg
13
+ else
14
+ # do task here
15
+ sh "mkdir -p #{args.to}" unless test(?e, "#{Dir.pwd}/#{args.to}")
16
+ sh "cp -r #{args.from} #{args.to}"
17
+ end
18
+ end
19
+
20
+ desc "Move file/dir(s) :from => :to (from=path/2/.., to=path/2/..)"
21
+ task :move, [:from, :to] do |t, args|
22
+ unless args.from && args.to
23
+ msg = %Q[\nERROR:\n\n You must define the :from, :to variable like this:\n]
24
+ msg << %Q[ rake fs:move from=path/2/something/ to=path/2/something \n\n]
25
+ msg << %Q[ NB! remember to add a trailing '/' to the end of :from \n]
26
+ msg << %Q[ when you want to move the contents only \n\n]
27
+ puts msg
28
+ else
29
+ # do task here
30
+ sh "mkdir -p #{args.to}" unless test(?e, "#{Dir.pwd}/#{args.to}")
31
+ sh "mv #{args.from} #{args.to}"
32
+ end
33
+ end
34
+
35
+
36
+ namespace :create do
37
+
38
+ namespace :dir do
39
+
40
+ desc "Creates Models directory at (path=path/2/dir)"
41
+ task :models, [:path] do |t, args|
42
+ unless args.path
43
+ msg = %Q[\nERROR:\n\n You must define the :path variable like this:\n]
44
+ msg << %Q[ rake fs:create:dir:models path=path/2/dir \n\n]
45
+ puts msg
46
+ else
47
+ # do task here
48
+ sh "mkdir -p #{Dir.pwd}/#{args.path}models"
49
+ end
50
+ end
51
+
52
+ desc "Creates Helpers directory at (path=path/2/dir)"
53
+ task :helpers, [:path] do |t, args|
54
+ unless args.path
55
+ msg = %Q[\nERROR:\n\n You must define the :path variable like this:\n]
56
+ msg << %Q[ rake fs:create:dir:helpers path=path/2/dir \n\n]
57
+ puts msg
58
+ else
59
+ # do task here
60
+ sh "mkdir -p #{Dir.pwd}/#{args.path}helpers"
61
+ end
62
+ end
63
+
64
+ desc "Creates Routes directory at (path=path/2/dir)"
65
+ task :routes, [:path] do |t, args|
66
+ unless args.path
67
+ msg = %Q[\nERROR:\n\n You must define the :path variable like this:\n]
68
+ msg << %Q[ rake fs:create:dir:routes path=path/2/dir \n\n]
69
+ puts msg
70
+ else
71
+ # do task here
72
+ sh "mkdir -p #{Dir.pwd}/#{args.path}routes"
73
+ end
74
+ end
75
+
76
+ desc "Creates a Classes directory at (path=path/2/dir)"
77
+ task :classes, [:path] do |t, args|
78
+ unless args.path
79
+ msg = %Q[\nERROR:\n\n You must define the :path variable like this:\n]
80
+ msg << %Q[ rake fs:create:dir:classes path=path/2/dir \n\n]
81
+ puts msg
82
+ else
83
+ # do task here
84
+ sh "mkdir -p #{Dir.pwd}/#{args.path}classes"
85
+ end
86
+ end
87
+
88
+ desc "Create a New directory at (path=path/2/new/dir)"
89
+ task :new, [:path] do |t, args|
90
+ unless args.path
91
+ msg = %Q[\nERROR:\n\n You must define the :path variable like this:\n]
92
+ msg << %Q[ rake fs:create:dir:new path=path/2/new/dir \n\n]
93
+ puts msg
94
+ else
95
+ sh "mkdir -p #{Dir.pwd}/#{args.path}"
96
+ end
97
+ end
98
+
99
+ end # namespace :dir
100
+
101
+ end #/ namespace :create
102
+
103
+ end #/ namespace fs
104
+
@@ -0,0 +1,36 @@
1
+
2
+
3
+ namespace :passenger do
4
+
5
+ desc "Initialize tmp/restart"
6
+ task :init => ['passenger:restart']
7
+
8
+ desc "Restart Passenger (touch tmp/restart.txt)"
9
+ task :restart do
10
+ sh "touch tmp/restart.txt"
11
+ end
12
+
13
+ namespace :always do
14
+
15
+ desc "Turn ON always restart Passenger (touch tmp/always_restart.txt)"
16
+ task :on do
17
+ sh "touch tmp/always_restart.txt"
18
+ end
19
+
20
+ desc "Turn OFF always restart Passenger (rm tmp/always_restart.txt)"
21
+ task :off do
22
+ sh "rm -f tmp/always_restart.txt"
23
+ end
24
+
25
+ end #/ namespace always
26
+
27
+ end #/ namespace passenger
28
+
29
+ desc "Shortcut to :passenger:restart"
30
+ task :psr => ['passenger:restart']
31
+
32
+ desc "Shortcut to :passenger:always:on"
33
+ task :pson => ['passenger:always:on']
34
+
35
+ desc "Shortcut to :passenger:always:off"
36
+ task :psoff => ['passenger:always:off']
@@ -0,0 +1,39 @@
1
+
2
+
3
+
4
+ namespace :sass do
5
+
6
+ namespace :page do
7
+
8
+ desc "Create a NEW Sass page and include it in the loads"
9
+ task :new, [:page] do |t, args|
10
+ unless args.page
11
+ msg = %Q[\nERROR:\n\n You must define the :page variable like this:\n]
12
+ msg << %Q[ rake sass:page:new page=admin:news \n\n]
13
+ puts msg
14
+ else
15
+ app, page_name = args.page.split(':')
16
+ # puts "args.page = [#{args.page.inspect}] and app=[#{app}], page_name=[#{page_name}]"
17
+
18
+ sass_code = %Q[\n// \n=app-page-#{page_name}\n]
19
+ sass_code << %Q[ /* #{page_name.upcase} PAGE OVERRIDES ----------------------\n]
20
+ sass_code << %Q[ ##{page_name} \n]
21
+ sass_code << %Q[ #main-content \n]
22
+ sass_code << %Q[ /* should be defined \n]
23
+ sass_code << %Q[ \n]
24
+ sass_code << %Q[ /* /#{page_name.upcase} PAGE -------------------------------\n \n]
25
+
26
+ # add the sass_code to the sass page
27
+ # sh %Q[echo "#{sass_code}" > apps/#{app}/sass/pages/#{page_name}.sass]
28
+ `echo "#{sass_code}" > apps/#{app}/sass/pages/#{page_name}.sass`
29
+ # now add the loader
30
+ # FIXME:: Need to look for loader and only add if NOT found
31
+ `echo "@import pages/#{page_name}.sass" >> apps/#{app}/sass/_pages.sass`
32
+ puts "\n Created Sass page [ apps/#{app}/sass/pages/#{page_name}.sass ]\n\n"
33
+ end
34
+ end
35
+
36
+ end #/ namespace page
37
+
38
+ end #/ namespace sass
39
+
@@ -0,0 +1,32 @@
1
+
2
+ namespace :symlink do
3
+
4
+ desc "Symlink all shared directories to public"
5
+ task :shared, [:dirs] do |t, args|
6
+ unless args.dirs
7
+ msg = %Q[\nERROR:\n\n You must define the :dirs variable like this:\n]
8
+ msg << %Q[ rake symlink:shared dirs=assets, downloads, images, photos, movies, system, uploads,... \n\n]
9
+ puts msg
10
+ else
11
+ PROJECT_ROOT = File.dirname(File.expand_path(__FILE__))
12
+ dirs.each do |dir|
13
+ `ln -s #{File.join(File.dirname(PROJECT_ROOT), 'shared', dir)} #{File.join(PROJECT_ROOT, 'public', dir)}`
14
+ puts "symlinked '../shared/#{dir}' => 'current/public/#{dir}'"
15
+ end
16
+ end
17
+ end
18
+
19
+ end #/ namespace symlink
20
+ #
21
+ # namespace :symlink do
22
+ #
23
+ # desc "Symlink shared directories to current/public"
24
+ # task :shared do
25
+ # PROJECT_ROOT = File.dirname(File.expand_path(__FILE__))
26
+ # %w(assets downloads images photos movies system uploads).each do |dir|
27
+ # `ln -s #{File.join(File.dirname(PROJECT_ROOT), 'shared', dir)} #{File.join(PROJECT_ROOT, 'public', dir)}`
28
+ # puts "symlinked '../shared/#{dir}' => 'current/public/#{dir}'"
29
+ # end
30
+ # end
31
+ #
32
+ # end #/ namespace symlink
@@ -0,0 +1,56 @@
1
+
2
+
3
+ module Kematzy
4
+
5
+ module Tasks
6
+ VERSION = '0.1.0'
7
+ def self.version
8
+ "Kematzy::Tasks v#{VERSION}"
9
+ end
10
+
11
+ module Rake
12
+ module DB
13
+
14
+ #
15
+ # TODO: add some comments here
16
+ #
17
+ # ==== Examples
18
+ #
19
+ #
20
+ # @api private
21
+ def self.dump_all_dbs_and_wrap_dumps_with_comments(dump_dir = :backups)
22
+ # ensure we have that directory to dump into first
23
+ FileUtils.mkdir_p("db/#{dump_dir.to_s}")
24
+
25
+ Dir["db/*.db"].each do |db|
26
+ if dump_dir == :bootstraps
27
+ backup_file = "db/#{dump_dir}/#{File.basename(db)}.sql"
28
+ else
29
+ backup_file = "db/#{dump_dir}/#{Time.now.strftime("%Y%m%d-%H%M%S")}-#{File.basename(db)}.sql"
30
+ end
31
+
32
+ comment = %Q['-- ++++ ]
33
+ if dump_dir == :bootstraps
34
+ comment << %Q[\n-- BOOTSTRAP FILE FOR DB [ #{File.basename(db)} ] ]
35
+ else
36
+ comment << %Q[\n-- BACKUP OF DB [ #{File.basename(db)} ] ]
37
+ end
38
+ comment << %Q[\n-- IN APP [ #{Dir.pwd} ] ]
39
+ comment << %Q[\n-- Created on [ #{Time.now.strftime("%Y-%m-%d at %H:%M:%S")} ] ]
40
+ comment << %Q[\n-- ]
41
+ comment << %Q[\n-- /++++ \n']
42
+
43
+ `echo #{comment} > #{backup_file}`
44
+ sh "sqlite3 #{db} .dump >> #{backup_file}"
45
+ `echo '\n-- \n-- /EOF \n-- ' >> #{backup_file}`
46
+ end
47
+
48
+ end
49
+
50
+ end #/module DB
51
+
52
+ end #/module Rake
53
+
54
+ end #/module Tasks
55
+
56
+ end #/module Kematzy
@@ -0,0 +1,13 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../spec_helper')
2
+
3
+ describe "Kematzy" do
4
+
5
+ describe "Tasks" do
6
+
7
+ it "should have some real tests where all the functionality is carefully tested" do
8
+ "If You know how to do this, please fork and show me ;-)".should be_a_kind_of(String)
9
+ end
10
+
11
+ end #/ Tasks
12
+
13
+ end #/ Kematzy
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'kematzy/tasks'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+ # require 'spec/interop/test'
7
+
8
+ Spec::Runner.configure do |config|
9
+
10
+ end
11
+
12
+ def fixtures_path
13
+ "#{File.dirname(File.expand_path(__FILE__))}/fixtures"
14
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kematzy-tasks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kematzy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-22 00:00:00 +08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.8.7
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description: All those helpful little Rake tasks in one single location for use in any site
36
+ email: kematzy@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - LICENSE
43
+ - README.rdoc
44
+ files:
45
+ - .document
46
+ - .gitignore
47
+ - LICENSE
48
+ - README.rdoc
49
+ - Rakefile
50
+ - VERSION
51
+ - kematzy-tasks.gemspec
52
+ - lib/kematzy/tasks.rb
53
+ - lib/kematzy/tasks/rake/all.rb
54
+ - lib/kematzy/tasks/rake/db.rb
55
+ - lib/kematzy/tasks/rake/filesystem.rb
56
+ - lib/kematzy/tasks/rake/passenger.rb
57
+ - lib/kematzy/tasks/rake/sass.rb
58
+ - lib/kematzy/tasks/rake/symlink.rb
59
+ - spec/kematzy/tasks_spec.rb
60
+ - spec/spec_helper.rb
61
+ has_rdoc: true
62
+ homepage: http://github.com/kematzy/kematzy-tasks
63
+ licenses: []
64
+
65
+ post_install_message:
66
+ rdoc_options:
67
+ - --charset=UTF-8
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: "0"
75
+ version:
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ requirements: []
83
+
84
+ rubyforge_project:
85
+ rubygems_version: 1.3.5
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: A helpful collection of Rake tasks for improved workflows
89
+ test_files:
90
+ - spec/kematzy/tasks_spec.rb
91
+ - spec/spec_helper.rb