Skip to content

Commit 8a69b21

Browse files
committed
Adding whitespace rake tasks.
This should make sure that formatting is followed.
1 parent 354f242 commit 8a69b21

1 file changed

Lines changed: 94 additions & 83 deletions

File tree

Rakefile

Lines changed: 94 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -7,102 +7,113 @@ require 'cucumber/rake/task'
77
#this lets us run 'rake spec' to run rspec tests
88
Spec::Rake::SpecTask.new do |t|
99

10-
#tell rspec where our spec files are
11-
t.spec_files = FileList['spec/*_spec.rb',]
12-
13-
#get some nice pretty options
14-
t.spec_opts = ["--colour", "--backtrace"]
15-
#
16-
#include our spec helper
17-
t.ruby_opts = ["-r spec/spec_helper.rb"]
10+
#tell rspec where our spec files are
11+
t.spec_files = FileList['spec/*_spec.rb',]
12+
13+
#get some nice pretty options
14+
t.spec_opts = ["--colour", "--backtrace"]
15+
#
16+
#include our spec helper
17+
t.ruby_opts = ["-r spec/spec_helper.rb"]
1818
end
1919

2020
#this lets us run 'rake features' to run cucumber tests
2121
Cucumber::Rake::Task.new(:features) do |t|
22-
t.cucumber_opts = "--format progress"
22+
t.cucumber_opts = "--format progress"
2323
end
2424

2525
#this namespace is used for all database related tasks
2626
namespace :db do
2727

28-
desc "Seed the database with initial data."
29-
task :seed do
30-
#connect to the database
31-
environment = ENV['RACK_ENV'] || "development"
32-
33-
require 'mongo_mapper'
34-
MongoMapper.connection = Mongo::Connection.new('localhost')
35-
MongoMapper.database = "hackety-#{environment}"
36-
MongoMapper.database.collections.each do |c|
37-
c.remove
38-
end
39-
40-
41-
#make an admin user
42-
require 'models/hacker'
43-
admin = Hacker.create({
44-
:username => "steve",
45-
:email => "steve@steveklabnik.com",
46-
:password => "password",
47-
:password_confirmation => "password",
48-
:admin => true,
49-
:about => "I hack on Hackety Hack!"
50-
})
51-
52-
#we're also going to make a regular user too
53-
somebody = Hacker.create({
54-
:username => "somebody",
55-
:email => "somebody@example.com",
56-
:password => "password",
57-
:password_confirmation => "password",
58-
:about => "I'm just a regular person!"
59-
})
60-
#make an initial Post, with a comment
61-
require 'models/post'
62-
require 'models/comment'
63-
post = Post.create({
64-
:title => "Welcome to the Hackety Site!",
65-
:body => "This is an intial post, so that you can see how everything looks. Here's a [link](http://github.com/hacketyhack/hackety-hack.com) to the source code on GitHub. Now I'm just going to do the usual stuff:
28+
desc "Seed the database with initial data."
29+
task :seed do
30+
#connect to the database
31+
environment = ENV['RACK_ENV'] || "development"
32+
33+
require 'mongo_mapper'
34+
MongoMapper.connection = Mongo::Connection.new('localhost')
35+
MongoMapper.database = "hackety-#{environment}"
36+
MongoMapper.database.collections.each do |c|
37+
c.remove
38+
end
39+
40+
41+
#make an admin user
42+
require 'models/hacker'
43+
admin = Hacker.create({
44+
:username => "steve",
45+
:email => "steve@steveklabnik.com",
46+
:password => "password",
47+
:password_confirmation => "password",
48+
:admin => true,
49+
:about => "I hack on Hackety Hack!"
50+
})
51+
52+
#we're also going to make a regular user too
53+
somebody = Hacker.create({
54+
:username => "somebody",
55+
:email => "somebody@example.com",
56+
:password => "password",
57+
:password_confirmation => "password",
58+
:about => "I'm just a regular person!"
59+
})
60+
#make an initial Post, with a comment
61+
require 'models/post'
62+
require 'models/comment'
63+
post = Post.create({
64+
:title => "Welcome to the Hackety Site!",
65+
:body => "This is an intial post, so that you can see how everything looks. Here's a [link](http://github.com/hacketyhack/hackety-hack.com) to the source code on GitHub. Now I'm just going to do the usual stuff:
6666
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
6767
6868
And a blockquote:
6969
7070
> Lorem ipsum dolor sit amet, consectetur adipiscicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
7171
72-
Esse insolens mnesarchum eam id, nec ad detracto disputando. Nec malorum postulant disputationi ad. Pri menandri inimicus ut. Pro velit affert mediocritatem at, eu nec voluptua inciderint, ne mei diam praesent. No eum tamquam appetere, ex eos habemus evertitur consequat, quo et wisi tincidunt consectetuer. Vocent lobortis est cu."
73-
})
74-
75-
post.comments << Comment.new({
76-
:body => "This post is awesome! I've never seen such insightful commentary!",
77-
:author => "somebody",
78-
:author_email => "somebody@example.com"
79-
})
80-
post.comments << Comment.new({
81-
:body => "Oh, and I almost forgot! I wanted to say something really long, so that we could see how a long comment looks, but I was in such a hurry to compliment your excellent writing that I could barely contain myself! Luckily, this time I'm much more verbose, and so it should fulfill the objective. Great!",
82-
:author => "somebody",
83-
:author_email => "somebody@example.com"
84-
})
85-
post.save
86-
87-
#now let's make a discussion on the forum:
88-
require 'models/discussion'
89-
require 'models/reply'
90-
require 'utility'
91-
halp = Discussion.create({
92-
:title => "HALP ME!",
93-
:body => "I just don't understand!",
94-
:forum => "learning_ruby",
95-
:author => "somebody",
96-
:author_email => "somebody@example.com"
97-
})
98-
99-
#and a reply:
100-
halp.replies << Reply.new({
101-
:body => "I'd love to help you!",
102-
:author => "steve",
103-
:author_email => "steve@steveklabnik.com"
104-
})
105-
106-
halp.save
107-
end
72+
Esse insolens mnesarchum eam id, nec ad detracto disputando. Nec malorum postulant disputationi ad. Pri menandri inimicus ut. Pro velit affert mediocritatem at, eu nec voluptua inciderint, ne mei diam praesent. No eum tamquam appetere, ex eos habemus evertitur consequat, quo et wisi tincidunt consectetuer. Vocent lobortis est cu."
73+
})
74+
75+
post.comments << Comment.new({
76+
:body => "This post is awesome! I've never seen such insightful commentary!",
77+
:author => "somebody",
78+
:author_email => "somebody@example.com"
79+
})
80+
post.comments << Comment.new({
81+
:body => "Oh, and I almost forgot! I wanted to say something really long, so that we could see how a long comment looks, but I was in such a hurry to compliment your excellent writing that I could barely contain myself! Luckily, this time I'm much more verbose, and so it should fulfill the objective. Great!",
82+
:author => "somebody",
83+
:author_email => "somebody@example.com"
84+
})
85+
post.save
86+
87+
#now let's make a discussion on the forum:
88+
require 'models/discussion'
89+
require 'models/reply'
90+
require 'utility'
91+
halp = Discussion.create({
92+
:title => "HALP ME!",
93+
:body => "I just don't understand!",
94+
:forum => "learning_ruby",
95+
:author => "somebody",
96+
:author_email => "somebody@example.com"
97+
})
98+
99+
#and a reply:
100+
halp.replies << Reply.new({
101+
:body => "I'd love to help you!",
102+
:author => "steve",
103+
:author_email => "steve@steveklabnik.com"
104+
})
105+
106+
halp.save
107+
end
108108
end
109+
110+
namespace :whitespace do
111+
desc 'Removes trailing whitespace'
112+
task :cleanup do
113+
sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
114+
end
115+
task :retab do
116+
sh %{find . -name '*.rb' -exec sed -i '' 's/\t/ /g' {} \\;}
117+
end
118+
end
119+

0 commit comments

Comments
 (0)