termnote 1.1.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +31 -1
- data/example/slideshow1.yaml +5 -6
- data/lib/termnote.rb +1 -1
- data/lib/termnote/pane.rb +15 -6
- data/lib/termnote/pane/chapter.rb +6 -13
- data/lib/termnote/pane/code.rb +9 -0
- data/lib/termnote/pane/helpers.rb +10 -0
- data/lib/termnote/pane/helpers/content.rb +17 -0
- data/lib/termnote/pane/helpers/title.rb +21 -0
- data/lib/termnote/pane/text.rb +9 -3
- data/lib/termnote/show.rb +2 -2
- data/lib/termnote/version.rb +1 -1
- data/termnote.gemspec +1 -1
- metadata +10 -9
- data/example/list.png +0 -0
- data/lib/termnote/pane/list.rb +0 -22
data/README.md
CHANGED
@@ -9,7 +9,7 @@ require 'termnote'
|
|
9
9
|
include TermNote
|
10
10
|
|
11
11
|
show.add chapter title: "Hello, World"
|
12
|
-
show.add code language: "
|
12
|
+
show.add code language: "ruby", source: <<-SOURCE
|
13
13
|
puts "Hello, world!"
|
14
14
|
SOURCE
|
15
15
|
show.start
|
@@ -63,6 +63,36 @@ Usage is pretty simple, there are 4 types of slides:
|
|
63
63
|
You can change the way things are printed out by overriding the classes for
|
64
64
|
your specific presentation, but only if you do things programatically.
|
65
65
|
|
66
|
+
Ruby Usage Examples
|
67
|
+
=============
|
68
|
+
|
69
|
+
**Add a title slide**
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
show.add chapter title: "Title Slide"
|
73
|
+
```
|
74
|
+
|
75
|
+
**Add a text slide**
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
show.add text title: "Content Title", content: "content blob"
|
79
|
+
```
|
80
|
+
|
81
|
+
**Add a list slide**
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
show.add list title: "title", items: ["item 1", "item 2", "item 3"]
|
85
|
+
```
|
86
|
+
|
87
|
+
**Add a slide with code**
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
show.add code langauge: "ruby", source: <<-SOURCE
|
91
|
+
def method
|
92
|
+
awesome = true
|
93
|
+
end
|
94
|
+
SOURCE
|
95
|
+
```
|
66
96
|
|
67
97
|
Contributing
|
68
98
|
============
|
data/example/slideshow1.yaml
CHANGED
@@ -14,12 +14,11 @@ content: |
|
|
14
14
|
|
15
15
|
-- Henry Ford
|
16
16
|
---
|
17
|
-
type:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
- Heart
|
17
|
+
type: text
|
18
|
+
content: |
|
19
|
+
* Be assertive
|
20
|
+
* Don't let anyone down!
|
21
|
+
* Be yourself!
|
23
22
|
---
|
24
23
|
type: console
|
25
24
|
binary: irb
|
data/lib/termnote.rb
CHANGED
data/lib/termnote/pane.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
+
require_relative 'pane/helpers'
|
1
2
|
require_relative 'pane/chapter'
|
2
|
-
require_relative 'pane/code'
|
3
|
-
require_relative 'pane/list'
|
4
3
|
require_relative 'pane/text'
|
4
|
+
require_relative 'pane/code'
|
5
5
|
require_relative 'pane/console'
|
6
6
|
|
7
7
|
module TermNote
|
@@ -27,15 +27,24 @@ module TermNote
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def space
|
30
|
-
|
30
|
+
"\n" * (height / 2)
|
31
31
|
end
|
32
32
|
|
33
33
|
def formated_rows
|
34
|
-
rows.map
|
34
|
+
@output ||= rows.map(&method(:guttered_row)).join("\n")
|
35
|
+
end
|
36
|
+
|
37
|
+
def guttered_row(row)
|
38
|
+
raise ArgumentError, "content was larger than screen" if gutter_width(row) < 0
|
39
|
+
gutter(row) + row
|
40
|
+
end
|
41
|
+
|
42
|
+
def gutter(row)
|
43
|
+
" " * gutter_width(row)
|
35
44
|
end
|
36
45
|
|
37
|
-
def
|
38
|
-
|
46
|
+
def gutter_width(row)
|
47
|
+
(width / 2.0).floor - (row.width / 2.0).ceil
|
39
48
|
end
|
40
49
|
end
|
41
50
|
end
|
@@ -2,6 +2,7 @@ module TermNote
|
|
2
2
|
module Pane
|
3
3
|
class Chapter
|
4
4
|
include Pane
|
5
|
+
include Helpers::Title
|
5
6
|
|
6
7
|
attr_accessor :title, :subtitle
|
7
8
|
|
@@ -11,25 +12,17 @@ module TermNote
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def rows
|
14
|
-
|
15
|
-
title_rows + subtitle_rows
|
16
|
-
else
|
17
|
-
title_rows
|
18
|
-
end
|
15
|
+
subtitle ? title_row + subtitle_row : title_row
|
19
16
|
end
|
20
17
|
|
21
18
|
private
|
22
19
|
|
23
|
-
def
|
24
|
-
|
25
|
-
row.join.center(width).bold
|
26
|
-
end
|
20
|
+
def subtitle_row
|
21
|
+
wrapped_title(subtitle).map &method(:subtitle_row_format)
|
27
22
|
end
|
28
23
|
|
29
|
-
def
|
30
|
-
|
31
|
-
row.join.center(width)
|
32
|
-
end
|
24
|
+
def subtitle_row_format(row)
|
25
|
+
row.join
|
33
26
|
end
|
34
27
|
end
|
35
28
|
end
|
data/lib/termnote/pane/code.rb
CHANGED
@@ -19,6 +19,15 @@ module TermNote
|
|
19
19
|
def highlighted
|
20
20
|
Pygments.highlight source, formatter: 'terminal256', lexer: language
|
21
21
|
end
|
22
|
+
|
23
|
+
def gutter_width(row)
|
24
|
+
width * 0.25
|
25
|
+
end
|
26
|
+
|
27
|
+
def space
|
28
|
+
newlines = height > rows.size ? (height - rows.size) / 2 : 0
|
29
|
+
"\n" * newlines
|
30
|
+
end
|
22
31
|
end
|
23
32
|
end
|
24
33
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module TermNote
|
2
|
+
module Pane
|
3
|
+
module Helpers
|
4
|
+
module Title
|
5
|
+
private
|
6
|
+
|
7
|
+
def title_row
|
8
|
+
wrapped_title(title).map &method(:title_row_format)
|
9
|
+
end
|
10
|
+
|
11
|
+
def title_row_format(row)
|
12
|
+
row.join.bold
|
13
|
+
end
|
14
|
+
|
15
|
+
def wrapped_title(title)
|
16
|
+
title.split('').each_slice(80)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/termnote/pane/text.rb
CHANGED
@@ -2,6 +2,8 @@ module TermNote
|
|
2
2
|
module Pane
|
3
3
|
class Text
|
4
4
|
include Pane
|
5
|
+
include Helpers::Title
|
6
|
+
include Helpers::Content
|
5
7
|
|
6
8
|
attr_accessor :title, :content
|
7
9
|
|
@@ -10,10 +12,14 @@ module TermNote
|
|
10
12
|
@content = options[:content] || options['content']
|
11
13
|
end
|
12
14
|
|
15
|
+
private
|
16
|
+
|
13
17
|
def rows
|
14
|
-
|
15
|
-
|
16
|
-
|
18
|
+
title ? title_row + content_row : content_row
|
19
|
+
end
|
20
|
+
|
21
|
+
def gutter_width(row)
|
22
|
+
width * 0.25
|
17
23
|
end
|
18
24
|
end
|
19
25
|
end
|
data/lib/termnote/show.rb
CHANGED
@@ -3,7 +3,7 @@ module TermNote
|
|
3
3
|
attr_accessor :panes
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@panes
|
6
|
+
@panes ||= []
|
7
7
|
end
|
8
8
|
|
9
9
|
def add(pane)
|
@@ -45,7 +45,7 @@ module TermNote
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def header
|
48
|
-
"[#{position}/#{total}] - #{panes.first.title}\n".bold
|
48
|
+
"[#{position + 1}/#{total}] - #{panes.first.title}\n".bold
|
49
49
|
end
|
50
50
|
|
51
51
|
private
|
data/lib/termnote/version.rb
CHANGED
data/termnote.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_runtime_dependency '
|
20
|
+
gem.add_runtime_dependency 'smart_colored', '~> 1.1'
|
21
21
|
gem.add_runtime_dependency 'pygments.rb', '~> 0.3'
|
22
22
|
gem.add_development_dependency 'yard'
|
23
23
|
gem.add_development_dependency 'kramdown'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: termnote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,16 +9,16 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: smart_colored
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
21
|
+
version: '1.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '1.
|
29
|
+
version: '1.1'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: pygments.rb
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,7 +92,6 @@ files:
|
|
92
92
|
- bin/termnote
|
93
93
|
- example/chapter.png
|
94
94
|
- example/code.png
|
95
|
-
- example/list.png
|
96
95
|
- example/running.png
|
97
96
|
- example/slideshow1.yaml
|
98
97
|
- example/text.png
|
@@ -102,7 +101,9 @@ files:
|
|
102
101
|
- lib/termnote/pane/chapter.rb
|
103
102
|
- lib/termnote/pane/code.rb
|
104
103
|
- lib/termnote/pane/console.rb
|
105
|
-
- lib/termnote/pane/
|
104
|
+
- lib/termnote/pane/helpers.rb
|
105
|
+
- lib/termnote/pane/helpers/content.rb
|
106
|
+
- lib/termnote/pane/helpers/title.rb
|
106
107
|
- lib/termnote/pane/text.rb
|
107
108
|
- lib/termnote/show.rb
|
108
109
|
- lib/termnote/version.rb
|
@@ -121,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
122
|
version: '0'
|
122
123
|
segments:
|
123
124
|
- 0
|
124
|
-
hash:
|
125
|
+
hash: 1175875945885039062
|
125
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
127
|
none: false
|
127
128
|
requirements:
|
@@ -130,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
131
|
version: '0'
|
131
132
|
segments:
|
132
133
|
- 0
|
133
|
-
hash:
|
134
|
+
hash: 1175875945885039062
|
134
135
|
requirements: []
|
135
136
|
rubyforge_project:
|
136
137
|
rubygems_version: 1.8.24
|
data/example/list.png
DELETED
Binary file
|
data/lib/termnote/pane/list.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module TermNote
|
2
|
-
module Pane
|
3
|
-
class List
|
4
|
-
include Pane
|
5
|
-
|
6
|
-
attr_accessor :title, :items
|
7
|
-
|
8
|
-
def initialize(options)
|
9
|
-
@title = options[:title] || options['title']
|
10
|
-
@items = options[:items] || options['items']
|
11
|
-
end
|
12
|
-
|
13
|
-
def rows
|
14
|
-
items.map { |item| "* #{item}" }.unshift title.bold + "\n"
|
15
|
-
end
|
16
|
-
|
17
|
-
def gutter
|
18
|
-
" " * (width * 0.5)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|