daigaku 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/README.md +1 -1
- data/daigaku.gemspec +23 -26
- data/lib/daigaku.rb +0 -1
- data/lib/daigaku/chapter.rb +3 -4
- data/lib/daigaku/coloring.rb +13 -13
- data/lib/daigaku/configuration.rb +25 -28
- data/lib/daigaku/congratulator.rb +17 -5
- data/lib/daigaku/course.rb +9 -8
- data/lib/daigaku/exceptions.rb +0 -2
- data/lib/daigaku/generator.rb +13 -13
- data/lib/daigaku/github_client.rb +4 -4
- data/lib/daigaku/loadable.rb +11 -15
- data/lib/daigaku/loading/chapters.rb +0 -2
- data/lib/daigaku/loading/courses.rb +0 -2
- data/lib/daigaku/loading/units.rb +0 -2
- data/lib/daigaku/markdown.rb +1 -0
- data/lib/daigaku/markdown/printer.rb +89 -0
- data/lib/daigaku/markdown/ruby_doc.rb +6 -8
- data/lib/daigaku/solution.rb +18 -15
- data/lib/daigaku/storeable.rb +11 -12
- data/lib/daigaku/task.rb +1 -1
- data/lib/daigaku/terminal.rb +3 -4
- data/lib/daigaku/terminal/cli.rb +6 -8
- data/lib/daigaku/terminal/courses.rb +19 -16
- data/lib/daigaku/terminal/output.rb +0 -2
- data/lib/daigaku/terminal/setup.rb +13 -18
- data/lib/daigaku/terminal/solutions.rb +27 -32
- data/lib/daigaku/terminal/welcome.rb +9 -11
- data/lib/daigaku/test.rb +7 -10
- data/lib/daigaku/test_result.rb +13 -16
- data/lib/daigaku/unit.rb +1 -3
- data/lib/daigaku/version.rb +1 -1
- data/lib/daigaku/views.rb +4 -3
- data/lib/daigaku/views/chapters_menu.rb +16 -20
- data/lib/daigaku/views/courses_menu.rb +12 -15
- data/lib/daigaku/views/main_menu.rb +23 -23
- data/lib/daigaku/views/menu.rb +9 -13
- data/lib/daigaku/views/splash.rb +11 -13
- data/lib/daigaku/views/subscriber.rb +38 -0
- data/lib/daigaku/views/task_view.rb +80 -78
- data/lib/daigaku/views/top_bar.rb +4 -10
- data/lib/daigaku/views/units_menu.rb +16 -21
- data/lib/daigaku/window.rb +12 -70
- data/spec/daigaku/chapter_spec.rb +23 -18
- data/spec/daigaku/coloring_spec.rb +0 -1
- data/spec/daigaku/configuration_spec.rb +54 -50
- data/spec/daigaku/congratulator_spec.rb +11 -8
- data/spec/daigaku/course_spec.rb +70 -51
- data/spec/daigaku/generator_spec.rb +24 -25
- data/spec/daigaku/github_client_spec.rb +17 -18
- data/spec/daigaku/loading/chapters_spec.rb +2 -3
- data/spec/daigaku/loading/courses_spec.rb +2 -3
- data/spec/daigaku/loading/units_spec.rb +4 -5
- data/spec/daigaku/markdown/ruby_doc_spec.rb +3 -6
- data/spec/daigaku/reference_solution_spec.rb +8 -10
- data/spec/daigaku/solution_spec.rb +18 -20
- data/spec/daigaku/storeable_spec.rb +12 -10
- data/spec/daigaku/task_spec.rb +3 -4
- data/spec/daigaku/terminal/cli_spec.rb +29 -21
- data/spec/daigaku/terminal/courses_spec.rb +104 -99
- data/spec/daigaku/terminal/output_spec.rb +44 -39
- data/spec/daigaku/terminal/setup_spec.rb +1 -3
- data/spec/daigaku/terminal/solutions_spec.rb +0 -2
- data/spec/daigaku/terminal/welcome_spec.rb +0 -2
- data/spec/daigaku/terminal_spec.rb +5 -7
- data/spec/daigaku/test_example_spec.rb +16 -14
- data/spec/daigaku/test_result_spec.rb +21 -25
- data/spec/daigaku/test_spec.rb +11 -12
- data/spec/daigaku/unit_spec.rb +24 -27
- data/spec/daigaku/views/chapters_menu_spec.rb +0 -1
- data/spec/daigaku/views/courses_menu_spec.rb +0 -1
- data/spec/daigaku/views/menu_spec.rb +1 -2
- data/spec/daigaku/views/task_view_spec.rb +0 -2
- data/spec/daigaku/views/units_menu_spec.rb +0 -1
- data/spec/daigaku/views_spec.rb +0 -1
- data/spec/daigaku_spec.rb +9 -12
- data/spec/path_helpers_spec.rb +11 -12
- data/spec/resource_helpers_spec.rb +11 -12
- data/spec/spec_helper.rb +3 -4
- data/spec/support/macros/content_helpers.rb +16 -17
- data/spec/support/macros/mock_helpers.rb +6 -6
- data/spec/support/macros/path_helpers.rb +15 -15
- data/spec/support/macros/resource_helpers.rb +34 -35
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b133fa5493044ca1533d21e52864d9603097e493
|
4
|
+
data.tar.gz: ab071c41328776194b3020be3d5f51150b1493d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8fdc1c221006d16e99b97e458878c2d2564ef2c16dd7b9f0080fd76b58b7945d94946df9e6d885ca9fe81e5e6bd2e8a263e5f7d06ef7d95432d7fdcfa2db30b
|
7
|
+
data.tar.gz: d84c449fcd505eacfb5c2c78bb1691d634963c74831af2360f3490ba24d46c4837b124b2c4f16f843385df769030de145e83fe97d83e7686ecc3b5ed64bf82ee
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -16,7 +16,7 @@ language-explaining programming tasks.
|
|
16
16
|
## Installation
|
17
17
|
|
18
18
|
First of all make sure Ruby is installed on your computer.
|
19
|
-
Daigaku works with [MRI Ruby](https://www.ruby-lang.org/en/documentation/installation/) v2.
|
19
|
+
Daigaku works with [MRI Ruby](https://www.ruby-lang.org/en/documentation/installation/) v2.2.5 or higher.
|
20
20
|
|
21
21
|
Then open a terminal and install Daigaku by running:
|
22
22
|
|
data/daigaku.gemspec
CHANGED
@@ -3,37 +3,34 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
require 'daigaku/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = 'daigaku'
|
7
7
|
spec.version = Daigaku::VERSION
|
8
|
-
spec.
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.
|
13
|
-
spec.
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
8
|
+
spec.authors = ['Paul Götze']
|
9
|
+
spec.email = ['paul.christoph.goetze@gmail.com']
|
10
|
+
spec.summary = 'Learning Ruby on the command line.'
|
11
|
+
spec.description = 'Daigaku is the Japanese word for university. With Daigaku you can interactively learn the Ruby programming language using the command line.'
|
12
|
+
spec.homepage = 'https://github.com/daigaku-ruby/daigaku'
|
13
|
+
spec.license = 'MIT'
|
16
14
|
spec.files = `git ls-files -z`.split("\x0")
|
17
15
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
17
|
+
spec.require_paths = ['lib']
|
20
18
|
|
21
|
-
|
22
|
-
spec.add_runtime_dependency "curses", "~> 1.0"
|
23
|
-
end
|
19
|
+
spec.required_ruby_version = '>= 2.2.5'
|
24
20
|
|
25
|
-
spec.add_runtime_dependency
|
26
|
-
spec.add_runtime_dependency
|
27
|
-
spec.add_runtime_dependency
|
28
|
-
spec.add_runtime_dependency
|
29
|
-
spec.add_runtime_dependency
|
30
|
-
spec.add_runtime_dependency
|
31
|
-
spec.add_runtime_dependency
|
32
|
-
spec.add_runtime_dependency
|
33
|
-
spec.add_runtime_dependency
|
21
|
+
spec.add_runtime_dependency 'curses', '~> 1.0'
|
22
|
+
spec.add_runtime_dependency 'activesupport', '~> 4.0'
|
23
|
+
spec.add_runtime_dependency 'rspec', '~> 3.0'
|
24
|
+
spec.add_runtime_dependency 'thor', '~> 0.19.1'
|
25
|
+
spec.add_runtime_dependency 'os', '~> 0.9.6'
|
26
|
+
spec.add_runtime_dependency 'colorize', '~> 0.7.5'
|
27
|
+
spec.add_runtime_dependency 'rubyzip', '~> 1.0'
|
28
|
+
spec.add_runtime_dependency 'wisper', '~> 1.6.1'
|
29
|
+
spec.add_runtime_dependency 'quick_store', '~> 0.2'
|
30
|
+
spec.add_runtime_dependency 'code_breaker', '~> 0.3'
|
34
31
|
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency
|
38
|
-
spec.add_development_dependency
|
32
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
33
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
+
spec.add_development_dependency 'webmock', '~> 1.20.4'
|
35
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.5.0'
|
39
36
|
end
|
data/lib/daigaku.rb
CHANGED
data/lib/daigaku/chapter.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
module Daigaku
|
2
2
|
class Chapter
|
3
|
-
|
4
3
|
attr_reader :title, :path
|
5
4
|
|
6
5
|
def initialize(path)
|
7
|
-
@path
|
6
|
+
@path = path
|
8
7
|
@title = File.basename(path).gsub(/\_+/, ' ')
|
9
8
|
end
|
10
9
|
|
@@ -13,11 +12,11 @@ module Daigaku
|
|
13
12
|
end
|
14
13
|
|
15
14
|
def started?
|
16
|
-
units.
|
15
|
+
units.any?(&:mastered?)
|
17
16
|
end
|
18
17
|
|
19
18
|
def mastered?
|
20
|
-
units.
|
19
|
+
units.all?(&:mastered?)
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
data/lib/daigaku/coloring.rb
CHANGED
@@ -6,20 +6,20 @@ module Daigaku
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
included do
|
9
|
-
COLOR_TEXT
|
10
|
-
COLOR_TEXT_EMPHASIZE = Curses::COLOR_CYAN
|
11
|
-
COLOR_HEADING
|
12
|
-
COLOR_RED
|
13
|
-
COLOR_GREEN
|
14
|
-
COLOR_YELLOW
|
9
|
+
COLOR_TEXT = Curses::COLOR_YELLOW unless defined? COLOR_TEXT
|
10
|
+
COLOR_TEXT_EMPHASIZE = Curses::COLOR_CYAN unless defined? COLOR_TEXT_EMPHASIZE
|
11
|
+
COLOR_HEADING = Curses::COLOR_WHITE unless defined? COLOR_HEADING
|
12
|
+
COLOR_RED = Curses::COLOR_BLUE unless defined? COLOR_RED
|
13
|
+
COLOR_GREEN = Curses::COLOR_MAGENTA unless defined? COLOR_GREEN
|
14
|
+
COLOR_YELLOW = Curses::COLOR_RED unless defined? COLOR_YELLOW
|
15
15
|
|
16
|
-
BACKGROUND
|
17
|
-
FONT
|
18
|
-
FONT_HEADING
|
19
|
-
FONT_EMPHASIZE
|
20
|
-
RED
|
21
|
-
GREEN
|
22
|
-
YELLOW
|
16
|
+
BACKGROUND = Curses::COLOR_WHITE unless defined? BACKGROUND
|
17
|
+
FONT = Curses::COLOR_BLACK unless defined? FONT
|
18
|
+
FONT_HEADING = Curses::COLOR_MAGENTA unless defined? FONT_HEADING
|
19
|
+
FONT_EMPHASIZE = Curses::COLOR_BLUE unless defined? FONT_EMPHASIZE
|
20
|
+
RED = Curses::COLOR_RED unless defined? RED
|
21
|
+
GREEN = Curses::COLOR_GREEN unless defined? GREEN
|
22
|
+
YELLOW = Curses::COLOR_YELLOW unless defined? YELLOW
|
23
23
|
|
24
24
|
protected
|
25
25
|
|
@@ -1,15 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'fileutils'
|
1
|
+
require 'singleton'
|
2
|
+
require 'fileutils'
|
4
3
|
|
4
|
+
module Daigaku
|
5
5
|
class Configuration
|
6
6
|
include Singleton
|
7
7
|
|
8
|
-
LOCAL_DIR
|
9
|
-
COURSES_DIR
|
10
|
-
SOLUTIONS_DIR
|
11
|
-
STORAGE_FILE
|
12
|
-
DAIGAKU_INITIAL_COURSE = 'daigaku-ruby/Get_started_with_Ruby'
|
8
|
+
LOCAL_DIR = '.daigaku'.freeze
|
9
|
+
COURSES_DIR = 'courses'.freeze
|
10
|
+
SOLUTIONS_DIR = 'solutions'.freeze
|
11
|
+
STORAGE_FILE = 'daigaku.db.yml'.freeze
|
12
|
+
DAIGAKU_INITIAL_COURSE = 'daigaku-ruby/Get_started_with_Ruby'.freeze
|
13
13
|
|
14
14
|
attr_accessor :courses_path
|
15
15
|
attr_reader :storage_file
|
@@ -26,52 +26,50 @@ module Daigaku
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def solutions_path
|
29
|
-
@solutions_path ||
|
29
|
+
@solutions_path ||
|
30
|
+
raise(Daigaku::ConfigurationError, 'Solutions path is not set.')
|
30
31
|
end
|
31
32
|
|
32
33
|
def solutions_path=(path)
|
33
34
|
full_path = File.expand_path(path, Dir.pwd)
|
34
35
|
|
35
36
|
unless Dir.exist?(full_path)
|
36
|
-
|
37
|
+
raise(
|
37
38
|
Daigaku::ConfigurationError,
|
38
|
-
"Solutions path \"#{path}\" isn
|
39
|
-
|
40
|
-
|
41
|
-
raise(*error)
|
39
|
+
"Solutions path \"#{path}\" isn’t an existing directory."
|
40
|
+
)
|
42
41
|
end
|
43
42
|
|
44
43
|
@solutions_path = full_path
|
45
44
|
end
|
46
45
|
|
47
46
|
def save
|
48
|
-
settings =
|
47
|
+
settings = instance_variables
|
49
48
|
settings.delete(:@storage_file)
|
50
49
|
|
51
50
|
settings.each do |variable|
|
52
|
-
key
|
53
|
-
value =
|
51
|
+
key = variable.to_s.delete('@')
|
52
|
+
value = instance_variable_get(variable.to_sym)
|
54
53
|
QuickStore.store.set(key, value)
|
55
54
|
end
|
56
55
|
end
|
57
56
|
|
58
|
-
def import
|
59
|
-
|
60
|
-
@
|
57
|
+
def import
|
58
|
+
store = QuickStore.store
|
59
|
+
@courses_path = store.courses_path || @courses_path
|
60
|
+
@solutions_path = store.solutions_path || @solutions_path
|
61
61
|
self
|
62
62
|
end
|
63
63
|
|
64
64
|
def summary
|
65
|
-
settings =
|
65
|
+
settings = instance_variables
|
66
66
|
settings.delete(:@storage_file)
|
67
67
|
|
68
|
-
|
69
|
-
key
|
70
|
-
value =
|
71
|
-
"* #{key}: #{value}"
|
68
|
+
settings.reduce('') do |lines, variable|
|
69
|
+
key = variable.to_s.delete('@').tr('_', ' ')
|
70
|
+
value = instance_variable_get(variable.to_sym)
|
71
|
+
lines + "* #{key}: #{value}\n"
|
72
72
|
end
|
73
|
-
|
74
|
-
lines.join("\n")
|
75
73
|
end
|
76
74
|
|
77
75
|
def initial_course
|
@@ -85,5 +83,4 @@ module Daigaku
|
|
85
83
|
File.expand_path(path, __FILE__)
|
86
84
|
end
|
87
85
|
end
|
88
|
-
|
89
86
|
end
|
@@ -1,13 +1,25 @@
|
|
1
1
|
module Daigaku
|
2
|
-
|
3
2
|
class Congratulator
|
4
|
-
|
5
3
|
def self.message
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
new.message
|
5
|
+
end
|
6
|
+
|
7
|
+
def message
|
9
8
|
lines[random_value]
|
10
9
|
end
|
11
10
|
|
11
|
+
private
|
12
|
+
|
13
|
+
def lines
|
14
|
+
@lines ||= Terminal.text(:congratulations).lines.map(&:strip).compact
|
15
|
+
end
|
16
|
+
|
17
|
+
def random_value
|
18
|
+
rand(0..lines_count)
|
19
|
+
end
|
20
|
+
|
21
|
+
def lines_count
|
22
|
+
[lines.count - 1, 0].max
|
23
|
+
end
|
12
24
|
end
|
13
25
|
end
|
data/lib/daigaku/course.rb
CHANGED
@@ -2,12 +2,11 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
module Daigaku
|
4
4
|
class Course
|
5
|
-
|
6
5
|
attr_reader :title, :path, :author, :link
|
7
6
|
|
8
7
|
def initialize(path)
|
9
|
-
@path
|
10
|
-
@title
|
8
|
+
@path = path
|
9
|
+
@title = File.basename(path).gsub(/\_+/, ' ')
|
11
10
|
@author = QuickStore.store.get(key(:author))
|
12
11
|
end
|
13
12
|
|
@@ -16,11 +15,11 @@ module Daigaku
|
|
16
15
|
end
|
17
16
|
|
18
17
|
def started?
|
19
|
-
chapters.
|
18
|
+
chapters.any?(&:started?)
|
20
19
|
end
|
21
20
|
|
22
21
|
def mastered?
|
23
|
-
chapters.
|
22
|
+
chapters.all?(&:mastered?)
|
24
23
|
end
|
25
24
|
|
26
25
|
def key(key_name)
|
@@ -44,7 +43,6 @@ module Daigaku
|
|
44
43
|
|
45
44
|
Zip::File.open(file_path) do |zip_file|
|
46
45
|
zip_file.each do |entry|
|
47
|
-
|
48
46
|
if options[:github_repo]
|
49
47
|
first, *others = entry.to_s.split('/')
|
50
48
|
directory = File.join(first.split('-')[0..-2].join('-'), others)
|
@@ -66,10 +64,13 @@ module Daigaku
|
|
66
64
|
end
|
67
65
|
|
68
66
|
FileUtils.rm(file_path)
|
69
|
-
rescue
|
67
|
+
rescue StandardError => e
|
70
68
|
puts e
|
71
69
|
old_dir = "#{course_dir}_old/"
|
72
|
-
|
70
|
+
|
71
|
+
if Dir.exist?(old_dir)
|
72
|
+
FileUtils.copy_entry(old_dir, "#{course_dir}/", true)
|
73
|
+
end
|
73
74
|
ensure
|
74
75
|
old_dir = "#{course_dir}_old/"
|
75
76
|
FileUtils.rm_r(old_dir) if Dir.exist?(old_dir)
|
data/lib/daigaku/exceptions.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
module Daigaku
|
2
|
-
|
3
2
|
class Error < StandardError; end
|
4
3
|
class CourseNotFoundError < Error; end
|
5
4
|
class ChaptersNotFoundError < Error; end
|
@@ -15,5 +14,4 @@ module Daigaku
|
|
15
14
|
class NoUrlError < Error; end
|
16
15
|
class NoZipFileUrlError < Error; end
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
data/lib/daigaku/generator.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require 'active_support/core_ext'
|
1
|
+
require 'fileutils'
|
2
|
+
require 'active_support'
|
3
|
+
require 'active_support/core_ext'
|
5
4
|
|
5
|
+
module Daigaku
|
6
6
|
class Generator
|
7
|
+
LEADING_NUMBERS = /^\d+[\_\-\s]/
|
8
|
+
PART_JOINTS = /[\_\-\s]+/
|
7
9
|
|
8
10
|
def scaffold(courses_path, target_path)
|
9
|
-
Dir[File.join(courses_path,
|
11
|
+
Dir[File.join(courses_path, '*/*/*/*.md')].each do |file|
|
10
12
|
content_dir_parts = file.split('/')[-4..-2].map do |part|
|
11
13
|
clean_up_path_part(part)
|
12
14
|
end
|
13
15
|
|
14
16
|
content_dir = File.join(content_dir_parts)
|
15
|
-
directory
|
17
|
+
directory = File.join(target_path, File.dirname(content_dir))
|
16
18
|
|
17
19
|
solution_file = File.basename(content_dir) + Solution::FILE_SUFFIX
|
18
|
-
file_path
|
20
|
+
file_path = File.join(directory, solution_file)
|
19
21
|
|
20
22
|
create_dir(directory)
|
21
23
|
create_file(file_path)
|
@@ -25,9 +27,9 @@ module Daigaku
|
|
25
27
|
def prepare
|
26
28
|
begin
|
27
29
|
solutions_path = Daigaku.config.solutions_path
|
28
|
-
rescue ConfigurationError
|
29
|
-
base_dir
|
30
|
-
solutions_dir
|
30
|
+
rescue ConfigurationError
|
31
|
+
base_dir = File.dirname(Daigaku.config.courses_path)
|
32
|
+
solutions_dir = Daigaku::Configuration::SOLUTIONS_DIR
|
31
33
|
solutions_path = File.join(base_dir, solutions_dir)
|
32
34
|
end
|
33
35
|
|
@@ -52,9 +54,7 @@ module Daigaku
|
|
52
54
|
end
|
53
55
|
|
54
56
|
def clean_up_path_part(text)
|
55
|
-
|
56
|
-
part_joints = /[\_\-\s]+/
|
57
|
-
text.gsub(leading_numbers, '').gsub(part_joints, '_').downcase
|
57
|
+
text.gsub(LEADING_NUMBERS, '').gsub(PART_JOINTS, '_').downcase
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -4,7 +4,6 @@ require 'date'
|
|
4
4
|
|
5
5
|
module Daigaku
|
6
6
|
module GithubClient
|
7
|
-
|
8
7
|
# Returns the url to the master zip file of the Github repo.
|
9
8
|
def self.master_zip_url(user_and_repo)
|
10
9
|
"https://github.com/#{user_and_repo}/archive/master.zip"
|
@@ -21,9 +20,10 @@ module Daigaku
|
|
21
20
|
def self.updated?(user_and_repo)
|
22
21
|
return false unless user_and_repo
|
23
22
|
|
24
|
-
course
|
25
|
-
stored_time
|
26
|
-
current_time =
|
23
|
+
course = Course.new(user_and_repo.split('/').last)
|
24
|
+
stored_time = QuickStore.store.get(course.key(:updated_at))
|
25
|
+
current_time = updated_at(user_and_repo)
|
26
|
+
|
27
27
|
DateTime.parse(stored_time) < DateTime.parse(current_time)
|
28
28
|
end
|
29
29
|
end
|
data/lib/daigaku/loadable.rb
CHANGED
@@ -1,23 +1,19 @@
|
|
1
|
+
require 'active_support/inflector'
|
2
|
+
|
1
3
|
module Daigaku
|
2
4
|
module Loadable
|
3
|
-
|
4
|
-
require 'active_support/inflector'
|
5
|
-
|
6
5
|
def load(path)
|
7
|
-
|
8
|
-
dirs = Dir.entries(path).select do |entry|
|
9
|
-
!entry.match(/\./)
|
10
|
-
end
|
6
|
+
return [] unless Dir.exist?(path)
|
11
7
|
|
12
|
-
|
13
|
-
|
14
|
-
class_name = self.to_s.demodulize.singularize
|
15
|
-
"Daigaku::#{class_name}".constantize.new(dir_path)
|
16
|
-
end
|
17
|
-
else
|
18
|
-
Array.new
|
8
|
+
dirs = Dir.entries(path).select do |entry|
|
9
|
+
!entry.match(/\./)
|
19
10
|
end
|
20
|
-
end
|
21
11
|
|
12
|
+
dirs.sort.map do |dir|
|
13
|
+
dir_path = File.join(path, dir)
|
14
|
+
class_name = to_s.demodulize.singularize
|
15
|
+
"Daigaku::#{class_name}".constantize.new(dir_path)
|
16
|
+
end
|
17
|
+
end
|
22
18
|
end
|
23
19
|
end
|