forked from w3cub/automaticgit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
82 lines (68 loc) · 1.96 KB
/
Rakefile
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
#!/usr/bin/env ruby
require 'find'
require 'fileutils'
def generate_word
(0...8).map { (65 + rand(26)).chr }.join
end
def create_file(path, extension)
dir = File.dirname(path)
unless File.directory?(dir)
FileUtils.mkdir_p(dir)
end
path << ".#{extension}"
File.open(path, 'w') do |page|
page << "word = " + generate_word
end
end
# find . -maxdepth 1 -type f | xargs git add
desc "dircommit file"
task :dircommit do
commitdir = "dircommit"
FileUtils.cd(commitdir) do |path|
dir = File.join(File.dirname(__FILE__), path, "*")
subdir = File.join(File.dirname(__FILE__), path)
Dir[dir].each { |x|
if FileTest.directory?(x)
cmdir = x.sub(File.join(File.dirname(__FILE__), commitdir, "/"), "")
# puts x
puts "\n add directory #{cmdir}"
system "git add -A #{cmdir}/"
message = "Site updated #{cmdir} directory at #{Time.now.utc}"
puts "\n## Committing: #{message}"
system "git commit -m \"#{message}\""
puts "\n## Pushing generated #{cmdir} website"
Bundler.with_clean_env { system "git push origin master" }
puts "\n## Github Pages deploy complete"
end
}
puts "\n add directory #{commitdir}"
system "git add -A ."
message = "Site updated #{commitdir} directory at #{Time.now.utc}"
puts "\n## Committing: #{message}"
system "git commit -m \"#{message}\""
puts "\n## Pushing generated #{commitdir} website"
Bundler.with_clean_env { system "git push origin master" }
puts "\n## Github Pages deploy complete"
end
end
desc "generate file"
task :generate do
dircommitglob = Dir.glob(File.join(File.dirname(__FILE__), "dircommit", "*"))
FileUtils.rm_rf(dircommitglob)
FileUtils.cd("dircommit/") do
10.times do
p1 = generate_word
p2 = generate_word
create_file(File.join(p1, p2, generate_word), 'txt')
2.times do
create_file(File.join(p1, generate_word), 'txt')
end
end
2.times do
create_file(File.join(generate_word), 'txt')
end
end
end
desc "Task description"
task :default do
end