daigaku 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b133fa5493044ca1533d21e52864d9603097e493
4
- data.tar.gz: ab071c41328776194b3020be3d5f51150b1493d5
3
+ metadata.gz: cfaf629e68b2b89a328f0d06a4307e5a900388b3
4
+ data.tar.gz: 7269916d126c5d850b2014ff2f8c79b58187a4e9
5
5
  SHA512:
6
- metadata.gz: e8fdc1c221006d16e99b97e458878c2d2564ef2c16dd7b9f0080fd76b58b7945d94946df9e6d885ca9fe81e5e6bd2e8a263e5f7d06ef7d95432d7fdcfa2db30b
7
- data.tar.gz: d84c449fcd505eacfb5c2c78bb1691d634963c74831af2360f3490ba24d46c4837b124b2c4f16f843385df769030de145e83fe97d83e7686ecc3b5ed64bf82ee
6
+ metadata.gz: 5e1763f2fffb8334776e79b1a2e80e3cc38cef0a515f18aa4020422aae6f1a2d651ba54a8ed058a601fd05ef1dbecde3c54b8ac54775379f55bbb89998c210c4
7
+ data.tar.gz: 33dda0a419b22b9c03af15d0223cd004da09f610ef7c1f2e665845faed7239ecf7ed9b10eb56c65060c9f88400a4d02c3958c094a5ba894ffaef6d6b3cf58992
@@ -6,5 +6,9 @@ before_install:
6
6
 
7
7
  rvm:
8
8
  - 2.2.5
9
+ - 2.2.7
9
10
  - 2.3.0
10
- - 2.3.1
11
+ - 2.3.4
12
+ - 2.4.0
13
+ - 2.4.1
14
+ - ruby-head
@@ -18,19 +18,18 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.required_ruby_version = '>= 2.2.5'
20
20
 
21
- spec.add_runtime_dependency 'curses', '~> 1.0'
22
- spec.add_runtime_dependency 'activesupport', '~> 4.0'
21
+ spec.add_runtime_dependency 'curses', '~> 1.2'
23
22
  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'
23
+ spec.add_runtime_dependency 'thor', '~> 0.19'
24
+ spec.add_runtime_dependency 'os', '~> 1.0'
25
+ spec.add_runtime_dependency 'colorize', '~> 0.8'
27
26
  spec.add_runtime_dependency 'rubyzip', '~> 1.0'
28
- spec.add_runtime_dependency 'wisper', '~> 1.6.1'
27
+ spec.add_runtime_dependency 'wisper', '~> 2.0'
29
28
  spec.add_runtime_dependency 'quick_store', '~> 0.2'
30
29
  spec.add_runtime_dependency 'code_breaker', '~> 0.3'
31
30
 
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'
31
+ spec.add_development_dependency 'bundler', '~> 1.14'
32
+ spec.add_development_dependency 'rake', '~> 12.0'
33
+ spec.add_development_dependency 'webmock', '~> 3.0'
34
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
36
35
  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,6 +1,4 @@
1
1
  require 'fileutils'
2
- require 'active_support'
3
- require 'active_support/core_ext'
4
2
 
5
3
  module Daigaku
6
4
  class Generator
@@ -43,12 +41,12 @@ module Daigaku
43
41
  private
44
42
 
45
43
  def create_dir(path)
46
- return if path.blank?
44
+ return if path.nil? || path.empty?
47
45
  FileUtils.makedirs(path) unless Dir.exist?(path)
48
46
  end
49
47
 
50
48
  def create_file(path)
51
- return if path.blank?
49
+ return if path.nil? || path.empty?
52
50
  create_dir(File.dirname(path))
53
51
  FileUtils.touch(path) unless File.exist?(path)
54
52
  end
@@ -1,5 +1,3 @@
1
- require 'active_support/inflector'
2
-
3
1
  module Daigaku
4
2
  module Loadable
5
3
  def load(path)
@@ -11,9 +9,24 @@ module Daigaku
11
9
 
12
10
  dirs.sort.map do |dir|
13
11
  dir_path = File.join(path, dir)
14
- class_name = to_s.demodulize.singularize
15
- "Daigaku::#{class_name}".constantize.new(dir_path)
12
+ module_name = demodulize(to_s)
13
+ class_name = singularize(module_name)
14
+ daigaku_class(class_name).new(dir_path)
16
15
  end
17
16
  end
17
+
18
+ private
19
+
20
+ def demodulize(string)
21
+ string.split('::').last
22
+ end
23
+
24
+ def singularize(string)
25
+ string.end_with?('s') ? string[0..-2] : string
26
+ end
27
+
28
+ def daigaku_class(name)
29
+ Kernel.const_get("Daigaku::#{name}")
30
+ end
18
31
  end
19
32
  end
@@ -129,8 +129,8 @@ module Daigaku
129
129
 
130
130
  def store_repo_data(user_and_repo)
131
131
  parts = (user_and_repo ||= Daigaku.config.initial_course).split('/')
132
- author = parts.first
133
- course = parts.second
132
+ author = parts[0]
133
+ course = parts[1]
134
134
 
135
135
  course = Course.new(course)
136
136
  QuickStore.store.set(course.key(:author), author)
@@ -1,76 +1,71 @@
1
1
  require 'thor'
2
- require 'active_support/concern'
3
2
  require 'colorize'
4
3
 
5
4
  module Daigaku
6
5
  module Terminal
7
6
  module Output
8
- extend ActiveSupport::Concern
7
+ private
9
8
 
10
- included do
11
- private
12
-
13
- def say(text)
14
- output = text.split("\n").map {|line| "\t#{line}" }.join("\n")
15
- $stdout.puts output
16
- end
17
-
18
- def empty_line
19
- $stdout.puts ''
20
- end
9
+ def say(text)
10
+ output = text.split("\n").map { |line| "\t#{line}" }.join("\n")
11
+ $stdout.puts output
12
+ end
21
13
 
22
- def get(string)
23
- $stdout.print "\n\t#{string} "
24
- $stdin.gets.strip
25
- end
14
+ def empty_line
15
+ $stdout.puts ''
16
+ end
26
17
 
27
- def say_info(text)
28
- say_box(text, ' ℹ', :light_blue)
29
- end
18
+ def get(string)
19
+ $stdout.print "\n\t#{string} "
20
+ $stdin.gets.strip
21
+ end
30
22
 
31
- def say_warning(text)
32
- say_box(text, ' ', :light_red)
33
- end
23
+ def say_info(text)
24
+ say_box(text, ' ', :light_blue)
25
+ end
34
26
 
35
- def say_box(text, symbol, color)
36
- empty_line
37
- say line.send(color)
38
- empty_line
27
+ def say_warning(text)
28
+ say_box(text, '⚠ ', :light_red)
29
+ end
39
30
 
40
- indented_text = text.split("\n").join("\n#{' ' * (symbol.length + 1)}")
41
- say indented_text.prepend("#{symbol} ").send(color)
31
+ def say_box(text, symbol, color)
32
+ empty_line
33
+ say line.send(color)
34
+ empty_line
42
35
 
43
- empty_line
44
- say line.send(color)
45
- empty_line
46
- end
36
+ indented_text = text.split("\n").join("\n#{' ' * (symbol.length + 1)}")
37
+ say indented_text.prepend("#{symbol} ").send(color)
47
38
 
48
- def line(symbol = '-')
49
- symbol * 70
50
- end
39
+ empty_line
40
+ say line.send(color)
41
+ empty_line
42
+ end
51
43
 
52
- def get_command(command, description)
53
- say description
44
+ def line(symbol = '-')
45
+ symbol * 70
46
+ end
54
47
 
55
- loop do
56
- cmd = get '>'
48
+ def get_command(command, description)
49
+ say description
57
50
 
58
- unless cmd == command
59
- say "This was something else. Try \"#{command}\"."
60
- next
61
- end
51
+ loop do
52
+ cmd = get '>'
62
53
 
63
- system cmd
64
- break
54
+ unless cmd == command
55
+ say "This was something else. Try \"#{command}\"."
56
+ next
65
57
  end
66
- end
67
58
 
68
- def get_confirm(description)
69
- say_warning description
70
- confirm = get '(yes|no)'
71
- yield if confirm == 'yes' && block_given?
59
+ system cmd
60
+ break
72
61
  end
73
62
  end
63
+
64
+ def get_confirm(description)
65
+ say_warning description
66
+ confirm = get '(yes|no)'
67
+ yield if confirm == 'yes' && block_given?
68
+ end
74
69
  end
75
70
  end
76
71
  end
@@ -1,3 +1,3 @@
1
1
  module Daigaku
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
@@ -1,52 +1,47 @@
1
1
  require 'curses'
2
- require 'active_support/concern'
3
2
  require 'daigaku/views/top_bar'
4
3
 
5
4
  module Daigaku
6
5
  module Views
7
- extend ActiveSupport::Concern
6
+ include Curses
8
7
 
9
- included do
10
- include Curses
11
-
12
- def reset_menu_position
13
- @position = 0
14
- end
15
-
16
- private
8
+ def reset_menu_position
9
+ @position = 0
10
+ end
17
11
 
18
- def default_window(height = nil, width = nil, top = 0, left = 0)
19
- init_screen
12
+ private
20
13
 
21
- noecho
22
- crmode
23
- curs_set(0) # invisible cursor
14
+ def default_window(height = nil, width = nil, top = 0, left = 0)
15
+ init_screen
24
16
 
25
- height ||= lines
26
- width ||= cols + 1
17
+ noecho
18
+ crmode
19
+ curs_set(0) # invisible cursor
27
20
 
28
- window = Daigaku::Window.new(height, width, top, left)
21
+ height ||= lines
22
+ width ||= cols + 1
29
23
 
30
- Curses.lines.times do |line|
31
- window.setpos(line, 0)
32
- window.clear_line
33
- end
24
+ window = Daigaku::Window.new(height, width, top, left)
34
25
 
35
- window.keypad(true)
36
- window.scrollok(true)
37
- window.refresh
38
- window
26
+ Curses.lines.times do |line|
27
+ window.setpos(line, 0)
28
+ window.clear_line
39
29
  end
40
30
 
41
- def sub_window_below_top_bar(window, top_bar)
42
- top_bar.show
31
+ window.keypad(true)
32
+ window.scrollok(true)
33
+ window.refresh
34
+ window
35
+ end
43
36
 
44
- top = top_bar.height
45
- sub_window = window.subwin(window.maxy - top, window.maxx, top, 0)
37
+ def sub_window_below_top_bar(window, top_bar)
38
+ top_bar.show
46
39
 
47
- sub_window.keypad(true)
48
- sub_window
49
- end
40
+ top = top_bar.height
41
+ sub_window = window.subwin(window.maxy - top, window.maxx, top, 0)
42
+
43
+ sub_window.keypad(true)
44
+ sub_window
50
45
  end
51
46
  end
52
47
  end
@@ -55,7 +55,7 @@ module Daigaku
55
55
  window.attrset(index == active_index ? A_STANDOUT : A_NORMAL)
56
56
  window.write " #{item} "
57
57
  window.attrset(A_NORMAL)
58
- window.write " #{items_info[index].try(:join, ' ')}"
58
+ window.write " #{items_info[index] && items_info[index].join(' ')}"
59
59
  end
60
60
 
61
61
  window.refresh
@@ -143,9 +143,13 @@ describe Daigaku::Course do
143
143
  it 'returns the unzipped course' do
144
144
  dir = course_dirs.first
145
145
  path = File.join(File.dirname(dir), 'unzip', File.basename(dir))
146
- course = Daigaku::Course.new(path)
147
146
 
148
- expect(Daigaku::Course.unzip(@zip_file_path).to_json).to eq course.to_json
147
+ actual = Daigaku::Course.unzip(@zip_file_path)
148
+ expected = Daigaku::Course.new(path)
149
+
150
+ expect(actual.path).to eq expected.path
151
+ expect(actual.title).to eq expected.title
152
+ expect(actual.author).to eq expected.author
149
153
  end
150
154
 
151
155
  it 'removes the zip file' do
@@ -66,7 +66,7 @@ module ResourceHelpers
66
66
  first_course_matches = name.match(course_dirs.first)
67
67
 
68
68
  if multiple_courses
69
- first_course_matches || name.match(course_dirs.second)
69
+ first_course_matches || name.match(course_dirs[1])
70
70
  else
71
71
  first_course_matches
72
72
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daigaku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Götze
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-09 00:00:00.000000000 Z
11
+ date: 2017-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
- name: activesupport
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '4.0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '4.0'
26
+ version: '1.2'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rspec
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,42 +44,42 @@ dependencies:
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: 0.19.1
47
+ version: '0.19'
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: 0.19.1
54
+ version: '0.19'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: os
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: 0.9.6
61
+ version: '1.0'
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: 0.9.6
68
+ version: '1.0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: colorize
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: 0.7.5
75
+ version: '0.8'
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: 0.7.5
82
+ version: '0.8'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: rubyzip
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +100,14 @@ dependencies:
114
100
  requirements:
115
101
  - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: 1.6.1
103
+ version: '2.0'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - "~>"
123
109
  - !ruby/object:Gem::Version
124
- version: 1.6.1
110
+ version: '2.0'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: quick_store
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -156,56 +142,56 @@ dependencies:
156
142
  requirements:
157
143
  - - "~>"
158
144
  - !ruby/object:Gem::Version
159
- version: '1.7'
145
+ version: '1.14'
160
146
  type: :development
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - "~>"
165
151
  - !ruby/object:Gem::Version
166
- version: '1.7'
152
+ version: '1.14'
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: rake
169
155
  requirement: !ruby/object:Gem::Requirement
170
156
  requirements:
171
157
  - - "~>"
172
158
  - !ruby/object:Gem::Version
173
- version: '10.0'
159
+ version: '12.0'
174
160
  type: :development
175
161
  prerelease: false
176
162
  version_requirements: !ruby/object:Gem::Requirement
177
163
  requirements:
178
164
  - - "~>"
179
165
  - !ruby/object:Gem::Version
180
- version: '10.0'
166
+ version: '12.0'
181
167
  - !ruby/object:Gem::Dependency
182
168
  name: webmock
183
169
  requirement: !ruby/object:Gem::Requirement
184
170
  requirements:
185
171
  - - "~>"
186
172
  - !ruby/object:Gem::Version
187
- version: 1.20.4
173
+ version: '3.0'
188
174
  type: :development
189
175
  prerelease: false
190
176
  version_requirements: !ruby/object:Gem::Requirement
191
177
  requirements:
192
178
  - - "~>"
193
179
  - !ruby/object:Gem::Version
194
- version: 1.20.4
180
+ version: '3.0'
195
181
  - !ruby/object:Gem::Dependency
196
182
  name: guard-rspec
197
183
  requirement: !ruby/object:Gem::Requirement
198
184
  requirements:
199
185
  - - "~>"
200
186
  - !ruby/object:Gem::Version
201
- version: 4.5.0
187
+ version: '4.7'
202
188
  type: :development
203
189
  prerelease: false
204
190
  version_requirements: !ruby/object:Gem::Requirement
205
191
  requirements:
206
192
  - - "~>"
207
193
  - !ruby/object:Gem::Version
208
- version: 4.5.0
194
+ version: '4.7'
209
195
  description: Daigaku is the Japanese word for university. With Daigaku you can interactively
210
196
  learn the Ruby programming language using the command line.
211
197
  email:
@@ -331,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
331
317
  version: '0'
332
318
  requirements: []
333
319
  rubyforge_project:
334
- rubygems_version: 2.5.1
320
+ rubygems_version: 2.6.8
335
321
  signing_key:
336
322
  specification_version: 4
337
323
  summary: Learning Ruby on the command line.