-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun.rake
113 lines (102 loc) · 3.82 KB
/
run.rake
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
def say(msg, &block)
puts "#{msg}..."
if block_given?
yield
puts " Done."
end
end
namespace :run_app do
desc 'To do `bundle install` in given directory'
task :bundle_install, [:dir_name] do |t, args|
say 'bundle install command is executing inside '+ "#{args[:dir_name]}" do
if Dir.exists?("#{args[:dir_name]}")
system("cd #{args[:dir_name]} && bundle install")
else
puts "File #{args[:dir_name]} not found."
end
end
end
desc 'To do `bundle update` in given directory'
task :bundle_update, [:dir_name] do |t, args|
say 'bundle update command is executing inside ' + "#{args[:dir_name]}" do
if Dir.exists?("#{args[:dir_name]}")
system("cd #{args[:dir_name]} && bundle update")
end
end
end
desc 'To do `bundle exec rails s` in given directory'
task :rails_server, [:dir_name] do |t, args|
say 'bundle update command is executing inside '+ "#{args[:dir_name]}" do
if Dir.exists?("#{args[:dir_name]}")
system("cd #{args[:dir_name]} && bundle exec rails s")
end
end
end
desc 'To run demo_rails rails app '
task :rails do
say 'Running rails app..' do
file_name = 'demo_rails'
# Rake.application.invoke_task("run_app:bundle_install[#{file_name}]")
# Rake.application.invoke_task("run_app:bundle_update[#{file_name}]")
# Rake.application.invoke_task("run_app:rails_server[#{file_name}]")
#
# or do these lines:
Rake::Task["run_app:bundle_install"].invoke("#{file_name}")
Rake::Task["run_app:bundle_update"].invoke("#{file_name}")
Rake::Task["run_app:rails_server"].invoke("#{file_name}")
end
end
desc 'To do `bundle exec nanoc compile` in given directory'
task :nanoc_compile, [:dir_name] do |t, args|
say '`nanoc` command is executing inside '+ "#{args[:dir_name]}" do
if Dir.exists?("#{args[:dir_name]}")
system("cd #{args[:dir_name]} && bundle exec nanoc")
end
end
end
desc 'To do `bundle exec nanoc view` in given directory'
task :nanoc_server, [:dir_name] do |t, args|
say '`nanoc view` command is executing inside '+ "#{args[:dir_name]}" do
if Dir.exists?("#{args[:dir_name]}")
system("cd #{args[:dir_name]} && bundle exec nanoc view")
end
end
end
desc 'To run demo_nanoc nanoc app '
task :nanoc do
say 'Running nanoc app..' do
file_name = 'demo_nanoc'
# Rake.application.invoke_task("run_app:bundle_install[#{file_name}]")
# Rake.application.invoke_task("run_app:bundle_update[#{file_name}]")
# Rake.application.invoke_task("run_app:rails_server[#{file_name}]")
#
# or do these lines:
Rake::Task["run_app:bundle_install"].invoke("#{file_name}")
Rake::Task["run_app:bundle_update"].invoke("#{file_name}")
Rake::Task["run_app:nanoc_compile"].invoke("#{file_name}")
Rake::Task["run_app:nanoc_server"].invoke("#{file_name}")
end
end
desc 'To do `bundle exec ruby app.rb` in given directory'
task :sinatra_server, [:dir_name] do |t, args|
say '`ruby app.rb` command is executing inside '+ "#{args[:dir_name]}" do
if Dir.exists?("#{args[:dir_name]}")
system("cd #{args[:dir_name]} && bundle exec ruby app.rb")
end
end
end
desc 'To run demo_sinatra Sinatra app '
task :sinatra do
say 'Running sinatra app..' do
file_name = 'demo_sinatra'
# Rake.application.invoke_task("run_app:bundle_install[#{file_name}]")
# Rake.application.invoke_task("run_app:bundle_update[#{file_name}]")
# Rake.application.invoke_task("run_app:rails_server[#{file_name}]")
#
# or do these lines:
Rake::Task["run_app:bundle_install"].invoke("#{file_name}")
Rake::Task["run_app:bundle_update"].invoke("#{file_name}")
Rake::Task["run_app:sinatra_server"].invoke("#{file_name}")
end
end
end