class FlatironScheduler
Attributes
day[R]
path[R]
week[R]
Public Class Methods
clean_schedule(branch)
click to toggle source
# File lib/flatiron_scheduler.rb, line 81 def self.clean_schedule(branch) if branch == 'future' system("rm -rf blogs") system("rm -rf presentations") system("rm -rf videos") system("rm -rf interviews") elsif branch == 'master' dir = Dir.new(Dir.pwd) dir.each { |file_name| system("rm -rf #{file_name}") if file_name.start_with?("week") } end end
create_schedule(name, path)
click to toggle source
# File lib/flatiron_scheduler.rb, line 93 def self.create_schedule(name, path) git_clone(path, name) move_to_dir(name) checkout("future", ["-b"]) clean_schedule("future") new_schedule_commit checkout("master") system("git merge future") clean_schedule("master") new_schedule_commit system("git remote remove origin") end
move_to_dir(dir)
click to toggle source
# File lib/flatiron_scheduler.rb, line 72 def self.move_to_dir(dir) Dir.chdir(dir) end
new(week, day)
click to toggle source
# File lib/flatiron_scheduler.rb, line 9 def initialize(week, day) @path = read_path @week = week @day = day end
new_schedule_commit()
click to toggle source
# File lib/flatiron_scheduler.rb, line 76 def self.new_schedule_commit system('git add --all') system("git commit -am \"New Schedule\"") end
rollback()
click to toggle source
CLASS METHODS
# File lib/flatiron_scheduler.rb, line 60 def self.rollback self.move_to_dir(read_path) self.checkout("master") log = `git log` split_log = log.split("\n") commit_id = split_log[1].split("\e[")[1].split("m")[1] system("git reset --hard #{commit_id}") system("git push -f") end
Public Instance Methods
add_commit()
click to toggle source
# File lib/flatiron_scheduler.rb, line 21 def add_commit system('git add .') self.day.to_i <= 5 ? system("git commit -am \"Week #{self.week}, Day #{self.day}\"") : system("git commit -am \"Day #{self.day}\"") end
change_symlink()
click to toggle source
# File lib/flatiron_scheduler.rb, line 30 def change_symlink system("ln -sfn #{file_name} README.md") end
checkout_today()
click to toggle source
# File lib/flatiron_scheduler.rb, line 26 def checkout_today system("git checkout future -- #{file_name}") end
file_name()
click to toggle source
INSTANCE METHODS
# File lib/flatiron_scheduler.rb, line 17 def file_name "week-#{week}/day-#{day}.md" end
future_branch_updates()
click to toggle source
GROUPS
# File lib/flatiron_scheduler.rb, line 36 def future_branch_updates FlatironScheduler.checkout("future") FlatironScheduler.pull add_commit FlatironScheduler.push end
master_branch_updates()
click to toggle source
# File lib/flatiron_scheduler.rb, line 43 def master_branch_updates FlatironScheduler.checkout("master") FlatironScheduler.pull checkout_today change_symlink add_commit FlatironScheduler.push end
run()
click to toggle source
# File lib/flatiron_scheduler.rb, line 52 def run FlatironScheduler.move_to_dir(self.path) future_branch_updates master_branch_updates end