Last active
January 3, 2016 08:49
-
-
Save huydx/8438905 to your computer and use it in GitHub Desktop.
ascii.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'date' | |
require 'rugged' | |
data = File.read('./source.txt').split("\n") | |
dist = data[0].size.times.map {|i| data.map {|n| n[i] } }.flatten | |
date = Date.today - 366 | |
date += 1 until date.wday.zero? | |
Dir.chdir('./dist') do | |
repo = Rugged::Repository.init_at('.') | |
dist.each do |char| | |
date += 1 | |
next if char == ' ' | |
index = Rugged::Index.new | |
options = {} | |
options[:author] = { email: "[email protected]", name: '[email protected]', time: date.to_time } | |
options[:committer] = { email: "[email protected]", name: '[email protected]', time: date.to_time } | |
options[:message] = '[email protected]' | |
options[:update_ref] = 'HEAD' | |
70.times do | |
options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact | |
options[:tree] = index.write_tree(repo) | |
Rugged::Commit.create(repo, options) | |
end | |
end | |
end | |
====================== source.txt: | |
# # # # # # | |
# # # # # # | |
# # # # # # | |
######## # # ## | |
# # # # # | |
# # # # # | |
# # ####### # |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment