-
Notifications
You must be signed in to change notification settings - Fork 3
/
Thorfile
80 lines (61 loc) · 1.96 KB
/
Thorfile
1
2
3
4
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
class Monk < Thor
namespace :monk
include Thor::Actions
desc "test", "Run all the tests"
def test
verify "config/settings.example.yml"
verify "config/redis/test.example.conf"
$:.unshift File.join(File.dirname(__FILE__), "test")
Dir['test/**/*_test.rb'].each do |file|
load file unless file =~ /^-/
end
end
desc "start ENV", "Start Monk in the supplied environment"
def start(env = ENV["RACK_ENV"] || "development")
verify "config/settings.example.yml"
verify "config/redis/#{env}.example.conf"
exec "env RACK_ENV=#{env} ruby init.rb"
end
desc "copy_example EXAMPLE, TARGET", "Copies an example file to its destination"
def copy_example(example, target = target_file_for(example))
File.exists?(target) ? return : say_status(:missing, target)
File.exists?(example) ? confirm_copy_file(example, target) : say_status(:missing, example)
end
desc "verify EXAMPLE_FILE", "Verifies that the corresponding file exists for the supplied example file"
def verify(example)
copy_example(example) unless File.exists?(target_file_for(example))
end
desc "seed", "Seeds the database with random data"
def seed
init
Ohm.flush
100.times do
Post.spawn(:datetime => (Time.now - rand(24) * 60 * 60).strftime("%Y-%m-%d %H:%M:%S"))
end
end
desc "sass", "Compile all Sass files into CSS"
def sass
init
require "sass/plugin"
Sass::Plugin.options.merge! \
:template_location => root_path("app", "views", "css"),
:css_location => File.join(Main.public, "css"),
:cache => false
Sass::Plugin.update_stylesheets
end
private
def init
require "init"
end
def self.source_root
File.dirname(__FILE__)
end
def confirm_copy_file(source, target)
if yes?("Do you want to copy the file #{source} to #{target}? [yn]")
copy_file(source, target)
end
end
def target_file_for(example_file)
example_file.sub(".example", "")
end
end