curricula 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/lib/curricula/version.rb +1 -1
- data/lib/curricula.rb +6 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 232b1d7fd959f48ed2923c81a67bf0adede85fed
|
4
|
+
data.tar.gz: 55e09181ed74124ab5839d3cd54e53164026d6e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 952cf6b5ca4596d6a3796745ed9927c971c94177f3833f72010959546d6fddc2f5eed3dfc1376f14977860c6ccf8c1cae877d77773fd63ca750b9b67e8e670bf
|
7
|
+
data.tar.gz: ce280ca40dfd635f5dd794833883bb1fae92682bfb4c2994bfaf227d7bd5e0ef17e153648869c9e8ad781eedd2234d6b509894de108281e58cc5d1235fcf42c4
|
data/lib/curricula/version.rb
CHANGED
data/lib/curricula.rb
CHANGED
@@ -16,7 +16,7 @@ module Curricula
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def graph_edges
|
19
|
-
prereqs.map{ |prereq| { source: prereq
|
19
|
+
prereqs.map{ |prereq| { source: prereq, destination: name } }
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -68,18 +68,18 @@ module Curricula
|
|
68
68
|
def build_courses
|
69
69
|
Spreadsheet.open(@spreadsheet).worksheets.first.each do |row|
|
70
70
|
if row[1]
|
71
|
-
@courses[row.last].prereqs <<
|
71
|
+
@courses[row.last].prereqs << row.first
|
72
72
|
increase_cruciality row.first, row.last
|
73
73
|
else
|
74
74
|
@courses[row.first] = Course.new row.first, row.last
|
75
75
|
end
|
76
|
-
end rescue error :format
|
76
|
+
end #rescue error :format
|
77
77
|
end
|
78
78
|
|
79
79
|
def course_hours course, visited = []
|
80
|
-
error :circular if visited.include? course
|
81
|
-
visited << course
|
82
|
-
course.hours + course.prereqs.map{ |prereq| course_hours(prereq, visited).to_i }.reduce(:+).to_i
|
80
|
+
error :circular if visited.include? course.name
|
81
|
+
visited << course.name
|
82
|
+
course.hours + course.prereqs.map{ |prereq| course_hours(@courses[prereq], visited).to_i }.reduce(:+).to_i
|
83
83
|
end
|
84
84
|
|
85
85
|
def increase_cruciality prerequisite, course
|