daigaku 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -3
  3. data/README.md +1 -1
  4. data/daigaku.gemspec +23 -26
  5. data/lib/daigaku.rb +0 -1
  6. data/lib/daigaku/chapter.rb +3 -4
  7. data/lib/daigaku/coloring.rb +13 -13
  8. data/lib/daigaku/configuration.rb +25 -28
  9. data/lib/daigaku/congratulator.rb +17 -5
  10. data/lib/daigaku/course.rb +9 -8
  11. data/lib/daigaku/exceptions.rb +0 -2
  12. data/lib/daigaku/generator.rb +13 -13
  13. data/lib/daigaku/github_client.rb +4 -4
  14. data/lib/daigaku/loadable.rb +11 -15
  15. data/lib/daigaku/loading/chapters.rb +0 -2
  16. data/lib/daigaku/loading/courses.rb +0 -2
  17. data/lib/daigaku/loading/units.rb +0 -2
  18. data/lib/daigaku/markdown.rb +1 -0
  19. data/lib/daigaku/markdown/printer.rb +89 -0
  20. data/lib/daigaku/markdown/ruby_doc.rb +6 -8
  21. data/lib/daigaku/solution.rb +18 -15
  22. data/lib/daigaku/storeable.rb +11 -12
  23. data/lib/daigaku/task.rb +1 -1
  24. data/lib/daigaku/terminal.rb +3 -4
  25. data/lib/daigaku/terminal/cli.rb +6 -8
  26. data/lib/daigaku/terminal/courses.rb +19 -16
  27. data/lib/daigaku/terminal/output.rb +0 -2
  28. data/lib/daigaku/terminal/setup.rb +13 -18
  29. data/lib/daigaku/terminal/solutions.rb +27 -32
  30. data/lib/daigaku/terminal/welcome.rb +9 -11
  31. data/lib/daigaku/test.rb +7 -10
  32. data/lib/daigaku/test_result.rb +13 -16
  33. data/lib/daigaku/unit.rb +1 -3
  34. data/lib/daigaku/version.rb +1 -1
  35. data/lib/daigaku/views.rb +4 -3
  36. data/lib/daigaku/views/chapters_menu.rb +16 -20
  37. data/lib/daigaku/views/courses_menu.rb +12 -15
  38. data/lib/daigaku/views/main_menu.rb +23 -23
  39. data/lib/daigaku/views/menu.rb +9 -13
  40. data/lib/daigaku/views/splash.rb +11 -13
  41. data/lib/daigaku/views/subscriber.rb +38 -0
  42. data/lib/daigaku/views/task_view.rb +80 -78
  43. data/lib/daigaku/views/top_bar.rb +4 -10
  44. data/lib/daigaku/views/units_menu.rb +16 -21
  45. data/lib/daigaku/window.rb +12 -70
  46. data/spec/daigaku/chapter_spec.rb +23 -18
  47. data/spec/daigaku/coloring_spec.rb +0 -1
  48. data/spec/daigaku/configuration_spec.rb +54 -50
  49. data/spec/daigaku/congratulator_spec.rb +11 -8
  50. data/spec/daigaku/course_spec.rb +70 -51
  51. data/spec/daigaku/generator_spec.rb +24 -25
  52. data/spec/daigaku/github_client_spec.rb +17 -18
  53. data/spec/daigaku/loading/chapters_spec.rb +2 -3
  54. data/spec/daigaku/loading/courses_spec.rb +2 -3
  55. data/spec/daigaku/loading/units_spec.rb +4 -5
  56. data/spec/daigaku/markdown/ruby_doc_spec.rb +3 -6
  57. data/spec/daigaku/reference_solution_spec.rb +8 -10
  58. data/spec/daigaku/solution_spec.rb +18 -20
  59. data/spec/daigaku/storeable_spec.rb +12 -10
  60. data/spec/daigaku/task_spec.rb +3 -4
  61. data/spec/daigaku/terminal/cli_spec.rb +29 -21
  62. data/spec/daigaku/terminal/courses_spec.rb +104 -99
  63. data/spec/daigaku/terminal/output_spec.rb +44 -39
  64. data/spec/daigaku/terminal/setup_spec.rb +1 -3
  65. data/spec/daigaku/terminal/solutions_spec.rb +0 -2
  66. data/spec/daigaku/terminal/welcome_spec.rb +0 -2
  67. data/spec/daigaku/terminal_spec.rb +5 -7
  68. data/spec/daigaku/test_example_spec.rb +16 -14
  69. data/spec/daigaku/test_result_spec.rb +21 -25
  70. data/spec/daigaku/test_spec.rb +11 -12
  71. data/spec/daigaku/unit_spec.rb +24 -27
  72. data/spec/daigaku/views/chapters_menu_spec.rb +0 -1
  73. data/spec/daigaku/views/courses_menu_spec.rb +0 -1
  74. data/spec/daigaku/views/menu_spec.rb +1 -2
  75. data/spec/daigaku/views/task_view_spec.rb +0 -2
  76. data/spec/daigaku/views/units_menu_spec.rb +0 -1
  77. data/spec/daigaku/views_spec.rb +0 -1
  78. data/spec/daigaku_spec.rb +9 -12
  79. data/spec/path_helpers_spec.rb +11 -12
  80. data/spec/resource_helpers_spec.rb +11 -12
  81. data/spec/spec_helper.rb +3 -4
  82. data/spec/support/macros/content_helpers.rb +16 -17
  83. data/spec/support/macros/mock_helpers.rb +6 -6
  84. data/spec/support/macros/path_helpers.rb +15 -15
  85. data/spec/support/macros/resource_helpers.rb +34 -35
  86. metadata +12 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4318ff789d428a55ecc01cefa1d55267a2193503
4
- data.tar.gz: a3b3744b1bffe6a4ac11f25bbfe202d977ce3022
3
+ metadata.gz: b133fa5493044ca1533d21e52864d9603097e493
4
+ data.tar.gz: ab071c41328776194b3020be3d5f51150b1493d5
5
5
  SHA512:
6
- metadata.gz: 46b6c10e541c8e38af57ef69f25535c87d358a9ae3e895d6a07d9efc873f938299a642e603d2371eecc0fb6cd8495ff57a6f0bd7a0da698d751a7bb9768a7113
7
- data.tar.gz: 05b555e1144e5d6c1fda261463445484dcb1d32bf0ab9d873d6ee52e8974dcd9d575b083e558d41329c45a7c512b2dc5bf55f3aaf21fabed08d38d604af0ffab
6
+ metadata.gz: e8fdc1c221006d16e99b97e458878c2d2564ef2c16dd7b9f0080fd76b58b7945d94946df9e6d885ca9fe81e5e6bd2e8a263e5f7d06ef7d95432d7fdcfa2db30b
7
+ data.tar.gz: d84c449fcd505eacfb5c2c78bb1691d634963c74831af2360f3490ba24d46c4837b124b2c4f16f843385df769030de145e83fe97d83e7686ecc3b5ed64bf82ee
data/.travis.yml CHANGED
@@ -5,7 +5,6 @@ before_install:
5
5
  - gem install bundler
6
6
 
7
7
  rvm:
8
- - 2.0.0
9
- - 2.2.0
8
+ - 2.2.5
10
9
  - 2.3.0
11
- - rbx-2
10
+ - 2.3.1
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.x and [Rubinius](http://rubini.us/doc/en/getting-started/) v2.x.
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 = "daigaku"
6
+ spec.name = 'daigaku'
7
7
  spec.version = Daigaku::VERSION
8
- spec.required_ruby_version = '~> 2.0'
9
- spec.authors = ["Paul Götze"]
10
- spec.email = ["paul.christoph.goetze@gmail.com"]
11
- spec.summary = %q{Learning Ruby on the command line.}
12
- spec.description = %q{Daigaku is the Japanese word for university. With Daigaku you can interactively learn the Ruby programming language using the command line.}
13
- spec.homepage = "https://github.com/daigaku-ruby/daigaku"
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 = ["lib"]
17
+ spec.require_paths = ['lib']
20
18
 
21
- if RUBY_VERSION >= '2.1'
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 "activesupport", "~> 4.0"
26
- spec.add_runtime_dependency "rspec", "~> 3.0"
27
- spec.add_runtime_dependency "thor", "~> 0.19.1"
28
- spec.add_runtime_dependency "os", "~> 0.9.6"
29
- spec.add_runtime_dependency "colorize", "~> 0.7.5"
30
- spec.add_runtime_dependency "rubyzip", "~> 1.0"
31
- spec.add_runtime_dependency "wisper", "~> 2.0.0.rc1"
32
- spec.add_runtime_dependency "quick_store", "~> 0.1"
33
- spec.add_runtime_dependency "code_breaker", "~> 0.1"
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 "bundler", "~> 1.7"
36
- spec.add_development_dependency "rake", "~> 10.0"
37
- spec.add_development_dependency "webmock", "~> 1.20.4"
38
- spec.add_development_dependency "guard-rspec", "~> 4.5.0"
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
@@ -6,7 +6,6 @@ Dir[File.join("#{File.dirname(__FILE__)}/**/*.rb")].sort.each do |file|
6
6
  end
7
7
 
8
8
  module Daigaku
9
-
10
9
  class << self
11
10
  def config
12
11
  Configuration.instance
@@ -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 = 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.reduce(false) { |started, unit| started ||= unit.mastered? }
15
+ units.any?(&:mastered?)
17
16
  end
18
17
 
19
18
  def mastered?
20
- units.reduce(true) { |mastered, unit| mastered &&= unit.mastered? }
19
+ units.all?(&:mastered?)
21
20
  end
22
21
  end
23
22
  end
@@ -6,20 +6,20 @@ module Daigaku
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
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
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 = 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
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
- module Daigaku
2
- require 'singleton'
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 = '.daigaku'
9
- COURSES_DIR = 'courses'
10
- SOLUTIONS_DIR = 'solutions'
11
- STORAGE_FILE = 'daigaku.db.yml'
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 || raise(Daigaku::ConfigurationError, 'Solutions path is not set.')
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
- error = [
37
+ raise(
37
38
  Daigaku::ConfigurationError,
38
- "Solutions path \"#{path}\" isn't an existing directory."
39
- ]
40
-
41
- raise(*error)
39
+ "Solutions path \"#{path}\" isnt 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 = self.instance_variables
47
+ settings = instance_variables
49
48
  settings.delete(:@storage_file)
50
49
 
51
50
  settings.each do |variable|
52
- key = variable.to_s.delete('@')
53
- value = self.instance_variable_get(variable.to_sym)
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
- @courses_path = QuickStore.store.courses_path || @courses_path
60
- @solutions_path = QuickStore.store.solutions_path || @solutions_path
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 = self.instance_variables
65
+ settings = instance_variables
66
66
  settings.delete(:@storage_file)
67
67
 
68
- lines = settings.map do |variable|
69
- key = variable.to_s.delete('@').gsub('_', ' ')
70
- value = self.instance_variable_get(variable.to_sym)
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
- lines = Terminal.text(:congratulations).lines.map(&:strip).compact
7
- count = lines.count.zero? ? 0 : (lines.count - 1)
8
- random_value = rand(0..count)
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
@@ -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 = path
10
- @title = File.basename(path).gsub(/\_+/, ' ')
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.reduce(false) { |started, chapter| started ||= chapter.started? }
18
+ chapters.any?(&:started?)
20
19
  end
21
20
 
22
21
  def mastered?
23
- chapters.reduce(true) { |mastered, chapter| mastered &&= chapter.mastered? }
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 Exception => e
67
+ rescue StandardError => e
70
68
  puts e
71
69
  old_dir = "#{course_dir}_old/"
72
- FileUtils.copy_entry(old_dir, "#{course_dir}/", true) if Dir.exist?(old_dir)
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)
@@ -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
@@ -1,21 +1,23 @@
1
- module Daigaku
2
- require 'fileutils'
3
- require 'active_support'
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, "*/*/*/*.md")].each do |file|
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 = File.join(target_path, File.dirname(content_dir))
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 = File.join(directory, solution_file)
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 => e
29
- base_dir = File.dirname(Daigaku.config.courses_path)
30
- solutions_dir = Daigaku::Configuration::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
- leading_numbers = /^\d+[\_\-\s]/
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 = Course.new(user_and_repo.split('/').last)
25
- stored_time = QuickStore.store.get(course.key(:updated_at))
26
- current_time = self.updated_at(user_and_repo)
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
@@ -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
- if Dir.exist?(path)
8
- dirs = Dir.entries(path).select do |entry|
9
- !entry.match(/\./)
10
- end
6
+ return [] unless Dir.exist?(path)
11
7
 
12
- dirs.sort.map do |dir|
13
- dir_path = File.join(path, dir)
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