lecture 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +866 -0
- data/.ruby-version +1 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +145 -0
- data/Rakefile +4 -0
- data/bin/console +18 -0
- data/bin/lecture +29 -0
- data/bin/setup +6 -0
- data/examples/example.rb +35 -0
- data/lecture.gemspec +34 -0
- data/lib/lecture.rb +89 -0
- data/lib/lecture/config.rb +23 -0
- data/lib/lecture/runner.rb +89 -0
- data/lib/lecture/slide.rb +23 -0
- data/lib/lecture/slide/base.rb +43 -0
- data/lib/lecture/slide/block.rb +25 -0
- data/lib/lecture/slide/center.rb +21 -0
- data/lib/lecture/slide/code.rb +21 -0
- data/lib/lecture/slide/section.rb +29 -0
- data/lib/lecture/terminal.rb +64 -0
- data/lib/lecture/version.rb +5 -0
- data/screenshots/block.png +0 -0
- data/screenshots/center.png +0 -0
- data/screenshots/code.png +0 -0
- data/screenshots/section.png +0 -0
- metadata +184 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lecture
|
4
|
+
class Slide
|
5
|
+
attr_accessor :content, :format, :options
|
6
|
+
|
7
|
+
def initialize(content:, format:, **options)
|
8
|
+
@content = content
|
9
|
+
@format = format
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def display
|
14
|
+
type_class.new(content: content, **options).display
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def type_class
|
20
|
+
"Lecture::Slide::#{format.to_s.classify}".constantize
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lecture
|
4
|
+
class Slide
|
5
|
+
class Base
|
6
|
+
include Terminal
|
7
|
+
|
8
|
+
attr_accessor :content, :options
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def inherited(base)
|
12
|
+
Lecture.slide_types.add(base.to_s.demodulize.downcase.to_sym)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(content:, **options)
|
17
|
+
@content = content
|
18
|
+
@options = options.with_indifferent_access
|
19
|
+
end
|
20
|
+
|
21
|
+
def display
|
22
|
+
raise(
|
23
|
+
NotImplementedError,
|
24
|
+
"self.#{__method__} must be implemented by including class."
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def method_missing(method_name, *arguments, &block)
|
31
|
+
if options.key?(method_name)
|
32
|
+
options[method_name]
|
33
|
+
else
|
34
|
+
super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def respond_to_missing?(method_name, include_private = false)
|
39
|
+
options.key?(method_name) || super
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lecture
|
4
|
+
class Slide
|
5
|
+
class Block < Base
|
6
|
+
def display
|
7
|
+
content.each_line.with_index do |line, i|
|
8
|
+
print_line(line, col, row + i)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def col
|
15
|
+
[1, 1 + (cols - content.each_line.map do |line|
|
16
|
+
line.chomp.uncolorize.length
|
17
|
+
end.max) / 2].max
|
18
|
+
end
|
19
|
+
|
20
|
+
def row
|
21
|
+
[1, 1 + (lines - content.count("\n")) / 2].max
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lecture
|
4
|
+
class Slide
|
5
|
+
class Center < Base
|
6
|
+
def display
|
7
|
+
content.each_line.with_index do |line, i|
|
8
|
+
col = [1, 1 + (cols - line.chomp.uncolorize.length) / 2].max
|
9
|
+
|
10
|
+
print_line(line, col, row + i)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def row
|
17
|
+
@first_center_row ||= [1, 1 + (lines - content.count("\n")) / 2].max
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lecture
|
4
|
+
class Slide
|
5
|
+
class Code < Base
|
6
|
+
def display
|
7
|
+
Block.new(content: pygmentize_code(@content, lexer)).display
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def pygmentize_code(code, lexer)
|
13
|
+
Pygments.highlight(
|
14
|
+
code,
|
15
|
+
formatter: "terminal16m", lexer: lexer,
|
16
|
+
options: { style: Lecture.pygment_style }
|
17
|
+
).gsub("\e[39m", "\e[0m")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lecture
|
4
|
+
class Slide
|
5
|
+
class Section < Base
|
6
|
+
def display
|
7
|
+
Center.new(content: content_with_bars).display
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def content_with_bars
|
13
|
+
half_count_of_dashes = [1, (max_col_length - 3)].max / 2
|
14
|
+
dashes = "─" * half_count_of_dashes
|
15
|
+
|
16
|
+
header_section = "#{dashes}#{Lecture.section_header_text}#{dashes}"
|
17
|
+
footer_section = "#{dashes}#{Lecture.section_footer_text}#{dashes}"
|
18
|
+
|
19
|
+
"#{header_section}\n\n#{content}\n\n#{footer_section}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def max_col_length
|
23
|
+
content.each_line.map do |line|
|
24
|
+
line.chomp.uncolorize.length
|
25
|
+
end.max
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Lecture
|
4
|
+
module Terminal
|
5
|
+
private
|
6
|
+
|
7
|
+
def clear
|
8
|
+
print "\e[2J\e[H"
|
9
|
+
end
|
10
|
+
|
11
|
+
def clear_and_exit(exit_status = 0)
|
12
|
+
clear
|
13
|
+
exit exit_status
|
14
|
+
end
|
15
|
+
|
16
|
+
def cols
|
17
|
+
IO.console.winsize[1]
|
18
|
+
end
|
19
|
+
|
20
|
+
def getch
|
21
|
+
prep_for_keyboard_entry do
|
22
|
+
if (input = STDIN.getc.chr) == "\e"
|
23
|
+
input << STDIN.read_nonblock(3) rescue nil
|
24
|
+
input << STDIN.read_nonblock(2) rescue nil
|
25
|
+
end
|
26
|
+
|
27
|
+
input
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def lines
|
32
|
+
IO.console.winsize[0]
|
33
|
+
end
|
34
|
+
|
35
|
+
def move_to(x, y)
|
36
|
+
print "\033[#{y};#{x}H"
|
37
|
+
end
|
38
|
+
|
39
|
+
def prep_for_keyboard_entry
|
40
|
+
begin
|
41
|
+
STDIN.echo = false
|
42
|
+
STDIN.raw!
|
43
|
+
|
44
|
+
input = yield
|
45
|
+
ensure
|
46
|
+
STDIN.echo = true
|
47
|
+
STDIN.cooked!
|
48
|
+
end
|
49
|
+
|
50
|
+
input
|
51
|
+
end
|
52
|
+
|
53
|
+
def print_line(line, x, y)
|
54
|
+
move_to(x, y)
|
55
|
+
|
56
|
+
line.each_char do |c|
|
57
|
+
print c
|
58
|
+
sleep [
|
59
|
+
Lecture.transition_time / line.length, Lecture.character_print_delay
|
60
|
+
].min
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lecture
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- npezza93
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pygments.rb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colorize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.15'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.15'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: minitest
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description:
|
126
|
+
email:
|
127
|
+
- npezza93@gmail.com
|
128
|
+
executables:
|
129
|
+
- lecture
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rubocop.yml"
|
135
|
+
- ".ruby-version"
|
136
|
+
- Gemfile
|
137
|
+
- LICENSE.txt
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- bin/console
|
141
|
+
- bin/lecture
|
142
|
+
- bin/setup
|
143
|
+
- examples/example.rb
|
144
|
+
- lecture.gemspec
|
145
|
+
- lib/lecture.rb
|
146
|
+
- lib/lecture/config.rb
|
147
|
+
- lib/lecture/runner.rb
|
148
|
+
- lib/lecture/slide.rb
|
149
|
+
- lib/lecture/slide/base.rb
|
150
|
+
- lib/lecture/slide/block.rb
|
151
|
+
- lib/lecture/slide/center.rb
|
152
|
+
- lib/lecture/slide/code.rb
|
153
|
+
- lib/lecture/slide/section.rb
|
154
|
+
- lib/lecture/terminal.rb
|
155
|
+
- lib/lecture/version.rb
|
156
|
+
- screenshots/block.png
|
157
|
+
- screenshots/center.png
|
158
|
+
- screenshots/code.png
|
159
|
+
- screenshots/section.png
|
160
|
+
homepage:
|
161
|
+
licenses:
|
162
|
+
- MIT
|
163
|
+
metadata: {}
|
164
|
+
post_install_message:
|
165
|
+
rdoc_options: []
|
166
|
+
require_paths:
|
167
|
+
- lib
|
168
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
requirements: []
|
179
|
+
rubyforge_project:
|
180
|
+
rubygems_version: 2.6.12
|
181
|
+
signing_key:
|
182
|
+
specification_version: 4
|
183
|
+
summary: Terminal Slideshow
|
184
|
+
test_files: []
|