daigaku 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +7 -4
- data/CODE_OF_CONDUCT.md +77 -0
- data/README.md +11 -11
- data/bin/daigaku +6 -2
- data/daigaku.gemspec +22 -26
- data/lib/daigaku.rb +0 -1
- data/lib/daigaku/chapter.rb +3 -4
- data/lib/daigaku/coloring.rb +22 -27
- 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 -15
- data/lib/daigaku/github_client.rb +5 -5
- data/lib/daigaku/loadable.rb +23 -14
- 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 +15 -15
- data/lib/daigaku/solution.rb +23 -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 +8 -8
- data/lib/daigaku/terminal/courses.rb +22 -19
- data/lib/daigaku/terminal/output.rb +46 -53
- 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 +54 -21
- data/lib/daigaku/unit.rb +2 -4
- data/lib/daigaku/version.rb +1 -1
- data/lib/daigaku/views.rb +29 -33
- 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 +14 -18
- data/lib/daigaku/views/splash.rb +11 -13
- data/lib/daigaku/views/subscriber.rb +38 -0
- data/lib/daigaku/views/task_view.rb +97 -80
- 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 +75 -52
- 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 +12 -6
- data/spec/daigaku/reference_solution_spec.rb +8 -10
- data/spec/daigaku/solution_spec.rb +21 -22
- 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 +32 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3d2569151b28f6803d8c351ad6c131e13d741c7515a08e3d6e5ff2db007d085b
|
4
|
+
data.tar.gz: d53b84a072e46320f7e4555c00ba3955e9de81a0729037257c4c41e217e72c67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3d43f800a282522f4cae4550e56785e92b1feee01f179306e5022e81223716437fd2b3b813adb37328d9d6b835cfafacd6842de8d7db5c8cbe05c4703deb4ad
|
7
|
+
data.tar.gz: 6373c4ae4ba47cb9ae150d5048b16898b98cf4e768d8f70b9f46d406e2b6951e0e4d260b141fe85e5602007be44dc92f55b25a3763000e81b366d55534e786c0
|
data/.travis.yml
CHANGED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to make participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
9
|
+
level of experience, education, socio-economic status, nationality, personal
|
10
|
+
appearance, race, religion, or sexual identity and orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies within all project spaces, and it also applies when
|
49
|
+
an individual is representing the project or its community in public spaces.
|
50
|
+
Examples of representing a project or community include using an official
|
51
|
+
project e-mail address, posting via an official social media account, or acting
|
52
|
+
as an appointed representative at an online or offline event. Representation of
|
53
|
+
a project may be further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at paul.christoph.goetze@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72
|
+
|
73
|
+
[homepage]: https://www.contributor-covenant.org
|
74
|
+
|
75
|
+
For answers to common questions about this code of conduct, see
|
76
|
+
https://www.contributor-covenant.org/faq
|
77
|
+
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# ![Daigaku](
|
1
|
+
# ![Daigaku](https://res.cloudinary.com/paulgoetze/image/upload/v1520762114/daigaku/rect5481_si3rjr.png)
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/daigaku.svg)](http://badge.fury.io/rb/daigaku)
|
4
4
|
[![Travis Build](https://travis-ci.org/daigaku-ruby/daigaku.svg)](https://travis-ci.org/daigaku-ruby/daigaku)
|
@@ -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.5 or higher.
|
20
20
|
|
21
21
|
Then open a terminal and install Daigaku by running:
|
22
22
|
|
@@ -32,34 +32,34 @@ Daigaku will lead you through the setup and some important commands.
|
|
32
32
|
|
33
33
|
## Command line interface
|
34
34
|
|
35
|
-
Daigaku
|
35
|
+
Daigaku’s command line interface provides several commands which you
|
36
36
|
can use in your terminal to setup the system, download new courses,
|
37
37
|
and navigate through your solutions.
|
38
38
|
|
39
39
|
Please visit the [Daigaku Wiki](https://github.com/daigaku-ruby/daigaku/wiki/How-to-use-Daigaku%27s-command-line-interface-%28CLI%29) to learn more about available commands.
|
40
40
|
|
41
|
-
![Daigaku CLI screenshot](
|
41
|
+
![Daigaku CLI screenshot](https://res.cloudinary.com/paulgoetze/image/upload/v1520762037/daigaku/daigaku-cli-screenshot_xgpav6.png)
|
42
42
|
|
43
43
|
## Daigaku screen
|
44
44
|
|
45
|
-
Daigaku
|
45
|
+
Daigaku’s text based interface—the Daigaku screen—shows your installed courses and allows you to navigate through their chapters and units. In the task view you can read the unit’s task and validate your solution code.
|
46
46
|
|
47
47
|
Please visit the [Diagaku Wiki](https://github.com/daigaku-ruby/daigaku/wiki/How-to-learn-Ruby-in-the-Daigaku-screen) to learn how to use the Daigaku screen.
|
48
48
|
|
49
|
-
![Daigaku screen screenshot](
|
49
|
+
![Daigaku screen screenshot](https://res.cloudinary.com/paulgoetze/image/upload/v1520762097/daigaku/daigaku-task-view_zbvsia.png)
|
50
50
|
|
51
51
|
## Contributing
|
52
52
|
|
53
53
|
We encourage you to contribute to Daigaku development and course creation.
|
54
54
|
|
55
|
-
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant
|
55
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant Code of Conduct](https://github.com/daigaku-ruby/daigaku/blob/master/CODE_OF_CONDUCT.md).
|
56
56
|
|
57
57
|
### Creating Daigaku courses
|
58
58
|
|
59
|
-
Daigaku is a great tool, but it
|
59
|
+
Daigaku is a great tool, but it’s nothing without courses to learn from.
|
60
60
|
Go ahead and help with making Daigaku a worthwile and fun resource for learning Ruby!
|
61
61
|
|
62
|
-
Daigaku uses the course
|
62
|
+
Daigaku uses the course “Get started with Ruby” by default.
|
63
63
|
Any contributions to the basic Daigaku course are more than welcome.
|
64
64
|
To add chapters to the course fork it from https://github.com/daigaku-ruby/Get_started_with_Ruby
|
65
65
|
and follow its guidelines for adding chapters or units.
|
@@ -72,7 +72,7 @@ Learn how to create a Daigaku course in the [Daigaku Wiki](https://github.com/da
|
|
72
72
|
Any ideas, feature proposals, filing and feedback on issues are very welcome.
|
73
73
|
We use the [git branching model](http://nvie.com/posts/a-successful-git-branching-model/) described by [nvie](https://github.com/nvie).
|
74
74
|
|
75
|
-
Here
|
75
|
+
Here’s how to contribute:
|
76
76
|
|
77
77
|
1. Fork it ( https://github.com/daigaku-ruby/daigaku/fork )
|
78
78
|
2. Create your feature branch (`git checkout -b feature/my-new-feature develop`)
|
@@ -82,7 +82,7 @@ Here's how to contribute:
|
|
82
82
|
|
83
83
|
Please try to add RSpec tests with your new features. This will ensure that your code does not break existing functionality and that your feature is working as expected.
|
84
84
|
|
85
|
-
Ah, don
|
85
|
+
Ah, don’t forget step 6: Celebrate that you made Daigaku a better tool after your code was merged in! :octocat: :tada:
|
86
86
|
|
87
87
|
### License
|
88
88
|
|
data/bin/daigaku
CHANGED
data/daigaku.gemspec
CHANGED
@@ -3,37 +3,33 @@ $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.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.3'
|
22
|
+
spec.add_runtime_dependency 'rspec', '~> 3.0'
|
23
|
+
spec.add_runtime_dependency 'thor', '~> 1.0'
|
24
|
+
spec.add_runtime_dependency 'os', '~> 1.0'
|
25
|
+
spec.add_runtime_dependency 'colorize', '~> 0.8'
|
26
|
+
spec.add_runtime_dependency 'rubyzip', '~> 2.0'
|
27
|
+
spec.add_runtime_dependency 'wisper', '~> 2.0'
|
28
|
+
spec.add_runtime_dependency 'quick_store', '~> 1.0'
|
29
|
+
spec.add_runtime_dependency 'code_breaker', '~> 1.0'
|
34
30
|
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency
|
38
|
-
spec.add_development_dependency
|
31
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
32
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
33
|
+
spec.add_development_dependency 'webmock', '~> 3.0'
|
34
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
39
35
|
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
@@ -1,37 +1,32 @@
|
|
1
1
|
require 'curses'
|
2
|
-
require 'active_support/concern'
|
3
2
|
|
4
3
|
module Daigaku
|
5
4
|
module Coloring
|
6
|
-
|
5
|
+
COLOR_TEXT = Curses::COLOR_YELLOW unless defined? COLOR_TEXT
|
6
|
+
COLOR_TEXT_EMPHASIZE = Curses::COLOR_CYAN unless defined? COLOR_TEXT_EMPHASIZE
|
7
|
+
COLOR_HEADING = Curses::COLOR_WHITE unless defined? COLOR_HEADING
|
8
|
+
COLOR_RED = Curses::COLOR_BLUE unless defined? COLOR_RED
|
9
|
+
COLOR_GREEN = Curses::COLOR_MAGENTA unless defined? COLOR_GREEN
|
10
|
+
COLOR_YELLOW = Curses::COLOR_RED unless defined? COLOR_YELLOW
|
7
11
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
BACKGROUND = Curses::COLOR_WHITE unless defined? BACKGROUND
|
13
|
+
FONT = Curses::COLOR_BLACK unless defined? FONT
|
14
|
+
FONT_HEADING = Curses::COLOR_MAGENTA unless defined? FONT_HEADING
|
15
|
+
FONT_EMPHASIZE = Curses::COLOR_BLUE unless defined? FONT_EMPHASIZE
|
16
|
+
RED = Curses::COLOR_RED unless defined? RED
|
17
|
+
GREEN = Curses::COLOR_GREEN unless defined? GREEN
|
18
|
+
YELLOW = Curses::COLOR_YELLOW unless defined? YELLOW
|
15
19
|
|
16
|
-
|
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
|
20
|
+
protected
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
Curses.init_pair(COLOR_GREEN, GREEN, BACKGROUND)
|
33
|
-
Curses.init_pair(COLOR_YELLOW, YELLOW, BACKGROUND)
|
34
|
-
end
|
22
|
+
def init_colors
|
23
|
+
Curses.start_color
|
24
|
+
Curses.init_pair(COLOR_TEXT, FONT, BACKGROUND)
|
25
|
+
Curses.init_pair(COLOR_TEXT_EMPHASIZE, FONT_EMPHASIZE, BACKGROUND)
|
26
|
+
Curses.init_pair(COLOR_HEADING, FONT_HEADING, BACKGROUND)
|
27
|
+
Curses.init_pair(COLOR_RED, RED, BACKGROUND)
|
28
|
+
Curses.init_pair(COLOR_GREEN, GREEN, BACKGROUND)
|
29
|
+
Curses.init_pair(COLOR_YELLOW, YELLOW, BACKGROUND)
|
35
30
|
end
|
36
31
|
end
|
37
32
|
end
|
@@ -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
|