flatiron_scheduler 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5e89e9833bc36c8a4e21de3163c7e830869d76c1
4
+ data.tar.gz: 8bf57866b5af100620ec161ba65f201b9f0f0e32
5
+ SHA512:
6
+ metadata.gz: e9b7180312e7fb9ebc4b7a4fcc1a4335bafdcaf5d8da4ea18df49c4e9e5c086373a41f5e06a6f0f7f254fcc004b6d5a72afc1825f142c27f8f739797136bb83a
7
+ data.tar.gz: 81f5a3a4c78d389701aa9a52ef1e7820cceed2e25979c8fa843a86f4fc4d7cc97da7d4dfed7328fd657f47a462959b8881d1e21b74839961f1fc42fe428ed9bc
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'flatiron_scheduler'
4
+ require 'path_setup'
5
+ require 'templater'
6
+
7
+ include PathSetup
8
+ include Templater
9
+
10
+ def documentation
11
+ message = '''
12
+ ERROR executing gem. Valid commands:
13
+
14
+ flatiron_scheduler WEEK DAY
15
+ flatiron_scheduler new SCHEDULE_NAME CLONE_URL
16
+ flatiron_scheduler setup SETUP_PATH
17
+ flatiron_scheduler template FILE_NAME
18
+ '''
19
+ puts message
20
+ end
21
+
22
+ if ARGV[0] == 'setup'
23
+ setup_path(ARGV[1])
24
+ elsif ARGV[0] == 'new'
25
+ FlatironScheduler.create_schedule(ARGV[1], ARGV[2])
26
+ elsif ARGV[0].to_i != 0 && ARGV[1].to_i != 0
27
+ if !File.exist?("/Users/#{ENV['USER']}/.fis_scheduler")
28
+ puts "What is the path of your repo?"
29
+ setup_path($stdin.gets.chomp)
30
+ end
31
+ FlatironScheduler.new(ARGV[0], ARGV[1]).run
32
+ elsif ARGV[0] == 'template'
33
+ new_file(ARGV[1])
34
+ else
35
+ documentation
36
+ end
@@ -0,0 +1,98 @@
1
+ require 'path_setup'
2
+ require 'git_helper'
3
+
4
+ class FlatironScheduler
5
+ include PathSetup
6
+ extend GitHelper
7
+ attr_reader :week, :day, :path
8
+
9
+ def initialize(week, day)
10
+ @path = read_path
11
+ @week = week
12
+ @day = day
13
+ end
14
+
15
+ ## INSTANCE METHODS
16
+
17
+ def file_name
18
+ "week-#{week}/day-#{day}.md"
19
+ end
20
+
21
+ def add_commit
22
+ system('git add .')
23
+ self.day.to_i <= 5 ? system("git commit -am \"Week #{self.week}, Day #{self.day}\"") : system("git commit -am \"Day #{self.day}\"")
24
+ end
25
+
26
+ def checkout_today
27
+ system("git checkout future -- #{file_name}")
28
+ end
29
+
30
+ def change_symlink
31
+ system("ln -sfn #{file_name} README.md")
32
+ end
33
+
34
+ ## GROUPS
35
+
36
+ def future_branch_updates
37
+ FlatironScheduler.checkout("future")
38
+ FlatironScheduler.pull
39
+ add_commit
40
+ FlatironScheduler.push
41
+ end
42
+
43
+ def master_branch_updates
44
+ FlatironScheduler.checkout("master")
45
+ FlatironScheduler.pull
46
+ checkout_today
47
+ change_symlink
48
+ add_commit
49
+ FlatironScheduler.push
50
+ end
51
+
52
+ def run
53
+ FlatironScheduler.move_to_dir(self.path)
54
+ future_branch_updates
55
+ master_branch_updates
56
+ end
57
+
58
+ ## CLASS METHODS
59
+
60
+ def self.move_to_dir(dir)
61
+ Dir.chdir(dir)
62
+ end
63
+
64
+ def self.new_schedule_commit
65
+ system('git add --all')
66
+ system("git commit -am \"New Schedule\"")
67
+ end
68
+
69
+ def self.clean_schedule(branch)
70
+ if branch == 'future'
71
+ system("rm -rf blogs")
72
+ system("rm -rf presentations")
73
+ system("rm -rf videos")
74
+ system("rm -rf interviews")
75
+ elsif branch == 'master'
76
+ dir = Dir.new(Dir.pwd)
77
+ dir.each { |file_name| system("rm -rf #{file_name}") if file_name.start_with?("week") }
78
+ end
79
+ end
80
+
81
+ def self.create_schedule(name, path)
82
+ git_clone(path, name)
83
+ move_to_dir(name)
84
+
85
+ checkout("future", ["-b"])
86
+
87
+ clean_schedule("future")
88
+ new_schedule_commit
89
+
90
+ checkout("master")
91
+ system("git merge future")
92
+
93
+ clean_schedule("master")
94
+ new_schedule_commit
95
+
96
+ system("git remote remove origin")
97
+ end
98
+ end
@@ -0,0 +1,17 @@
1
+ module GitHelper
2
+ def git_clone(path, name = "")
3
+ system("git clone #{path} #{name}")
4
+ end
5
+
6
+ def checkout(branch_name, flags = [])
7
+ system("git checkout #{flags.join(' ')} #{branch_name}")
8
+ end
9
+
10
+ def pull
11
+ system('git pull')
12
+ end
13
+
14
+ def push
15
+ system('git push')
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module PathSetup
2
+ def setup_path(path)
3
+ File.open("/Users/#{ENV['USER']}/.fis_scheduler", "w+"){ |f| f.write(path) }
4
+ end
5
+
6
+ def read_path
7
+ File.read("/Users/#{ENV['USER']}/.fis_scheduler")
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ module Templater
2
+ def new_file(file_name)
3
+ dir_path = file_name.split('/')[0..-2].join('/')
4
+ FileUtils.mkdir_p(dir_path) if dir_path != ""
5
+ File.open(file_name, "w+"){ |f| f.write(blank_template) }
6
+ end
7
+
8
+ def blank_template
9
+ '''# Day Number - Date
10
+
11
+ The Plan | |
12
+ ----------------|-------
13
+ |
14
+ |
15
+ |
16
+
17
+ # Labs
18
+
19
+ # Readings
20
+
21
+ # HW'''
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flatiron_scheduler
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Amanda Chang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple FIS Scheduling Gem
14
+ email: chang@flatironschool.com
15
+ executables:
16
+ - flatiron_scheduler
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/flatiron_scheduler
21
+ - lib/flatiron_scheduler.rb
22
+ - lib/git_helper.rb
23
+ - lib/path_setup.rb
24
+ - lib/templater.rb
25
+ homepage: http://rubygems.org/gems/flatiron_scheduler
26
+ licenses:
27
+ - MIT
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubyforge_project:
45
+ rubygems_version: 2.4.6
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Flatiron Scheduler!
49
+ test_files: []