daigaku 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +7 -4
  3. data/CODE_OF_CONDUCT.md +77 -0
  4. data/README.md +11 -11
  5. data/bin/daigaku +6 -2
  6. data/daigaku.gemspec +22 -26
  7. data/lib/daigaku.rb +0 -1
  8. data/lib/daigaku/chapter.rb +3 -4
  9. data/lib/daigaku/coloring.rb +22 -27
  10. data/lib/daigaku/configuration.rb +25 -28
  11. data/lib/daigaku/congratulator.rb +17 -5
  12. data/lib/daigaku/course.rb +9 -8
  13. data/lib/daigaku/exceptions.rb +0 -2
  14. data/lib/daigaku/generator.rb +13 -15
  15. data/lib/daigaku/github_client.rb +5 -5
  16. data/lib/daigaku/loadable.rb +23 -14
  17. data/lib/daigaku/loading/chapters.rb +0 -2
  18. data/lib/daigaku/loading/courses.rb +0 -2
  19. data/lib/daigaku/loading/units.rb +0 -2
  20. data/lib/daigaku/markdown.rb +1 -0
  21. data/lib/daigaku/markdown/printer.rb +89 -0
  22. data/lib/daigaku/markdown/ruby_doc.rb +15 -15
  23. data/lib/daigaku/solution.rb +23 -15
  24. data/lib/daigaku/storeable.rb +11 -12
  25. data/lib/daigaku/task.rb +1 -1
  26. data/lib/daigaku/terminal.rb +3 -4
  27. data/lib/daigaku/terminal/cli.rb +8 -8
  28. data/lib/daigaku/terminal/courses.rb +22 -19
  29. data/lib/daigaku/terminal/output.rb +46 -53
  30. data/lib/daigaku/terminal/setup.rb +13 -18
  31. data/lib/daigaku/terminal/solutions.rb +27 -32
  32. data/lib/daigaku/terminal/welcome.rb +9 -11
  33. data/lib/daigaku/test.rb +7 -10
  34. data/lib/daigaku/test_result.rb +54 -21
  35. data/lib/daigaku/unit.rb +2 -4
  36. data/lib/daigaku/version.rb +1 -1
  37. data/lib/daigaku/views.rb +29 -33
  38. data/lib/daigaku/views/chapters_menu.rb +16 -20
  39. data/lib/daigaku/views/courses_menu.rb +12 -15
  40. data/lib/daigaku/views/main_menu.rb +23 -23
  41. data/lib/daigaku/views/menu.rb +14 -18
  42. data/lib/daigaku/views/splash.rb +11 -13
  43. data/lib/daigaku/views/subscriber.rb +38 -0
  44. data/lib/daigaku/views/task_view.rb +97 -80
  45. data/lib/daigaku/views/top_bar.rb +4 -10
  46. data/lib/daigaku/views/units_menu.rb +16 -21
  47. data/lib/daigaku/window.rb +12 -70
  48. data/spec/daigaku/chapter_spec.rb +23 -18
  49. data/spec/daigaku/coloring_spec.rb +0 -1
  50. data/spec/daigaku/configuration_spec.rb +54 -50
  51. data/spec/daigaku/congratulator_spec.rb +11 -8
  52. data/spec/daigaku/course_spec.rb +75 -52
  53. data/spec/daigaku/generator_spec.rb +24 -25
  54. data/spec/daigaku/github_client_spec.rb +17 -18
  55. data/spec/daigaku/loading/chapters_spec.rb +2 -3
  56. data/spec/daigaku/loading/courses_spec.rb +2 -3
  57. data/spec/daigaku/loading/units_spec.rb +4 -5
  58. data/spec/daigaku/markdown/ruby_doc_spec.rb +12 -6
  59. data/spec/daigaku/reference_solution_spec.rb +8 -10
  60. data/spec/daigaku/solution_spec.rb +21 -22
  61. data/spec/daigaku/storeable_spec.rb +12 -10
  62. data/spec/daigaku/task_spec.rb +3 -4
  63. data/spec/daigaku/terminal/cli_spec.rb +29 -21
  64. data/spec/daigaku/terminal/courses_spec.rb +104 -99
  65. data/spec/daigaku/terminal/output_spec.rb +44 -39
  66. data/spec/daigaku/terminal/setup_spec.rb +1 -3
  67. data/spec/daigaku/terminal/solutions_spec.rb +0 -2
  68. data/spec/daigaku/terminal/welcome_spec.rb +0 -2
  69. data/spec/daigaku/terminal_spec.rb +5 -7
  70. data/spec/daigaku/test_example_spec.rb +16 -14
  71. data/spec/daigaku/test_result_spec.rb +21 -25
  72. data/spec/daigaku/test_spec.rb +11 -12
  73. data/spec/daigaku/unit_spec.rb +24 -27
  74. data/spec/daigaku/views/chapters_menu_spec.rb +0 -1
  75. data/spec/daigaku/views/courses_menu_spec.rb +0 -1
  76. data/spec/daigaku/views/menu_spec.rb +1 -2
  77. data/spec/daigaku/views/task_view_spec.rb +0 -2
  78. data/spec/daigaku/views/units_menu_spec.rb +0 -1
  79. data/spec/daigaku/views_spec.rb +0 -1
  80. data/spec/daigaku_spec.rb +9 -12
  81. data/spec/path_helpers_spec.rb +11 -12
  82. data/spec/resource_helpers_spec.rb +11 -12
  83. data/spec/spec_helper.rb +3 -4
  84. data/spec/support/macros/content_helpers.rb +16 -17
  85. data/spec/support/macros/mock_helpers.rb +6 -6
  86. data/spec/support/macros/path_helpers.rb +15 -15
  87. data/spec/support/macros/resource_helpers.rb +34 -35
  88. metadata +32 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9c6f1f336e0af615495359124f476852ef7dfa36
4
- data.tar.gz: 2baf4a0586e8b933fb30cd9af7bbe2be9a3fe983
2
+ SHA256:
3
+ metadata.gz: 3d2569151b28f6803d8c351ad6c131e13d741c7515a08e3d6e5ff2db007d085b
4
+ data.tar.gz: d53b84a072e46320f7e4555c00ba3955e9de81a0729037257c4c41e217e72c67
5
5
  SHA512:
6
- metadata.gz: 537a9fa9742cda1129165bf8f0a163213d415fd3d6f221e93c54244f6a0eb379451146ba9e4e7f094c705416e9aef9f6ed350e9b849030fa6cba0278ac33eb19
7
- data.tar.gz: c4a943a667fd22f0d420838ee6f83cac333613b4740ba889d3a24b8b32e989ca63813ab80206bd2aa8afb1429cc739a3f9717c07d9dc2ba3a9818b93794b1198
6
+ metadata.gz: c3d43f800a282522f4cae4550e56785e92b1feee01f179306e5022e81223716437fd2b3b813adb37328d9d6b835cfafacd6842de8d7db5c8cbe05c4703deb4ad
7
+ data.tar.gz: 6373c4ae4ba47cb9ae150d5048b16898b98cf4e768d8f70b9f46d406e2b6951e0e4d260b141fe85e5602007be44dc92f55b25a3763000e81b366d55534e786c0
@@ -1,6 +1,9 @@
1
1
  language: ruby
2
+
3
+ before_install:
4
+ - gem install bundler
5
+
2
6
  rvm:
3
- - 2.0.0
4
- - 2.2.0
5
- - rbx-2
6
- - ruby-head
7
+ - 2.5.0
8
+ - 2.6.0
9
+ - 2.7.0
@@ -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](http://res.cloudinary.com/daigaku-ruby/image/upload/c_scale,h_100/v1426946323/rect5481_si3rjr.png)
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.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.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's command line interface provides several commands which you
35
+ Daigakus 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](http://res.cloudinary.com/daigaku-ruby/image/upload/v1427558807/daigaku-cli-screenshot_xgpav6.png)
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'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.
45
+ Daigakus text based interfacethe Daigaku screenshows your installed courses and allows you to navigate through their chapters and units. In the task view you can read the units 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](http://res.cloudinary.com/daigaku-ruby/image/upload/v1430859202/daigaku-taskview_erwzrh.png)
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 code of conduct](http://contributor-covenant.org/version/1/2/0).
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's nothing without courses to learn from.
59
+ Daigaku is a great tool, but its 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 "Get started with Ruby" by default.
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's how to contribute:
75
+ Heres 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't forget step 6: Celebrate that you made Daigaku a better tool after your code was merged in! :octocat: :tada:
85
+ Ah, dont 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
 
@@ -6,7 +6,11 @@ begin
6
6
  require 'daigaku'
7
7
  rescue LoadError => e
8
8
  warn "could not load \"daigaku\"\n#{e}"
9
- exit -1
9
+ exit(-1)
10
10
  end
11
11
 
12
- Daigaku::Terminal::CLI.start
12
+ begin
13
+ Daigaku::Terminal::CLI.start
14
+ rescue Interrupt
15
+ puts "\n\n\t👋 See you soon!"
16
+ end
@@ -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 = "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.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.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 "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"
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
@@ -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
@@ -1,37 +1,32 @@
1
1
  require 'curses'
2
- require 'active_support/concern'
3
2
 
4
3
  module Daigaku
5
4
  module Coloring
6
- extend ActiveSupport::Concern
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
- 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
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
- 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
20
+ protected
23
21
 
24
- protected
25
-
26
- def init_colors
27
- Curses.start_color
28
- Curses.init_pair(COLOR_TEXT, FONT, BACKGROUND)
29
- Curses.init_pair(COLOR_TEXT_EMPHASIZE, FONT_EMPHASIZE, BACKGROUND)
30
- Curses.init_pair(COLOR_HEADING, FONT_HEADING, BACKGROUND)
31
- Curses.init_pair(COLOR_RED, RED, BACKGROUND)
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
- 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