qcourses 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock
CHANGED
@@ -32,8 +32,8 @@ module Qcourses
|
|
32
32
|
configure MemoryCourseRepository.new
|
33
33
|
end
|
34
34
|
|
35
|
-
def self.on_file_system
|
36
|
-
configure CourseRepository.new
|
35
|
+
def self.on_file_system(root_dir = nil)
|
36
|
+
configure CourseRepository.new(root_dir)
|
37
37
|
end
|
38
38
|
|
39
39
|
def self.method_missing(method, *args)
|
@@ -43,9 +43,10 @@ module Qcourses
|
|
43
43
|
|
44
44
|
KEY_VALUE_SEPARATOR = ":"
|
45
45
|
|
46
|
-
def initialize(directory = Dir, file_opener = File)
|
46
|
+
def initialize(root_dir = nil, directory = Dir, file_opener = File)
|
47
47
|
@directory = directory
|
48
48
|
@file_opener = file_opener
|
49
|
+
@root_dir = root_dir
|
49
50
|
end
|
50
51
|
|
51
52
|
def all
|
@@ -65,10 +66,17 @@ module Qcourses
|
|
65
66
|
course_files.collect { |file| parse_course(file) }.uniq
|
66
67
|
end
|
67
68
|
def course_files
|
68
|
-
files = (
|
69
|
+
files = ( course_files_for('courses') + course_files_for("cursussen"))
|
69
70
|
files.delete_if {|file| file.end_with?('index.mdown')}
|
70
71
|
end
|
71
72
|
|
73
|
+
def course_files_for(folder)
|
74
|
+
path = "**/#{folder}/*.mdown"
|
75
|
+
path = File.join(@root_dir, path) if @root_dir
|
76
|
+
p "looking in #{path} for courses"
|
77
|
+
@directory.glob(path)
|
78
|
+
end
|
79
|
+
|
72
80
|
def parse_course(filename)
|
73
81
|
@file_opener.open(filename) do |file|
|
74
82
|
course_identification = File.basename(filename, '.mdown')
|
data/lib/qcourses/version.rb
CHANGED
@@ -31,10 +31,10 @@ module Qcourses
|
|
31
31
|
end
|
32
32
|
|
33
33
|
describe 'CourseRepository' do
|
34
|
-
let(:directory) { StubDirectory.new }
|
35
34
|
let(:file_opener) { StubCourseFileOpener.new('first_course.mdown' => "Name: first course",
|
36
35
|
'second_course.mdown' => "Name: second course") }
|
37
|
-
let(:
|
36
|
+
let(:directory) { StubDirectory.new }
|
37
|
+
let(:repository) { CourseRepository.new(nil, directory, file_opener) }
|
38
38
|
let(:first_course) { repository.all.first }
|
39
39
|
|
40
40
|
describe 'class methods' do
|
@@ -79,6 +79,23 @@ module Qcourses
|
|
79
79
|
|
80
80
|
repository.all.should == []
|
81
81
|
end
|
82
|
+
|
83
|
+
context "when root given" do
|
84
|
+
let(:repository) { CourseRepository.new('some_root', directory, file_opener) }
|
85
|
+
it "searches for courses in specified root directory" do
|
86
|
+
directory.pattern("some_root/**/courses/*.mdown", returns: ['first_course.mdown', 'second_course.mdown'])
|
87
|
+
|
88
|
+
repository.all.should == [
|
89
|
+
Course.new(identification: 'first_course', name: 'first course'),
|
90
|
+
Course.new(identification: 'second_course', name: 'second_course') ]
|
91
|
+
end
|
92
|
+
it "returns a course for all the **/cursussen/*.mdown files in the root dir" do
|
93
|
+
directory.pattern("some_root/**/cursussen/*.mdown", returns: ['first_course.mdown', 'second_course.mdown'])
|
94
|
+
|
95
|
+
repository.all.should == [ Course.new(identification: 'first_course', name: 'first course'),
|
96
|
+
Course.new(identification: 'second_course', name: 'second_course') ]
|
97
|
+
end
|
98
|
+
end
|
82
99
|
end
|
83
100
|
|
84
101
|
context "parsing the course" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qcourses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|